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