// wxMask
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxMask: public wxObject
+class WXDLLIMPEXP_CORE wxMask: public wxMaskBase
{
public:
wxMask();
wxMask( const wxBitmap& bitmap );
virtual ~wxMask();
- bool Create( const wxBitmap& bitmap, const wxColour& colour );
-#if wxUSE_PALETTE
- bool Create( const wxBitmap& bitmap, int paletteIndex );
-#endif // wxUSE_PALETTE
- bool Create( const wxBitmap& bitmap );
-
// implementation
GdkBitmap *m_bitmap;
-
GdkBitmap *GetBitmap() const;
-private:
+protected:
+ virtual void FreeData();
+ virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour);
+ virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
+
DECLARE_DYNAMIC_CLASS(wxMask)
};
// wxMask
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxMask, wxMaskBase)
wxMask::wxMask()
{
wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour )
{
m_bitmap = NULL;
- Create( bitmap, colour );
+ InitFromColour(bitmap, colour);
}
#if wxUSE_PALETTE
wxMask::wxMask( const wxBitmap& bitmap )
{
m_bitmap = NULL;
- Create( bitmap );
+ InitFromMonoBitmap(bitmap);
}
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();
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") );