wxMemoryDC constructor now optionally accepts a wxBitmap parameter,

calling SelectObject itself if a valid bitmap is passed.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-10-13 18:48:36 +00:00
parent 51ad652fa2
commit 432efcb004
26 changed files with 77 additions and 27 deletions

View File

@@ -52,6 +52,17 @@ Major changes in 2.7 release
- New AUI library supporting docking windows and much more - New AUI library supporting docking windows and much more
2.7.2
-----
All (GUI):
- wxMemoryDC constructor now optionally accepts a wxBitmap parameter,
calling SelectObject itself if a valid bitmap is passed.
2.7.1 2.7.1
----- -----

View File

@@ -41,13 +41,14 @@ can be reselected into another memory DC.
\membersection{wxMemoryDC::wxMemoryDC}\label{wxmemorydcctor} \membersection{wxMemoryDC::wxMemoryDC}\label{wxmemorydcctor}
\func{}{wxMemoryDC}{\void} \func{}{wxMemoryDC}{\param{const wxBitmap\& }{bitmap = wxNullBitmap}}
Constructs a new memory device context. Constructs a new memory device context.
Use the {\it Ok} member to test whether the constructor was successful Use the {\it Ok} member to test whether the constructor was successful
in creating a usable device context. Don't forget to select a bitmap in creating a usable device context. If you don't pass a valid bitmap
into the DC before drawing on it. to the constructor, don't forget to select a bitmap into the DC before
drawing on it.
\membersection{wxMemoryDC::SelectObject}\label{wxmemorydcselectobject} \membersection{wxMemoryDC::SelectObject}\label{wxmemorydcselectobject}

View File

