X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a660d684eda27638bca0384b2058911a31c8e845..e00a5d3ca15eec8db3e231d79d82ff6965e3466b:/docs/latex/wx/paintevt.tex diff --git a/docs/latex/wx/paintevt.tex b/docs/latex/wx/paintevt.tex index b60f34bf16..cae225e95e 100644 --- a/docs/latex/wx/paintevt.tex +++ b/docs/latex/wx/paintevt.tex @@ -7,6 +7,10 @@ A paint event is sent when a window's contents needs to be repainted. \helpref{wxEvent}{wxevent}\\ \helpref{wxObject}{wxobject} +\wxheading{Include files} + + + \wxheading{Event table macros} To process a paint event, use this event handler macro to direct input to a member @@ -19,7 +23,68 @@ function that takes a wxPaintEvent argument. \wxheading{See also} -\helpref{wxWindow::OnPaint}{wxwindowonpaint}, \helpref{Event handling overview}{eventhandlingoverview} +%\helpref{wxWindow::OnPaint}{wxwindowonpaint}, +\helpref{Event handling overview}{eventhandlingoverview} + +\wxheading{Remarks} + +Note that In a paint event handler, the application must {\it always} create a \helpref{wxPaintDC}{wxpaintdc} object, +even if you do not use it. Otherwise, under MS Windows, refreshing for this and other windows will go wrong. + +For example: + +\small{% +\begin{verbatim} + void MyWindow::OnPaint(wxPaintEvent& event) + { + wxPaintDC dc(this); + + DrawMyDocument(dc); + } +\end{verbatim} +}% + +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 \helpref{wxRegionIterator}{wxregioniterator} class: + +{\small% +\begin{verbatim} +// 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 ++ ; + } +} +\end{verbatim} +}% + \latexignore{\rtfignore{\wxheading{Members}}}