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