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.
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.
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.
\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.
\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.
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.
\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.
\membersection{wxImageHandler::GetMimeType}\label{wximagehandlergetmimetype}
-\constfunc{wxString}{GetMimeType}{\void}
+\constfunc{const wxString\&}{GetMimeType}{\void}
Gets the MIME type associated with this handler.
// 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"
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:
wxString m_extension;
wxBitmapType m_type;
-private:
DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
};
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;
// 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:
// 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;
static void CleanUpHandlers() { }
};
+class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
+{
+ DECLARE_ABSTRACT_CLASS(wxBitmapHandler)
+};
+
#endif // __WX_COCOA_BITMAP_H__
// 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
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
wxIDirectFBSurfacePtr GetDirectFBSurface() const;
protected:
- bool CreateFromXpm(const char **bits);
-
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
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();
void UseAlpha();
protected:
- bool CreateFromXpm(const char* const* bits);
bool CreateFromImage(const wxImage& image, int depth);
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_
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();
void UseAlpha();
protected:
- bool CreateFromXpm(const char **bits);
bool CreateFromImage(const wxImage& image, int depth);
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__
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
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 );
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
};
-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)
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);
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;
// 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
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() {}
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:
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)
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);
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);
// 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,
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,
// 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,
);
// 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
)
{ Init(); }
// New constructor for generalised creation from data
- wxBitmap( void* pData
+ wxBitmap( const void* pData
,long lType
,int nWidth
,int nHeight
,int nHeight
,int nDepth = -1
);
- virtual bool Create( void* pData
+ virtual bool Create( const void* pData
,long lType
,int nWidth
,int nHeight
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:
// 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
);
virtual bool Create( wxGDIImage* pImage
- ,void* pData
+ ,const void* pData
,long lFlags
,int nWidth
,int nHeight
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)
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);
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);
// 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,
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,
// 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,
// 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
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();
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);
WXDisplay *GetDisplay() const;
-protected:
- bool CreateFromXpm(const char **bits);
-
private:
DECLARE_DYNAMIC_CLASS(wxBitmap)
};
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
#import <AppKit/NSImage.h>
#import <AppKit/NSColor.h>
+IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase)
+
// ========================================================================
// wxBitmapRefData
// ========================================================================
(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);
}
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();
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();
}
}
+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)
#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
// ----------------------------------------------------------------------------
#include "wx/filefn.h"
#include "wx/wfstream.h"
-
-#if wxUSE_XPM
- #include "wx/xpmdecod.h"
-#endif
+#include "wx/xpmdecod.h"
// For memcpy
#include <string.h>
}
#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();
#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 <string.h>
-
#include <ctype.h>
-#include "wx/xpmdecod.h"
-
#if wxUSE_STREAMS
bool wxXPMDecoder::CanRead(wxInputStream& stream)
{
};
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") );
#include "wx/colour.h"
#include "wx/image.h"
-#warning "move this to common"
-#include "wx/xpmdecod.h"
-
#include "wx/dfb/private.h"
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
-IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase)
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxBitmapBase)
wxBitmap::wxBitmap(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)
{
}
}
+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()
{
}
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;
// 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()
{
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();
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)
{
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 )
{
}
-
bool wxBitmap::HasAlpha() const
{
return false;
// 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()
{
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
#ifdef __DARWIN__
#include <ApplicationServices/ApplicationServices.h>
(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);
}
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") ) ;
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
{
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();
// 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
#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)
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;
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),
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),
#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);
(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);
}
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();
// ----------------------------------------------------------------------------
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,
{
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,
{
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);
}
// ----------------------------------------------------------------------------
// 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),
} // end of wxBitmap::wxBitmap
wxBitmap::wxBitmap(
- void* pData
+ const void* pData
, long lType
, int nWidth
, int nHeight
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();
} // end of wxBitmap::LoadFile
bool wxBitmap::Create(
- void* pData
+ const void* pData
, long lType
, int nWidth
, int nHeight
// ----------------------------------------------------------------------------
bool wxBitmapHandler::Create( wxGDIImage* pImage,
- void* pData,
+ const void* pData,
long WXUNUSED(lFlags),
int nWidth,
int nHeight,
bool wxBitmapHandler::Create(
wxBitmap* WXUNUSED(pBitmap)
-, void* WXUNUSED(pData)
+, const void* WXUNUSED(pData)
, long WXUNUSED(lType)
, int WXUNUSED(nWidth)
, int WXUNUSED(nHeight)
// 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)
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)
{
}
{
}
-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)
{
}
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;
}
// ----------------------------------------------------------------------------
bool wxBitmapHandler::Create(wxGDIImage *image,
- void *data,
+ const void* data,
long flags,
int width, int height, int depth)
{
}
bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap),
- void *WXUNUSED(data),
+ const void* WXUNUSED(data),
long WXUNUSED(type),
int WXUNUSED(width),
int WXUNUSED(height),
return Ok();
}
-bool wxBitmap::Create(void *data, wxBitmapType type,
+bool wxBitmap::Create(const void* data, wxBitmapType type,
int width, int height, int depth)
{
UnRef();
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 )
{
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()
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; }
};
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))
{
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))
{