wxStaticBitmap +text Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
TGT
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Dec 15, 2005 8:09 pm

wxStaticBitmap +text

Post by TGT »

Hi,

the idea was to simple but a text onto a bitmap
I guess this is really basic stuff but it seems missing something :?

.h

Code: Select all

// headers

class
wxBitmapCaption : public wxStaticBitmap
{
  public:
    // the 3 constructors of wxStaticBitmap
    wxBitmapCaption();
    wxBitmapCaption( ... );
    void OnPaint(wxPaintEvent &event);

  private:
    DECLARE_EVENT_TABLE();
};
.cpp

Code: Select all

// headers

BEGIN_EVENT_TABLE(wxBitmapCaption, wxStaticBitmap)
  EVT_PAINT(wxBitmapCaption::OnPaint)
END_EVENT_TABLE()

// ... the constructors

void
wxBitmapCaption::OnPaint(wxPaintEvent &WXUNUSED(event))
{
  wxPaintDC dc(this);
  dc.DrawText(wxT("text"), 10, 10);
}
Thanks for any replies, Tom
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

Your are handling the EVT_PAINT, so all the drawing will need to be taken care by you. thats why you can't see the bitmap. you have to manually select the bitmap and draw yourself, then the text over it.
TGT
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Dec 15, 2005 8:09 pm

Post by TGT »

*arg* another time forgot the description of the behavior :oops: sorry.

:!: I do see the picture/ bitmap but the text isn't visible.
The wxBitmapCaption is used as follows:

Code: Select all

wxImage::AddHandler(new wxPNGHandler);
wxImage img(wxT("picutre.png"), wxBITMAP_TYPE_PNG);
wxBitmapCaption *bc = new wxBitmapCaption(this, wxID_ANY, wxBitmap(&img));

// +sizer
Tom
TGT
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Dec 15, 2005 8:09 pm

Post by TGT »

You have to take wxMemoryDC and draw directly onto the wxBitmap object of the wxStaticBitmap!
Post Reply