X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cf7a7e133be36522ec3afd0417f1d2bd860b4f6c..9c039d08bfbb59c0abcbc705fb49f9b2cb321edf:/src/gtk1/bitmap.cpp diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index e4adea4dd1..07519ea19f 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -16,7 +16,7 @@ #include "wx/icon.h" #include "gdk/gdkprivate.h" -#ifdef USE_GDK_IMLIB +#ifdef wxUSE_GDK_IMLIB #include "../gdk_imlib/gdk_imlib.h" #include "gdk/gdkx.h" // GDK_DISPLAY @@ -50,7 +50,7 @@ wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap) ) wxMask::~wxMask(void) { -#ifdef USE_GDK_IMLIB +#ifdef wxUSE_GDK_IMLIB // do not delete the mask, gdk_imlib does it for you #else if (m_bitmap) gdk_bitmap_unref( m_bitmap ); @@ -80,7 +80,7 @@ class wxBitmapRefData: public wxObjectRefData int m_width; int m_height; int m_bpp; -#ifdef USE_GDK_IMLIB +#ifdef wxUSE_GDK_IMLIB GdkImlibImage *m_image; #endif wxPalette *m_palette; @@ -95,14 +95,14 @@ wxBitmapRefData::wxBitmapRefData(void) m_height = 0; m_bpp = 0; m_palette = (wxPalette *) NULL; -#ifdef USE_GDK_IMLIB +#ifdef wxUSE_GDK_IMLIB m_image = (GdkImlibImage *) NULL; #endif } wxBitmapRefData::~wxBitmapRefData(void) { -#ifdef USE_GDK_IMLIB +#ifdef wxUSE_GDK_IMLIB if (m_pixmap) gdk_imlib_free_pixmap( m_pixmap ); if (m_image) gdk_imlib_kill_image( m_image ); #else @@ -141,7 +141,7 @@ wxBitmap::wxBitmap( char **bits ) { m_refData = new wxBitmapRefData(); -#ifndef USE_GDK_IMLIB +#ifndef wxUSE_GDK_IMLIB GdkBitmap *mask = NULL; @@ -228,25 +228,39 @@ bool wxBitmap::operator != ( const wxBitmap& bmp ) bool wxBitmap::Ok(void) const { - wxASSERT_MSG( m_refData != NULL, "invalid bitmap" ); return (m_refData != NULL); } int wxBitmap::GetHeight(void) const { - if (!Ok()) return 0; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return -1; + } + return M_BMPDATA->m_height; } int wxBitmap::GetWidth(void) const { - if (!Ok()) return 0; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return -1; + } + return M_BMPDATA->m_width; } int wxBitmap::GetDepth(void) const { - if (!Ok()) return 0; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return -1; + } + return M_BMPDATA->m_bpp; } @@ -279,14 +293,22 @@ void wxBitmap::SetDepth( int depth ) wxMask *wxBitmap::GetMask(void) const { - if (!Ok()) return (wxMask *) NULL; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return (wxMask *) NULL; + } return M_BMPDATA->m_mask; } void wxBitmap::SetMask( wxMask *mask ) { - if (!Ok()) return; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return; + } if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask; @@ -295,11 +317,19 @@ void wxBitmap::SetMask( wxMask *mask ) void wxBitmap::Resize( int height, int width ) { - if (!Ok()) return; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return; + } -#ifdef USE_GDK_IMLIB +#ifdef wxUSE_GDK_IMLIB - if (M_BMPDATA->m_bitmap) return; // not supported for bitmaps + if (M_BMPDATA->m_bitmap) + { + wxFAIL_MSG( "wxBitmap::Resize not supported for mono-bitmaps" ); + return; + } if (!M_BMPDATA->m_image) RecreateImage(); @@ -324,9 +354,19 @@ void wxBitmap::Resize( int height, int width ) bool wxBitmap::SaveFile( const wxString &name, int WXUNUSED(type), wxPalette *WXUNUSED(palette) ) { -#ifdef USE_GDK_IMLIB + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return FALSE; + } + +#ifdef wxUSE_GDK_IMLIB - if (!Ok()) return FALSE; + if (M_BMPDATA->m_bitmap) + { + wxFAIL_MSG( "wxBitmap::SaveFile not supported for mono-bitmaps" ); + return FALSE; + } if (!M_BMPDATA->m_image) RecreateImage(); @@ -343,7 +383,7 @@ bool wxBitmap::SaveFile( const wxString &name, int WXUNUSED(type), bool wxBitmap::LoadFile( const wxString &name, int WXUNUSED(type) ) { -#ifdef USE_GDK_IMLIB +#ifdef wxUSE_GDK_IMLIB UnRef(); m_refData = new wxBitmapRefData(); @@ -380,7 +420,11 @@ wxPalette *wxBitmap::GetPalette(void) const GdkPixmap *wxBitmap::GetPixmap(void) const { - if (!Ok()) return (GdkPixmap *) NULL; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return (GdkPixmap *) NULL; + } // if (!M_BMPDATA->m_image) RecreateImage(); @@ -389,14 +433,22 @@ GdkPixmap *wxBitmap::GetPixmap(void) const GdkBitmap *wxBitmap::GetBitmap(void) const { - if (!Ok()) return (GdkBitmap *) NULL; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return (GdkBitmap *) NULL; + } return M_BMPDATA->m_bitmap; } void wxBitmap::DestroyImage(void) { - if (!Ok()) return; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return; + } if (M_BMPDATA->m_image) { @@ -407,9 +459,13 @@ void wxBitmap::DestroyImage(void) void wxBitmap::RecreateImage(void) { - if (!Ok()) return; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return; + } -#ifdef USE_GDK_IMLIB +#ifdef wxUSE_GDK_IMLIB DestroyImage(); @@ -458,9 +514,13 @@ void wxBitmap::RecreateImage(void) void wxBitmap::Render(void) { - if (!Ok()) return; + if (!Ok()) + { + wxFAIL_MSG( "invalid bitmap" ); + return; + } -#ifdef USE_GDK_IMLIB +#ifdef wxUSE_GDK_IMLIB if (!M_BMPDATA->m_image) RecreateImage();