]>
Commit | Line | Data |
---|---|---|
d6af57d4 VZ |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: bufferdc.tex | |
3 | %% Purpose: wxBufferedDC documentation | |
4 | %% Author: Vadim Zeitlin | |
5 | %% Modified by: | |
6 | %% Created: 07.02.04 | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) 2004 Vadim Zeitlin | |
8795498c | 9 | %% License: wxWindows license |
d6af57d4 VZ |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
11 | ||
12 | \section{\class{wxBufferedDC}}\label{wxbuffereddc} | |
13 | ||
4fa3f8c3 VZ |
14 | This class provides a simple way to avoid flicker: when drawing on it, |
15 | everything is in fact first drawn on an in-memory buffer (a | |
16 | \helpref{wxBitmap}{wxbitmap}) and then copied to the screen, using the | |
17 | associated wxDC, only once, when this object is destroyed. wxBufferedDC itself | |
18 | is typically associated with \helpref{wxClientDC}{wxclientdc}, if you want to | |
19 | use it in your \texttt{EVT\_PAINT} handler, you should look at | |
20 | \helpref{wxBufferedPaintDC}{wxbufferedpaintdc} instead. | |
21 | ||
22 | When used like this, a valid \arg{dc} must be specified in the constructor | |
23 | while the \arg{buffer} bitmap doesn't have to be explicitly provided, by | |
24 | default this class will allocate the bitmap of required size itself. However | |
25 | using a dedicated bitmap can speed up the redrawing process by eliminating the | |
26 | repeated creation and destruction of a possibly big bitmap. Otherwise, | |
27 | wxBufferedDC can be used in the same way as any other device context. | |
28 | ||
29 | There is another possible use for wxBufferedDC is to use it to maintain a | |
30 | backing store for the window contents. In this case, the associated \arg{dc} | |
31 | may be \NULL but a valid backing store bitmap should be specified. | |
32 | ||
33 | Finally, please note that GTK+ 2.0 as well as OS X provide double buffering | |
34 | themselves natively. You can either use \helpref{wxWindow::IsDoubleBuffered}{wxwindowisdoublebuffered} | |
35 | to determine whether you need to use buffering or not, or use | |
36 | \helpref{wxAutoBufferedPaintDC}{wxautobufferedpaintdc} to avoid needless double | |
37 | buffering on the systems which already do it automatically. | |
64e4759f | 38 | |
d6af57d4 VZ |
39 | \wxheading{Derived from} |
40 | ||
19c9f36f | 41 | \helpref{wxMemoryDC}{wxmemorydc}\\ |
14c7f3dd | 42 | \helpref{wxDC}{wxdc}\\ |
d6af57d4 VZ |
43 | \helpref{wxObject}{wxobject} |
44 | ||
45 | \wxheading{Include files} | |
46 | ||
47 | <wx/dcbuffer.h> | |
48 | ||
a7af285d VZ |
49 | \wxheading{Library} |
50 | ||
51 | \helpref{wxCore}{librarieslist} | |
52 | ||
d6af57d4 VZ |
53 | \wxheading{See also} |
54 | ||
3dfd8daf RR |
55 | \helpref{wxDC}{wxdc},\rtfsp |
56 | \helpref{wxMemoryDC}{wxmemorydc},\rtfsp | |
57 | \helpref{wxBufferedPaintDC}{wxbufferedpaintdc},\rtfsp | |
58 | \helpref{wxAutoBufferedPaintDC}{wxautobufferedpaintdc} | |
d6af57d4 VZ |
59 | |
60 | ||
61 | \latexignore{\rtfignore{\wxheading{Members}}} | |
62 | ||
461fb267 | 63 | \membersection{wxBufferedDC::wxBufferedDC}\label{wxbuffereddcctor} |
d6af57d4 VZ |
64 | |
65 | \func{}{wxBufferedDC}{\void} | |
66 | ||
19c9f36f | 67 | \func{}{wxBufferedDC}{\param{wxDC *}{dc}, \param{const wxSize\& }{area}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}} |
d6af57d4 | 68 | |
fea35690 | 69 | \func{}{wxBufferedDC}{\param{wxDC *}{dc}, \param{wxBitmap\& }{buffer}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}} |
3dfd8daf | 70 | |
d6af57d4 | 71 | If you use the first, default, constructor, you must call one of the |
461fb267 | 72 | \helpref{Init}{wxbuffereddcinit} methods later in order to use the object. |
d6af57d4 VZ |
73 | |
74 | The other constructors initialize the object immediately and \texttt{Init()} | |
75 | must not be called after using them. | |
76 | ||
77 | \wxheading{Parameters} | |
78 | ||
79 | \docparam{dc}{The underlying DC: everything drawn to this object will be | |
7775e41f RD |
80 | flushed to this DC when this object is destroyed. You may pass NULL |
81 | in order to just initialize the buffer, and not flush it.} | |
d6af57d4 VZ |
82 | |
83 | \docparam{area}{The size of the bitmap to be used for buffering (this bitmap is | |
dbd94b75 | 84 | created internally when it is not given explicitly).} |
d6af57d4 | 85 | |
d6af57d4 VZ |
86 | \docparam{buffer}{Explicitly provided bitmap to be used for buffering: this is |
87 | the most efficient solution as the bitmap doesn't have to be recreated each | |
88 | time but it also requires more memory as the bitmap is never freed. The bitmap | |
89 | should have appropriate size, anything drawn outside of its bounds is clipped.} | |
90 | ||
265a3864 JS |
91 | \docparam{style}{wxBUFFER\_CLIENT\_AREA to indicate that just the client area of |
92 | the window is buffered, or wxBUFFER\_VIRTUAL\_AREA to indicate that the buffer bitmap | |
93 | covers the virtual area (in which case PrepareDC is automatically called for the actual window | |
94 | device context).} | |
d6af57d4 | 95 | |
461fb267 | 96 | \membersection{wxBufferedDC::Init}\label{wxbuffereddcinit} |
d6af57d4 | 97 | |
19c9f36f | 98 | \func{void}{Init}{\param{wxDC *}{dc}, \param{const wxSize\& }{area}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}} |
d6af57d4 | 99 | |
fea35690 | 100 | \func{void}{Init}{\param{wxDC *}{dc}, \param{wxBitmap\& }{buffer}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}} |
3dfd8daf | 101 | |
d6af57d4 | 102 | These functions initialize the object created using the default constructor. |
461fb267 | 103 | Please see \helpref{constructors documentation}{wxbuffereddcctor} for details. |
d6af57d4 VZ |
104 | |
105 | ||
106 | % VZ: UnMask() intentionally not documented, we might want to make it private | |
107 | ||
108 | ||
109 | \membersection{wxBufferedDC::\destruct{wxBufferedDC}}\label{wxbuffereddcdtor} | |
110 | ||
111 | Copies everything drawn on the DC so far to the underlying DC associated with | |
7775e41f | 112 | this object, if any. |
d6af57d4 VZ |
113 | |
114 | ||
115 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
116 | ||
117 | \section{\class{wxBufferedPaintDC}}\label{wxbufferedpaintdc} | |
118 | ||
119 | This is a subclass of \helpref{wxBufferedDC}{wxbuffereddc} which can be used | |
7775e41f | 120 | inside of an \texttt{OnPaint()} event handler. Just create an object of this class instead |
3dfd8daf RR |
121 | of \helpref{wxPaintDC}{wxpaintdc} and make sure \helpref{wxWindow::SetBackgroundStyle}{wxwindowgetbackgroundstyle} |
122 | is called with wxBG\_STYLE\_CUSTOM somewhere in the class initialization code, and that's all | |
123 | you have to do to (mostly) avoid flicker. The only thing to watch out for is that if you are | |
124 | using this class together with \helpref{wxScrolledWindow}{wxscrolledwindow}, you probably | |
461fb267 | 125 | do \textbf{not} want to call \helpref{PrepareDC}{wxscrolledwindowpreparedc} on it as it |
d6af57d4 VZ |
126 | already does this internally for the real underlying wxPaintDC. |
127 | ||
128 | \wxheading{Derived from} | |
129 | ||
3dfd8daf | 130 | \helpref{wxBufferedDC}{wxbuffereddc}\\ |
19c9f36f | 131 | \helpref{wxMemoryDC}{wxmemorydc}\\ |
14c7f3dd | 132 | \helpref{wxDC}{wxdc}\\ |
d6af57d4 VZ |
133 | \helpref{wxObject}{wxobject} |
134 | ||
135 | \wxheading{Include files} | |
136 | ||
137 | <wx/dcbuffer.h> | |
138 | ||
a7af285d VZ |
139 | \wxheading{Library} |
140 | ||
141 | \helpref{wxCore}{librarieslist} | |
142 | ||
3dfd8daf RR |
143 | \wxheading{See also} |
144 | ||
145 | \helpref{wxDC}{wxdc},\rtfsp | |
146 | \helpref{wxBufferedDC}{wxbuffereddc},\rtfsp | |
147 | \helpref{wxAutoBufferedPaintDC}{wxautobufferedpaintdc} | |
148 | ||
d6af57d4 VZ |
149 | |
150 | \latexignore{\rtfignore{\wxheading{Members}}} | |
151 | ||
152 | \membersection{wxBufferedPaintDC::wxBufferedPaintDC}\label{wxbufferedpaintdcctor} | |
153 | ||
fea35690 | 154 | \func{}{wxBufferedPaintDC}{\param{wxWindow *}{window}, \param{wxBitmap\& }{buffer}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}} |
265a3864 JS |
155 | |
156 | \func{}{wxBufferedPaintDC}{\param{wxWindow *}{window}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}} | |
d6af57d4 VZ |
157 | |
158 | As with \helpref{wxBufferedDC}{wxbuffereddcctor}, you may either provide the | |
159 | bitmap to be used for buffering or let this object create one internally (in | |
160 | the latter case, the size of the client part of the window is used). | |
161 | ||
265a3864 JS |
162 | Pass wxBUFFER\_CLIENT\_AREA for the {\it style} parameter to indicate that just the client area of |
163 | the window is buffered, or wxBUFFER\_VIRTUAL\_AREA to indicate that the buffer bitmap | |
164 | covers the virtual area (in which case PrepareDC is automatically called for the actual window | |
165 | device context). | |
d6af57d4 VZ |
166 | |
167 | \membersection{wxBufferedPaintDC::\destruct{wxBufferedPaintDC}}\label{wxbufferedpaintdcdtor} | |
168 | ||
169 | Copies everything drawn on the DC so far to the window associated with this | |
7775e41f | 170 | object, using a \helpref{wxPaintDC}{wxpaintdc}. |
d6af57d4 VZ |
171 | |
172 | ||
3dfd8daf RR |
173 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
174 | ||
175 | \section{\class{wxAutoBufferedPaintDC}}\label{wxautobufferedpaintdc} | |
176 | ||
177 | This wxDC derivative can be used inside of an \texttt{OnPaint()} event handler to achieve | |
178 | double-buffered drawing. Just create an object of this class instead of \helpref{wxPaintDC}{wxpaintdc} | |
179 | and make sure \helpref{wxWindow::SetBackgroundStyle}{wxwindowgetbackgroundstyle} is called | |
180 | with wxBG\_STYLE\_CUSTOM somewhere in the class initialization code, and that's all you have | |
181 | to do to (mostly) avoid flicker. | |
182 | ||
183 | The difference between \helpref{wxBufferedPaintDC}{wxbufferedpaintdc} and this class, | |
184 | is the lightweigthness - on platforms which have native double-buffering, wxAutoBufferedPaintDC is simply | |
185 | a typedef of wxPaintDC. Otherwise, it is a typedef of wxBufferedPaintDC. | |
186 | ||
187 | ||
188 | \wxheading{Derived from} | |
189 | ||
190 | \helpref{wxBufferedPaintDC}{wxbufferedpaintdc}\\ | |
7376079d VZ |
191 | \helpref{wxBufferedDC}{wxbuffereddc}\\ |
192 | \helpref{wxMemoryDC}{wxmemorydc}\\ | |
3dfd8daf RR |
193 | \helpref{wxDC}{wxdc}\\ |
194 | \helpref{wxObject}{wxobject} | |
195 | ||
196 | \wxheading{Include files} | |
197 | ||
198 | <wx/dcbuffer.h> | |
199 | ||
200 | \wxheading{See also} | |
201 | ||
202 | \helpref{wxDC}{wxdc},\rtfsp | |
203 | \helpref{wxBufferedPaintDC}{wxbufferedpaintdc} | |
204 | ||
205 | ||
206 | \latexignore{\rtfignore{\wxheading{Members}}} | |
207 | ||
208 | \membersection{wxAutoBufferedPaintDC::wxAutoBufferedPaintDC}\label{wxautobufferedpaintdcctor} | |
209 | ||
210 | \func{}{wxAutoBufferedPaintDC}{\param{wxWindow *}{window}} | |
211 | ||
212 | Constructor. Pass a pointer to the window on which you wish to paint. | |
213 |