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