]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/bufferdc.tex
Use generic collapsible pane for wxUniv based builds.
[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
14This simple class provides a simple way to avoid flicker: when drawing on it,
7775e41f
RD
15everything 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
17object is destroyed.
18
19It can be used in the same way as any other device context. wxBufferedDC itself
20typically replaces \helpref{wxClientDC}{wxclientdc}, if you want to use it in
21your \texttt{OnPaint()} handler, you should look at
3dfd8daf 22\helpref{wxBufferedPaintDC}{wxbufferedpaintdc} or \helpref{wxAutoBufferedPaintDC}{wxautobufferedpaintdc}.
d6af57d4 23
604affda 24Please 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 56If 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
59The other constructors initialize the object immediately and \texttt{Init()}
60must 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
65flushed to this DC when this object is destroyed. You may pass NULL
66in 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 69created internally when it is not given explicitly).}
d6af57d4 70
d6af57d4
VZ
71\docparam{buffer}{Explicitly provided bitmap to be used for buffering: this is
72the most efficient solution as the bitmap doesn't have to be recreated each
73time but it also requires more memory as the bitmap is never freed. The bitmap
74should 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
77the window is buffered, or wxBUFFER\_VIRTUAL\_AREA to indicate that the buffer bitmap
78covers the virtual area (in which case PrepareDC is automatically called for the actual window
79device 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 87These functions initialize the object created using the default constructor.
461fb267 88Please 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
96Copies everything drawn on the DC so far to the underlying DC associated with
7775e41f 97this object, if any.
d6af57d4
VZ
98
99
100%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101
102\section{\class{wxBufferedPaintDC}}\label{wxbufferedpaintdc}
103
104This is a subclass of \helpref{wxBufferedDC}{wxbuffereddc} which can be used
7775e41f 105inside of an \texttt{OnPaint()} event handler. Just create an object of this class instead
3dfd8daf
RR
106of \helpref{wxPaintDC}{wxpaintdc} and make sure \helpref{wxWindow::SetBackgroundStyle}{wxwindowgetbackgroundstyle}
107is called with wxBG\_STYLE\_CUSTOM somewhere in the class initialization code, and that's all
108you have to do to (mostly) avoid flicker. The only thing to watch out for is that if you are
109using this class together with \helpref{wxScrolledWindow}{wxscrolledwindow}, you probably
461fb267 110do \textbf{not} want to call \helpref{PrepareDC}{wxscrolledwindowpreparedc} on it as it
d6af57d4
VZ
111already 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
139As with \helpref{wxBufferedDC}{wxbuffereddcctor}, you may either provide the
140bitmap to be used for buffering or let this object create one internally (in
141the latter case, the size of the client part of the window is used).
142
265a3864
JS
143Pass wxBUFFER\_CLIENT\_AREA for the {\it style} parameter to indicate that just the client area of
144the window is buffered, or wxBUFFER\_VIRTUAL\_AREA to indicate that the buffer bitmap
145covers the virtual area (in which case PrepareDC is automatically called for the actual window
146device context).
d6af57d4
VZ
147
148\membersection{wxBufferedPaintDC::\destruct{wxBufferedPaintDC}}\label{wxbufferedpaintdcdtor}
149
150Copies everything drawn on the DC so far to the window associated with this
7775e41f 151object, using a \helpref{wxPaintDC}{wxpaintdc}.
d6af57d4
VZ
152
153
3dfd8daf
RR
154%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155
156\section{\class{wxAutoBufferedPaintDC}}\label{wxautobufferedpaintdc}
157
158This wxDC derivative can be used inside of an \texttt{OnPaint()} event handler to achieve
159double-buffered drawing. Just create an object of this class instead of \helpref{wxPaintDC}{wxpaintdc}
160and make sure \helpref{wxWindow::SetBackgroundStyle}{wxwindowgetbackgroundstyle} is called
161with wxBG\_STYLE\_CUSTOM somewhere in the class initialization code, and that's all you have
162to do to (mostly) avoid flicker.
163
164The difference between \helpref{wxBufferedPaintDC}{wxbufferedpaintdc} and this class,
165is the lightweigthness - on platforms which have native double-buffering, wxAutoBufferedPaintDC is simply
166a 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
192Constructor. Pass a pointer to the window on which you wish to paint.
193