}
//-----------------------------------------------------------------------------
-// wxBitmap
+// wxBitmapRefData
//-----------------------------------------------------------------------------
-class wxBitmapRefData: public wxObjectRefData
+class wxBitmapRefData : public wxGDIRefData
{
public:
wxBitmapRefData();
// shouldn't be called more than once as it doesn't free the existing data
bool Create(int width, int height, int depth);
+ virtual bool IsOk() const { return m_pixmap || m_bitmap; }
+
Pixmap m_pixmap;
Pixmap m_bitmap;
Display *m_display;
m_width = 0;
m_height = 0;
m_bpp = 0;
- m_palette = (wxPalette *) NULL;
+ m_palette = NULL;
}
wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data)
return (WXPixmap)ret;
}
-#define M_BMPDATA ((wxBitmapRefData *)m_refData)
-IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject)
+//-----------------------------------------------------------------------------
+// wxBitmap
+//-----------------------------------------------------------------------------
-wxBitmap::wxBitmap()
-{
-}
+#define M_BMPDATA ((wxBitmapRefData *)m_refData)
-wxBitmap::wxBitmap( int width, int height, int depth )
-{
- Create( width, height, depth );
-}
+IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject)
bool wxBitmap::Create( int width, int height, int depth )
{
Create(bits, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
}
-wxObjectRefData *wxBitmap::CreateRefData() const
+wxGDIRefData *wxBitmap::CreateGDIRefData() const
{
return new wxBitmapRefData;
}
-wxObjectRefData *wxBitmap::CloneRefData(const wxObjectRefData *data) const
+wxGDIRefData *wxBitmap::CloneGDIRefData(const wxGDIRefData *data) const
{
- return new wxBitmapRefData(*wx_static_cast(const wxBitmapRefData *, data));
+ return new wxBitmapRefData(*static_cast<const wxBitmapRefData *>(data));
}
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
M_BMPDATA->m_pixmap = XCreatePixmap( xdisplay, xroot, width, height, depth );
- // Create mask
+ // Create mask if necessary
+ const bool hasMask = image.HasMask();
- XImage *mask_image = (XImage*) NULL;
- if (image.HasMask())
+ XImage *mask_image = NULL;
+ if ( hasMask )
{
mask_image = XCreateImage( xdisplay, xvisual, 1, ZPixmap, 0, 0, width, height, 32, 0 );
mask_image->data = (char*) malloc( mask_image->bytes_per_line * mask_image->height );
unsigned char *colorCube =
wxTheApp->GetVisualInfo(M_BMPDATA->m_display)->m_colorCube;
- bool hasMask = image.HasMask();
-
int index = 0;
for (int y = 0; y < height; y++)
{
{
}
-bool wxBitmap::IsOk() const
-{
- return (m_refData != NULL);
-}
-
int wxBitmap::GetHeight() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
wxMask *wxBitmap::GetMask() const
{
- wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") );
+ wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
return M_BMPDATA->m_mask;
}
wxPalette *wxBitmap::GetPalette() const
{
- if (!Ok()) return (wxPalette *) NULL;
+ if (!Ok()) return NULL;
return M_BMPDATA->m_palette;
}
WXDisplay *wxBitmap::GetDisplay() const
{
- wxCHECK_MSG( Ok(), (WXDisplay*) NULL, wxT("invalid bitmap") );
+ wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
return M_BMPDATA->m_display;
}
// Bitmap handlers
// ============================================================================
-IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase)
-
#define M_BMPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
#if wxUSE_XPM
Pixmap mask = 0;
int ErrorStatus = XpmReadFileToPixmap( xdisplay, xroot,
- (char*) name.c_str(),
+ (char*) ((const char*) name.c_str()),
&pixmap, &mask, &xpmAttr);
if (ErrorStatus == XpmSuccess)
XpmFreeAttributes(&xpmAttr);
- M_BMPHANDLERDATA->m_bitmap = (WXPixmap) pixmap;
+ M_BMPHANDLERDATA->m_bitmap = (Pixmap) pixmap;
if (mask)
{
#elif wxUSE_STREAMS
wxXPMDecoder decoder;
wxFileInputStream stream(name);
- if (stream.Ok())
+ if (stream.IsOk())
{
wxImage image(decoder.ReadFile(stream));
- return image.Ok() && bitmap->CreateFromImage(image);
+ return image.IsOk() && bitmap->CreateFromImage(image);
}
return false;
virtual bool LoadFile(wxBitmap *WXUNUSED(bitmap),
const wxString& WXUNUSED(name),
- long WXUNUSED(flags),
+ wxBitmapType WXUNUSED(flags),
int WXUNUSED(desiredWidth),
int WXUNUSED(desiredHeight))
{ return false; }
virtual bool SaveFile(const wxBitmap *WXUNUSED(bitmap),
const wxString& WXUNUSED(name),
- int WXUNUSED(type),
+ wxBitmapType WXUNUSED(type),
const wxPalette *WXUNUSED(palette) = NULL)
{ return false; }
- virtual bool Create(wxBitmap *bitmap, const void* data, long flags,
+ virtual bool Create(wxBitmap *bitmap, const void* data, wxBitmapType flags,
int width, int height, int depth = 1);
};
IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler)
bool wxXPMDataHandler::Create(wxBitmap *bitmap, const void* bits,
- long WXUNUSED(flags),
+ wxBitmapType WXUNUSED(flags),
int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth))
{
#if wxHAVE_LIB_XPM
M_BMPHANDLERDATA->m_bpp = bpp; // mono as well?
-#if __WXDEBUG__
+#if wxDEBUG_LEVEL
unsigned int depthRet;
int xRet, yRet;
unsigned int widthRet, heightRet, borderWidthRet;
&widthRet, &heightRet, &borderWidthRet, &depthRet);
wxASSERT_MSG( bpp == (int)depthRet, wxT("colour depth mismatch") );
-#endif
+#endif // wxDEBUG_LEVEL
XpmFreeAttributes(&xpmAttr);
- M_BMPHANDLERDATA->m_pixmap = (WXPixmap) pixmap;
+ M_BMPHANDLERDATA->m_pixmap = (Pixmap) pixmap;
if (mask)
{
int xscreen = DefaultScreen( xdisplay );
Window xroot = RootWindow( xdisplay, xscreen );
- M_BMPHANDLERDATA->m_mask = (wxMask *) NULL;
+ M_BMPHANDLERDATA->m_mask = NULL;
M_BMPHANDLERDATA->m_bitmap =
XCreateBitmapFromData(xdisplay, xroot,
(char *) bits, width, height );