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