X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae3c17b4013e80b99976c750c19fca47729517f6..92c0fc34c104c8d7c12d6a3b78ea232690fc23f4:/interface/wx/dcbuffer.h diff --git a/interface/wx/dcbuffer.h b/interface/wx/dcbuffer.h index 569ccdba03..9268e437aa 100644 --- a/interface/wx/dcbuffer.h +++ b/interface/wx/dcbuffer.h @@ -2,13 +2,24 @@ // Name: dcbuffer.h // Purpose: interface of wxBufferedDC // Author: wxWidgets team -// RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// Assumes the buffer bitmap covers the entire scrolled window, +// and prepares the window DC accordingly +#define wxBUFFER_VIRTUAL_AREA 0x01 + +// Assumes the buffer bitmap only covers the client area; +// does not prepare the window DC +#define wxBUFFER_CLIENT_AREA 0x02 + +// Set when not using specific buffer bitmap. Note that this +// is private style and not returned by GetStyle. +#define wxBUFFER_USES_SHARED_BUFFER 0x04 + + /** @class wxBufferedDC - @wxheader{dcbuffer.h} This class provides a simple way to avoid flicker: when drawing on it, everything is in fact first drawn on an in-memory buffer (a wxBitmap) and @@ -49,9 +60,8 @@ public: */ wxBufferedDC(); - //@{ /** - Creates a buffer for the provided @dc. Init() must not be called when + Creates a buffer for the provided @a dc. Init() must not be called when using this constructor. @param dc @@ -61,6 +71,22 @@ public: @param area The size of the bitmap to be used for buffering (this bitmap is created internally when it is not given explicitly). + @param style + wxBUFFER_CLIENT_AREA to indicate that just the client area of the + window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the + buffer bitmap covers the virtual area. + */ + wxBufferedDC(wxDC* dc, const wxSize& area, + int style = wxBUFFER_CLIENT_AREA); + + /** + Creates a buffer for the provided dc. Init() must not be called when + using this constructor. + + @param dc + The underlying DC: everything drawn to this object will be flushed + to this DC when this object is destroyed. You may pass @NULL in + order to just initialize the buffer, and not flush it. @param buffer Explicitly provided bitmap to be used for buffering: this is the most efficient solution as the bitmap doesn't have to be recreated @@ -72,17 +98,14 @@ public: window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the buffer bitmap covers the virtual area. */ - wxBufferedDC(wxDC* dc, const wxSize& area, + wxBufferedDC(wxDC* dc, wxBitmap& buffer = wxNullBitmap, int style = wxBUFFER_CLIENT_AREA); - wxBufferedDC(wxDC* dc, wxBitmap& buffer, - int style = wxBUFFER_CLIENT_AREA); - //@} /** Copies everything drawn on the DC so far to the underlying DC associated with this object, if any. */ - ~wxBufferedDC(); + virtual ~wxBufferedDC(); //@{ /** @@ -91,32 +114,52 @@ public: */ void Init(wxDC* dc, const wxSize& area, int style = wxBUFFER_CLIENT_AREA); - void Init(wxDC* dc, wxBitmap& buffer, + void Init(wxDC* dc, wxBitmap& buffer = wxNullBitmap, int style = wxBUFFER_CLIENT_AREA); //@} + + + /** + Blits the buffer to the dc, and detaches the dc from the buffer (so it + can be effectively used once only). + + Usually only called in the destructor or by the destructor of derived + classes if the BufferedDC must blit before the derived class (which may + own the dc it's blitting to) is destroyed. + */ + void UnMask(); + + /** + Set the style. + */ + void SetStyle(int style); + + /** + Get the style. + */ + int GetStyle() const; }; /** @class wxAutoBufferedPaintDC - @wxheader{dcbuffer.h} This wxDC derivative can be used inside of an @c EVT_PAINT() event handler to achieve double-buffered drawing. Just use this class instead of wxPaintDC and make sure wxWindow::SetBackgroundStyle() is called with - wxBG_STYLE_CUSTOM somewhere in the class initialization code, and that's + wxBG_STYLE_PAINT somewhere in the class initialization code, and that's all you have to do to (mostly) avoid flicker. The difference between wxBufferedPaintDC and this class is that this class won't double-buffer on platforms which have native double-buffering - already, avoiding any unneccessary buffering to avoid flicker. + already, avoiding any unnecessary buffering to avoid flicker. wxAutoBufferedPaintDC is simply a typedef of wxPaintDC on platforms that have native double-buffering, otherwise, it is a typedef of wxBufferedPaintDC. - @library{wxbase} + @library{wxcore} @category{dc} @see wxDC, wxBufferedPaintDC, wxPaintDC @@ -131,15 +174,21 @@ public: }; +/** + * Check if the window is natively double buffered and will return a wxPaintDC + * if it is, a wxBufferedPaintDC otherwise. It is the caller's responsibility + * to delete the wxDC pointer when finished with it. + */ +wxDC* wxAutoBufferedPaintDCFactory(wxWindow* window); + /** @class wxBufferedPaintDC - @wxheader{dcbuffer.h} This is a subclass of wxBufferedDC which can be used inside of an @c EVT_PAINT() event handler to achieve double-buffered drawing. Just use this class instead of wxPaintDC and make sure - wxWindow::SetBackgroundStyle() is called with wxBG_STYLE_CUSTOM somewhere + wxWindow::SetBackgroundStyle() is called with wxBG_STYLE_PAINT somewhere in the class initialization code, and that's all you have to do to (mostly) avoid flicker. The only thing to watch out for is that if you are using this class together with wxScrolled, you probably do @b not want to call @@ -175,6 +224,6 @@ public: Copies everything drawn on the DC so far to the window associated with this object, using a wxPaintDC. */ - ~wxBufferedPaintDC(); + virtual ~wxBufferedPaintDC(); };