Version: 2.9.4
Public Member Functions
wxPaintEvent Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/event.h>

Inheritance diagram for wxPaintEvent:

Detailed Description

ペイントイベントはウィンドウのコンテンツを再描画する必要があるときに送信されます。

The handler of this event must create a wxPaintDC object and use it for painting the window contents. 以下に例を示します:

    void MyWindow::OnPaint(wxPaintEvent& event)
    {
        wxPaintDC dc(this);

        DrawMyDocument(dc);
    }

Notice that you must not create other kinds of wxDC (e.g. wxClientDC or wxWindowDC) in EVT_PAINT handlers and also don't create wxPaintDC outside of this event handlers.

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 ++ ;
        }
    }
注意:
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.

Events using this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxPaintEvent& event)

Event macros:

Library:  wxCore
Category:  Events
参照:
イベントとイベント処理

Public Member Functions

 wxPaintEvent (int id=0)
 Constructor.

List of all members.


Constructor & Destructor Documentation

wxPaintEvent::wxPaintEvent ( int  id = 0)

Constructor.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines