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. Use
\helpref{wxWindow::IsDoubleBuffered
}{wxwindowisdoublebuffered
} to
26 +determine whether you need to use buffering or not.
28 \wxheading{Localization Support
}
30 If you pass in a valid DC, wxBufferedDC will inherit its layout direction.
32 \wxheading{Derived from
}
34 \helpref{wxMemoryDC
}{wxmemorydc
}\\
35 \helpref{wxDC
}{wxdc
}\\
36 \helpref{wxObject
}{wxobject
}
38 \wxheading{Include files
}
44 \helpref{wxDC
}{wxdc
},
\rtfsp
45 \helpref{wxMemoryDC
}{wxmemorydc
},
\rtfsp
46 \helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
},
\rtfsp
47 \helpref{wxAutoBufferedPaintDC
}{wxautobufferedpaintdc
}
50 \latexignore{\rtfignore{\wxheading{Members
}}}
52 \membersection{wxBufferedDC::wxBufferedDC
}\label{wxbuffereddcctor
}
54 \func{}{wxBufferedDC
}{\void}
56 \func{}{wxBufferedDC
}{\param{wxDC *
}{dc
},
\param{const wxSize\&
}{area
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
58 \func{}{wxBufferedDC
}{\param{wxDC *
}{dc
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
60 If you use the first, default, constructor, you must call one of the
61 \helpref{Init
}{wxbuffereddcinit
} methods later in order to use the object.
63 The other constructors initialize the object immediately and
\texttt{Init()
}
64 must not be called after using them.
66 \wxheading{Parameters
}
68 \docparam{dc
}{The underlying DC: everything drawn to this object will be
69 flushed to this DC when this object is destroyed. You may pass NULL
70 in order to just initialize the buffer, and not flush it.
}
72 \docparam{area
}{The size of the bitmap to be used for buffering (this bitmap is
73 created internally when it is not given explicitly).
}
75 \docparam{buffer
}{Explicitly provided bitmap to be used for buffering: this is
76 the most efficient solution as the bitmap doesn't have to be recreated each
77 time but it also requires more memory as the bitmap is never freed. The bitmap
78 should have appropriate size, anything drawn outside of its bounds is clipped.
}
80 \docparam{style
}{wxBUFFER
\_CLIENT\_AREA to indicate that just the client area of
81 the window is buffered, or wxBUFFER
\_VIRTUAL\_AREA to indicate that the buffer bitmap
82 covers the virtual area (in which case PrepareDC is automatically called for the actual window
85 \membersection{wxBufferedDC::Init
}\label{wxbuffereddcinit
}
87 \func{void
}{Init
}{\param{wxDC *
}{dc
},
\param{const wxSize\&
}{area
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
89 \func{void
}{Init
}{\param{wxDC *
}{dc
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
91 These functions initialize the object created using the default constructor.
92 Please see
\helpref{constructors documentation
}{wxbuffereddcctor
} for details.
95 % VZ: UnMask() intentionally not documented, we might want to make it private
98 \membersection{wxBufferedDC::
\destruct{wxBufferedDC
}}\label{wxbuffereddcdtor
}
100 Copies everything drawn on the DC so far to the underlying DC associated with
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 \section{\class{wxBufferedPaintDC
}}\label{wxbufferedpaintdc
}
108 This is a subclass of
\helpref{wxBufferedDC
}{wxbuffereddc
} which can be used
109 inside of an
\texttt{OnPaint()
} event handler. Just create an object of this class instead
110 of
\helpref{wxPaintDC
}{wxpaintdc
} and make sure
\helpref{wxWindow::SetBackgroundStyle
}{wxwindowgetbackgroundstyle
}
111 is called with wxBG
\_STYLE\_CUSTOM somewhere in the class initialization code, and that's all
112 you have to do to (mostly) avoid flicker. The only thing to watch out for is that if you are
113 using this class together with
\helpref{wxScrolledWindow
}{wxscrolledwindow
}, you probably
114 do
\textbf{not
} want to call
\helpref{PrepareDC
}{wxscrolledwindowpreparedc
} on it as it
115 already does this internally for the real underlying wxPaintDC.
117 \wxheading{Derived from
}
119 \helpref{wxBufferedDC
}{wxbuffereddc
}\\
120 \helpref{wxMemoryDC
}{wxmemorydc
}\\
121 \helpref{wxDC
}{wxdc
}\\
122 \helpref{wxObject
}{wxobject
}
124 \wxheading{Include files
}
130 \helpref{wxDC
}{wxdc
},
\rtfsp
131 \helpref{wxBufferedDC
}{wxbuffereddc
},
\rtfsp
132 \helpref{wxAutoBufferedPaintDC
}{wxautobufferedpaintdc
}
135 \latexignore{\rtfignore{\wxheading{Members
}}}
137 \membersection{wxBufferedPaintDC::wxBufferedPaintDC
}\label{wxbufferedpaintdcctor
}
139 \func{}{wxBufferedPaintDC
}{\param{wxWindow *
}{window
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
141 \func{}{wxBufferedPaintDC
}{\param{wxWindow *
}{window
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
143 As with
\helpref{wxBufferedDC
}{wxbuffereddcctor
}, you may either provide the
144 bitmap to be used for buffering or let this object create one internally (in
145 the latter case, the size of the client part of the window is used).
147 Pass wxBUFFER
\_CLIENT\_AREA for the
{\it style
} parameter to indicate that just the client area of
148 the window is buffered, or wxBUFFER
\_VIRTUAL\_AREA to indicate that the buffer bitmap
149 covers the virtual area (in which case PrepareDC is automatically called for the actual window
152 \membersection{wxBufferedPaintDC::
\destruct{wxBufferedPaintDC
}}\label{wxbufferedpaintdcdtor
}
154 Copies everything drawn on the DC so far to the window associated with this
155 object, using a
\helpref{wxPaintDC
}{wxpaintdc
}.
158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
160 \section{\class{wxAutoBufferedPaintDC
}}\label{wxautobufferedpaintdc
}
162 This wxDC derivative can be used inside of an
\texttt{OnPaint()
} event handler to achieve
163 double-buffered drawing. Just create an object of this class instead of
\helpref{wxPaintDC
}{wxpaintdc
}
164 and make sure
\helpref{wxWindow::SetBackgroundStyle
}{wxwindowgetbackgroundstyle
} is called
165 with wxBG
\_STYLE\_CUSTOM somewhere in the class initialization code, and that's all you have
166 to do to (mostly) avoid flicker.
168 The difference between
\helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
} and this class,
169 is the lightweigthness - on platforms which have native double-buffering, wxAutoBufferedPaintDC is simply
170 a typedef of wxPaintDC. Otherwise, it is a typedef of wxBufferedPaintDC.
173 \wxheading{Derived from
}
175 \helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
}\\
176 \helpref{wxPaintDC
}{wxpaintdc
}\\
177 \helpref{wxDC
}{wxdc
}\\
178 \helpref{wxObject
}{wxobject
}
180 \wxheading{Include files
}
186 \helpref{wxDC
}{wxdc
},
\rtfsp
187 \helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
}
190 \latexignore{\rtfignore{\wxheading{Members
}}}
192 \membersection{wxAutoBufferedPaintDC::wxAutoBufferedPaintDC
}\label{wxautobufferedpaintdcctor
}
194 \func{}{wxAutoBufferedPaintDC
}{\param{wxWindow *
}{window
}}
196 Constructor. Pass a pointer to the window on which you wish to paint.