From 432efcb004c8a7f4997acab1aa044c78226c36bb Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 13 Oct 2006 18:48:36 +0000 Subject: [PATCH] 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 --- docs/changes.txt | 11 +++++++++++ docs/latex/wx/memorydc.tex | 7 ++++--- include/wx/cocoa/dcmemory.h | 2 +- include/wx/dfb/dcmemory.h | 2 +- include/wx/gtk/dcmemory.h | 2 +- include/wx/gtk1/dcmemory.h | 2 +- include/wx/mac/carbon/dcmemory.h | 2 +- include/wx/mac/classic/dcmemory.h | 2 +- include/wx/mgl/dcmemory.h | 2 +- include/wx/motif/dcmemory.h | 2 +- include/wx/msw/dcmemory.h | 2 +- include/wx/os2/dcmemory.h | 2 +- include/wx/palmos/dcmemory.h | 2 +- include/wx/x11/dcmemory.h | 2 +- src/cocoa/dcmemory.mm | 5 ++++- src/dfb/dcmemory.cpp | 4 +++- src/gtk/dcmemory.cpp | 6 +++++- src/gtk1/dcmemory.cpp | 6 +++++- src/mac/carbon/dcmemory.cpp | 5 ++++- src/mac/classic/dcmemory.cpp | 5 ++++- src/mgl/dcmemory.cpp | 6 +++++- src/motif/dcmemory.cpp | 5 ++++- src/msw/dcmemory.cpp | 5 ++++- src/os2/dcmemory.cpp | 5 ++++- src/palmos/dcmemory.cpp | 4 +++- src/x11/dcmemory.cpp | 6 +++++- 26 files changed, 77 insertions(+), 27 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 089088fef2..e18d24de6e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -52,6 +52,17 @@ Major changes in 2.7 release - 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 ----- diff --git a/docs/latex/wx/memorydc.tex b/docs/latex/wx/memorydc.tex index 8f4c510d2b..eadaa1d991 100644 --- a/docs/latex/wx/memorydc.tex +++ b/docs/latex/wx/memorydc.tex @@ -41,13 +41,14 @@ can be reselected into another memory DC. \membersection{wxMemoryDC::wxMemoryDC}\label{wxmemorydcctor} -\func{}{wxMemoryDC}{\void} +\func{}{wxMemoryDC}{\param{const wxBitmap\& }{bitmap = wxNullBitmap}} Constructs a new memory device context. 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 -into the DC before drawing on it. +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. \membersection{wxMemoryDC::SelectObject}\label{wxmemorydcselectobject} diff --git a/include/wx/cocoa/dcmemory.h b/include/wx/cocoa/dcmemory.h index e6580bab96..6a09f4fb42 100644 --- a/include/wx/cocoa/dcmemory.h +++ b/include/wx/cocoa/dcmemory.h @@ -18,7 +18,7 @@ class WXDLLEXPORT wxMemoryDC: public wxDC { DECLARE_DYNAMIC_CLASS(wxMemoryDC) public: - wxMemoryDC(void); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC( wxDC *dc ); // Create compatible DC virtual ~wxMemoryDC(void); virtual void SelectObject(const wxBitmap& bitmap); diff --git a/include/wx/dfb/dcmemory.h b/include/wx/dfb/dcmemory.h index dbb0e955c8..86ce650a72 100644 --- a/include/wx/dfb/dcmemory.h +++ b/include/wx/dfb/dcmemory.h @@ -17,7 +17,7 @@ class WXDLLIMPEXP_CORE wxMemoryDC : public wxDC { public: - wxMemoryDC(); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC(wxDC *dc); // create compatible DC virtual void SelectObject(const wxBitmap& bitmap); diff --git a/include/wx/gtk/dcmemory.h b/include/wx/gtk/dcmemory.h index b4e6be4c82..0dbded2feb 100644 --- a/include/wx/gtk/dcmemory.h +++ b/include/wx/gtk/dcmemory.h @@ -26,7 +26,7 @@ class WXDLLIMPEXP_CORE wxMemoryDC; class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC { public: - wxMemoryDC(); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC( wxDC *dc ); // Create compatible DC virtual ~wxMemoryDC(); virtual void SelectObject( const wxBitmap& bitmap ); diff --git a/include/wx/gtk1/dcmemory.h b/include/wx/gtk1/dcmemory.h index c998df979e..ba5b573e5f 100644 --- a/include/wx/gtk1/dcmemory.h +++ b/include/wx/gtk1/dcmemory.h @@ -26,7 +26,7 @@ class WXDLLIMPEXP_CORE wxMemoryDC; class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC { public: - wxMemoryDC(); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC( wxDC *dc ); // Create compatible DC virtual ~wxMemoryDC(); virtual void SelectObject( const wxBitmap& bitmap ); diff --git a/include/wx/mac/carbon/dcmemory.h b/include/wx/mac/carbon/dcmemory.h index bc6f99ee3a..9e1045c8bd 100644 --- a/include/wx/mac/carbon/dcmemory.h +++ b/include/wx/mac/carbon/dcmemory.h @@ -19,7 +19,7 @@ class WXDLLEXPORT wxMemoryDC: public wxPaintDC DECLARE_DYNAMIC_CLASS(wxMemoryDC) public: - wxMemoryDC(void); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC( wxDC *dc ); // Create compatible DC virtual ~wxMemoryDC(void); virtual void SelectObject( const wxBitmap& bitmap ); diff --git a/include/wx/mac/classic/dcmemory.h b/include/wx/mac/classic/dcmemory.h index c9780e2c68..4a2c8f191e 100644 --- a/include/wx/mac/classic/dcmemory.h +++ b/include/wx/mac/classic/dcmemory.h @@ -19,7 +19,7 @@ class WXDLLEXPORT wxMemoryDC: public wxPaintDC DECLARE_DYNAMIC_CLASS(wxMemoryDC) public: - wxMemoryDC(void); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC( wxDC *dc ); // Create compatible DC virtual ~wxMemoryDC(void); virtual void SelectObject( const wxBitmap& bitmap ); diff --git a/include/wx/mgl/dcmemory.h b/include/wx/mgl/dcmemory.h index 73407d12f9..8bda585ff4 100644 --- a/include/wx/mgl/dcmemory.h +++ b/include/wx/mgl/dcmemory.h @@ -26,7 +26,7 @@ class WXDLLEXPORT wxMemoryDC; class WXDLLEXPORT wxMemoryDC : public wxDC { public: - wxMemoryDC(); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC(wxDC *dc); // Create compatible DC virtual ~wxMemoryDC(); virtual void SelectObject(const wxBitmap& bitmap); diff --git a/include/wx/motif/dcmemory.h b/include/wx/motif/dcmemory.h index 121dda6604..0d453f5505 100644 --- a/include/wx/motif/dcmemory.h +++ b/include/wx/motif/dcmemory.h @@ -19,7 +19,7 @@ class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC DECLARE_DYNAMIC_CLASS(wxMemoryDC) public: - wxMemoryDC(); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC( wxDC *dc ); // Create compatible DC virtual ~wxMemoryDC(); diff --git a/include/wx/msw/dcmemory.h b/include/wx/msw/dcmemory.h index 39de2e1702..1e138b2e32 100644 --- a/include/wx/msw/dcmemory.h +++ b/include/wx/msw/dcmemory.h @@ -17,7 +17,7 @@ class WXDLLEXPORT wxMemoryDC : public wxDC { public: - wxMemoryDC(); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC(wxDC *dc); // Create compatible DC virtual void SelectObject(const wxBitmap& bitmap); diff --git a/include/wx/os2/dcmemory.h b/include/wx/os2/dcmemory.h index f0484a8dee..33001f619e 100644 --- a/include/wx/os2/dcmemory.h +++ b/include/wx/os2/dcmemory.h @@ -17,7 +17,7 @@ class WXDLLEXPORT wxMemoryDC: public wxDC { public: - wxMemoryDC(void); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC(wxDC* pDC); // Create compatible DC virtual void SelectObject(const wxBitmap& rBitmap); diff --git a/include/wx/palmos/dcmemory.h b/include/wx/palmos/dcmemory.h index be87436f96..56d6c305f4 100644 --- a/include/wx/palmos/dcmemory.h +++ b/include/wx/palmos/dcmemory.h @@ -17,7 +17,7 @@ class WXDLLEXPORT wxMemoryDC : public wxDC { public: - wxMemoryDC(); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC(wxDC *dc); // Create compatible DC virtual void SelectObject(const wxBitmap& bitmap); diff --git a/include/wx/x11/dcmemory.h b/include/wx/x11/dcmemory.h index a9d5ebd7f7..40c97fc7f0 100644 --- a/include/wx/x11/dcmemory.h +++ b/include/wx/x11/dcmemory.h @@ -17,7 +17,7 @@ class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC { public: - wxMemoryDC(); + wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap ); wxMemoryDC( wxDC *dc ); // Create compatible DC virtual ~wxMemoryDC(); virtual void SelectObject( const wxBitmap& bitmap ); diff --git a/src/cocoa/dcmemory.mm b/src/cocoa/dcmemory.mm index 218fb4ff8e..bf3920f49e 100644 --- a/src/cocoa/dcmemory.mm +++ b/src/cocoa/dcmemory.mm @@ -30,10 +30,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxDC) -wxMemoryDC::wxMemoryDC(void) +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) { m_cocoaNSImage = NULL; m_ok = false; + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) diff --git a/src/dfb/dcmemory.cpp b/src/dfb/dcmemory.cpp index bb9171db67..036fcb81e1 100644 --- a/src/dfb/dcmemory.cpp +++ b/src/dfb/dcmemory.cpp @@ -39,8 +39,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) -wxMemoryDC::wxMemoryDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) { + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc)) diff --git a/src/gtk/dcmemory.cpp b/src/gtk/dcmemory.cpp index b57a4b8aa8..f24a06e95e 100644 --- a/src/gtk/dcmemory.cpp +++ b/src/gtk/dcmemory.cpp @@ -21,7 +21,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) -wxMemoryDC::wxMemoryDC() : wxWindowDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) + : wxWindowDC() { m_ok = false; @@ -33,6 +34,9 @@ wxMemoryDC::wxMemoryDC() : wxWindowDC() 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) ) diff --git a/src/gtk1/dcmemory.cpp b/src/gtk1/dcmemory.cpp index 713e58e881..add3cc54f5 100644 --- a/src/gtk1/dcmemory.cpp +++ b/src/gtk1/dcmemory.cpp @@ -21,11 +21,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) -wxMemoryDC::wxMemoryDC() : wxWindowDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) + : wxWindowDC() { m_ok = false; m_cmap = gtk_widget_get_default_colormap(); + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) diff --git a/src/mac/carbon/dcmemory.cpp b/src/mac/carbon/dcmemory.cpp index 20c371825a..ee44e18330 100644 --- a/src/mac/carbon/dcmemory.cpp +++ b/src/mac/carbon/dcmemory.cpp @@ -21,7 +21,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) -wxMemoryDC::wxMemoryDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) : m_selected() { m_ok = true; @@ -30,6 +30,9 @@ wxMemoryDC::wxMemoryDC() SetPen(*wxBLACK_PEN); SetFont(*wxNORMAL_FONT); m_ok = false; + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) diff --git a/src/mac/classic/dcmemory.cpp b/src/mac/classic/dcmemory.cpp index 32949efa75..ad765139d9 100644 --- a/src/mac/classic/dcmemory.cpp +++ b/src/mac/classic/dcmemory.cpp @@ -21,7 +21,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) -wxMemoryDC::wxMemoryDC(void) +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) : m_selected() { m_ok = true; @@ -29,6 +29,9 @@ wxMemoryDC::wxMemoryDC(void) SetBrush(*wxWHITE_BRUSH); SetPen(*wxBLACK_PEN); m_ok = false; + + if ( bitmap.IsOk() ) + SelectObject(bitmap); }; wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) diff --git a/src/mgl/dcmemory.cpp b/src/mgl/dcmemory.cpp index c6c4233795..6017861c05 100644 --- a/src/mgl/dcmemory.cpp +++ b/src/mgl/dcmemory.cpp @@ -24,9 +24,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) -wxMemoryDC::wxMemoryDC() : wxDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) + : wxDC() { m_isMemDC = true; + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc)) : wxDC() diff --git a/src/motif/dcmemory.cpp b/src/motif/dcmemory.cpp index 0f2eb13bff..789dac864d 100644 --- a/src/motif/dcmemory.cpp +++ b/src/motif/dcmemory.cpp @@ -35,7 +35,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC) -wxMemoryDC::wxMemoryDC(void) +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) { m_ok = true; m_display = wxGetDisplay(); @@ -57,6 +57,9 @@ wxMemoryDC::wxMemoryDC(void) SetBrush (* wxWHITE_BRUSH); SetPen (* wxBLACK_PEN); SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC( wxDC* dc ) diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp index e68fe93b10..36ff844b21 100644 --- a/src/msw/dcmemory.cpp +++ b/src/msw/dcmemory.cpp @@ -47,11 +47,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) // wxMemoryDC // ---------------------------------------------------------------------------- -wxMemoryDC::wxMemoryDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) { CreateCompatible(NULL); Init(); + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC(wxDC *dc) diff --git a/src/os2/dcmemory.cpp b/src/os2/dcmemory.cpp index b42e384441..770e42bce4 100644 --- a/src/os2/dcmemory.cpp +++ b/src/os2/dcmemory.cpp @@ -28,10 +28,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) // Memory DC ///////////////////////////////////////////////////////////////////////////// -wxMemoryDC::wxMemoryDC(void) +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) { CreateCompatible(NULL); Init(); + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } // end of wxMemoryDC::wxMemoryDC wxMemoryDC::wxMemoryDC( diff --git a/src/palmos/dcmemory.cpp b/src/palmos/dcmemory.cpp index 461b478a53..96487eba36 100644 --- a/src/palmos/dcmemory.cpp +++ b/src/palmos/dcmemory.cpp @@ -45,8 +45,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC) // wxMemoryDC // ---------------------------------------------------------------------------- -wxMemoryDC::wxMemoryDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) { + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC(wxDC *dc) diff --git a/src/x11/dcmemory.cpp b/src/x11/dcmemory.cpp index 0b2f67aad7..f5a4bddb64 100644 --- a/src/x11/dcmemory.cpp +++ b/src/x11/dcmemory.cpp @@ -23,7 +23,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) -wxMemoryDC::wxMemoryDC() : wxWindowDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) + : wxWindowDC() { m_ok = false; @@ -31,6 +32,9 @@ wxMemoryDC::wxMemoryDC() : wxWindowDC() int screen = DefaultScreen( wxGlobalDisplay() ); m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen ); + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) -- 2.45.2