1 \section{\class{wxPaintEvent
}}\label{wxpaintevent
}
3 A paint event is sent when a window's contents needs to be repainted.
5 Please notice that in general it is impossible to change the drawing of a
6 standard control (such as
\helpref{wxButton
}{wxbutton
}) and so you shouldn't
7 attempt to handle paint events for them as even if it might work on some
8 platforms, this is inherently not portable and won't work everywhere.
10 \wxheading{Derived from
}
12 \helpref{wxEvent
}{wxevent
}\\
13 \helpref{wxObject
}{wxobject
}
15 \wxheading{Include files
}
19 \wxheading{Event table macros
}
21 To process a paint event, use this event handler macro to direct input to a member
22 function that takes a wxPaintEvent argument.
25 \begin{twocollist
}\itemsep=
0pt
26 \twocolitem{{\bf EVT
\_PAINT(func)
}}{Process a wxEVT
\_PAINT event.
}
31 %\helpref{wxWindow::OnPaint}{wxwindowonpaint},
32 \helpref{Event handling overview
}{eventhandlingoverview
}
36 Note that In a paint event handler, the application must
{\it always
} create a
\helpref{wxPaintDC
}{wxpaintdc
} object,
37 even if you do not use it. Otherwise, under MS Windows, refreshing for this and other windows will go wrong.
43 void MyWindow::OnPaint(wxPaintEvent& event)
52 You can optimize painting by retrieving the rectangles
53 that have been damaged and only repainting these. The rectangles are in
54 terms of the client area, and are unscrolled, so you will need to do
55 some calculations using the current view position to obtain logical,
58 Here is an example of using the
\helpref{wxRegionIterator
}{wxregioniterator
} class:
62 // Called when window needs to be repainted.
63 void MyWindow::OnPaint(wxPaintEvent& event)
67 // Find Out where the window is scrolled to
68 int vbX,vbY; // Top left corner of client
69 GetViewStart(&vbX,&vbY);
71 int vX,vY,vW,vH; // Dimensions of client area in pixels
72 wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
81 // Alternatively we can do this:
82 // wxRect rect(upd.GetRect());
84 // Repaint this rectangle
94 \latexignore{\rtfignore{\wxheading{Members
}}}
96 \membersection{wxPaintEvent::wxPaintEvent
}\label{wxpainteventctor
}
98 \func{}{wxPaintEvent
}{\param{int
}{id =
0}}