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