@COND_PLATFORM_WIN32_1@ wx/msw/gsockmsw.h $(NET_WINCE_HDR)
@COND_TOOLKIT_COCOA@LOWLEVEL_HDR =
COND_TOOLKIT_DFB_LOWLEVEL_HDR = \
+ wx/generic/caret.h \
+ wx/generic/colour.h \
+ wx/generic/icon.h \
+ wx/generic/mask.h \
+ wx/generic/imaglist.h \
+ wx/generic/timer.h \
wx/dfb/app.h \
wx/dfb/bitmap.h \
wx/dfb/brush.h \
wx/dfb/region.h \
wx/dfb/toplevel.h \
wx/dfb/window.h \
- wx/dfb/wrapdfb.h \
- wx/generic/caret.h \
- wx/generic/colour.h \
- wx/generic/icon.h \
- wx/generic/imaglist.h \
- wx/generic/timer.h
+ wx/dfb/wrapdfb.h
@COND_TOOLKIT_DFB@LOWLEVEL_HDR = $(COND_TOOLKIT_DFB_LOWLEVEL_HDR)
COND_TOOLKIT_GTK_TOOLKIT_VERSION__LOWLEVEL_HDR = \
wx/generic/caret.h \
wx/generic/colour.h \
wx/generic/icon.h \
wx/generic/imaglist.h \
+ wx/generic/mask.h \
wx/generic/timer.h \
wx/mgl/app.h \
wx/mgl/bitmap.h \
wx/univ/button.h \
wx/univ/checkbox.h \
wx/univ/checklst.h \
+ wx/univ/chkconf.h \
wx/univ/choice.h \
wx/univ/colschem.h \
wx/univ/combobox.h \
@COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS = \
@COND_TOOLKIT_COCOA@ monodll_gsockosx.o monodll_hid.o monodll_utilsexc_cf.o
COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS = \
+ monodll_caret.o \
+ monodll_colour.o \
+ monodll_icon.o \
+ monodll_imaglist.o \
+ monodll_mask.o \
+ monodll_timer.o \
monodll_app.o \
monodll_bitmap.o \
monodll_brush.o \
monodll_toplevel.o \
monodll_utils.o \
monodll_window.o \
- monodll_wrapdfb.o \
- monodll_caret.o \
- monodll_colour.o \
- monodll_icon.o \
- monodll_imaglist.o \
- monodll_timer.o
+ monodll_wrapdfb.o
@COND_TOOLKIT_DFB@__LOWLEVEL_SRC_OBJECTS = $(COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS)
COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS = \
monodll_caret.o \
monodll_caret.o \
monodll_colour.o \
monodll_icon.o \
+ monodll_mask.o \
monodll_imaglist.o \
monodll_timer.o \
monodll_app.o \
@COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_1 = \
@COND_TOOLKIT_COCOA@ monodll_gsockosx.o monodll_hid.o monodll_utilsexc_cf.o
COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_1 = \
+ monodll_caret.o \
+ monodll_colour.o \
+ monodll_icon.o \
+ monodll_imaglist.o \
+ monodll_mask.o \
+ monodll_timer.o \
monodll_app.o \
monodll_bitmap.o \
monodll_brush.o \
monodll_toplevel.o \
monodll_utils.o \
monodll_window.o \
- monodll_wrapdfb.o \
- monodll_caret.o \
- monodll_colour.o \
- monodll_icon.o \
- monodll_imaglist.o \
- monodll_timer.o
+ monodll_wrapdfb.o
@COND_TOOLKIT_DFB@__LOWLEVEL_SRC_OBJECTS_1 = $(COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_1)
COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_1 = \
monodll_caret.o \
monodll_caret.o \
monodll_colour.o \
monodll_icon.o \
+ monodll_mask.o \
monodll_imaglist.o \
monodll_timer.o \
monodll_app.o \
@COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_2 = \
@COND_TOOLKIT_COCOA@ monolib_gsockosx.o monolib_hid.o monolib_utilsexc_cf.o
COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_2 = \
+ monolib_caret.o \
+ monolib_colour.o \
+ monolib_icon.o \
+ monolib_imaglist.o \
+ monolib_mask.o \
+ monolib_timer.o \
monolib_app.o \
monolib_bitmap.o \
monolib_brush.o \
monolib_toplevel.o \
monolib_utils.o \
monolib_window.o \
- monolib_wrapdfb.o \
- monolib_caret.o \
- monolib_colour.o \
- monolib_icon.o \
- monolib_imaglist.o \
- monolib_timer.o
+ monolib_wrapdfb.o
@COND_TOOLKIT_DFB@__LOWLEVEL_SRC_OBJECTS_2 = $(COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_2)
COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_2 = \
monolib_caret.o \
monolib_caret.o \
monolib_colour.o \
monolib_icon.o \
+ monolib_mask.o \
monolib_imaglist.o \
monolib_timer.o \
monolib_app.o \
@COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_3 = \
@COND_TOOLKIT_COCOA@ monolib_gsockosx.o monolib_hid.o monolib_utilsexc_cf.o
COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_3 = \
+ monolib_caret.o \
+ monolib_colour.o \
+ monolib_icon.o \
+ monolib_imaglist.o \
+ monolib_mask.o \
+ monolib_timer.o \
monolib_app.o \
monolib_bitmap.o \
monolib_brush.o \
monolib_toplevel.o \
monolib_utils.o \
monolib_window.o \
- monolib_wrapdfb.o \
- monolib_caret.o \
- monolib_colour.o \
- monolib_icon.o \
- monolib_imaglist.o \
- monolib_timer.o
+ monolib_wrapdfb.o
@COND_TOOLKIT_DFB@__LOWLEVEL_SRC_OBJECTS_3 = $(COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_3)
COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_3 = \
monolib_caret.o \
monolib_caret.o \
monolib_colour.o \
monolib_icon.o \
+ monolib_mask.o \
monolib_imaglist.o \
monolib_timer.o \
monolib_app.o \
@COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_4 = \
@COND_TOOLKIT_COCOA@ coredll_gsockosx.o coredll_hid.o coredll_utilsexc_cf.o
COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_4 = \
+ coredll_caret.o \
+ coredll_colour.o \
+ coredll_icon.o \
+ coredll_imaglist.o \
+ coredll_mask.o \
+ coredll_timer.o \
coredll_app.o \
coredll_bitmap.o \
coredll_brush.o \
coredll_toplevel.o \
coredll_utils.o \
coredll_window.o \
- coredll_wrapdfb.o \
- coredll_caret.o \
- coredll_colour.o \
- coredll_icon.o \
- coredll_imaglist.o \
- coredll_timer.o
+ coredll_wrapdfb.o
@COND_TOOLKIT_DFB@__LOWLEVEL_SRC_OBJECTS_4 = $(COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_4)
COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_4 = \
coredll_caret.o \
coredll_caret.o \
coredll_colour.o \
coredll_icon.o \
+ coredll_mask.o \
coredll_imaglist.o \
coredll_timer.o \
coredll_app.o \
@COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_5 = \
@COND_TOOLKIT_COCOA@ coredll_gsockosx.o coredll_hid.o coredll_utilsexc_cf.o
COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_5 = \
+ coredll_caret.o \
+ coredll_colour.o \
+ coredll_icon.o \
+ coredll_imaglist.o \
+ coredll_mask.o \
+ coredll_timer.o \
coredll_app.o \
coredll_bitmap.o \
coredll_brush.o \
coredll_toplevel.o \
coredll_utils.o \
coredll_window.o \
- coredll_wrapdfb.o \
- coredll_caret.o \
- coredll_colour.o \
- coredll_icon.o \
- coredll_imaglist.o \
- coredll_timer.o
+ coredll_wrapdfb.o
@COND_TOOLKIT_DFB@__LOWLEVEL_SRC_OBJECTS_5 = $(COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_5)
COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_5 = \
coredll_caret.o \
coredll_caret.o \
coredll_colour.o \
coredll_icon.o \
+ coredll_mask.o \
coredll_imaglist.o \
coredll_timer.o \
coredll_app.o \
@COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_6 = \
@COND_TOOLKIT_COCOA@ corelib_gsockosx.o corelib_hid.o corelib_utilsexc_cf.o
COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_6 = \
+ corelib_caret.o \
+ corelib_colour.o \
+ corelib_icon.o \
+ corelib_imaglist.o \
+ corelib_mask.o \
+ corelib_timer.o \
corelib_app.o \
corelib_bitmap.o \
corelib_brush.o \
corelib_toplevel.o \
corelib_utils.o \
corelib_window.o \
- corelib_wrapdfb.o \
- corelib_caret.o \
- corelib_colour.o \
- corelib_icon.o \
- corelib_imaglist.o \
- corelib_timer.o
+ corelib_wrapdfb.o
@COND_TOOLKIT_DFB@__LOWLEVEL_SRC_OBJECTS_6 = $(COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_6)
COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_6 = \
corelib_caret.o \
corelib_caret.o \
corelib_colour.o \
corelib_icon.o \
+ corelib_mask.o \
corelib_imaglist.o \
corelib_timer.o \
corelib_app.o \
@COND_TOOLKIT_COCOA@__LOWLEVEL_SRC_OBJECTS_7 = \
@COND_TOOLKIT_COCOA@ corelib_gsockosx.o corelib_hid.o corelib_utilsexc_cf.o
COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_7 = \
+ corelib_caret.o \
+ corelib_colour.o \
+ corelib_icon.o \
+ corelib_imaglist.o \
+ corelib_mask.o \
+ corelib_timer.o \
corelib_app.o \
corelib_bitmap.o \
corelib_brush.o \
corelib_toplevel.o \
corelib_utils.o \
corelib_window.o \
- corelib_wrapdfb.o \
- corelib_caret.o \
- corelib_colour.o \
- corelib_icon.o \
- corelib_imaglist.o \
- corelib_timer.o
+ corelib_wrapdfb.o
@COND_TOOLKIT_DFB@__LOWLEVEL_SRC_OBJECTS_7 = $(COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_7)
COND_TOOLKIT_GTK_TOOLKIT_VERSION____LOWLEVEL_SRC_OBJECTS_7 = \
corelib_caret.o \
corelib_caret.o \
corelib_colour.o \
corelib_icon.o \
+ corelib_mask.o \
corelib_imaglist.o \
corelib_timer.o \
corelib_app.o \
@COND_TOOLKIT_X11_USE_GUI_1@monodll_reparent.o: $(srcdir)/src/x11/reparent.cpp $(MONODLL_ODEP)
@COND_TOOLKIT_X11_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/x11/reparent.cpp
+@COND_TOOLKIT_MGL_USE_GUI_1@monodll_mask.o: $(srcdir)/src/generic/mask.cpp $(MONODLL_ODEP)
+@COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/mask.cpp
+
+@COND_TOOLKIT_DFB_USE_GUI_1@monodll_mask.o: $(srcdir)/src/generic/mask.cpp $(MONODLL_ODEP)
+@COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/mask.cpp
+
@COND_TOOLKIT_MGL_USE_GUI_1@monodll_dirmgl.o: $(srcdir)/src/mgl/dirmgl.cpp $(MONODLL_ODEP)
@COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mgl/dirmgl.cpp
@COND_TOOLKIT_X11_USE_GUI_1@monolib_reparent.o: $(srcdir)/src/x11/reparent.cpp $(MONOLIB_ODEP)
@COND_TOOLKIT_X11_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/x11/reparent.cpp
+@COND_TOOLKIT_MGL_USE_GUI_1@monolib_mask.o: $(srcdir)/src/generic/mask.cpp $(MONOLIB_ODEP)
+@COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/mask.cpp
+
+@COND_TOOLKIT_DFB_USE_GUI_1@monolib_mask.o: $(srcdir)/src/generic/mask.cpp $(MONOLIB_ODEP)
+@COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/mask.cpp
+
@COND_TOOLKIT_MGL_USE_GUI_1@monolib_dirmgl.o: $(srcdir)/src/mgl/dirmgl.cpp $(MONOLIB_ODEP)
@COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mgl/dirmgl.cpp
@COND_TOOLKIT_X11_USE_GUI_1@coredll_reparent.o: $(srcdir)/src/x11/reparent.cpp $(COREDLL_ODEP)
@COND_TOOLKIT_X11_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/x11/reparent.cpp
+@COND_TOOLKIT_MGL_USE_GUI_1@coredll_mask.o: $(srcdir)/src/generic/mask.cpp $(COREDLL_ODEP)
+@COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/generic/mask.cpp
+
+@COND_TOOLKIT_DFB_USE_GUI_1@coredll_mask.o: $(srcdir)/src/generic/mask.cpp $(COREDLL_ODEP)
+@COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/generic/mask.cpp
+
@COND_TOOLKIT_MGL_USE_GUI_1@coredll_dirmgl.o: $(srcdir)/src/mgl/dirmgl.cpp $(COREDLL_ODEP)
@COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mgl/dirmgl.cpp
@COND_TOOLKIT_X11_USE_GUI_1@corelib_reparent.o: $(srcdir)/src/x11/reparent.cpp $(CORELIB_ODEP)
@COND_TOOLKIT_X11_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/x11/reparent.cpp
+@COND_TOOLKIT_MGL_USE_GUI_1@corelib_mask.o: $(srcdir)/src/generic/mask.cpp $(CORELIB_ODEP)
+@COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/generic/mask.cpp
+
+@COND_TOOLKIT_DFB_USE_GUI_1@corelib_mask.o: $(srcdir)/src/generic/mask.cpp $(CORELIB_ODEP)
+@COND_TOOLKIT_DFB_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/generic/mask.cpp
+
@COND_TOOLKIT_MGL_USE_GUI_1@corelib_dirmgl.o: $(srcdir)/src/mgl/dirmgl.cpp $(CORELIB_ODEP)
@COND_TOOLKIT_MGL_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mgl/dirmgl.cpp
src/generic/colour.cpp
src/generic/icon.cpp
src/generic/imaglist.cpp
+ src/generic/mask.cpp
src/generic/timer.cpp
src/mgl/app.cpp
src/mgl/bitmap.cpp
wx/generic/colour.h
wx/generic/icon.h
wx/generic/imaglist.h
+ wx/generic/mask.h
wx/generic/timer.h
wx/mgl/app.h
wx/mgl/bitmap.h
src/generic/colour.cpp
src/generic/icon.cpp
src/generic/imaglist.cpp
+ src/generic/mask.cpp
src/generic/timer.cpp
src/dfb/app.cpp
src/dfb/bitmap.cpp
wx/generic/colour.h
wx/generic/icon.h
wx/generic/imaglist.h
+ wx/generic/mask.h
wx/generic/timer.h
wx/dfb/app.h
wx/dfb/bitmap.h
class WXDLLEXPORT wxBitmap;
class WXDLLEXPORT wxBitmapHandler;
+class WXDLLEXPORT wxIcon;
class WXDLLEXPORT wxImage;
class WXDLLEXPORT wxMask;
class WXDLLEXPORT wxPalette;
+// ----------------------------------------------------------------------------
+// wxMask represents the transparent area of the bitmap
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxMaskBase : public wxObject
+{
+public:
+ // create the mask from bitmap pixels of the given colour
+ bool Create(const wxBitmap& bitmap, const wxColour& colour);
+
+#if wxUSE_PALETTE
+ // create the mask from bitmap pixels with the given palette index
+ bool Create(const wxBitmap& bitmap, int paletteIndex);
+#endif // wxUSE_PALETTE
+
+ // create the mask from the given mono bitmap
+ bool Create(const wxBitmap& bitmap);
+
+protected:
+ // this function is called from Create() to free the existing mask data
+ virtual void FreeData() = 0;
+
+ // these functions must be overridden to implement the corresponding public
+ // Create() methods, they shouldn't call FreeData() as it's already called
+ // by the public wrappers
+ virtual bool InitFromColour(const wxBitmap& bitmap,
+ const wxColour& colour) = 0;
+ virtual bool InitFromMonoBitmap(const wxBitmap& bitmap) = 0;
+};
+
#if defined(__WXMGL__) || \
defined(__WXDFB__) || \
defined(__WXMAC__) || \
static void CleanUpHandlers();
+ // this method is only used by the generic implementation of wxMask
+ // currently but could be useful elsewhere in the future: it can be
+ // overridden to quantize the colour to correspond to bitmap colour depth
+ // if necessary; default implementation simply returns the colour as is
+ virtual wxColour QuantizeColour(const wxColour& colour) const
+ {
+ return colour;
+ }
+
protected:
static wxList sm_handlers;
#include "wx/os2/bitmap.h"
#endif
+// we must include generic mask.h after wxBitmap definition
+#if defined(__WXMGL__) || defined(__WXDFB__)
+ #define wxUSE_GENERIC_MASK 1
+#else
+ #define wxUSE_GENERIC_MASK 0
+#endif
+
+#if wxUSE_GENERIC_MASK
+ #include "wx/generic/mask.h"
+#endif
+
#endif // _WX_BITMAP_H_BASE_
wxDFB_DECLARE_INTERFACE(IDirectFBSurface);
-//-----------------------------------------------------------------------------
-// wxMask
-//-----------------------------------------------------------------------------
-
-#warning "FIXME: move wxMask to common code"
-class WXDLLIMPEXP_CORE wxMask: public wxObject
-{
-public:
- wxMask();
- wxMask(const wxBitmap& bitmap);
- wxMask(const wxBitmap& bitmap, const wxColour& colour);
-#if wxUSE_PALETTE
- wxMask(const wxBitmap& bitmap, int paletteIndex);
-#endif
- wxMask(const wxMask& mask);
- ~wxMask();
-
- bool Create(const wxBitmap& bitmap);
- bool Create(const wxBitmap& bitmap, const wxColour& colour);
-#if wxUSE_PALETTE
- bool Create(const wxBitmap& bitmap, int paletteIndex);
-#endif
-
- // implementation
- const wxBitmap& GetBitmap() const;
-
-private:
- wxBitmap *m_bitmap;
-
- DECLARE_DYNAMIC_CLASS(wxMask)
-};
-
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/generic/mask.h
+// Purpose: generic implementation of wxMask
+// Author: Vadim Zeitlin
+// Created: 2006-09-28
+// RCS-ID: $Id$
+// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_GENERIC_MASKG_H_
+#define _WX_GENERIC_MASKG_H_
+
+// ----------------------------------------------------------------------------
+// generic wxMask implementation
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxMask : public wxMaskBase
+{
+public:
+ wxMask() { }
+ wxMask(const wxBitmap& bitmap, const wxColour& colour)
+ {
+ InitFromColour(bitmap, colour);
+ }
+
+#if wxUSE_PALETTE
+ wxMask(const wxBitmap& bitmap, int paletteIndex)
+ {
+ Create(bitmap, paletteIndex);
+ }
+#endif // wxUSE_PALETTE
+
+ wxMask(const wxBitmap& bitmap)
+ {
+ InitFromMonoBitmap(bitmap);
+ }
+
+ // implementation-only from now on
+ wxBitmap GetBitmap() const { return m_bitmap; }
+
+private:
+ // implement wxMaskBase pure virtuals
+ virtual void FreeData();
+ virtual bool InitFromColour(const wxBitmap& bitmap, const wxColour& colour);
+ virtual bool InitFromMonoBitmap(const wxBitmap& bitmap);
+
+ wxBitmap m_bitmap;
+
+ DECLARE_DYNAMIC_CLASS(wxMask)
+};
+
+#endif // _WX_GENERIC_MASKG_H_
+
#ifndef __WX_BITMAP_H__
#define __WX_BITMAP_H__
-#include "wx/defs.h"
-#include "wx/object.h"
-#include "wx/string.h"
-#include "wx/palette.h"
-#include "wx/gdiobj.h"
-
-
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
-class WXDLLEXPORT wxMask;
-class WXDLLEXPORT wxBitmap;
-class WXDLLEXPORT wxImage;
class WXDLLEXPORT wxDC;
class WXDLLEXPORT wxMemoryDC;
class MGLDevCtx;
struct bitmap_t;
-//-----------------------------------------------------------------------------
-// wxMask
-//-----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxMask: public wxObject
-{
-public:
- wxMask();
- wxMask(const wxBitmap& bitmap, const wxColour& colour);
- wxMask(const wxBitmap& bitmap, int paletteIndex);
- wxMask(const wxBitmap& bitmap);
- virtual ~wxMask();
-
- bool Create(const wxBitmap& bitmap, const wxColour& colour);
- bool Create(const wxBitmap& bitmap, int paletteIndex);
- bool Create(const wxBitmap& bitmap);
-
- // implementation
- wxBitmap *m_bitmap;
-
- wxBitmap *GetBitmap() const { return m_bitmap; }
-
-private:
- DECLARE_DYNAMIC_CLASS(wxMask)
-};
-
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
virtual void SetWidth(int width);
virtual void SetDepth(int depth);
+ virtual wxColour QuantizeColour(const wxColour& colour) const;
+
// get underlying native representation:
bitmap_t *GetMGLbitmap_t() const;
#endif // wxUSE_BITMAP_BASE
+// ----------------------------------------------------------------------------
+// wxMaskBase
+// ----------------------------------------------------------------------------
+
+bool wxMaskBase::Create(const wxBitmap& bitmap, const wxColour& colour)
+{
+ FreeData();
+
+ return InitFromColour(bitmap, colour);
+}
+
+#if wxUSE_PALETTE
+
+bool wxMaskBase::Create(const wxBitmap& bitmap, int paletteIndex)
+{
+ wxPalette *pal = bitmap.GetPalette();
+
+ wxCHECK_MSG( pal, false,
+ wxT("Cannot create mask from palette index of a bitmap without palette") );
+
+ unsigned char r,g,b;
+ pal->GetRGB(paletteIndex, &r, &g, &b);
+
+ return Create(bitmap, wxColour(r, g, b));
+}
+
+#endif // wxUSE_PALETTE
+
+bool wxMaskBase::Create(const wxBitmap& bitmap)
+{
+ FreeData();
+
+ return InitFromMonoBitmap(bitmap);
+}
+
// helpers
//-----------------------------------------------------------------------------
-// Convert wxColour into it's quantized value in lower-precision
-// pixel format (needed for masking by colour).
-static wxColour wxQuantizeColour(const wxColour& clr, const wxBitmap& bmp)
-{
-#if 0
- pixel_format_t *pf = bmp.GetMGLbitmap_t()->pf;
-
- if ( pf->redAdjust == 0 && pf->greenAdjust == 0 && pf->blueAdjust == 0 )
- return clr;
- else
- return wxColour((unsigned char)((clr.Red() >> pf->redAdjust) << pf->redAdjust),
- (unsigned char)((clr.Green() >> pf->greenAdjust) << pf->greenAdjust),
- (unsigned char)((clr.Blue() >> pf->blueAdjust) << pf->blueAdjust));
-#endif
-}
-
// Creates a surface that will use wxImage's pixel data (RGB only)
static wxIDirectFBSurfacePtr CreateSurfaceForImage(const wxImage& image)
{
return wxIDirectFB::Get()->CreateSurface(&desc);
}
-//-----------------------------------------------------------------------------
-// wxMask
-//-----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
-
-wxMask::wxMask() : m_bitmap(NULL)
-{
-}
-
-wxMask::wxMask(const wxBitmap& bitmap)
- : m_bitmap(NULL)
-{
- Create(bitmap);
-}
-
-wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
- : m_bitmap(NULL)
-{
- Create(bitmap, colour);
-}
-
-#if wxUSE_PALETTE
-wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
- : m_bitmap(NULL)
-{
- Create(bitmap, paletteIndex);
-}
-#endif // wxUSE_PALETTE
-
-wxMask::wxMask(const wxMask& mask)
-{
- m_bitmap = mask.m_bitmap ? new wxBitmap(*mask.m_bitmap) : NULL;
-}
-
-wxMask::~wxMask()
-{
- delete m_bitmap;
-}
-
-#warning "move this to common code"
-bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
-{
- delete m_bitmap;
- m_bitmap = NULL;
-
- wxColour clr(wxQuantizeColour(colour, bitmap));
-
- wxImage imgSrc(bitmap.ConvertToImage());
- imgSrc.SetMask(false);
- wxImage image(imgSrc.ConvertToMono(clr.Red(), clr.Green(), clr.Blue()));
- if ( !image.Ok() )
- return false;
-
- m_bitmap = new wxBitmap(image, 1);
-
- return m_bitmap->Ok();
-}
-
-#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)
-{
- delete m_bitmap;
- m_bitmap = NULL;
-
- wxCHECK_MSG( bitmap.Ok(), false, wxT("Invalid bitmap") );
- wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") );
-
- m_bitmap = new wxBitmap(bitmap);
- return true;
-}
-
-const wxBitmap& wxMask::GetBitmap() const
-{
- return m_bitmap ? *m_bitmap : wxNullBitmap;
-}
-
-
//-----------------------------------------------------------------------------
// wxBitmapRefData
//-----------------------------------------------------------------------------
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: src/generic/mask.cpp
+// Purpose: generic wxMask implementation
+// Author: Vadim Zeitlin
+// Created: 2006-09-28
+// RCS-ID: $Id$
+// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/bitmap.h"
+ #include "wx/image.h"
+#endif // WX_PRECOMP
+
+#if wxUSE_GENERIC_MASK
+
+// ============================================================================
+// wxMask implementation
+// ============================================================================
+
+IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
+
+void wxMask::FreeData()
+{
+ m_bitmap = wxNullBitmap;
+}
+
+bool wxMask::InitFromColour(const wxBitmap& bitmap, const wxColour& colour)
+{
+#if wxUSE_IMAGE
+ const wxColour clr(bitmap.QuantizeColour(colour));
+
+ wxImage imgSrc(bitmap.ConvertToImage());
+ imgSrc.SetMask(false);
+ wxImage image(imgSrc.ConvertToMono(clr.Red(), clr.Green(), clr.Blue()));
+ if ( !image.Ok() )
+ return false;
+
+ m_bitmap = wxBitmap(image, 1);
+
+ return m_bitmap.Ok();
+#else // !wxUSE_IMAGE
+ wxUnusedVar(bitmap);
+ wxUnusedVar(colour);
+
+ return false;
+#endif // wxUSE_IMAGE/!wxUSE_IMAGE
+}
+
+bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap)
+{
+ wxCHECK_MSG( bitmap.Ok(), false, wxT("Invalid bitmap") );
+ wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") );
+
+ m_bitmap = bitmap;
+
+ return true;
+}
+
+#endif // wxUSE_GENERIC_MASK
static pixel_format_t gs_pixel_format_wxImage =
{0xFF,0x00,0, 0xFF,0x08,0, 0xFF,0x10,0, 0x00,0x00,0}; // RGB 24bpp for wxImage
-//-----------------------------------------------------------------------------
-// helpers
-//-----------------------------------------------------------------------------
-
-// Convert wxColour into it's quantized value in lower-precision
-// pixel format (needed for masking by colour).
-static wxColour wxQuantizeColour(const wxColour& clr, const wxBitmap& bmp)
-{
- pixel_format_t *pf = bmp.GetMGLbitmap_t()->pf;
-
- if ( pf->redAdjust == 0 && pf->greenAdjust == 0 && pf->blueAdjust == 0 )
- return clr;
- else
- return wxColour((unsigned char)((clr.Red() >> pf->redAdjust) << pf->redAdjust),
- (unsigned char)((clr.Green() >> pf->greenAdjust) << pf->greenAdjust),
- (unsigned char)((clr.Blue() >> pf->blueAdjust) << pf->blueAdjust));
-}
-
-
-
-//-----------------------------------------------------------------------------
-// wxMask
-//-----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject)
-
-wxMask::wxMask()
-{
- m_bitmap = NULL;
-}
-
-wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
-{
- m_bitmap = NULL;
- Create(bitmap, colour);
-}
-
-wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
-{
- m_bitmap = NULL;
- Create(bitmap, paletteIndex);
-}
-
-wxMask::wxMask(const wxBitmap& bitmap)
-{
- m_bitmap = NULL;
- Create(bitmap);
-}
-
-wxMask::~wxMask()
-{
- delete m_bitmap;
-}
-
-bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
-{
- delete m_bitmap;
- m_bitmap = NULL;
-
- wxColour clr(wxQuantizeColour(colour, bitmap));
-
- wxImage imgSrc(bitmap.ConvertToImage());
- imgSrc.SetMask(false);
- wxImage image(imgSrc.ConvertToMono(clr.Red(), clr.Green(), clr.Blue()));
- if ( !image.Ok() )
- return false;
-
- m_bitmap = new wxBitmap(image, 1);
-
- return m_bitmap->Ok();
-}
-
-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));
-}
-
-bool wxMask::Create(const wxBitmap& bitmap)
-{
- delete m_bitmap;
- m_bitmap = NULL;
-
- wxCHECK_MSG( bitmap.Ok(), false, wxT("Invalid bitmap") );
- wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") );
-
- m_bitmap = new wxBitmap(bitmap);
- return true;
-}
-
-
//-----------------------------------------------------------------------------
// wxBitmap
//-----------------------------------------------------------------------------
if ( GetMask() )
{
- wxBitmap submask = GetMask()->GetBitmap()->GetSubBitmap(rect);
+ wxBitmap submask = GetMask()->GetBitmap().GetSubBitmap(rect);
ret.SetMask(new wxMask(submask));
}
return M_BMPDATA->m_bitmap;
}
+// Convert wxColour into it's quantized value in lower-precision
+// pixel format (needed for masking by colour).
+wxColour wxBitmap::QuantizeColour(const wxColour& clr)
+{
+ pixel_format_t *pf = GetMGLbitmap_t()->pf;
+
+ if ( pf->redAdjust == 0 && pf->greenAdjust == 0 && pf->blueAdjust == 0 )
+ return clr;
+ else
+ return wxColour((unsigned char)((clr.Red() >> pf->redAdjust) << pf->redAdjust),
+ (unsigned char)((clr.Green() >> pf->greenAdjust) << pf->greenAdjust),
+ (unsigned char)((clr.Blue() >> pf->blueAdjust) << pf->blueAdjust));
+}
//-----------------------------------------------------------------------------
if ( mask && bitmap.GetMask() )
{
- mem.SelectObject(*bitmap.GetMask()->GetBitmap());
+ mem.SelectObject(bitmap.GetMask()->GetBitmap());
dc = mem.GetMGLDC();
wxCurrentDCSwitcher curDC(dc);
dc->beginPixel();
// This sequence of operations ensures that the source's transparent
// area need not be black, and logical functions are supported.
- wxBitmap *mask = bmp.GetMask()->GetBitmap();
+ wxBitmap mask = bmp.GetMask()->GetBitmap();
MGLMemoryDC *temp;
DoBitBlt(bmp, temp, x, y, w, h, 0, 0, dw, dh, mglRop,
useStretching, putSection);
- mask->SetMonoPalette(wxColour(0,0,0), wxColour(255,255,255));
- DoBitBlt(*mask, temp, x, y, w, h, 0, 0, dw, dh, MGL_R2_MASKSRC,
+ mask.SetMonoPalette(wxColour(0,0,0), wxColour(255,255,255));
+ DoBitBlt(mask, temp, x, y, w, h, 0, 0, dw, dh, MGL_R2_MASKSRC,
useStretching, putSection);
- DoBitBlt(*mask, m_MGLDC, x, y, w, h, dx, dy, dw, dh, MGL_R2_MASKNOTSRC,
+ DoBitBlt(mask, m_MGLDC, x, y, w, h, dx, dy, dw, dh, MGL_R2_MASKNOTSRC,
useStretching, putSection);
m_MGLDC->bitBlt(*temp, 0, 0, dw, dh, dx, dy, MGL_OR_MODE);