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{Derived from
}
30 \helpref{wxMemoryDC
}{wxmemorydc
}\\
31 \helpref{wxDC
}{wxdc
}\\
32 \helpref{wxObject
}{wxobject
}
34 \wxheading{Include files
}
40 \helpref{wxDC
}{wxdc
},
\rtfsp
41 \helpref{wxMemoryDC
}{wxmemorydc
},
\rtfsp
42 \helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
},
\rtfsp
43 \helpref{wxAutoBufferedPaintDC
}{wxautobufferedpaintdc
}
46 \latexignore{\rtfignore{\wxheading{Members
}}}
48 \membersection{wxBufferedDC::wxBufferedDC
}\label{wxbuffereddcctor
}
50 \func{}{wxBufferedDC
}{\void}
52 \func{}{wxBufferedDC
}{\param{wxDC *
}{dc
},
\param{const wxSize\&
}{area
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
54 \func{}{wxBufferedDC
}{\param{wxDC *
}{dc
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
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.
59 The other constructors initialize the object immediately and
\texttt{Init()
}
60 must not be called after using them.
62 \wxheading{Parameters
}
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.
}
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).
}
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.
}
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
81 \membersection{wxBufferedDC::Init
}\label{wxbuffereddcinit
}
83 \func{void
}{Init
}{\param{wxDC *
}{dc
},
\param{const wxSize\&
}{area
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
85 \func{void
}{Init
}{\param{wxDC *
}{dc
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
87 These functions initialize the object created using the default constructor.
88 Please see
\helpref{constructors documentation
}{wxbuffereddcctor
} for details.
91 % VZ: UnMask() intentionally not documented, we might want to make it private
94 \membersection{wxBufferedDC::
\destruct{wxBufferedDC
}}\label{wxbuffereddcdtor
}
96 Copies everything drawn on the DC so far to the underlying DC associated with
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102 \section{\class{wxBufferedPaintDC
}}\label{wxbufferedpaintdc
}
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.
113 \wxheading{Derived from
}
115 \helpref{wxBufferedDC
}{wxbuffereddc
}\\
116 \helpref{wxMemoryDC
}{wxmemorydc
}\\
117 \helpref{wxDC
}{wxdc
}\\
118 \helpref{wxObject
}{wxobject
}
120 \wxheading{Include files
}
126 \helpref{wxDC
}{wxdc
},
\rtfsp
127 \helpref{wxBufferedDC
}{wxbuffereddc
},
\rtfsp
128 \helpref{wxAutoBufferedPaintDC
}{wxautobufferedpaintdc
}
131 \latexignore{\rtfignore{\wxheading{Members
}}}
133 \membersection{wxBufferedPaintDC::wxBufferedPaintDC
}\label{wxbufferedpaintdcctor
}
135 \func{}{wxBufferedPaintDC
}{\param{wxWindow *
}{window
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
137 \func{}{wxBufferedPaintDC
}{\param{wxWindow *
}{window
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
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).
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
148 \membersection{wxBufferedPaintDC::
\destruct{wxBufferedPaintDC
}}\label{wxbufferedpaintdcdtor
}
150 Copies everything drawn on the DC so far to the window associated with this
151 object, using a
\helpref{wxPaintDC
}{wxpaintdc
}.
154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156 \section{\class{wxAutoBufferedPaintDC
}}\label{wxautobufferedpaintdc
}
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.
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.
169 \wxheading{Derived from
}
171 \helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
}\\
172 \helpref{wxPaintDC
}{wxpaintdc
}\\
173 \helpref{wxDC
}{wxdc
}\\
174 \helpref{wxObject
}{wxobject
}
176 \wxheading{Include files
}
182 \helpref{wxDC
}{wxdc
},
\rtfsp
183 \helpref{wxBufferedPaintDC
}{wxbufferedpaintdc
}
186 \latexignore{\rtfignore{\wxheading{Members
}}}
188 \membersection{wxAutoBufferedPaintDC::wxAutoBufferedPaintDC
}\label{wxautobufferedpaintdcctor
}
190 \func{}{wxAutoBufferedPaintDC
}{\param{wxWindow *
}{window
}}
192 Constructor. Pass a pointer to the window on which you wish to paint.