1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxBufferedDC documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) 2004 Vadim Zeitlin
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxBufferedDC
}}\label{wxbuffereddc
}
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
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
}.
24 Please note that GTK+
2.0 as well as OS X provide double buffering themselves
25 natively. wxBufferedDC is aware of this however, and will bypass the buffering
26 unless explicit buffer bitmap is given.
28 \wxheading{Derived from
}
30 \helpref{wxDC
}{wxdc
}\\
31 \helpref{wxObject
}{wxobject
}
33 \wxheading{Include files
}
39 \helpref{wxDC
}{wxdc
},
\rtfsp
40 \helpref{wxMemoryDC
}{wxmemorydc
},
\rtfsp
41 \helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
},
\rtfsp
42 \helpref{wxAutoBufferedPaintDC
}{wxautobufferedpaintdc
}
45 \latexignore{\rtfignore{\wxheading{Members
}}}
47 \membersection{wxBufferedDC::wxBufferedDC
}\label{wxbuffereddcctor
}
49 \func{}{wxBufferedDC
}{\void}
51 \func{}{wxBufferedDC
}{\param{wxDC *
}{dc
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
53 \func{}{wxBufferedDC
}{\param{wxWindow*
}{window
},
\param{wxDC *
}{dc
},
\param{const wxSize\&
}{area
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
55 If you use the first, default, constructor, you must call one of the
56 \helpref{Init
}{wxbuffereddcinit
} methods later in order to use the object.
58 The other constructors initialize the object immediately and
\texttt{Init()
}
59 must not be called after using them.
61 \wxheading{Parameters
}
63 \docparam{dc
}{The underlying DC: everything drawn to this object will be
64 flushed to this DC when this object is destroyed. You may pass NULL
65 in order to just initialize the buffer, and not flush it.
}
67 \docparam{window
}{The window on which the dc paints. May be NULL, but
68 you should normally specify this so that the DC can be aware whether the
69 surface is natively double-buffered or not.
}
71 \docparam{area
}{The size of the bitmap to be used for buffering (this bitmap is
72 created internally when it is not given explicitly).
}
74 \docparam{buffer
}{Explicitly provided bitmap to be used for buffering: this is
75 the most efficient solution as the bitmap doesn't have to be recreated each
76 time but it also requires more memory as the bitmap is never freed. The bitmap
77 should have appropriate size, anything drawn outside of its bounds is clipped.
}
79 \docparam{style
}{wxBUFFER
\_CLIENT\_AREA to indicate that just the client area of
80 the window is buffered, or wxBUFFER
\_VIRTUAL\_AREA to indicate that the buffer bitmap
81 covers the virtual area (in which case PrepareDC is automatically called for the actual window
84 \membersection{wxBufferedDC::Init
}\label{wxbuffereddcinit
}
86 \func{void
}{Init
}{\param{wxDC *
}{dc
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
88 \func{void
}{Init
}{\param{wxWindow*
}{window
},
\param{wxDC *
}{dc
},
\param{const wxSize\&
}{area
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
90 These functions initialize the object created using the default constructor.
91 Please see
\helpref{constructors documentation
}{wxbuffereddcctor
} for details.
94 % VZ: UnMask() intentionally not documented, we might want to make it private
97 \membersection{wxBufferedDC::
\destruct{wxBufferedDC
}}\label{wxbuffereddcdtor
}
99 Copies everything drawn on the DC so far to the underlying DC associated with
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 \section{\class{wxBufferedPaintDC
}}\label{wxbufferedpaintdc
}
107 This is a subclass of
\helpref{wxBufferedDC
}{wxbuffereddc
} which can be used
108 inside of an
\texttt{OnPaint()
} event handler. Just create an object of this class instead
109 of
\helpref{wxPaintDC
}{wxpaintdc
} and make sure
\helpref{wxWindow::SetBackgroundStyle
}{wxwindowgetbackgroundstyle
}
110 is called with wxBG
\_STYLE\_CUSTOM somewhere in the class initialization code, and that's all
111 you have to do to (mostly) avoid flicker. The only thing to watch out for is that if you are
112 using this class together with
\helpref{wxScrolledWindow
}{wxscrolledwindow
}, you probably
113 do
\textbf{not
} want to call
\helpref{PrepareDC
}{wxscrolledwindowpreparedc
} on it as it
114 already does this internally for the real underlying wxPaintDC.
116 \wxheading{Derived from
}
118 \helpref{wxBufferedDC
}{wxbuffereddc
}\\
119 \helpref{wxDC
}{wxdc
}\\
120 \helpref{wxObject
}{wxobject
}
122 \wxheading{Include files
}
128 \helpref{wxDC
}{wxdc
},
\rtfsp
129 \helpref{wxBufferedDC
}{wxbuffereddc
},
\rtfsp
130 \helpref{wxAutoBufferedPaintDC
}{wxautobufferedpaintdc
}
133 \latexignore{\rtfignore{\wxheading{Members
}}}
135 \membersection{wxBufferedPaintDC::wxBufferedPaintDC
}\label{wxbufferedpaintdcctor
}
137 \func{}{wxBufferedPaintDC
}{\param{wxWindow *
}{window
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
139 \func{}{wxBufferedPaintDC
}{\param{wxWindow *
}{window
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
141 As with
\helpref{wxBufferedDC
}{wxbuffereddcctor
}, you may either provide the
142 bitmap to be used for buffering or let this object create one internally (in
143 the latter case, the size of the client part of the window is used).
145 Pass wxBUFFER
\_CLIENT\_AREA for the
{\it style
} parameter to indicate that just the client area of
146 the window is buffered, or wxBUFFER
\_VIRTUAL\_AREA to indicate that the buffer bitmap
147 covers the virtual area (in which case PrepareDC is automatically called for the actual window
150 \membersection{wxBufferedPaintDC::
\destruct{wxBufferedPaintDC
}}\label{wxbufferedpaintdcdtor
}
152 Copies everything drawn on the DC so far to the window associated with this
153 object, using a
\helpref{wxPaintDC
}{wxpaintdc
}.
156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 \section{\class{wxAutoBufferedPaintDC
}}\label{wxautobufferedpaintdc
}
160 This wxDC derivative can be used inside of an
\texttt{OnPaint()
} event handler to achieve
161 double-buffered drawing. Just create an object of this class instead of
\helpref{wxPaintDC
}{wxpaintdc
}
162 and make sure
\helpref{wxWindow::SetBackgroundStyle
}{wxwindowgetbackgroundstyle
} is called
163 with wxBG
\_STYLE\_CUSTOM somewhere in the class initialization code, and that's all you have
164 to do to (mostly) avoid flicker.
166 The difference between
\helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
} and this class,
167 is the lightweigthness - on platforms which have native double-buffering, wxAutoBufferedPaintDC is simply
168 a typedef of wxPaintDC. Otherwise, it is a typedef of wxBufferedPaintDC.
171 \wxheading{Derived from
}
173 \helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
}\\
174 \helpref{wxPaintDC
}{wxpaintdc
}\\
175 \helpref{wxDC
}{wxdc
}\\
176 \helpref{wxObject
}{wxobject
}
178 \wxheading{Include files
}
184 \helpref{wxDC
}{wxdc
},
\rtfsp
185 \helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
}
188 \latexignore{\rtfignore{\wxheading{Members
}}}
190 \membersection{wxAutoBufferedPaintDC::wxAutoBufferedPaintDC
}\label{wxautobufferedpaintdcctor
}
192 \func{}{wxAutoBufferedPaintDC
}{\param{wxWindow *
}{window
}}
194 Constructor. Pass a pointer to the window on which you wish to paint.