From 452418c4b0763eb611432e84f077c9766e282057 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sun, 8 Oct 2006 08:04:49 +0000 Subject: [PATCH] Move some things to wxBitmapBase to avoid much duplication. Use proper const for XPM data, and const void* for arbitary bitmap data. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41689 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/bitmap.tex | 6 +-- docs/latex/wx/bmphand.tex | 6 +-- docs/latex/wx/image.tex | 8 ++-- include/wx/bitmap.h | 26 ++++-------- include/wx/cocoa/bitmap.h | 14 ++++--- include/wx/dfb/bitmap.h | 12 ++---- include/wx/gtk/bitmap.h | 15 +------ include/wx/gtk1/bitmap.h | 17 +------- include/wx/image.h | 11 +++-- include/wx/mac/carbon/bitmap.h | 24 +++-------- include/wx/mgl/bitmap.h | 12 ++---- include/wx/msw/bitmap.h | 14 +++---- include/wx/msw/gdiimage.h | 2 +- include/wx/os2/bitmap.h | 13 +++--- include/wx/palmos/bitmap.h | 14 +++---- include/wx/palmos/gdiimage.h | 2 +- include/wx/x11/bitmap.h | 15 ++----- include/wx/xpmdecod.h | 2 +- src/cocoa/bitmap.mm | 24 ++--------- src/common/bmpbase.cpp | 36 +++++++++++++++++ src/common/image.cpp | 14 ++----- src/common/xpmdecod.cpp | 11 ++--- src/dfb/bitmap.cpp | 24 +---------- src/gtk/bitmap.cpp | 73 +++++++--------------------------- src/gtk1/bitmap.cpp | 50 ++--------------------- src/mac/carbon/bitmap.cpp | 53 ++---------------------- src/mgl/bitmap.cpp | 19 ++------- src/msw/bitmap.cpp | 57 +++----------------------- src/msw/gdiimage.cpp | 2 +- src/os2/bitmap.cpp | 29 ++------------ src/os2/gdiimage.cpp | 2 +- src/palmos/bitmap.cpp | 18 ++------- src/x11/bitmap.cpp | 20 +++++----- 33 files changed, 166 insertions(+), 479 deletions(-) diff --git a/docs/latex/wx/bitmap.tex b/docs/latex/wx/bitmap.tex index c354102ed1..f75303f6f2 100644 --- a/docs/latex/wx/bitmap.tex +++ b/docs/latex/wx/bitmap.tex @@ -48,7 +48,7 @@ use: wxRect(0, 0, oldBitmap.GetWidth(), oldBitmap.GetHeight())); \end{verbatim} -\func{}{wxBitmap}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}} +\func{}{wxBitmap}{\param{const void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}} Creates a bitmap from the given data which is interpreted in platform-dependent manner. @@ -75,7 +75,7 @@ or visual. Some platforms only support 1 for monochrome and -1 for the current colour setting. Beginning with version 2.5.4 of wxWidgets a depth of 32 including an alpha channel is supported under MSW, Mac and GTK+. -\func{}{wxBitmap}{\param{const char**}{ bits}} +\func{}{wxBitmap}{\param{const char* const*}{ bits}} Creates a bitmap from XPM data. @@ -260,7 +260,7 @@ Creates the bitmap from an icon. Creates a fresh bitmap. If the final argument is omitted, the display depth of the screen is used. -\func{virtual bool}{Create}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}} +\func{virtual bool}{Create}{\param{const void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}} Creates a bitmap from the given data, which can be of arbitrary type. diff --git a/docs/latex/wx/bmphand.tex b/docs/latex/wx/bmphand.tex index 2c1710872b..7c462305a9 100644 --- a/docs/latex/wx/bmphand.tex +++ b/docs/latex/wx/bmphand.tex @@ -38,7 +38,7 @@ Destroys the wxBitmapHandler object. \membersection{wxBitmapHandler::Create}\label{wxbitmaphandlercreate} -\func{virtual bool}{Create}{\param{wxBitmap* }{bitmap}, \param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}} +\func{virtual bool}{Create}{\param{wxBitmap* }{bitmap}, \param{const void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}} Creates a bitmap from the given data, which can be of arbitrary type. The wxBitmap object {\it bitmap} is manipulated by this function. @@ -64,13 +64,13 @@ true if the call succeeded, false otherwise (the default). \membersection{wxBitmapHandler::GetName}\label{wxbitmaphandlergetname} -\constfunc{wxString}{GetName}{\void} +\constfunc{const wxString\&}{ GetName}{\void} Gets the name of this handler. \membersection{wxBitmapHandler::GetExtension}\label{wxbitmaphandlergetextension} -\constfunc{wxString}{GetExtension}{\void} +\constfunc{const wxString\&}{ GetExtension}{\void} Gets the file extension associated with this handler. diff --git a/docs/latex/wx/image.tex b/docs/latex/wx/image.tex index 8f6ecf94c6..c15a01e950 100644 --- a/docs/latex/wx/image.tex +++ b/docs/latex/wx/image.tex @@ -128,7 +128,7 @@ Loads an image from a file. Loads an image from an input stream. -\func{}{wxImage}{\param{const char** }{xpmData}} +\func{}{wxImage}{\param{const char* const* }{xpmData}} Creates an image from XPM data. @@ -1383,14 +1383,14 @@ Destroys the wxImageHandler object. \membersection{wxImageHandler::GetName}\label{wximagehandlergetname} -\constfunc{wxString}{GetName}{\void} +\constfunc{const wxString\&}{GetName}{\void} Gets the name of this handler. \membersection{wxImageHandler::GetExtension}\label{wximagehandlergetextension} -\constfunc{wxString}{GetExtension}{\void} +\constfunc{const wxString\&}{GetExtension}{\void} Gets the file extension associated with this handler. @@ -1420,7 +1420,7 @@ Gets the image type associated with this handler. \membersection{wxImageHandler::GetMimeType}\label{wximagehandlergetmimetype} -\constfunc{wxString}{GetMimeType}{\void} +\constfunc{const wxString\&}{GetMimeType}{\void} Gets the MIME type associated with this handler. diff --git a/include/wx/bitmap.h b/include/wx/bitmap.h index b12e30dbea..f0b8cb1883 100644 --- a/include/wx/bitmap.h +++ b/include/wx/bitmap.h @@ -16,10 +16,7 @@ // headers // ---------------------------------------------------------------------------- -#include "wx/defs.h" -#include "wx/object.h" #include "wx/string.h" -#include "wx/gdiobj.h" #include "wx/gdicmn.h" // for wxBitmapType #include "wx/colour.h" @@ -93,26 +90,21 @@ protected: class WXDLLEXPORT wxBitmapHandlerBase : public wxObject { public: - wxBitmapHandlerBase() - : m_name() - , m_extension() - , m_type(wxBITMAP_TYPE_INVALID) - { } - + wxBitmapHandlerBase() { m_type = wxBITMAP_TYPE_INVALID; } virtual ~wxBitmapHandlerBase() { } - virtual bool Create(wxBitmap *bitmap, void *data, long flags, - int width, int height, int depth = 1) = 0; + virtual bool Create(wxBitmap *bitmap, const void* data, long flags, + int width, int height, int depth = 1); virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) = 0; + int desiredWidth, int desiredHeight); virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, - int type, const wxPalette *palette = NULL) = 0; + int type, const wxPalette *palette = NULL); void SetName(const wxString& name) { m_name = name; } void SetExtension(const wxString& ext) { m_extension = ext; } void SetType(wxBitmapType type) { m_type = type; } - wxString GetName() const { return m_name; } - wxString GetExtension() const { return m_extension; } + const wxString& GetName() const { return m_name; } + const wxString& GetExtension() const { return m_extension; } wxBitmapType GetType() const { return m_type; } private: @@ -120,7 +112,6 @@ private: wxString m_extension; wxBitmapType m_type; -private: DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase) }; @@ -133,8 +124,7 @@ public: wxBitmap(); wxBitmap(int width, int height, int depth = -1); wxBitmap(const char bits[], int width, int height, int depth = 1); - wxBitmap(const char **bits); - wxBitmap(char **bits); + wxBitmap(const char* const* bits); wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM); wxBitmap(const wxImage& image, int depth = -1); bool operator == (const wxBitmap& bmp) const; diff --git a/include/wx/cocoa/bitmap.h b/include/wx/cocoa/bitmap.h index d08dd9ea5a..4eccb2eb7c 100644 --- a/include/wx/cocoa/bitmap.h +++ b/include/wx/cocoa/bitmap.h @@ -71,12 +71,11 @@ public: // Initialize with raw data. wxBitmap(const char bits[], int width, int height, int depth = 1); // Initialize with XPM data - wxBitmap(const char **bits) { CreateFromXpm(bits); } - wxBitmap(char **bits) { CreateFromXpm((const char**)bits); } + wxBitmap(const char* const* bits); // Load a file or resource wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); // Constructor for generalised creation from data - wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1); + wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1); // If depth is omitted, will create a bitmap compatible with the display wxBitmap(int width, int height, int depth = -1); // Convert from wxImage: @@ -92,13 +91,11 @@ public: // Implementation // ------------------------------------------------------------------------ public: - // Initialize with XPM data - bool CreateFromXpm(const char **bits); // Initialize from wxImage bool CreateFromImage(const wxImage& image, int depth=-1); virtual bool Create(int width, int height, int depth = -1); - virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1); + virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1); virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const; @@ -152,4 +149,9 @@ public: static void CleanUpHandlers() { } }; +class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase +{ + DECLARE_ABSTRACT_CLASS(wxBitmapHandler) +}; + #endif // __WX_COCOA_BITMAP_H__ diff --git a/include/wx/dfb/bitmap.h b/include/wx/dfb/bitmap.h index 05f1fe5013..19767564f9 100644 --- a/include/wx/dfb/bitmap.h +++ b/include/wx/dfb/bitmap.h @@ -19,12 +19,9 @@ wxDFB_DECLARE_INTERFACE(IDirectFBSurface); // wxBitmap //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxBitmapHandler : public wxBitmapHandlerBase +class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase { -public: - wxBitmapHandler() : wxBitmapHandlerBase() {} -private: - DECLARE_DYNAMIC_CLASS(wxBitmapHandler) + DECLARE_ABSTRACT_CLASS(wxBitmapHandler) }; class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase @@ -35,8 +32,7 @@ public: wxBitmap(int width, int height, int depth = -1); wxBitmap(const char bits[], int width, int height, int depth = 1); wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_RESOURCE); - wxBitmap(const char **bits) { CreateFromXpm(bits); } - wxBitmap(char **bits) { CreateFromXpm((const char **)bits); } + wxBitmap(const char* const* bits); #if wxUSE_IMAGE wxBitmap(const wxImage& image, int depth = -1); #endif @@ -83,8 +79,6 @@ public: wxIDirectFBSurfacePtr GetDirectFBSurface() const; protected: - bool CreateFromXpm(const char **bits); - // ref counting code virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index 7b8306c5ee..13c0c5dffc 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -53,7 +53,7 @@ public: wxBitmap() { } wxBitmap( int width, int height, int depth = -1 ); wxBitmap( const char bits[], int width, int height, int depth = 1 ); - wxBitmap( const char* const* bits ) { CreateFromXpm(bits); } + wxBitmap( const char* const* bits ); wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM ); wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } virtual ~wxBitmap(); @@ -114,7 +114,6 @@ public: void UseAlpha(); protected: - bool CreateFromXpm(const char* const* bits); bool CreateFromImage(const wxImage& image, int depth); private: @@ -144,17 +143,7 @@ private: class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase { -public: - wxBitmapHandler() { } - virtual ~wxBitmapHandler(); - - virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); - virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight); - virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); - -private: - DECLARE_DYNAMIC_CLASS(wxBitmapHandler) + DECLARE_ABSTRACT_CLASS(wxBitmapHandler) }; #endif // _WX_GTK_BITMAP_H_ diff --git a/include/wx/gtk1/bitmap.h b/include/wx/gtk1/bitmap.h index 21dc2c07d2..db9f3549b2 100644 --- a/include/wx/gtk1/bitmap.h +++ b/include/wx/gtk1/bitmap.h @@ -67,8 +67,7 @@ public: wxBitmap(); wxBitmap( int width, int height, int depth = -1 ); wxBitmap( const char bits[], int width, int height, int depth = 1 ); - wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); } - wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); } + wxBitmap( const char* const* bits ); wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM ); wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } virtual ~wxBitmap(); @@ -128,7 +127,6 @@ public: void UseAlpha(); protected: - bool CreateFromXpm(const char **bits); bool CreateFromImage(const wxImage& image, int depth); private: @@ -148,18 +146,7 @@ private: class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase { -public: - wxBitmapHandler() { } - virtual ~wxBitmapHandler(); - - virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); - virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight); - virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); - -private: - DECLARE_DYNAMIC_CLASS(wxBitmapHandler) + DECLARE_ABSTRACT_CLASS(wxBitmapHandler) }; - #endif // __GTKBITMAPH__ diff --git a/include/wx/image.h b/include/wx/image.h index 8718380516..6e186e7d1c 100644 --- a/include/wx/image.h +++ b/include/wx/image.h @@ -99,10 +99,10 @@ public: void SetExtension(const wxString& ext) { m_extension = ext; } void SetType(long type) { m_type = type; } void SetMimeType(const wxString& type) { m_mime = type; } - wxString GetName() const { return m_name; } - wxString GetExtension() const { return m_extension; } + const wxString& GetName() const { return m_name; } + const wxString& GetExtension() const { return m_extension; } long GetType() const { return m_type; } - wxString GetMimeType() const { return m_mime; } + const wxString& GetMimeType() const { return m_mime; } protected: #if wxUSE_STREAMS @@ -199,8 +199,7 @@ public: wxImage( int width, int height, unsigned char* data, unsigned char* alpha, bool static_data = false ); wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1 ); wxImage( const wxString& name, const wxString& mimetype, int index = -1 ); - wxImage( const char** xpmData ); - wxImage( char** xpmData ); + wxImage( const char* const* xpmData ); #if wxUSE_STREAMS wxImage( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1 ); @@ -210,7 +209,7 @@ public: bool Create( int width, int height, bool clear = true ); bool Create( int width, int height, unsigned char* data, bool static_data = false ); bool Create( int width, int height, unsigned char* data, unsigned char* alpha, bool static_data = false ); - bool Create( const char** xpmData ); + bool Create( const char* const* xpmData ); void Destroy(); // creates an identical copy of the image (the = operator diff --git a/include/wx/mac/carbon/bitmap.h b/include/wx/mac/carbon/bitmap.h index fbeceb2993..a607ec3e9d 100644 --- a/include/wx/mac/carbon/bitmap.h +++ b/include/wx/mac/carbon/bitmap.h @@ -78,23 +78,11 @@ private: }; -class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase +class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase { -public: - wxBitmapHandler() { } - virtual ~wxBitmapHandler(); - - virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); - virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight); - virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); - -private: - DECLARE_DYNAMIC_CLASS(wxBitmapHandler) + DECLARE_ABSTRACT_CLASS(wxBitmapHandler) }; -#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData()) - class WXDLLEXPORT wxBitmap: public wxBitmapBase { DECLARE_DYNAMIC_CLASS(wxBitmap) @@ -108,15 +96,13 @@ public: wxBitmap(const char bits[], int width, int height, int depth = 1); // Initialize with XPM data - bool CreateFromXpm(const char **bits); - wxBitmap(const char **bits); - wxBitmap(char **bits); + wxBitmap(const char* const* bits); // Load a file or resource wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_PICT_RESOURCE); // Constructor for generalised creation from data - wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1); + wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1); // If depth is omitted, will create a bitmap compatible with the display wxBitmap(int width, int height, int depth = -1); @@ -135,7 +121,7 @@ public: wxBitmap GetSubBitmap( const wxRect& rect ) const; virtual bool Create(int width, int height, int depth = -1); - virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1); + virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1); // virtual bool Create( WXHICON icon) ; virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const; diff --git a/include/wx/mgl/bitmap.h b/include/wx/mgl/bitmap.h index 320be07e03..0f5b073554 100644 --- a/include/wx/mgl/bitmap.h +++ b/include/wx/mgl/bitmap.h @@ -23,12 +23,9 @@ struct bitmap_t; // wxBitmap //----------------------------------------------------------------------------- -class WXDLLEXPORT wxBitmapHandler : public wxBitmapHandlerBase +class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase { -public: - wxBitmapHandler() : wxBitmapHandlerBase() {} -private: - DECLARE_DYNAMIC_CLASS(wxBitmapHandler) + DECLARE_ABSTRACT_CLASS(wxBitmapHandler) }; class WXDLLEXPORT wxBitmap: public wxBitmapBase @@ -37,8 +34,7 @@ public: wxBitmap() {} wxBitmap(int width, int height, int depth = -1); wxBitmap(const char bits[], int width, int height, int depth = 1); - wxBitmap(const char **bits) { CreateFromXpm(bits); } - wxBitmap(char **bits) { CreateFromXpm((const char **)bits); } + wxBitmap(const char* const* bits); wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_RESOURCE); wxBitmap(const wxImage& image, int depth = -1); virtual ~wxBitmap() {} @@ -81,8 +77,6 @@ public: bitmap_t *GetMGLbitmap_t() const; protected: - bool CreateFromXpm(const char **bits); - // creates temporary DC for access to bitmap's data: MGLDevCtx *CreateTmpDC() const; // sets fg & bg colours for 1bit bitmaps: diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h index 50fa1d1271..332da5790c 100644 --- a/include/wx/msw/bitmap.h +++ b/include/wx/msw/bitmap.h @@ -45,14 +45,13 @@ public: wxBitmap(const char bits[], int width, int height, int depth = 1); // Initialize with XPM data - wxBitmap(const char **data) { CreateFromXpm(data); } - wxBitmap(char **data) { CreateFromXpm((const char **)data); } + wxBitmap(const char* const* data); // Load a file or resource wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); // New constructor for generalised creation from data - wxBitmap(void *data, long type, int width, int height, int depth = 1); + wxBitmap(const void* data, long type, int width, int height, int depth = 1); // Create a new, uninitialized bitmap of the given size and depth (if it // is omitted, will create a bitmap compatible with the display) @@ -114,7 +113,7 @@ public: virtual bool Create(int width, int height, int depth = -1); virtual bool Create(int width, int height, const wxDC& dc); - virtual bool Create(void *data, long type, int width, int height, int depth = 1); + virtual bool Create(const void* data, long type, int width, int height, int depth = 1); virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE); virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); @@ -165,9 +164,6 @@ protected: virtual wxGDIImageRefData *CreateData() const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; - // creates the bitmap from XPM data, supposed to be called from ctor - bool CreateFromXpm(const char **bits); - // creates an uninitialized bitmap, called from Create()s above bool DoCreate(int w, int h, int depth, WXHDC hdc); @@ -245,7 +241,7 @@ public: // keep wxBitmapHandler derived from wxGDIImageHandler compatible with the // old class which worked only with bitmaps virtual bool Create(wxBitmap *bitmap, - void *data, + const void* data, long flags, int width, int height, int depth = 1); virtual bool LoadFile(wxBitmap *bitmap, @@ -258,7 +254,7 @@ public: const wxPalette *palette = NULL); virtual bool Create(wxGDIImage *image, - void *data, + const void* data, long flags, int width, int height, int depth = 1); virtual bool Load(wxGDIImage *image, diff --git a/include/wx/msw/gdiimage.h b/include/wx/msw/gdiimage.h index 8c6cd818cb..8db767023a 100644 --- a/include/wx/msw/gdiimage.h +++ b/include/wx/msw/gdiimage.h @@ -104,7 +104,7 @@ public: // real handler operations: to implement in derived classes virtual bool Create(wxGDIImage *image, - void *data, + const void* data, long flags, int width, int height, int depth = 1) = 0; virtual bool Load(wxGDIImage *image, diff --git a/include/wx/os2/bitmap.h b/include/wx/os2/bitmap.h index eba49f641b..a809df37ad 100644 --- a/include/wx/os2/bitmap.h +++ b/include/wx/os2/bitmap.h @@ -84,8 +84,7 @@ public: ); // Initialize with XPM data - wxBitmap(const char** ppData) { CreateFromXpm(ppData); } - wxBitmap(char** ppData) { CreateFromXpm((const char**)ppData); } + wxBitmap(const char* const* bits); // Load a resource wxBitmap( int nId @@ -98,7 +97,7 @@ public: ) { Init(); } // New constructor for generalised creation from data - wxBitmap( void* pData + wxBitmap( const void* pData ,long lType ,int nWidth ,int nHeight @@ -146,7 +145,7 @@ public: ,int nHeight ,int nDepth = -1 ); - virtual bool Create( void* pData + virtual bool Create( const void* pData ,long lType ,int nWidth ,int nHeight @@ -213,8 +212,6 @@ protected: inline virtual wxGDIImageRefData* CreateData() const { return new wxBitmapRefData; } - // creates the bitmap from XPM data, supposed to be called from ctor - bool CreateFromXpm(const char** ppData); bool CreateFromImage(const wxImage& image, int depth); private: @@ -296,7 +293,7 @@ public: // keep wxBitmapHandler derived from wxGDIImageHandler compatible with the // old class which worked only with bitmaps virtual bool Create( wxBitmap* pBitmap - ,void* pData + ,const void* pData ,long lFlags ,int nWidth ,int nHeight @@ -321,7 +318,7 @@ public: ); virtual bool Create( wxGDIImage* pImage - ,void* pData + ,const void* pData ,long lFlags ,int nWidth ,int nHeight diff --git a/include/wx/palmos/bitmap.h b/include/wx/palmos/bitmap.h index 076784bc5a..983fcc0ce3 100644 --- a/include/wx/palmos/bitmap.h +++ b/include/wx/palmos/bitmap.h @@ -45,14 +45,13 @@ public: wxBitmap(const char bits[], int width, int height, int depth = 1); // Initialize with XPM data - wxBitmap(const char **data) { CreateFromXpm(data); } - wxBitmap(char **data) { CreateFromXpm((const char **)data); } + wxBitmap(const char* const* data); // Load a file or resource wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); // New constructor for generalised creation from data - wxBitmap(void *data, long type, int width, int height, int depth = 1); + wxBitmap(const void* data, long type, int width, int height, int depth = 1); // Create a new, uninitialized bitmap of the given size and depth (if it // is omitted, will create a bitmap compatible with the display) @@ -114,7 +113,7 @@ public: virtual bool Create(int width, int height, int depth = -1); virtual bool Create(int width, int height, const wxDC& dc); - virtual bool Create(void *data, long type, int width, int height, int depth = 1); + virtual bool Create(const void* data, long type, int width, int height, int depth = 1); virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE); virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); @@ -159,9 +158,6 @@ protected: virtual wxGDIImageRefData *CreateData() const; - // creates the bitmap from XPM data, supposed to be called from ctor - bool CreateFromXpm(const char **bits); - // creates an uninitialized bitmap, called from Create()s above bool DoCreate(int w, int h, int depth, WXHDC hdc); @@ -235,7 +231,7 @@ public: // keep wxBitmapHandler derived from wxGDIImageHandler compatible with the // old class which worked only with bitmaps virtual bool Create(wxBitmap *bitmap, - void *data, + const void* data, long flags, int width, int height, int depth = 1); virtual bool LoadFile(wxBitmap *bitmap, @@ -248,7 +244,7 @@ public: const wxPalette *palette = NULL); virtual bool Create(wxGDIImage *image, - void *data, + const void* data, long flags, int width, int height, int depth = 1); virtual bool Load(wxGDIImage *image, diff --git a/include/wx/palmos/gdiimage.h b/include/wx/palmos/gdiimage.h index 561134a248..b954e2a331 100644 --- a/include/wx/palmos/gdiimage.h +++ b/include/wx/palmos/gdiimage.h @@ -94,7 +94,7 @@ public: // real handler operations: to implement in derived classes virtual bool Create(wxGDIImage *image, - void *data, + const void* data, long flags, int width, int height, int depth = 1) = 0; virtual bool Load(wxGDIImage *image, diff --git a/include/wx/x11/bitmap.h b/include/wx/x11/bitmap.h index f846fe2784..9f104b2b00 100644 --- a/include/wx/x11/bitmap.h +++ b/include/wx/x11/bitmap.h @@ -62,12 +62,9 @@ private: // wxBitmap //----------------------------------------------------------------------------- -class WXDLLEXPORT wxBitmapHandler : public wxBitmapHandlerBase +class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase { -public: - wxBitmapHandler() : wxBitmapHandlerBase() {} -private: - DECLARE_DYNAMIC_CLASS(wxBitmapHandler) + DECLARE_ABSTRACT_CLASS(wxBitmapHandler) }; class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase @@ -76,8 +73,7 @@ public: wxBitmap(); wxBitmap( int width, int height, int depth = -1 ); wxBitmap( const char bits[], int width, int height, int depth = 1 ); - wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); } - wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); } + wxBitmap( const char* const* bits ); wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM ); virtual ~wxBitmap(); @@ -88,7 +84,7 @@ public: static void InitStandardHandlers(); bool Create(int width, int height, int depth = -1); - bool Create(void* data, wxBitmapType type, + bool Create(const void* data, wxBitmapType type, int width, int height, int depth = -1); // create the wxBitmap using a _copy_ of the pixmap bool Create(WXPixmap pixmap); @@ -135,9 +131,6 @@ public: WXDisplay *GetDisplay() const; -protected: - bool CreateFromXpm(const char **bits); - private: DECLARE_DYNAMIC_CLASS(wxBitmap) }; diff --git a/include/wx/xpmdecod.h b/include/wx/xpmdecod.h index bf75164ac3..96cdab7732 100644 --- a/include/wx/xpmdecod.h +++ b/include/wx/xpmdecod.h @@ -35,7 +35,7 @@ public: wxImage ReadFile(wxInputStream& stream); #endif // Read directly from XPM data (as passed to wxBitmap ctor): - wxImage ReadData(const char **xpm_data); + wxImage ReadData(const char* const* xpm_data); }; #endif // wxUSE_IMAGE && wxUSE_XPM diff --git a/src/cocoa/bitmap.mm b/src/cocoa/bitmap.mm index 6152fa12e8..08f4af5204 100644 --- a/src/cocoa/bitmap.mm +++ b/src/cocoa/bitmap.mm @@ -33,6 +33,8 @@ #import #import +IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase) + // ======================================================================== // wxBitmapRefData // ======================================================================== @@ -123,7 +125,7 @@ wxBitmap::wxBitmap(int w, int h, int d) (void)Create(w, h, d); } -wxBitmap::wxBitmap(void *data, wxBitmapType type, int width, int height, int depth) +wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth) { (void) Create(data, type, width, height, depth); } @@ -346,7 +348,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) return true; } -bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int depth) +bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height, int depth) { UnRef(); @@ -413,24 +415,6 @@ wxImage wxBitmap::ConvertToImage() const return newImage; } -bool wxBitmap::CreateFromXpm(const char **xpm) -{ -#if wxUSE_IMAGE && wxUSE_XPM - UnRef(); - - wxCHECK_MSG( xpm, false, wxT("invalid XPM data") ); - - wxXPMDecoder decoder; - wxImage img = decoder.ReadData(xpm); - wxCHECK_MSG( img.Ok(), false, wxT("invalid XPM data") ); - - *this = wxBitmap(img); - return true; -#else - return false; -#endif -} - bool wxBitmap::CreateFromImage(const wxImage& image, int depth) { UnRef(); diff --git a/src/common/bmpbase.cpp b/src/common/bmpbase.cpp index 4a5ca4d898..c9c0e66621 100644 --- a/src/common/bmpbase.cpp +++ b/src/common/bmpbase.cpp @@ -126,6 +126,21 @@ void wxBitmapBase::CleanUpHandlers() } } +bool wxBitmapHandlerBase::Create(wxBitmap*, const void*, long, int, int, int) +{ + return false; +} + +bool wxBitmapHandlerBase::LoadFile(wxBitmap*, const wxString&, long, int, int) +{ + return false; +} + +bool wxBitmapHandlerBase::SaveFile(const wxBitmap*, const wxString&, int, const wxPalette*) +{ + return false; +} + class wxBitmapBaseModule: public wxModule { DECLARE_DYNAMIC_CLASS(wxBitmapBaseModule) @@ -139,6 +154,27 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule) #endif // wxUSE_BITMAP_BASE +// ---------------------------------------------------------------------------- +// wxBitmap common +// ---------------------------------------------------------------------------- + +#if !(defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXX11__)) + +wxBitmap::wxBitmap(const char* const* bits) +{ + wxCHECK2_MSG(bits != NULL, return, wxT("invalid bitmap data")); + +#if wxUSE_IMAGE && wxUSE_XPM + wxImage image(bits); + wxCHECK2_MSG(image.Ok(), return, wxT("invalid bitmap data")); + + *this = wxBitmap(image); +#else + wxFAIL_MSG(_T("creating bitmaps from XPMs not supported")); +#endif // wxUSE_IMAGE && wxUSE_XPM +} +#endif // !(defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXX11__)) + // ---------------------------------------------------------------------------- // wxMaskBase // ---------------------------------------------------------------------------- diff --git a/src/common/image.cpp b/src/common/image.cpp index 8e65698989..97f42c347e 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -30,10 +30,7 @@ #include "wx/filefn.h" #include "wx/wfstream.h" - -#if wxUSE_XPM - #include "wx/xpmdecod.h" -#endif +#include "wx/xpmdecod.h" // For memcpy #include @@ -165,17 +162,12 @@ wxImage::wxImage( wxInputStream& stream, const wxString& mimetype, int index ) } #endif // wxUSE_STREAMS -wxImage::wxImage( const char** xpmData ) +wxImage::wxImage(const char* const* xpmData) { Create(xpmData); } -wxImage::wxImage( char** xpmData ) -{ - Create((const char**) xpmData); -} - -bool wxImage::Create( const char** xpmData ) +bool wxImage::Create(const char* const* xpmData) { #if wxUSE_XPM UnRef(); diff --git a/src/common/xpmdecod.cpp b/src/common/xpmdecod.cpp index fa9bcb9fc7..709cc6e7dc 100644 --- a/src/common/xpmdecod.cpp +++ b/src/common/xpmdecod.cpp @@ -99,23 +99,20 @@ license is as follows: #if wxUSE_IMAGE && wxUSE_XPM +#include "wx/xpmdecod.h" + #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/log.h" #include "wx/utils.h" #include "wx/hashmap.h" - #if wxUSE_STREAMS - #include "wx/stream.h" - #endif + #include "wx/stream.h" #include "wx/image.h" #endif #include - #include -#include "wx/xpmdecod.h" - #if wxUSE_STREAMS bool wxXPMDecoder::CanRead(wxInputStream& stream) { @@ -659,7 +656,7 @@ struct wxXPMColourMapData }; WX_DECLARE_STRING_HASH_MAP(wxXPMColourMapData, wxXPMColourMap); -wxImage wxXPMDecoder::ReadData(const char **xpm_data) +wxImage wxXPMDecoder::ReadData(const char* const* xpm_data) { wxCHECK_MSG(xpm_data, wxNullImage, wxT("NULL XPM data") ); diff --git a/src/dfb/bitmap.cpp b/src/dfb/bitmap.cpp index 60e0a9e861..1f65aacad0 100644 --- a/src/dfb/bitmap.cpp +++ b/src/dfb/bitmap.cpp @@ -24,9 +24,6 @@ #include "wx/colour.h" #include "wx/image.h" -#warning "move this to common" -#include "wx/xpmdecod.h" - #include "wx/dfb/private.h" //----------------------------------------------------------------------------- @@ -102,7 +99,7 @@ public: // wxBitmap //----------------------------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase) IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxBitmapBase) wxBitmap::wxBitmap(int width, int height, int depth) @@ -138,25 +135,6 @@ bool wxBitmap::Create(int width, int height, int depth) return Create(wxIDirectFB::Get()->CreateSurface(&desc)); } -#warning "FIXME: move this to common code" -bool wxBitmap::CreateFromXpm(const char **bits) -{ - wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") ); - -#if wxUSE_IMAGE && wxUSE_XPM - wxXPMDecoder decoder; - wxImage img = decoder.ReadData(bits); - wxCHECK_MSG( img.Ok(), false, wxT("invalid bitmap data") ); - - *this = wxBitmap(img); - - return true; -#else - wxFAIL_MSG( _T("creating bitmaps from XPMs not supported") ); - return false; -#endif // wxUSE_IMAGE && wxUSE_XPM -} - #if wxUSE_IMAGE wxBitmap::wxBitmap(const wxImage& image, int depth) { diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 5754ccba92..019d6cd213 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -250,6 +250,20 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) } } +wxBitmap::wxBitmap(const char* const* bits) +{ + wxCHECK2_MSG(bits != NULL, return, wxT("invalid bitmap data")); + + GdkBitmap* mask = NULL; + SetPixmap(gdk_pixmap_create_from_xpm_d(wxGetRootWindow()->window, &mask, NULL, wx_const_cast(char**, bits))); + + if (M_BMPDATA->m_pixmap != NULL && mask != NULL) + { + M_BMPDATA->m_mask = new wxMask; + M_BMPDATA->m_mask->m_bitmap = mask; + } +} + wxBitmap::~wxBitmap() { } @@ -284,26 +298,6 @@ bool wxBitmap::Create( int width, int height, int depth ) return Ok(); } -bool wxBitmap::CreateFromXpm(const char* const* bits) -{ - UnRef(); - - wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") ); - - GdkBitmap *mask = (GdkBitmap*) NULL; - SetPixmap(gdk_pixmap_create_from_xpm_d(wxGetRootWindow()->window, &mask, NULL, wx_const_cast(char**, bits))); - - wxCHECK_MSG( M_BMPDATA->m_pixmap, false, wxT("couldn't create pixmap") ); - - if (mask) - { - M_BMPDATA->m_mask = new wxMask; - M_BMPDATA->m_mask->m_bitmap = mask; - } - - return true; -} - wxBitmap wxBitmap::Rescale(int clipx, int clipy, int clipwidth, int clipheight, int newx, int newy) const { wxBitmap bmp; @@ -1060,44 +1054,7 @@ void wxBitmap::UseAlpha() // wxBitmapHandler //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler,wxBitmapHandlerBase) - -wxBitmapHandler::~wxBitmapHandler() -{ -} - -bool wxBitmapHandler::Create(wxBitmap * WXUNUSED(bitmap), - void * WXUNUSED(data), - long WXUNUSED(type), - int WXUNUSED(width), - int WXUNUSED(height), - int WXUNUSED(depth)) -{ - wxFAIL_MSG( _T("not implemented") ); - - return false; -} - -bool wxBitmapHandler::LoadFile(wxBitmap * WXUNUSED(bitmap), - const wxString& WXUNUSED(name), - long WXUNUSED(flags), - int WXUNUSED(desiredWidth), - int WXUNUSED(desiredHeight)) -{ - wxFAIL_MSG( _T("not implemented") ); - - return false; -} - -bool wxBitmapHandler::SaveFile(const wxBitmap * WXUNUSED(bitmap), - const wxString& WXUNUSED(name), - int WXUNUSED(type), - const wxPalette * WXUNUSED(palette)) -{ - wxFAIL_MSG( _T("not implemented") ); - - return false; -} +IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase) /* static */ void wxBitmap::InitStandardHandlers() { diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index 6b0631a2e8..e5c2c1d354 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -312,11 +312,9 @@ bool wxBitmap::Create( int width, int height, int depth ) return Ok(); } -bool wxBitmap::CreateFromXpm( const char **bits ) +wxBitmap::wxBitmap(const char* const* bits) { - UnRef(); - - wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") ); + wxCHECK2_MSG(bits != NULL, return, wxT("invalid bitmap data")); GdkVisual *visual = wxTheApp->GetGdkVisual(); @@ -326,7 +324,7 @@ bool wxBitmap::CreateFromXpm( const char **bits ) M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits ); - wxCHECK_MSG( M_BMPDATA->m_pixmap, false, wxT("couldn't create pixmap") ); + wxCHECK2_MSG(M_BMPDATA->m_pixmap, return, wxT("couldn't create pixmap")); if (mask) { @@ -337,8 +335,6 @@ bool wxBitmap::CreateFromXpm( const char **bits ) gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); M_BMPDATA->m_bpp = visual->depth; // Can we get a different depth from create_from_xpm_d() ? - - return true; } wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, int newx, int newy ) @@ -1320,7 +1316,6 @@ void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data)) { } - bool wxBitmap::HasAlpha() const { return false; @@ -1334,44 +1329,7 @@ void wxBitmap::UseAlpha() // wxBitmapHandler //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler,wxBitmapHandlerBase) - -wxBitmapHandler::~wxBitmapHandler() -{ -} - -bool wxBitmapHandler::Create(wxBitmap * WXUNUSED(bitmap), - void * WXUNUSED(data), - long WXUNUSED(type), - int WXUNUSED(width), - int WXUNUSED(height), - int WXUNUSED(depth)) -{ - wxFAIL_MSG( _T("not implemented") ); - - return false; -} - -bool wxBitmapHandler::LoadFile(wxBitmap * WXUNUSED(bitmap), - const wxString& WXUNUSED(name), - long WXUNUSED(flags), - int WXUNUSED(desiredWidth), - int WXUNUSED(desiredHeight)) -{ - wxFAIL_MSG( _T("not implemented") ); - - return false; -} - -bool wxBitmapHandler::SaveFile(const wxBitmap * WXUNUSED(bitmap), - const wxString& WXUNUSED(name), - int WXUNUSED(type), - const wxPalette * WXUNUSED(palette)) -{ - wxFAIL_MSG( _T("not implemented") ); - - return false; -} +IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase) /* static */ void wxBitmap::InitStandardHandlers() { diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index 4b2a1526b4..ed9892706c 100644 --- a/src/mac/carbon/bitmap.cpp +++ b/src/mac/carbon/bitmap.cpp @@ -27,7 +27,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) -IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject) #ifdef __DARWIN__ #include @@ -842,7 +841,7 @@ wxBitmap::wxBitmap(int w, int h, int d) (void)Create(w, h, d); } -wxBitmap::wxBitmap(void *data, wxBitmapType type, int width, int height, int depth) +wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth) { (void) Create(data, type, width, height, depth); } @@ -852,16 +851,6 @@ wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type) LoadFile(filename, type); } -wxBitmap::wxBitmap(const char **bits) -{ - (void) CreateFromXpm(bits); -} - -wxBitmap::wxBitmap(char **bits) -{ - (void) CreateFromXpm((const char **)bits); -} - void * wxBitmap::GetRawAccess() const { wxCHECK_MSG( Ok() , NULL , wxT("invalid bitmap") ) ; @@ -883,24 +872,6 @@ void wxBitmap::EndRawAccess() M_BITMAPDATA->EndRawAccess() ; } -bool wxBitmap::CreateFromXpm(const char **bits) -{ -#if wxUSE_IMAGE - wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") ); - - wxXPMDecoder decoder; - wxImage img = decoder.ReadData(bits); - wxCHECK_MSG( img.Ok(), false, wxT("invalid bitmap data") ); - - *this = wxBitmap(img); - - return true; -#else - - return false; -#endif -} - #ifdef __WXMAC_OSX__ WXCGIMAGEREF wxBitmap::CGImageCreate() const { @@ -1015,7 +986,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) return false; } -bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int depth) +bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height, int depth) { UnRef(); @@ -1536,25 +1507,7 @@ WXHBITMAP wxMask::GetHBITMAP() const // wxBitmapHandler // ---------------------------------------------------------------------------- -wxBitmapHandler::~wxBitmapHandler() -{ -} - -bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth) -{ - return false; -} - -bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) -{ - return false; -} - -bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) -{ - return false; -} +IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase) // ---------------------------------------------------------------------------- // Standard Handlers diff --git a/src/mgl/bitmap.cpp b/src/mgl/bitmap.cpp index a2f6ac217a..bd29f369b0 100644 --- a/src/mgl/bitmap.cpp +++ b/src/mgl/bitmap.cpp @@ -91,7 +91,7 @@ wxBitmapRefData::~wxBitmapRefData() #define M_BMPDATA ((wxBitmapRefData *)m_refData) -IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler,wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase) IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxBitmapBase) wxBitmap::wxBitmap(int width, int height, int depth) @@ -171,19 +171,6 @@ bool wxBitmap::Create(int width, int height, int depth) return Ok(); } -bool wxBitmap::CreateFromXpm(const char **bits) -{ - wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") ); - - wxXPMDecoder decoder; - wxImage img = decoder.ReadData(bits); - wxCHECK_MSG( img.Ok(), false, wxT("invalid bitmap data") ); - - *this = wxBitmap(img); - - return true; -} - wxBitmap::wxBitmap(const wxImage& image, int depth) { long width, height; @@ -559,7 +546,7 @@ public: const wxString& extension, const wxString& name); virtual bool Create(wxBitmap *WXUNUSED(bitmap), - void *WXUNUSED(data), + const void* WXUNUSED(data), long WXUNUSED(flags), int WXUNUSED(width), int WXUNUSED(height), @@ -777,7 +764,7 @@ class wxICOBitmapHandler: public wxBitmapHandler const wxString& extension, const wxString& name); virtual bool Create(wxBitmap *WXUNUSED(bitmap), - void *WXUNUSED(data), + const void* WXUNUSED(data), long WXUNUSED(flags), int WXUNUSED(width), int WXUNUSED(height), diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index c964726d83..f6e6b1820f 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -473,24 +473,6 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) #endif } -// Create from XPM data -bool wxBitmap::CreateFromXpm(const char **data) -{ -#if wxUSE_IMAGE && wxUSE_XPM && wxUSE_WXDIB - wxCHECK_MSG( data != NULL, false, wxT("invalid bitmap data") ); - - wxXPMDecoder decoder; - wxImage img = decoder.ReadData(data); - wxCHECK_MSG( img.Ok(), false, wxT("invalid bitmap data") ); - - *this = wxBitmap(img); - return true; -#else - wxUnusedVar(data); - return false; -#endif -} - wxBitmap::wxBitmap(int w, int h, int d) { (void)Create(w, h, d); @@ -501,7 +483,7 @@ wxBitmap::wxBitmap(int w, int h, const wxDC& dc) (void)Create(w, h, dc); } -wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth) +wxBitmap::wxBitmap(const void* data, long type, int width, int height, int depth) { (void)Create(data, type, width, height, depth); } @@ -1026,7 +1008,7 @@ bool wxBitmap::LoadFile(const wxString& filename, long type) return false; } -bool wxBitmap::Create(void *data, long type, int width, int height, int depth) +bool wxBitmap::Create(const void* data, long type, int width, int height, int depth) { UnRef(); @@ -1512,13 +1494,13 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) // ---------------------------------------------------------------------------- bool wxBitmapHandler::Create(wxGDIImage *image, - void *data, + const void* data, long flags, int width, int height, int depth) { wxBitmap *bitmap = wxDynamicCast(image, wxBitmap); - return bitmap ? Create(bitmap, data, flags, width, height, depth) : false; + return bitmap && Create(bitmap, data, flags, width, height, depth); } bool wxBitmapHandler::Load(wxGDIImage *image, @@ -1528,7 +1510,7 @@ bool wxBitmapHandler::Load(wxGDIImage *image, { wxBitmap *bitmap = wxDynamicCast(image, wxBitmap); - return bitmap ? LoadFile(bitmap, name, flags, width, height) : false; + return bitmap && LoadFile(bitmap, name, flags, width, height); } bool wxBitmapHandler::Save(wxGDIImage *image, @@ -1537,34 +1519,7 @@ bool wxBitmapHandler::Save(wxGDIImage *image, { wxBitmap *bitmap = wxDynamicCast(image, wxBitmap); - return bitmap ? SaveFile(bitmap, name, type) : false; -} - -bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), - void *WXUNUSED(data), - long WXUNUSED(type), - int WXUNUSED(width), - int WXUNUSED(height), - int WXUNUSED(depth)) -{ - return false; -} - -bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), - const wxString& WXUNUSED(name), - long WXUNUSED(type), - int WXUNUSED(desiredWidth), - int WXUNUSED(desiredHeight)) -{ - return false; -} - -bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), - const wxString& WXUNUSED(name), - int WXUNUSED(type), - const wxPalette *WXUNUSED(palette)) -{ - return false; + return bitmap && SaveFile(bitmap, name, type); } // ---------------------------------------------------------------------------- diff --git a/src/msw/gdiimage.cpp b/src/msw/gdiimage.cpp index 1675b52c60..6988f3d0c4 100644 --- a/src/msw/gdiimage.cpp +++ b/src/msw/gdiimage.cpp @@ -104,7 +104,7 @@ public: // creating and saving icons is not supported virtual bool Create(wxGDIImage *WXUNUSED(image), - void *WXUNUSED(data), + const void* WXUNUSED(data), long WXUNUSED(flags), int WXUNUSED(width), int WXUNUSED(height), diff --git a/src/os2/bitmap.cpp b/src/os2/bitmap.cpp index c7d256e0f7..c1bbb3e002 100644 --- a/src/os2/bitmap.cpp +++ b/src/os2/bitmap.cpp @@ -271,7 +271,7 @@ wxBitmap::wxBitmap( } // end of wxBitmap::wxBitmap wxBitmap::wxBitmap( - void* pData + const void* pData , long lType , int nWidth , int nHeight @@ -380,27 +380,6 @@ bool wxBitmap::Create( return Ok(); } // end of wxBitmap::Create -bool wxBitmap::CreateFromXpm( - const char** ppData -) -{ -#if wxUSE_IMAGE && wxUSE_XPM - Init(); - - wxCHECK_MSG(ppData != NULL, false, wxT("invalid bitmap data")); - - wxXPMDecoder vDecoder; - wxImage vImg = vDecoder.ReadData(ppData); - - wxCHECK_MSG(vImg.Ok(), false, wxT("invalid bitmap data")); - - *this = wxBitmap(vImg); - return true; -#else - return false; -#endif -} // end of wxBitmap::CreateFromXpm - bool wxBitmap::LoadFile(const wxString& filename, long type) { UnRef(); @@ -458,7 +437,7 @@ bool wxBitmap::LoadFile( } // end of wxBitmap::LoadFile bool wxBitmap::Create( - void* pData + const void* pData , long lType , int nWidth , int nHeight @@ -1450,7 +1429,7 @@ bool wxMask::Create( // ---------------------------------------------------------------------------- bool wxBitmapHandler::Create( wxGDIImage* pImage, - void* pData, + const void* pData, long WXUNUSED(lFlags), int nWidth, int nHeight, @@ -1506,7 +1485,7 @@ bool wxBitmapHandler::Save( bool wxBitmapHandler::Create( wxBitmap* WXUNUSED(pBitmap) -, void* WXUNUSED(pData) +, const void* WXUNUSED(pData) , long WXUNUSED(lType) , int WXUNUSED(nWidth) , int WXUNUSED(nHeight) diff --git a/src/os2/gdiimage.cpp b/src/os2/gdiimage.cpp index d19adb7e8b..a5b6a56e7a 100644 --- a/src/os2/gdiimage.cpp +++ b/src/os2/gdiimage.cpp @@ -113,7 +113,7 @@ public: // creating and saving icons is not supported virtual bool Create( wxGDIImage* WXUNUSED(pImage) - ,void* WXUNUSED(pData) + ,const void* WXUNUSED(pData) ,long WXUNUSED(lFlags) ,int WXUNUSED(nWidth) ,int WXUNUSED(nHeight) diff --git a/src/palmos/bitmap.cpp b/src/palmos/bitmap.cpp index 75ae168b58..5855685a63 100644 --- a/src/palmos/bitmap.cpp +++ b/src/palmos/bitmap.cpp @@ -211,16 +211,6 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) Init(); } -// Create from XPM data -#if wxUSE_IMAGE && wxUSE_XPM -bool wxBitmap::CreateFromXpm(const char **data) -#else -bool wxBitmap::CreateFromXpm(const char **WXUNUSED(data)) -#endif -{ - return false; -} - wxBitmap::wxBitmap(int w, int h, int d) { } @@ -229,7 +219,7 @@ wxBitmap::wxBitmap(int w, int h, const wxDC& dc) { } -wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth) +wxBitmap::wxBitmap(const void* data, long type, int width, int height, int depth) { } @@ -294,7 +284,7 @@ bool wxBitmap::LoadFile(const wxString& filename, long type) return false; } -bool wxBitmap::Create(void *data, long type, int width, int height, int depth) +bool wxBitmap::Create(const void* data, long type, int width, int height, int depth) { return false; } @@ -445,7 +435,7 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) // ---------------------------------------------------------------------------- bool wxBitmapHandler::Create(wxGDIImage *image, - void *data, + const void* data, long flags, int width, int height, int depth) { @@ -468,7 +458,7 @@ bool wxBitmapHandler::Save(wxGDIImage *image, } bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), - void *WXUNUSED(data), + const void* WXUNUSED(data), long WXUNUSED(type), int WXUNUSED(width), int WXUNUSED(height), diff --git a/src/x11/bitmap.cpp b/src/x11/bitmap.cpp index 920910df87..1c85afbe02 100644 --- a/src/x11/bitmap.cpp +++ b/src/x11/bitmap.cpp @@ -360,7 +360,7 @@ bool wxBitmap::Create( int width, int height, int depth ) return Ok(); } -bool wxBitmap::Create(void *data, wxBitmapType type, +bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height, int depth) { UnRef(); @@ -417,11 +417,9 @@ bool wxBitmap::Create(WXPixmap pixmap) return true; } -bool wxBitmap::CreateFromXpm( const char **bits ) +wxBitmap::wxBitmap(const char* const* bits) { - wxCHECK_MSG( bits, false, wxT("NULL pointer in wxBitmap::CreateFromXpm") ); - - return Create(bits, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); + Create(bits, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); } bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) @@ -912,7 +910,7 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int depth ) { m_refData = new wxBitmapRefData; - (void) Create((void*) bits, wxBITMAP_TYPE_XBM_DATA, width, height, depth); + (void) Create(bits, wxBITMAP_TYPE_XBM_DATA, width, height, depth); } wxBitmap::~wxBitmap() @@ -1320,7 +1318,7 @@ public: virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); - virtual bool Create(wxBitmap *WXUNUSED(bitmap), void *WXUNUSED(data), long WXUNUSED(flags), + virtual bool Create(wxBitmap *WXUNUSED(bitmap), const void* WXUNUSED(data), long WXUNUSED(flags), int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth) = 1) { return false; } }; @@ -1435,13 +1433,13 @@ public: const wxPalette *WXUNUSED(palette) = NULL) { return false; } - virtual bool Create(wxBitmap *bitmap, void *data, long flags, + virtual bool Create(wxBitmap *bitmap, const void* data, long flags, int width, int height, int depth = 1); }; IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler) -bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *bits, +bool wxXPMDataHandler::Create(wxBitmap *bitmap, const void* bits, long WXUNUSED(flags), int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth)) { @@ -1541,13 +1539,13 @@ public: const wxPalette *WXUNUSED(palette) = NULL) { return false; } - virtual bool Create(wxBitmap *bitmap, void *data, long flags, + virtual bool Create(wxBitmap *bitmap, const void* data, long flags, int width, int height, int depth = 1); }; IMPLEMENT_DYNAMIC_CLASS(wxXBMDataHandler, wxBitmapHandler) -bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *bits, +bool wxXBMDataHandler::Create( wxBitmap *bitmap, const void* bits, long WXUNUSED(flags), int width, int height, int WXUNUSED(depth)) { -- 2.45.2