X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7fc65a0384df4007a96cd5bab98b0f7abef0af52..e9a0cc4b727ed06da1a776a1b6c4ba66ed4bde3c:/src/x11/bitmap.cpp diff --git a/src/x11/bitmap.cpp b/src/x11/bitmap.cpp index 7d3d136169..7e42116984 100644 --- a/src/x11/bitmap.cpp +++ b/src/x11/bitmap.cpp @@ -13,12 +13,14 @@ #include "wx/wxprec.h" #include "wx/bitmap.h" -#include "wx/icon.h" -#include "wx/log.h" -#include "wx/image.h" -#include "wx/app.h" -#if wxUSE_NANOX -#include "wx/dcmemory.h" + +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/app.h" + #include "wx/dcmemory.h" + #include "wx/icon.h" + #include "wx/math.h" + #include "wx/image.h" #endif #include "wx/x11/private.h" @@ -40,7 +42,6 @@ bool wxGetImageFromDrawable(GR_DRAW_ID drawable, int srcX, int srcY, int width, #include "wx/wfstream.h" #endif #endif -#include "wx/math.h" //----------------------------------------------------------------------------- // wxMask @@ -230,7 +231,7 @@ class wxBitmapRefData: public wxObjectRefData { public: wxBitmapRefData(); - ~wxBitmapRefData(); + virtual ~wxBitmapRefData(); WXPixmap m_pixmap; WXPixmap m_bitmap; @@ -312,7 +313,7 @@ bool wxBitmap::Create( int width, int height, int depth ) { UnRef(); - wxCHECK_MSG( (width > 0) && (height > 0), false, wxT("invalid bitmap size") ) + wxCHECK_MSG( (width > 0) && (height > 0), false, wxT("invalid bitmap size") ); m_refData = new wxBitmapRefData(); @@ -327,7 +328,7 @@ bool wxBitmap::Create( int width, int height, int depth ) if (depth == -1) depth = bpp; wxCHECK_MSG( (depth == bpp) || - (depth == 1), false, wxT("invalid bitmap depth") ) + (depth == 1), false, wxT("invalid bitmap depth") ); M_BMPDATA->m_mask = (wxMask *) NULL; M_BMPDATA->m_width = width; @@ -359,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(); @@ -416,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 ) @@ -534,8 +533,8 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) UnRef(); - wxCHECK_MSG( image.Ok(), false, wxT("invalid image") ) - wxCHECK_MSG( depth == -1, false, wxT("invalid bitmap depth") ) + wxCHECK_MSG( image.Ok(), false, wxT("invalid image") ); + wxCHECK_MSG( depth == -1, false, wxT("invalid bitmap depth") ); m_refData = new wxBitmapRefData(); @@ -902,11 +901,6 @@ wxImage wxBitmap::ConvertToImage() const // wxUSE_NANOX } -wxBitmap::wxBitmap( const wxBitmap& bmp ) -{ - Ref( bmp ); -} - wxBitmap::wxBitmap( const wxString &filename, wxBitmapType type ) { LoadFile( filename, type ); @@ -916,21 +910,13 @@ 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() { } -wxBitmap& wxBitmap::operator = ( const wxBitmap& bmp ) -{ - if ( m_refData != bmp.m_refData ) - Ref( bmp ); - - return *this; -} - bool wxBitmap::operator == ( const wxBitmap& bmp ) const { return m_refData == bmp.m_refData; @@ -941,7 +927,7 @@ bool wxBitmap::operator != ( const wxBitmap& bmp ) const return m_refData != bmp.m_refData; } -bool wxBitmap::Ok() const +bool wxBitmap::IsOk() const { return (m_refData != NULL); } @@ -1303,7 +1289,7 @@ int GrGetPixelColor(GR_SCREEN_INFO* sinfo, GR_PALETTE* palette, GR_PIXELVAL pixe // Bitmap handlers // ============================================================================ -IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase); +IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler, wxBitmapHandlerBase) #define M_BMPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData()) @@ -1332,12 +1318,12 @@ 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; } }; -IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler); +IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler) bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long WXUNUSED(flags), int WXUNUSED(desiredWidth), @@ -1447,18 +1433,18 @@ 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); +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)) { #if wxHAVE_LIB_XPM - wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") ) + wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") ); if (!bitmap->GetRefData()) bitmap->SetRefData( new wxBitmapRefData() ); @@ -1553,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); +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)) {