The Lesser wxMask Refactoring: merged wxMGL and wxDFB version, added wxMaskBase which could/should be used by other ports later

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41495 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-09-28 23:02:39 +00:00
parent 4353a8df6e
commit 87f83ac867
12 changed files with 338 additions and 332 deletions

View File

@ -1662,6 +1662,12 @@ COND_PLATFORM_WIN32_1_BASE_PLATFORM_HDR = \
@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 \
@ -1680,12 +1686,7 @@ COND_TOOLKIT_DFB_LOWLEVEL_HDR = \
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 \
@ -1757,6 +1758,7 @@ COND_TOOLKIT_MGL_LOWLEVEL_HDR = \
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 \
@ -2684,6 +2686,7 @@ COND_USE_GUI_1_WXUNIV_1_GUI_CORE_HEADERS = \
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 \
@ -3576,6 +3579,12 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS = \
@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 \
@ -3593,12 +3602,7 @@ COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS = \
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 \
@ -3685,6 +3689,7 @@ COND_TOOLKIT_MGL___LOWLEVEL_SRC_OBJECTS = \
monodll_caret.o \
monodll_colour.o \
monodll_icon.o \
monodll_mask.o \
monodll_imaglist.o \
monodll_timer.o \
monodll_app.o \
@ -4396,6 +4401,12 @@ COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS = \
@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 \
@ -4413,12 +4424,7 @@ COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_1 = \
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 \
@ -4505,6 +4511,7 @@ COND_TOOLKIT_MGL___LOWLEVEL_SRC_OBJECTS_1 = \
monodll_caret.o \
monodll_colour.o \
monodll_icon.o \
monodll_mask.o \
monodll_imaglist.o \
monodll_timer.o \
monodll_app.o \
@ -5293,6 +5300,12 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_1 = \
@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 \
@ -5310,12 +5323,7 @@ COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_2 = \
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 \
@ -5403,6 +5411,7 @@ COND_TOOLKIT_MGL___LOWLEVEL_SRC_OBJECTS_2 = \
monolib_caret.o \
monolib_colour.o \
monolib_icon.o \
monolib_mask.o \
monolib_imaglist.o \
monolib_timer.o \
monolib_app.o \
@ -6114,6 +6123,12 @@ COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS_1 = \
@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 \
@ -6131,12 +6146,7 @@ COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_3 = \
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 \
@ -6224,6 +6234,7 @@ COND_TOOLKIT_MGL___LOWLEVEL_SRC_OBJECTS_3 = \
monolib_caret.o \
monolib_colour.o \
monolib_icon.o \
monolib_mask.o \
monolib_imaglist.o \
monolib_timer.o \
monolib_app.o \
@ -7228,6 +7239,12 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_2 = \
@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 \
@ -7245,12 +7262,7 @@ COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_4 = \
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 \
@ -7338,6 +7350,7 @@ COND_TOOLKIT_MGL___LOWLEVEL_SRC_OBJECTS_4 = \
coredll_caret.o \
coredll_colour.o \
coredll_icon.o \
coredll_mask.o \
coredll_imaglist.o \
coredll_timer.o \
coredll_app.o \
@ -8049,6 +8062,12 @@ COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS_2 = \
@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 \
@ -8066,12 +8085,7 @@ COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_5 = \
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 \
@ -8159,6 +8173,7 @@ COND_TOOLKIT_MGL___LOWLEVEL_SRC_OBJECTS_5 = \
coredll_caret.o \
coredll_colour.o \
coredll_icon.o \
coredll_mask.o \
coredll_imaglist.o \
coredll_timer.o \
coredll_app.o \
@ -8639,6 +8654,12 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_3 = \
@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 \
@ -8656,12 +8677,7 @@ COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_6 = \
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 \
@ -8749,6 +8765,7 @@ COND_TOOLKIT_MGL___LOWLEVEL_SRC_OBJECTS_6 = \
corelib_caret.o \
corelib_colour.o \
corelib_icon.o \
corelib_mask.o \
corelib_imaglist.o \
corelib_timer.o \
corelib_app.o \
@ -9460,6 +9477,12 @@ COND_PLATFORM_MACOSX_1___MAC_OSX_SRC_OBJECTS_3 = \
@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 \
@ -9477,12 +9500,7 @@ COND_TOOLKIT_DFB___LOWLEVEL_SRC_OBJECTS_7 = \
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 \
@ -9570,6 +9588,7 @@ COND_TOOLKIT_MGL___LOWLEVEL_SRC_OBJECTS_7 = \
corelib_caret.o \
corelib_colour.o \
corelib_icon.o \
corelib_mask.o \
corelib_imaglist.o \
corelib_timer.o \
corelib_app.o \
@ -14063,6 +14082,12 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP)
@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
@ -18017,6 +18042,12 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP)
@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
@ -22349,6 +22380,12 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP)
@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
@ -25232,6 +25269,12 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP)
@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

View File

@ -1721,6 +1721,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
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
@ -1750,6 +1751,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
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
@ -1782,6 +1784,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
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
@ -1808,6 +1811,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
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

View File

@ -24,10 +24,41 @@
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__) || \
@ -156,6 +187,15 @@ public:
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;
@ -188,4 +228,15 @@ protected:
#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_

View File

@ -15,38 +15,6 @@
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
//-----------------------------------------------------------------------------

54
include/wx/generic/mask.h Normal file
View File

@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////
// 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_

View File

@ -9,52 +9,16 @@
#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
//-----------------------------------------------------------------------------
@ -111,6 +75,8 @@ public:
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;

View File

@ -125,3 +125,38 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule)
#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);
}

View File

@ -33,22 +33,6 @@
// 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)
{
@ -71,97 +55,6 @@ 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
//-----------------------------------------------------------------------------

76
src/generic/mask.cpp Normal file
View File

@ -0,0 +1,76 @@
///////////////////////////////////////////////////////////////////////////////
// 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

View File

@ -50,103 +50,6 @@ static pixel_format_t gs_pixel_format_32 =
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
//-----------------------------------------------------------------------------
@ -456,7 +359,7 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect& rect) const
if ( GetMask() )
{
wxBitmap submask = GetMask()->GetBitmap()->GetSubBitmap(rect);
wxBitmap submask = GetMask()->GetBitmap().GetSubBitmap(rect);
ret.SetMask(new wxMask(submask));
}
@ -630,6 +533,19 @@ bitmap_t *wxBitmap::GetMGLbitmap_t() const
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));
}
//-----------------------------------------------------------------------------

View File

@ -50,7 +50,7 @@ void wxBitmapToPixPattern(const wxBitmap& bitmap,
if ( mask && bitmap.GetMask() )
{
mem.SelectObject(*bitmap.GetMask()->GetBitmap());
mem.SelectObject(bitmap.GetMask()->GetBitmap());
dc = mem.GetMGLDC();
wxCurrentDCSwitcher curDC(dc);
dc->beginPixel();

View File

@ -1547,7 +1547,7 @@ void wxDC::DoDrawSubBitmap(const wxBitmap &bmp,
// 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;
@ -1572,10 +1572,10 @@ void wxDC::DoDrawSubBitmap(const wxBitmap &bmp,
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);