wxpaintevent
a paint event is sent when a window's contents needs to be repainted.
please notice that in general it is impossible to change the drawing of a
standard control (such as wxbutton) and so you shouldn't
attempt to handle paint events for them as even if it might work on some
platforms, this is inherently not portable and won't work everywhere.
derived from
wxevent
wxobject
include files
<wx/event.h>
event table macros
to process a paint event, use this event handler macro to direct input to a member
function that takes a wxpaintevent argument.
evt_paint(func)
|
process a wxevt_paint event.
|
see also
event handling overview
remarks
note that in a paint event handler, the application must always create a wxpaintdc object,
even if you do not use it. otherwise, under ms windows, refreshing for this and other windows will go wrong.
for example:
void mywindow::onpaint(wxpaintevent& event)
{
wxpaintdc dc(this);
drawmydocument(dc);
}
you can optimize painting by retrieving the rectangles
that have been damaged and only repainting these. the rectangles are in
terms of the client area, and are unscrolled, so you will need to do
some calculations using the current view position to obtain logical,
scrolled units.
here is an example of using the wxregioniterator class:
// called when window needs to be repainted.
void mywindow::onpaint(wxpaintevent& event)
{
wxpaintdc dc(this);
// find out where the window is scrolled to
int vbx,vby; // top left corner of client
getviewstart(&vbx,&vby);
int vx,vy,vw,vh; // dimensions of client area in pixels
wxregioniterator upd(getupdateregion()); // get the update rect list
while (upd)
{
vx = upd.getx();
vy = upd.gety();
vw = upd.getw();
vh = upd.geth();
// alternatively we can do this:
// wxrect rect(upd.getrect());
// repaint this rectangle
...some code...
upd ++ ;
}
}
members
wxpaintevent::wxpaintevent
wxpaintevent::wxpaintevent
wxpaintevent(int id = 0)
constructor.
|