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.
TGT
Earned a small fee
Posts: 17 Joined: Thu Dec 15, 2005 8:09 pm
Post
by TGT » Sat Mar 04, 2006 8:50 am
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!
Posts: 1339 Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:
Post
by priyank_bolia » Sat Mar 04, 2006 10:41 am
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
Posts: 17 Joined: Thu Dec 15, 2005 8:09 pm
Post
by TGT » Sat Mar 04, 2006 10:54 am
*arg* another time forgot the description of the behavior
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
Posts: 17 Joined: Thu Dec 15, 2005 8:09 pm
Post
by TGT » Sun Mar 05, 2006 6:20 am
You have to take wxMemoryDC and draw directly onto the wxBitmap object of the wxStaticBitmap!