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
}.
24 Please note that GTK+
2.0 as well as OS X provide double buffering themselves
25 natively so this class should normally not be used there.
27 \wxheading{Derived from
}
29 \helpref{wxMemoryDC
}{wxmemorydc
}\\
30 \helpref{wxDC
}{wxdc
}\\
31 \helpref{wxObject
}{wxobject
}
33 \wxheading{Include files
}
42 \latexignore{\rtfignore{\wxheading{Members
}}}
44 \membersection{wxBufferedDC::wxBufferedDC
}\label{wxbuffereddcctor
}
46 \func{}{wxBufferedDC
}{\void}
48 \func{}{wxBufferedDC
}{\param{wxDC *
}{dc
},
\param{const wxSize\&
}{area
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
50 \func{}{wxBufferedDC
}{\param{wxDC *
}{dc
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
52 If you use the first, default, constructor, you must call one of the
53 \helpref{Init
}{wxbuffereddcinit
} methods later in order to use the object.
55 The other constructors initialize the object immediately and
\texttt{Init()
}
56 must not be called after using them.
58 \wxheading{Parameters
}
60 \docparam{dc
}{The underlying DC: everything drawn to this object will be
61 flushed to this DC when this object is destroyed. You may pass NULL
62 in order to just initialize the buffer, and not flush it.
}
64 \docparam{area
}{The size of the bitmap to be used for buffering (this bitmap is
65 created internally when it is not given explicitly).
}
67 \docparam{buffer
}{Explicitly provided bitmap to be used for buffering: this is
68 the most efficient solution as the bitmap doesn't have to be recreated each
69 time but it also requires more memory as the bitmap is never freed. The bitmap
70 should have appropriate size, anything drawn outside of its bounds is clipped.
}
72 \docparam{style
}{wxBUFFER
\_CLIENT\_AREA to indicate that just the client area of
73 the window is buffered, or wxBUFFER
\_VIRTUAL\_AREA to indicate that the buffer bitmap
74 covers the virtual area (in which case PrepareDC is automatically called for the actual window
77 \membersection{wxBufferedDC::Init
}\label{wxbuffereddcinit
}
79 \func{void
}{Init
}{\param{wxDC *
}{dc
},
\param{const wxSize\&
}{area
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
81 \func{void
}{Init
}{\param{wxDC *
}{dc
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
83 These functions initialize the object created using the default constructor.
84 Please see
\helpref{constructors documentation
}{wxbuffereddcctor
} for details.
87 % VZ: UnMask() intentionally not documented, we might want to make it private
90 \membersection{wxBufferedDC::
\destruct{wxBufferedDC
}}\label{wxbuffereddcdtor
}
92 Copies everything drawn on the DC so far to the underlying DC associated with
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98 \section{\class{wxBufferedPaintDC
}}\label{wxbufferedpaintdc
}
100 This is a subclass of
\helpref{wxBufferedDC
}{wxbuffereddc
} which can be used
101 inside of an
\texttt{OnPaint()
} event handler. Just create an object of this class instead
102 of
\helpref{wxPaintDC
}{wxpaintdc
} and that's all you have to do to (mostly)
103 avoid flicker. The only thing to watch out for is that if you are using this
104 class together with
\helpref{wxScrolledWindow
}{wxscrolledwindow
}, you probably
105 do
\textbf{not
} want to call
\helpref{PrepareDC
}{wxscrolledwindowpreparedc
} on it as it
106 already does this internally for the real underlying wxPaintDC.
108 \wxheading{Derived from
}
110 \helpref{wxMemoryDC
}{wxmemorydc
}\\
111 \helpref{wxDC
}{wxdc
}\\
112 \helpref{wxObject
}{wxobject
}
114 \wxheading{Include files
}
119 \latexignore{\rtfignore{\wxheading{Members
}}}
121 \membersection{wxBufferedPaintDC::wxBufferedPaintDC
}\label{wxbufferedpaintdcctor
}
123 \func{}{wxBufferedPaintDC
}{\param{wxWindow *
}{window
},
\param{const wxBitmap\&
}{buffer
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
125 \func{}{wxBufferedPaintDC
}{\param{wxWindow *
}{window
},
\param{int
}{style = wxBUFFER
\_CLIENT\_AREA}}
127 As with
\helpref{wxBufferedDC
}{wxbuffereddcctor
}, you may either provide the
128 bitmap to be used for buffering or let this object create one internally (in
129 the latter case, the size of the client part of the window is used).
131 Pass wxBUFFER
\_CLIENT\_AREA for the
{\it style
} parameter to indicate that just the client area of
132 the window is buffered, or wxBUFFER
\_VIRTUAL\_AREA to indicate that the buffer bitmap
133 covers the virtual area (in which case PrepareDC is automatically called for the actual window
136 \membersection{wxBufferedPaintDC::
\destruct{wxBufferedPaintDC
}}\label{wxbufferedpaintdcdtor
}
138 Copies everything drawn on the DC so far to the window associated with this
139 object, using a
\helpref{wxPaintDC
}{wxpaintdc
}.