]> git.saurik.com Git - wxWidgets.git/blame - interface/dcbuffer.h
Try out - instead of @li, more backslash escaping
[wxWidgets.git] / interface / dcbuffer.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcbuffer.h
e54c96f1 3// Purpose: interface of wxBufferedDC
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxBufferedDC
11 @wxheader{dcbuffer.h}
7c913512 12
23324ae1
FM
13 This class provides a simple way to avoid flicker: when drawing on it,
14 everything is in fact first drawn on an in-memory buffer (a
15 wxBitmap) and then copied to the screen, using the
16 associated wxDC, only once, when this object is destroyed. wxBufferedDC itself
17 is typically associated with wxClientDC, if you want to
18 use it in your @c EVT_PAINT handler, you should look at
19 wxBufferedPaintDC instead.
7c913512 20
23324ae1
FM
21 When used like this, a valid @e dc must be specified in the constructor
22 while the @e buffer bitmap doesn't have to be explicitly provided, by
23 default this class will allocate the bitmap of required size itself. However
24 using a dedicated bitmap can speed up the redrawing process by eliminating the
25 repeated creation and destruction of a possibly big bitmap. Otherwise,
7c913512
FM
26 wxBufferedDC can be used in the same way as any other device context.
27
23324ae1
FM
28 There is another possible use for wxBufferedDC is to use it to maintain a
29 backing store for the window contents. In this case, the associated @e dc
30 may be @NULL but a valid backing store bitmap should be specified.
7c913512 31
23324ae1 32 Finally, please note that GTK+ 2.0 as well as OS X provide double buffering
7c913512
FM
33 themselves natively. You can either use wxWindow::IsDoubleBuffered
34 to determine whether you need to use buffering or not, or use
23324ae1
FM
35 wxAutoBufferedPaintDC to avoid needless double
36 buffering on the systems which already do it automatically.
7c913512 37
23324ae1
FM
38 @library{wxcore}
39 @category{dc}
7c913512 40
e54c96f1 41 @see wxDC, wxMemoryDC, wxBufferedPaintDC, wxAutoBufferedPaintDC
23324ae1
FM
42*/
43class wxBufferedDC : public wxMemoryDC
44{
45public:
46 //@{
47 /**
7c913512 48 If you use the first, default, constructor, you must call one of the
23324ae1 49 Init() methods later in order to use the object.
7c913512 50 The other constructors initialize the object immediately and @c Init()
23324ae1 51 must not be called after using them.
3c4f71cc 52
7c913512 53 @param dc
4cc4bfaf
FM
54 The underlying DC: everything drawn to this object will be
55 flushed to this DC when this object is destroyed. You may pass @NULL
56 in order to just initialize the buffer, and not flush it.
7c913512 57 @param area
4cc4bfaf
FM
58 The size of the bitmap to be used for buffering (this bitmap is
59 created internally when it is not given explicitly).
7c913512 60 @param buffer
4cc4bfaf
FM
61 Explicitly provided bitmap to be used for buffering: this is
62 the most efficient solution as the bitmap doesn't have to be recreated each
63 time but it also requires more memory as the bitmap is never freed. The
23324ae1 64 bitmap
4cc4bfaf
FM
65 should have appropriate size, anything drawn outside of its bounds is
66 clipped.
67 @param style
68 wxBUFFER_CLIENT_AREA to indicate that just the client area of
69 the window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the
70 buffer bitmap
71 covers the virtual area (in which case PrepareDC is automatically called
72 for the actual window
73 device context).
23324ae1
FM
74 */
75 wxBufferedDC();
4cc4bfaf 76 wxBufferedDC(wxDC* dc, const wxSize& area,
7c913512 77 int style = wxBUFFER_CLIENT_AREA);
4cc4bfaf 78 wxBufferedDC(wxDC* dc, wxBitmap& buffer,
7c913512 79 int style = wxBUFFER_CLIENT_AREA);
23324ae1
FM
80 //@}
81
82 /**
83 Copies everything drawn on the DC so far to the underlying DC associated with
84 this object, if any.
85 */
86
87
88 //@{
89 /**
90 These functions initialize the object created using the default constructor.
91 Please see @ref ctor() "constructors documentation" for details.
92 */
4cc4bfaf 93 void Init(wxDC* dc, const wxSize& area,
23324ae1 94 int style = wxBUFFER_CLIENT_AREA);
4cc4bfaf 95 void Init(wxDC* dc, wxBitmap& buffer,
7c913512 96 int style = wxBUFFER_CLIENT_AREA);
23324ae1
FM
97 //@}
98};
99
100
e54c96f1 101
23324ae1
FM
102/**
103 @class wxAutoBufferedPaintDC
104 @wxheader{dcbuffer.h}
7c913512 105
23324ae1
FM
106 This wxDC derivative can be used inside of an @c OnPaint() event handler to
107 achieve
108 double-buffered drawing. Just create an object of this class instead of
109 wxPaintDC
110 and make sure wxWindow::SetBackgroundStyle is called
111 with wxBG_STYLE_CUSTOM somewhere in the class initialization code, and that's
112 all you have
113 to do to (mostly) avoid flicker.
7c913512 114
23324ae1
FM
115 The difference between wxBufferedPaintDC and this class,
116 is the lightweigthness - on platforms which have native double-buffering,
117 wxAutoBufferedPaintDC is simply
118 a typedef of wxPaintDC. Otherwise, it is a typedef of wxBufferedPaintDC.
7c913512 119
23324ae1
FM
120 @library{wxbase}
121 @category{dc}
7c913512 122
e54c96f1 123 @see wxDC, wxBufferedPaintDC
23324ae1
FM
124*/
125class wxAutoBufferedPaintDC : public wxBufferedPaintDC
126{
127public:
128 /**
129 Constructor. Pass a pointer to the window on which you wish to paint.
130 */
4cc4bfaf 131 wxAutoBufferedPaintDC(wxWindow* window);
23324ae1
FM
132};
133
134
e54c96f1 135
23324ae1
FM
136/**
137 @class wxBufferedPaintDC
138 @wxheader{dcbuffer.h}
7c913512 139
23324ae1
FM
140 This is a subclass of wxBufferedDC which can be used
141 inside of an @c OnPaint() event handler. Just create an object of this class
142 instead
143 of wxPaintDC and make sure wxWindow::SetBackgroundStyle
144 is called with wxBG_STYLE_CUSTOM somewhere in the class initialization code,
145 and that's all
146 you have to do to (mostly) avoid flicker. The only thing to watch out for is
147 that if you are
148 using this class together with wxScrolledWindow, you probably
149 do @b not want to call wxScrolledWindow::PrepareDC on it as it
150 already does this internally for the real underlying wxPaintDC.
7c913512 151
23324ae1
FM
152 @library{wxcore}
153 @category{dc}
7c913512 154
e54c96f1 155 @see wxDC, wxBufferedDC, wxAutoBufferedPaintDC
23324ae1
FM
156*/
157class wxBufferedPaintDC : public wxBufferedDC
158{
159public:
160 //@{
161 /**
162 As with @ref wxBufferedDC::ctor wxBufferedDC, you may either provide the
163 bitmap to be used for buffering or let this object create one internally (in
164 the latter case, the size of the client part of the window is used).
4cc4bfaf 165 Pass wxBUFFER_CLIENT_AREA for the @a style parameter to indicate that just the
23324ae1
FM
166 client area of
167 the window is buffered, or wxBUFFER_VIRTUAL_AREA to indicate that the buffer
168 bitmap
169 covers the virtual area (in which case PrepareDC is automatically called for
170 the actual window
171 device context).
172 */
4cc4bfaf 173 wxBufferedPaintDC(wxWindow* window, wxBitmap& buffer,
23324ae1 174 int style = wxBUFFER_CLIENT_AREA);
4cc4bfaf 175 wxBufferedPaintDC(wxWindow* window,
7c913512 176 int style = wxBUFFER_CLIENT_AREA);
23324ae1
FM
177 //@}
178
179 /**
180 Copies everything drawn on the DC so far to the window associated with this
181 object, using a wxPaintDC.
182 */
183};
e54c96f1 184