What control to add to box sizer to show wxClientDC? 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
Tapsa
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

What control to add to box sizer to show wxClientDC?

Post by Tapsa » Wed Jul 29, 2015 4:23 pm

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.

User avatar
doublemax
Moderator
Moderator
Posts: 15264
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post by doublemax » Wed Jul 29, 2015 5:07 pm

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.
Use the source, Luke!

Tapsa
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

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

Post by Tapsa » Wed Jul 29, 2015 5:14 pm

Thanks, I'll try wxPanel.
I assume that wxGenericStaticBitmap is not part of 2.8 version.

Post Reply