Added wxMemoryDC::SelectObjectAsSource() and make SelectObject() unshare

the bitmap to ensure that no other bitmaps are modified; also remove some code
duplication by introducing wxMemoryDCBase (patch 1580745)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42755 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-10-30 19:41:46 +00:00
parent d2a93a2af3
commit fea35690f1
28 changed files with 185 additions and 148 deletions

View File

@@ -62,7 +62,7 @@ buffering on the systems which already do it automatically.
\func{}{wxBufferedDC}{\param{wxDC *}{dc}, \param{const wxSize\& }{area}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}}
\func{}{wxBufferedDC}{\param{wxDC *}{dc}, \param{const wxBitmap\& }{buffer}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}}
\func{}{wxBufferedDC}{\param{wxDC *}{dc}, \param{wxBitmap\& }{buffer}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}}
If you use the first, default, constructor, you must call one of the
\helpref{Init}{wxbuffereddcinit} methods later in order to use the object.
@@ -93,7 +93,7 @@ device context).}
\func{void}{Init}{\param{wxDC *}{dc}, \param{const wxSize\& }{area}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}}
\func{void}{Init}{\param{wxDC *}{dc}, \param{const wxBitmap\& }{buffer}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}}
\func{void}{Init}{\param{wxDC *}{dc}, \param{wxBitmap\& }{buffer}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}}
These functions initialize the object created using the default constructor.
Please see \helpref{constructors documentation}{wxbuffereddcctor} for details.
@@ -143,7 +143,7 @@ already does this internally for the real underlying wxPaintDC.
\membersection{wxBufferedPaintDC::wxBufferedPaintDC}\label{wxbufferedpaintdcctor}
\func{}{wxBufferedPaintDC}{\param{wxWindow *}{window}, \param{const wxBitmap\& }{buffer}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}}
\func{}{wxBufferedPaintDC}{\param{wxWindow *}{window}, \param{wxBitmap\& }{buffer}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}}
\func{}{wxBufferedPaintDC}{\param{wxWindow *}{window}, \param{int }{style = wxBUFFER\_CLIENT\_AREA}}

View File

@@ -41,26 +41,55 @@ can be reselected into another memory DC.
\membersection{wxMemoryDC::wxMemoryDC}\label{wxmemorydcctor}
\func{}{wxMemoryDC}{\param{const wxBitmap\& }{bitmap = wxNullBitmap}}
\func{}{wxMemoryDC}{\void}
Constructs a new memory device context.
Use the {\it Ok} member to test whether the constructor was successful
in creating a usable device context. If you don't pass a valid bitmap
to the constructor, don't forget to select a bitmap into the DC before
drawing on it.
Use the \helpref{IsOk}{wxdcisok} member to test whether the constructor was successful
in creating a usable device context.
Don't forget to select a bitmap into the DC before drawing on it.
\func{}{wxMemoryDC}{\param{wxBitmap\& }{bitmap}}
Constructs a new memory device context and calls \helpref{SelectObject}{wxmemorydcselectobject}
with the given bitmap.
Use the \helpref{IsOk}{wxdcisok} member to test whether the constructor was successful
in creating a usable device context.
\membersection{wxMemoryDC::SelectObject}\label{wxmemorydcselectobject}
\func{void}{SelectObject}{\param{const wxBitmap\& }{bitmap}}
\func{void}{SelectObject}{\param{wxBitmap\& }{bitmap}}
Works exactly like \helpref{SelectObjectAsSource}{wxmemorydcselectobjectassource} but
this is the function you should use when you select a bitmap because you want to modify
it, e.g. drawing on this DC.
Be careful to use this function and not \helpref{SelectObjectAsSource}{wxmemorydcselectobjectassource}
when you want to modify the bitmap you are selecting otherwise you may incurr in some
problems related to wxBitmap being a reference counted object
(see \helpref{reference counting overview}{trefcount}).
\wxheading{See also}
\helpref{wxDC::DrawBitmap}{wxdcdrawbitmap}
\membersection{wxMemoryDC::SelectObjectAsSource}\label{wxmemorydcselectobjectassource}
\func{void}{SelectObjectAsSource}{\param{const wxBitmap\& }{bitmap}}
Selects the given bitmap into the device context, to use as the memory
bitmap. Selecting the bitmap into a memory DC allows you to draw into
the DC (and therefore the bitmap) and also to use {\bf Blit} to copy
the DC (and therefore the bitmap) and also to use \helpref{wxDC::Blit}{wxdcblit} to copy
the bitmap to a window. For this purpose, you may find \helpref{wxDC::DrawIcon}{wxdcdrawicon}\rtfsp
easier to use instead.
If the argument is wxNullBitmap (or some other uninitialised wxBitmap) the current bitmap is selected out of the device
context, and the original bitmap restored, allowing the current bitmap to
If the argument is wxNullBitmap (or some other uninitialised wxBitmap) the current bitmap is
selected out of the device context, and the original bitmap restored, allowing the current bitmap to
be destroyed safely.
\wxheading{See also}
\helpref{wxMemoryDC::SelectObject}{wxmemorydcselectobject}