Page 1 of 1

What control to add to box sizer to show wxClientDC?

Posted: Wed Jul 29, 2015 4:23 pm
by Tapsa
I can swap the bitmap of a toolbar item, but how do I show bitmap in place of wxStaticText and such?

Code: Select all

GetToolBar()->SetToolNormalBitmap(ToolBar_Hex, SLPtoBitMap(50705, 0));
wxClientDC dc(this);
dc.DrawBitmap(SLPtoBitMap(50705, 1), 0, 0, true);
The bitmap flashes in the upper left corner of this (the window).
PS. I don't want to use wxGraphicsContext, since that would mean recompiling wxWidgets.
EDIT: wxStaticBitmap doesn't accept large enough images.

Some of my images are small enough, but only first call to SetBitmap centers the image. After that all images are drawn to upper left corner.

Re: What control to add to box sizer to show wxClientDC?

Posted: Wed Jul 29, 2015 5:07 pm
by doublemax
Don't use wxClientDC. Forget that it exists.

Everything that you draw on a wxClientDC will be overdrawn by the next "regular" redraw, therefore it's useless except for some very specific redraw optimizations when speed is crucial.

If you want any custom content, take a wxPanel, catch its wxPAINT_EVENT and draw your content there.

BTW: wxGenericStaticBitmap can handle bitmaps of any size.

Re: What control to add to box sizer to show wxClientDC?

Posted: Wed Jul 29, 2015 5:14 pm
by Tapsa
Thanks, I'll try wxPanel.
I assume that wxGenericStaticBitmap is not part of 2.8 version.