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