\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.
\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.
\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}}
\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}
#include "wx/dc.h"
-class WXDLLEXPORT wxMemoryDC: public wxDC
+class WXDLLEXPORT wxMemoryDC: public wxDC, public wxMemoryDCBase
{
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
+
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() { Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(void);
- virtual void SelectObject(const wxBitmap& bitmap);
+
virtual void DoGetSize(int *width, int *height) const;
+ virtual void DoSelect(const wxBitmap& bitmap);
+
protected:
wxBitmap m_selectedBitmap;
WX_NSImage m_cocoaNSImage;
virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask);
+
+private:
+ void Init();
};
#endif
#include "wx/defs.h"
+// NOTE: different native implementations of wxMemoryDC will derive from
+// different wxDC classes (wxPaintDC, wxWindowDC, etc), so that
+// we cannot derive wxMemoryDCBase from wxDC and then use it as the
+// only base class for native impl of wxMemoryDC...
+class wxMemoryDCBase
+{
+public:
+ wxMemoryDCBase() { }
+
+ // avoid warnings about having virtual functions but non virtual dtor
+ virtual ~wxMemoryDCBase() { }
+
+ // select the given bitmap to draw on it
+ void SelectObject(wxBitmap& bmp)
+ {
+ // make sure that the given wxBitmap is not sharing its data with other
+ // wxBitmap instances as its contents will be modified by any drawing
+ // operation done on this DC
+ if (bmp.IsOk())
+ bmp.UnShare();
+
+ DoSelect(bmp);
+ }
+
+ // select the given bitmap for read-only
+ virtual void SelectObjectAsSource(const wxBitmap& bmp)
+ {
+ DoSelect(bmp);
+ }
+
+ virtual void DoSelect(const wxBitmap& bmp) = 0;
+};
+
#if defined(__WXPALMOS__)
#include "wx/palmos/dcmemory.h"
#elif defined(__WXMSW__)
#include "wx/dc.h"
#include "wx/bitmap.h"
-class WXDLLIMPEXP_CORE wxMemoryDC : public wxDC
+class WXDLLIMPEXP_CORE wxMemoryDC : public wxDC, public wxMemoryDCBase
{
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() { Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC(wxDC *dc); // create compatible DC
- virtual void SelectObject(const wxBitmap& bitmap);
-
// implementation from now on:
wxBitmap GetSelectedObject() const { return m_bmp; }
+protected:
+ virtual void DoSelect(const wxBitmap& bitmap);
+
private:
+ void Init();
+
wxBitmap m_bmp;
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
// wxMemoryDC
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC
+class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC, public wxMemoryDCBase
{
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() : wxWindowDC() { Init(); }
+ wxMemoryDC(wxBitmap& bitmap) : wxWindowDC() { Init(); SelectObject(bitmap); }
wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC();
- virtual void SelectObject( const wxBitmap& bitmap );
// these get reimplemented for mono-bitmaps to behave
// more like their Win32 couterparts. They now interpret
protected:
void DoGetSize( int *width, int *height ) const;
+ virtual void DoSelect(const wxBitmap& bitmap);
+
+private:
+ void Init();
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const
{ return subrect == NULL ? GetSelectedBitmap() : GetSelectedBitmap().GetSubBitmap(*subrect); }
// wxMemoryDC
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC
+class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC, public wxMemoryDCBase
{
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() { Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC();
- virtual void SelectObject( const wxBitmap& bitmap );
void DoGetSize( int *width, int *height ) const;
// these get reimplemented for mono-bitmaps to behave
// implementation
wxBitmap m_selected;
+protected:
+ virtual void DoSelect(const wxBitmap& bitmap);
+
private:
+ void Init();
+
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
};
#include "wx/dcclient.h"
-class WXDLLEXPORT wxMemoryDC: public wxPaintDC
+class WXDLLEXPORT wxMemoryDC: public wxPaintDC, public wxMemoryDCBase
{
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
- public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+public:
+ wxMemoryDC() { Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(void);
- virtual void SelectObject( const wxBitmap& bitmap );
+
const wxBitmap& GetSelectedBitmap() const { return m_selected; }
wxBitmap GetSelectedBitmap() { return m_selected; }
virtual void DoGetSize( int *width, int *height ) const;
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const
{ return subrect == NULL ? GetSelectedBitmap() : GetSelectedBitmap().GetSubBitmap(*subrect); }
+ virtual void DoSelect(const wxBitmap& bitmap);
+
+private:
+ void Init();
- private:
wxBitmap m_selected;
};
// wxMemoryDC
//-----------------------------------------------------------------------------
-class WXDLLEXPORT wxMemoryDC : public wxDC
+class WXDLLEXPORT wxMemoryDC : public wxDC, public wxMemoryDCBase
{
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() { Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC(wxDC *dc); // Create compatible DC
virtual ~wxMemoryDC();
- virtual void SelectObject(const wxBitmap& bitmap);
// these get reimplemented for mono-bitmaps to behave
// more like their Win32 couterparts. They now interpret
wxBitmap GetSelectedObject() const { return m_selected; }
+protected:
+ virtual void DoSelect(const wxBitmap& bitmap);
+
private:
+ void Init();
+
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
};
#include "wx/dcclient.h"
-class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC
+class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC, public wxMemoryDCBase
{
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() { Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC();
- virtual void SelectObject( const wxBitmap& bitmap );
-
void DoGetSize( int *width, int *height ) const;
wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
+protected:
+ virtual void DoSelect(const wxBitmap& bitmap);
+
private:
friend class wxPaintDC;
+ void Init();
+
wxBitmap m_bitmap;
};
#include "wx/dcclient.h"
-class WXDLLEXPORT wxMemoryDC : public wxDC
+class WXDLLEXPORT wxMemoryDC : public wxDC, public wxMemoryDCBase
{
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() { CreateCompatible(NULL); Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { CreateCompatible(NULL); Init(); SelectObject(bitmap); }
wxMemoryDC(wxDC *dc); // Create compatible DC
- virtual void SelectObject(const wxBitmap& bitmap);
protected:
// override some base class virtuals
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoGetSize(int* width, int* height) const;
+ virtual void DoSelect(const wxBitmap& bitmap);
// create DC compatible with the given one or screen if dc == NULL
bool CreateCompatible(wxDC *dc);
#include "wx/dcclient.h"
-class WXDLLEXPORT wxMemoryDC: public wxDC
+class WXDLLEXPORT wxMemoryDC: public wxDC, public wxMemoryDCBase
{
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() { CreateCompatible(NULL); Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { CreateCompatible(NULL); Init(); SelectObject(bitmap); }
wxMemoryDC(wxDC* pDC); // Create compatible DC
- virtual void SelectObject(const wxBitmap& rBitmap);
protected:
// override some base class virtuals
virtual void DoGetSize( int* pWidth
,int* pHeight
) const;
+ virtual void DoSelect(const wxBitmap& bitmap);
+
// create DC compatible with the given one or screen if dc == NULL
bool CreateCompatible(wxDC* pDC);
#include "wx/dcclient.h"
-class WXDLLEXPORT wxMemoryDC : public wxDC
+class WXDLLEXPORT wxMemoryDC : public wxDC, public wxMemoryDCBase
{
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() { Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC(wxDC *dc); // Create compatible DC
- virtual void SelectObject(const wxBitmap& bitmap);
-
protected:
// override some base class virtuals
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoGetSize(int* width, int* height) const;
+ virtual void DoSelect(const wxBitmap& bitmap);
// create DC compatible with the given one or screen if dc == NULL
bool CreateCompatible(wxDC *dc);
#include "wx/dcclient.h"
-class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC
+class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC, public wxMemoryDCBase
{
public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
+ wxMemoryDC() { Init(); }
+ wxMemoryDC(wxBitmap& bitmap) { Init(); SelectObject(bitmap); }
wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC();
- virtual void SelectObject( const wxBitmap& bitmap );
// implementation
wxBitmap m_selected;
protected:
- void DoGetSize( int *width, int *height ) const;
+ virtual void DoGetSize( int *width, int *height ) const;
+ virtual void DoSelect(const wxBitmap& bitmap);
+
+private:
+ void Init();
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
};
}
#endif // wxUSE_PALETTE
- dcMem.SelectObject(bitmap);
+ dcMem.SelectObjectAsSource(bitmap);
int i, j;
for (i = rect.x; i < rect.x + rect.width; i += w)
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
+void wxMemoryDC::Init()
{
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
}
wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc))
{
}
-void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
+void wxMemoryDC::DoSelect(const wxBitmap& bitmap)
{
m_bmp = bitmap;
}
#endif // USE_PALETTE_IN_SPLASH
- dcMem.SelectObject(bitmap);
+ dcMem.SelectObjectAsSource(bitmap);
dc.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0);
dcMem.SelectObject(wxNullBitmap);
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
- : wxWindowDC()
+void wxMemoryDC::Init()
{
m_ok = false;
pango_context_set_language( m_context, gtk_get_default_language() );
m_layout = pango_layout_new( m_context );
m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
-
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
}
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
: wxWindowDC()
{
- m_ok = false;
-
- m_cmap = gtk_widget_get_default_colormap();
-
- m_context = gdk_pango_context_get();
- pango_context_set_language( m_context, gtk_get_default_language() );
- m_layout = pango_layout_new( m_context );
- m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
+ Init();
}
wxMemoryDC::~wxMemoryDC()
g_object_unref(m_context);
}
-void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
+void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
{
Destroy();
+
m_selected = bitmap;
if (m_selected.Ok())
{
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
- : wxWindowDC()
+void wxMemoryDC::Init()
{
m_ok = false;
m_cmap = gtk_widget_get_default_colormap();
-
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
}
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
: wxWindowDC()
{
- m_ok = false;
-
- m_cmap = gtk_widget_get_default_colormap();
-
+ Init();
}
wxMemoryDC::~wxMemoryDC()
{
}
-void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
+void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
{
Destroy();
+
m_selected = bitmap;
if (m_selected.Ok())
{
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
-: m_selected()
+void wxMemoryDC::Init()
{
m_ok = true;
SetBackground(*wxWHITE_BRUSH);
SetPen(*wxBLACK_PEN);
SetFont(*wxNORMAL_FONT);
m_ok = false;
-
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
}
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
: m_selected()
{
- m_ok = true;
- SetBackground(*wxWHITE_BRUSH);
- SetBrush(*wxWHITE_BRUSH);
- SetPen(*wxBLACK_PEN);
- SetFont(*wxNORMAL_FONT);
- m_ok = false;
+ Init();
}
wxMemoryDC::~wxMemoryDC()
}
}
-void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
+void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
{
if ( m_selected.Ok() )
{
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
- : wxDC()
+void wxMemoryDC::Init()
{
m_isMemDC = true;
-
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
}
wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc)) : wxDC()
{
- m_isMemDC = true;
+ Init();
}
wxMemoryDC::~wxMemoryDC()
{
}
-void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
+void wxMemoryDC::DoSelect(const wxBitmap& bitmap)
{
if ( bitmap.Ok() )
{
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
+void wxMemoryDC::Init()
{
m_ok = true;
m_display = wxGetDisplay();
SetBrush (* wxWHITE_BRUSH);
SetPen (* wxBLACK_PEN);
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
-
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
}
wxMemoryDC::wxMemoryDC( wxDC* dc )
{
}
-void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
+void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
{
m_bitmap = bitmap;
// transparent pen) one pixel smaller in both directions and we want them
// to have the same size regardless of which pen is used - adjust
- // I wonder if this shouldnยดt be done after the LOG2DEV() conversions. RR.
+ // I wonder if this shouldnt be done after the LOG2DEV() conversions. RR.
if ( m_pen.GetStyle() == wxTRANSPARENT )
{
// Apparently not needed for WinCE (see e.g. Life! demo)
// Rather than reproduce wxDC::Blit, let's do it at the wxWin API
// level
wxMemoryDC memDC;
- memDC.SelectObject(bmp);
+
+ memDC.SelectObjectAsSource(bmp);
Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask);
// wxMemoryDC
// ----------------------------------------------------------------------------
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
-{
- CreateCompatible(NULL);
-
- Init();
-
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
-}
-
wxMemoryDC::wxMemoryDC(wxDC *dc)
{
wxCHECK_RET( dc, _T("NULL dc in wxMemoryDC ctor") );
return m_ok;
}
-void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
+void wxMemoryDC::DoSelect( const wxBitmap& bitmap)
{
// select old bitmap out of the device context
if ( m_oldBitmap )
{
// no support for StretchDIBits() or an error occurred if we got here
wxMemoryDC memDC;
- memDC.SelectObject(bmp);
+
+ memDC.SelectObjectAsSource(bmp);
Blit(x, y, width, height, &memDC, 0, 0, wxCOPY, useMask);
// Memory DC
/////////////////////////////////////////////////////////////////////////////
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
-{
- CreateCompatible(NULL);
- Init();
-
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
-} // end of wxMemoryDC::wxMemoryDC
-
wxMemoryDC::wxMemoryDC(
wxDC* pOldDC
)
return m_ok;
} // end of wxMemoryDC::CreateCompatible
-void wxMemoryDC::SelectObject(
+void wxMemoryDC::DoSelect(
const wxBitmap& rBitmap
)
{
);
m_vSelectedBitmap.SetSelectedInto(NULL);
}
+
m_vSelectedBitmap = rBitmap;
// wxMemoryDC
// ----------------------------------------------------------------------------
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
-{
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
-}
-
wxMemoryDC::wxMemoryDC(wxDC *dc)
{
}
return false;
}
-void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
+void wxMemoryDC::DoSelect(const wxBitmap& bitmap)
{
}
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
- : wxWindowDC()
+void wxMemoryDC::Init()
{
m_ok = false;
int screen = DefaultScreen( wxGlobalDisplay() );
m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen );
-
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
}
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
: wxWindowDC()
{
- m_ok = false;
-
- m_display = (WXDisplay *) wxGlobalDisplay();
-
- int screen = DefaultScreen( wxGlobalDisplay() );
- m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen );
+ Init();
}
wxMemoryDC::~wxMemoryDC()
{
}
-void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
+void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
{
Destroy();