X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3b9f782ef3949f583e8ac53795d36787f044fc3..c092ed3828985d8e4dd533eb0a2c2f02800fb564:/src/gtk/bitmap.cpp?ds=sidebyside diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 2cc8b7d78e..13d315e699 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -37,7 +37,7 @@ extern GtkWidget *wxGetRootWindow(); // wxMask //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject) +IMPLEMENT_DYNAMIC_CLASS(wxMask, wxMaskBase) wxMask::wxMask() { @@ -47,7 +47,7 @@ wxMask::wxMask() wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour ) { m_bitmap = NULL; - Create( bitmap, colour ); + InitFromColour(bitmap, colour); } #if wxUSE_PALETTE @@ -61,7 +61,7 @@ wxMask::wxMask( const wxBitmap& bitmap, int paletteIndex ) wxMask::wxMask( const wxBitmap& bitmap ) { m_bitmap = NULL; - Create( bitmap ); + InitFromMonoBitmap(bitmap); } wxMask::~wxMask() @@ -70,15 +70,17 @@ wxMask::~wxMask() g_object_unref (m_bitmap); } -bool wxMask::Create( const wxBitmap& bitmap, - const wxColour& colour ) +void wxMask::FreeData() { if (m_bitmap) { g_object_unref (m_bitmap); m_bitmap = NULL; } +} +bool wxMask::InitFromColour(const wxBitmap& bitmap, const wxColour& colour) +{ const int w = bitmap.GetWidth(); const int h = bitmap.GetHeight(); @@ -136,28 +138,8 @@ bool wxMask::Create( const wxBitmap& bitmap, return true; } -#if wxUSE_PALETTE -bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex ) -{ - unsigned char r,g,b; - wxPalette *pal = bitmap.GetPalette(); - - wxCHECK_MSG( pal, false, wxT("Cannot create mask from bitmap without palette") ); - - pal->GetRGB(paletteIndex, &r, &g, &b); - - return Create(bitmap, wxColour(r, g, b)); -} -#endif // wxUSE_PALETTE - -bool wxMask::Create( const wxBitmap& bitmap ) +bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap) { - if (m_bitmap) - { - g_object_unref (m_bitmap); - m_bitmap = NULL; - } - if (!bitmap.IsOk()) return false; wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") ); @@ -179,7 +161,7 @@ GdkBitmap *wxMask::GetBitmap() const } //----------------------------------------------------------------------------- -// wxBitmap +// wxBitmapRefData //----------------------------------------------------------------------------- class wxBitmapRefData: public wxGDIRefData @@ -226,17 +208,15 @@ wxBitmapRefData::~wxBitmapRefData() #endif // wxUSE_PALETTE } + +//----------------------------------------------------------------------------- +// wxBitmap //----------------------------------------------------------------------------- #define M_BMPDATA static_cast(m_refData) IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject) -wxBitmap::wxBitmap(int width, int height, int depth) -{ - Create(width, height, depth); -} - wxBitmap::wxBitmap(const wxString &filename, wxBitmapType type) { LoadFile(filename, type); @@ -856,6 +836,7 @@ void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep) } } +#ifdef wxHAS_RAW_BITMAP void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) { void* bits = NULL; @@ -876,6 +857,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data)) { } +#endif // wxHAS_RAW_BITMAP bool wxBitmap::HasAlpha() const {