@@ -18,7 +18,7 @@ class WXDLLEXPORT wxMemoryDC: public wxDC
{ {
DECLARE_DYNAMIC_CLASS(wxMemoryDC) DECLARE_DYNAMIC_CLASS(wxMemoryDC)
public: public:
wxMemoryDC(void); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC( wxDC *dc ); // Create compatible DC wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(void); virtual ~wxMemoryDC(void);
virtual void SelectObject(const wxBitmap& bitmap); virtual void SelectObject(const wxBitmap& bitmap);

View File

@@ -17,7 +17,7 @@
class WXDLLIMPEXP_CORE wxMemoryDC : public wxDC class WXDLLIMPEXP_CORE wxMemoryDC : public wxDC
{ {
public: public:
wxMemoryDC(); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC(wxDC *dc); // create compatible DC wxMemoryDC(wxDC *dc); // create compatible DC
virtual void SelectObject(const wxBitmap& bitmap); virtual void SelectObject(const wxBitmap& bitmap);

View File

@@ -26,7 +26,7 @@ class WXDLLIMPEXP_CORE wxMemoryDC;
class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC
{ {
public: public:
wxMemoryDC(); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC( wxDC *dc ); // Create compatible DC wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(); virtual ~wxMemoryDC();
virtual void SelectObject( const wxBitmap& bitmap ); virtual void SelectObject( const wxBitmap& bitmap );

View File

@@ -26,7 +26,7 @@ class WXDLLIMPEXP_CORE wxMemoryDC;
class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC
{ {
public: public:
wxMemoryDC(); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC( wxDC *dc ); // Create compatible DC wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(); virtual ~wxMemoryDC();
virtual void SelectObject( const wxBitmap& bitmap ); virtual void SelectObject( const wxBitmap& bitmap );

View File

@@ -19,7 +19,7 @@ class WXDLLEXPORT wxMemoryDC: public wxPaintDC
DECLARE_DYNAMIC_CLASS(wxMemoryDC) DECLARE_DYNAMIC_CLASS(wxMemoryDC)
public: public:
wxMemoryDC(void); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC( wxDC *dc ); // Create compatible DC wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(void); virtual ~wxMemoryDC(void);
virtual void SelectObject( const wxBitmap& bitmap ); virtual void SelectObject( const wxBitmap& bitmap );

View File

@@ -19,7 +19,7 @@ class WXDLLEXPORT wxMemoryDC: public wxPaintDC
DECLARE_DYNAMIC_CLASS(wxMemoryDC) DECLARE_DYNAMIC_CLASS(wxMemoryDC)
public: public:
wxMemoryDC(void); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC( wxDC *dc ); // Create compatible DC wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(void); virtual ~wxMemoryDC(void);
virtual void SelectObject( const wxBitmap& bitmap ); virtual void SelectObject( const wxBitmap& bitmap );

View File

@@ -26,7 +26,7 @@ class WXDLLEXPORT wxMemoryDC;
class WXDLLEXPORT wxMemoryDC : public wxDC class WXDLLEXPORT wxMemoryDC : public wxDC
{ {
public: public:
wxMemoryDC(); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC(wxDC *dc); // Create compatible DC wxMemoryDC(wxDC *dc); // Create compatible DC
virtual ~wxMemoryDC(); virtual ~wxMemoryDC();
virtual void SelectObject(const wxBitmap& bitmap); virtual void SelectObject(const wxBitmap& bitmap);

View File

@@ -19,7 +19,7 @@ class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC
DECLARE_DYNAMIC_CLASS(wxMemoryDC) DECLARE_DYNAMIC_CLASS(wxMemoryDC)
public: public:
wxMemoryDC(); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC( wxDC *dc ); // Create compatible DC wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(); virtual ~wxMemoryDC();

View File

@@ -17,7 +17,7 @@
class WXDLLEXPORT wxMemoryDC : public wxDC class WXDLLEXPORT wxMemoryDC : public wxDC
{ {
public: public:
wxMemoryDC(); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC(wxDC *dc); // Create compatible DC wxMemoryDC(wxDC *dc); // Create compatible DC
virtual void SelectObject(const wxBitmap& bitmap); virtual void SelectObject(const wxBitmap& bitmap);

View File

@@ -17,7 +17,7 @@
class WXDLLEXPORT wxMemoryDC: public wxDC class WXDLLEXPORT wxMemoryDC: public wxDC
{ {
public: public:
wxMemoryDC(void); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC(wxDC* pDC); // Create compatible DC wxMemoryDC(wxDC* pDC); // Create compatible DC
virtual void SelectObject(const wxBitmap& rBitmap); virtual void SelectObject(const wxBitmap& rBitmap);

View File

@@ -17,7 +17,7 @@
class WXDLLEXPORT wxMemoryDC : public wxDC class WXDLLEXPORT wxMemoryDC : public wxDC
{ {
public: public:
wxMemoryDC(); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC(wxDC *dc); // Create compatible DC wxMemoryDC(wxDC *dc); // Create compatible DC
virtual void SelectObject(const wxBitmap& bitmap); virtual void SelectObject(const wxBitmap& bitmap);

View File

@@ -17,7 +17,7 @@
class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC
{ {
public: public:
wxMemoryDC(); wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
wxMemoryDC( wxDC *dc ); // Create compatible DC wxMemoryDC( wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDC(); virtual ~wxMemoryDC();
virtual void SelectObject( const wxBitmap& bitmap ); virtual void SelectObject( const wxBitmap& bitmap );

View File

@@ -30,10 +30,13 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxDC)
wxMemoryDC::wxMemoryDC(void) wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
{ {
m_cocoaNSImage = NULL; m_cocoaNSImage = NULL;
m_ok = false; m_ok = false;
if ( bitmap.IsOk() )
SelectObject(bitmap);
} }
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )

View File

@@ -39,8 +39,10 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
wxMemoryDC::wxMemoryDC() wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
{ {
if ( bitmap.IsOk() )
SelectObject(bitmap);
} }
wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc)) wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc))

View File

@@ -21,7 +21,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
wxMemoryDC::wxMemoryDC() : wxWindowDC() wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
: wxWindowDC()
{ {
m_ok = false; m_ok = false;
@@ -33,6 +34,9 @@ wxMemoryDC::wxMemoryDC() : wxWindowDC()
pango_context_set_language( m_context, gtk_get_default_language() ); pango_context_set_language( m_context, gtk_get_default_language() );
m_layout = pango_layout_new( m_context ); m_layout = pango_layout_new( m_context );
m_fontdesc = pango_font_description_copy( pango_context_get_font_description( 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) ) wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )

View File

@@ -21,11 +21,15 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
wxMemoryDC::wxMemoryDC() : wxWindowDC() wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
: wxWindowDC()
{ {
m_ok = false; m_ok = false;
m_cmap = gtk_widget_get_default_colormap(); m_cmap = gtk_widget_get_default_colormap();
if ( bitmap.IsOk() )
SelectObject(bitmap);
} }
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )

View File

@@ -21,7 +21,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
wxMemoryDC::wxMemoryDC() wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
: m_selected() : m_selected()
{ {
m_ok = true; m_ok = true;
@@ -30,6 +30,9 @@ wxMemoryDC::wxMemoryDC()
SetPen(*wxBLACK_PEN); SetPen(*wxBLACK_PEN);
SetFont(*wxNORMAL_FONT); SetFont(*wxNORMAL_FONT);
m_ok = false; m_ok = false;
if ( bitmap.IsOk() )
SelectObject(bitmap);
} }
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )

View File

@@ -21,7 +21,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
wxMemoryDC::wxMemoryDC(void) wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
: m_selected() : m_selected()
{ {
m_ok = true; m_ok = true;
@@ -29,6 +29,9 @@ wxMemoryDC::wxMemoryDC(void)
SetBrush(*wxWHITE_BRUSH); SetBrush(*wxWHITE_BRUSH);
SetPen(*wxBLACK_PEN); SetPen(*wxBLACK_PEN);
m_ok = false; m_ok = false;
if ( bitmap.IsOk() )
SelectObject(bitmap);
}; };
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )

View File

@@ -24,9 +24,13 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
wxMemoryDC::wxMemoryDC() : wxDC() wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
: wxDC()
{ {
m_isMemDC = true; m_isMemDC = true;
if ( bitmap.IsOk() )
SelectObject(bitmap);
} }
wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc)) : wxDC() wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc)) : wxDC()

View File

@@ -35,7 +35,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
wxMemoryDC::wxMemoryDC(void) wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
{ {
m_ok = true; m_ok = true;
m_display = wxGetDisplay(); m_display = wxGetDisplay();
@@ -57,6 +57,9 @@ wxMemoryDC::wxMemoryDC(void)
SetBrush (* wxWHITE_BRUSH); SetBrush (* wxWHITE_BRUSH);
SetPen (* wxBLACK_PEN); SetPen (* wxBLACK_PEN);
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
if ( bitmap.IsOk() )
SelectObject(bitmap);
} }
wxMemoryDC::wxMemoryDC( wxDC* dc ) wxMemoryDC::wxMemoryDC( wxDC* dc )

View File

@@ -47,11 +47,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
// wxMemoryDC // wxMemoryDC
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxMemoryDC::wxMemoryDC() wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
{ {
CreateCompatible(NULL); CreateCompatible(NULL);
Init(); Init();
if ( bitmap.IsOk() )
SelectObject(bitmap);
} }
wxMemoryDC::wxMemoryDC(wxDC *dc) wxMemoryDC::wxMemoryDC(wxDC *dc)

View File

@@ -28,10 +28,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
// Memory DC // Memory DC
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
wxMemoryDC::wxMemoryDC(void) wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
{ {
CreateCompatible(NULL); CreateCompatible(NULL);
Init(); Init();
if ( bitmap.IsOk() )
SelectObject(bitmap);
} // end of wxMemoryDC::wxMemoryDC } // end of wxMemoryDC::wxMemoryDC
wxMemoryDC::wxMemoryDC( wxMemoryDC::wxMemoryDC(

View File

@@ -45,8 +45,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
// wxMemoryDC // wxMemoryDC
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxMemoryDC::wxMemoryDC() wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
{ {
if ( bitmap.IsOk() )
SelectObject(bitmap);
} }
wxMemoryDC::wxMemoryDC(wxDC *dc) wxMemoryDC::wxMemoryDC(wxDC *dc)

View File

@@ -23,7 +23,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
wxMemoryDC::wxMemoryDC() : wxWindowDC() wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
: wxWindowDC()
{ {
m_ok = false; m_ok = false;
@@ -31,6 +32,9 @@ wxMemoryDC::wxMemoryDC() : wxWindowDC()
int screen = DefaultScreen( wxGlobalDisplay() ); int screen = DefaultScreen( wxGlobalDisplay() );
m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen ); m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen );
if ( bitmap.IsOk() )
SelectObject(bitmap);
} }
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )