From d08498eb16e968285061b51c6b078668fe3d6f45 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 10 Apr 2022 17:17:02 +0100 Subject: [PATCH] Add wxBitmap(size, dc) ctor to all ports Previously this ctor was only available in wxMSW and wxOSX, which was especially strange as the equivalent Create() overload, taking wxDC, was already available in all ports. --- include/wx/dfb/bitmap.h | 1 + include/wx/gtk/bitmap.h | 2 ++ include/wx/gtk1/bitmap.h | 1 + include/wx/qt/bitmap.h | 3 ++- include/wx/x11/bitmap.h | 1 + interface/wx/bitmap.h | 14 ++++++++++++++ src/qt/bitmap.cpp | 5 +++++ 7 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/wx/dfb/bitmap.h b/include/wx/dfb/bitmap.h index cb0e4f0551..e2d44768b2 100644 --- a/include/wx/dfb/bitmap.h +++ b/include/wx/dfb/bitmap.h @@ -27,6 +27,7 @@ public: wxBitmap(const wxIDirectFBSurfacePtr& surface) { Create(surface); } wxBitmap(int width, int height, int depth = -1) { Create(width, height, depth); } wxBitmap(const wxSize& sz, int depth = -1) { Create(sz, depth); } + wxBitmap(int width, int height, const wxDC& dc) { Create(width, height, dc); } wxBitmap(const char bits[], int width, int height, int depth = 1); wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); wxBitmap(const char* const* bits); diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index e981f7a232..cb9e65e66c 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -68,6 +68,8 @@ public: { Create(width, height, depth); } wxBitmap( const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH ) { Create(sz, depth); } + wxBitmap( int width, int height, const wxDC& dc ) + { Create(width, height, dc); } wxBitmap( const char bits[], int width, int height, int depth = 1 ); wxBitmap( const char* const* bits ); wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE ); diff --git a/include/wx/gtk1/bitmap.h b/include/wx/gtk1/bitmap.h index b7e49d476c..313e68c012 100644 --- a/include/wx/gtk1/bitmap.h +++ b/include/wx/gtk1/bitmap.h @@ -64,6 +64,7 @@ public: wxBitmap() {} wxBitmap( int width, int height, int depth = -1 ) { Create( width, height, depth ); } wxBitmap( const wxSize& sz, int depth = -1 ) { Create( sz, depth ); } + wxBitmap( int width, int height, const wxDC& dc ) { Create(width, height, dc); } wxBitmap( const char bits[], int width, int height, int depth = 1 ); wxBitmap( const char* const* bits ); wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_DEFAULT_TYPE ); diff --git a/include/wx/qt/bitmap.h b/include/wx/qt/bitmap.h index d530ae6c31..2e1315a8fe 100644 --- a/include/wx/qt/bitmap.h +++ b/include/wx/qt/bitmap.h @@ -20,6 +20,7 @@ public: wxBitmap(const char bits[], int width, int height, int depth = 1); wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH); + wxBitmap(int width, int height, const wxDC& dc); wxBitmap(const char* const* bits); wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM); wxBitmap(const wxImage& image, int depth = wxBITMAP_SCREEN_DEPTH, double scale = 1.0); @@ -32,7 +33,7 @@ public: virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) wxOVERRIDE; virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) wxOVERRIDE; - virtual bool Create(int width, int height, const wxDC& WXUNUSED(dc)); + virtual bool Create(int width, int height, const wxDC& dc); virtual int GetHeight() const wxOVERRIDE; virtual int GetWidth() const wxOVERRIDE; diff --git a/include/wx/x11/bitmap.h b/include/wx/x11/bitmap.h index 9570e31a80..9f46c9cbd4 100644 --- a/include/wx/x11/bitmap.h +++ b/include/wx/x11/bitmap.h @@ -58,6 +58,7 @@ public: wxBitmap() {} wxBitmap( int width, int height, int depth = -1 ) { Create( width, height, depth ); } wxBitmap( const wxSize& sz, int depth = -1 ) { Create( sz, depth ); } + wxBitmap( int width, int height, const wxDC& dc ) { Create(width, height, dc); } wxBitmap( const char bits[], int width, int height, int depth = 1 ); wxBitmap( const char* const* bits ); diff --git a/interface/wx/bitmap.h b/interface/wx/bitmap.h index b39d1a6faa..9f38ccff5d 100644 --- a/interface/wx/bitmap.h +++ b/interface/wx/bitmap.h @@ -306,6 +306,20 @@ public: */ wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH); + /** + Create a bitmap compatible with the given DC, inheriting its magnification factor + + @param width + The width of the bitmap in pixels, must be strictly positive. + @param height + The height of the bitmap in pixels, must be strictly positive. + @param dc + DC from which the scaling factor is inherited + + @since 3.1.7 (previously available only in wxMSW and wxOSX ports). + */ + wxBitmap(int width, int height, const wxDC& dc); + /** Creates a bitmap from XPM data. diff --git a/src/qt/bitmap.cpp b/src/qt/bitmap.cpp index 349b044504..770c20c148 100644 --- a/src/qt/bitmap.cpp +++ b/src/qt/bitmap.cpp @@ -192,6 +192,11 @@ wxBitmap::wxBitmap(const wxSize& sz, int depth ) Create(sz, depth); } +wxBitmap::wxBitmap(int width, int height, const wxDC& dc) +{ + Create(width, height, dc); +} + // Create a wxBitmap from xpm data wxBitmap::wxBitmap(const char* const* bits) {