Make all wxMask constructors use the C++ (bitmap, colour) ctor, and
then just default in BLACK to simulate the default (monobitmap) behaviour. It's too tricky to make true monochome bitmaps in a platform independent way from the Python wrappers. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25787 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -40,7 +40,7 @@ class TestMaskWindow(wx.ScrolledWindow):
|
|||||||
self.bmp_withmask = images.getTestStar2Bitmap()
|
self.bmp_withmask = images.getTestStar2Bitmap()
|
||||||
|
|
||||||
# this mask comes from a monochrome bitmap
|
# this mask comes from a monochrome bitmap
|
||||||
self.bmp_themask = wx.BitmapFromImage(images.getTestMaskImage(), 1)
|
self.bmp_themask = images.getTestMaskBitmap()
|
||||||
mask = wx.Mask(self.bmp_themask)
|
mask = wx.Mask(self.bmp_themask)
|
||||||
|
|
||||||
# set the mask on our bitmap
|
# set the mask on our bitmap
|
||||||
|
@@ -201,19 +201,29 @@ DocStr(wxMask,
|
|||||||
|
|
||||||
class wxMask : public wxObject {
|
class wxMask : public wxObject {
|
||||||
public:
|
public:
|
||||||
|
#if 0
|
||||||
DocCtorStr(
|
DocCtorStr(
|
||||||
wxMask(const wxBitmap& bitmap),
|
wxMask(const wxBitmap& bitmap),
|
||||||
"Constructs a mask from a monochrome bitmap.");
|
"Constructs a mask from a monochrome bitmap.");
|
||||||
|
#endif
|
||||||
|
|
||||||
DocCtorStrName(
|
DocStr(wxMask,
|
||||||
wxMask(const wxBitmap& bitmap, const wxColour& colour),
|
"Constructs a mask from a bitmap and a colour in that bitmap that indicates\n"
|
||||||
"Constructs a mask from a bitmap and a colour in that bitmap that indicates the\n"
|
"the transparent portions of the mask, by default BLACK is used.");
|
||||||
"background.",
|
|
||||||
MaskColour);
|
%extend {
|
||||||
|
wxMask(const wxBitmap& bitmap, const wxColour& colour = wxNullColour) {
|
||||||
|
if ( !colour.Ok() )
|
||||||
|
return new wxMask(bitmap, *wxBLACK);
|
||||||
|
else
|
||||||
|
return new wxMask(bitmap, colour);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//~wxMask();
|
//~wxMask();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
%pythoncode { MaskColour = Mask }
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@@ -14,5 +14,7 @@ PostScriptDC_old
|
|||||||
MetaFileDC_old
|
MetaFileDC_old
|
||||||
PrinterDC_old
|
PrinterDC_old
|
||||||
|
|
||||||
|
MaskColour
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -556,9 +556,10 @@ class Mask(core.Object):
|
|||||||
return "<%s.%s; proxy of C++ wxMask instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
|
return "<%s.%s; proxy of C++ wxMask instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
__init__(Bitmap bitmap) -> Mask
|
__init__(Bitmap bitmap, Colour colour=NullColour) -> Mask
|
||||||
|
|
||||||
Constructs a mask from a monochrome bitmap.
|
Constructs a mask from a bitmap and a colour in that bitmap that indicates
|
||||||
|
the transparent portions of the mask, by default BLACK is used.
|
||||||
"""
|
"""
|
||||||
newobj = _gdi.new_Mask(*args, **kwargs)
|
newobj = _gdi.new_Mask(*args, **kwargs)
|
||||||
self.this = newobj.this
|
self.this = newobj.this
|
||||||
@@ -572,17 +573,7 @@ class MaskPtr(Mask):
|
|||||||
self.__class__ = Mask
|
self.__class__ = Mask
|
||||||
_gdi.Mask_swigregister(MaskPtr)
|
_gdi.Mask_swigregister(MaskPtr)
|
||||||
|
|
||||||
def MaskColour(*args, **kwargs):
|
MaskColour = Mask
|
||||||
"""
|
|
||||||
MaskColour(Bitmap bitmap, Colour colour) -> Mask
|
|
||||||
|
|
||||||
Constructs a mask from a bitmap and a colour in that bitmap that indicates the
|
|
||||||
background.
|
|
||||||
"""
|
|
||||||
val = _gdi.new_MaskColour(*args, **kwargs)
|
|
||||||
val.thisown = 1
|
|
||||||
return val
|
|
||||||
|
|
||||||
class Icon(GDIObject):
|
class Icon(GDIObject):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s.%s; proxy of C++ wxIcon instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
|
return "<%s.%s; proxy of C++ wxIcon instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
|
||||||
|
@@ -477,6 +477,12 @@ void wxBitmap_SetMaskColour(wxBitmap *self,wxColour const &colour){
|
|||||||
wxMask *mask = new wxMask(*self, colour);
|
wxMask *mask = new wxMask(*self, colour);
|
||||||
self->SetMask(mask);
|
self->SetMask(mask);
|
||||||
}
|
}
|
||||||
|
wxMask *new_wxMask(wxBitmap const &bitmap,wxColour const &colour){
|
||||||
|
if ( !colour.Ok() )
|
||||||
|
return new wxMask(bitmap, *wxBLACK);
|
||||||
|
else
|
||||||
|
return new wxMask(bitmap, colour);
|
||||||
|
}
|
||||||
|
|
||||||
#include <wx/iconbndl.h>
|
#include <wx/iconbndl.h>
|
||||||
|
|
||||||
@@ -3091,35 +3097,8 @@ static PyObject * Bitmap_swigregister(PyObject *self, PyObject *args) {
|
|||||||
static PyObject *_wrap_new_Mask(PyObject *self, PyObject *args, PyObject *kwargs) {
|
static PyObject *_wrap_new_Mask(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||||
PyObject *resultobj;
|
PyObject *resultobj;
|
||||||
wxBitmap *arg1 = 0 ;
|
wxBitmap *arg1 = 0 ;
|
||||||
wxMask *result;
|
wxColour const &arg2_defvalue = wxNullColour ;
|
||||||
PyObject * obj0 = 0 ;
|
wxColour *arg2 = (wxColour *) &arg2_defvalue ;
|
||||||
char *kwnames[] = {
|
|
||||||
(char *) "bitmap", NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:new_Mask",kwnames,&obj0)) goto fail;
|
|
||||||
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_wxBitmap,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
|
|
||||||
if (arg1 == NULL) {
|
|
||||||
PyErr_SetString(PyExc_TypeError,"null reference"); SWIG_fail;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
PyThreadState* __tstate = wxPyBeginAllowThreads();
|
|
||||||
result = (wxMask *)new wxMask((wxBitmap const &)*arg1);
|
|
||||||
|
|
||||||
wxPyEndAllowThreads(__tstate);
|
|
||||||
if (PyErr_Occurred()) SWIG_fail;
|
|
||||||
}
|
|
||||||
resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_wxMask, 1);
|
|
||||||
return resultobj;
|
|
||||||
fail:
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static PyObject *_wrap_new_MaskColour(PyObject *self, PyObject *args, PyObject *kwargs) {
|
|
||||||
PyObject *resultobj;
|
|
||||||
wxBitmap *arg1 = 0 ;
|
|
||||||
wxColour *arg2 = 0 ;
|
|
||||||
wxMask *result;
|
wxMask *result;
|
||||||
wxColour temp2 ;
|
wxColour temp2 ;
|
||||||
PyObject * obj0 = 0 ;
|
PyObject * obj0 = 0 ;
|
||||||
@@ -3128,18 +3107,20 @@ static PyObject *_wrap_new_MaskColour(PyObject *self, PyObject *args, PyObject *
|
|||||||
(char *) "bitmap",(char *) "colour", NULL
|
(char *) "bitmap",(char *) "colour", NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:new_MaskColour",kwnames,&obj0,&obj1)) goto fail;
|
if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:new_Mask",kwnames,&obj0,&obj1)) goto fail;
|
||||||
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_wxBitmap,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
|
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_wxBitmap,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
|
||||||
if (arg1 == NULL) {
|
if (arg1 == NULL) {
|
||||||
PyErr_SetString(PyExc_TypeError,"null reference"); SWIG_fail;
|
PyErr_SetString(PyExc_TypeError,"null reference"); SWIG_fail;
|
||||||
}
|
}
|
||||||
{
|
if (obj1) {
|
||||||
arg2 = &temp2;
|
{
|
||||||
if ( ! wxColour_helper(obj1, &arg2)) SWIG_fail;
|
arg2 = &temp2;
|
||||||
|
if ( ! wxColour_helper(obj1, &arg2)) SWIG_fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PyThreadState* __tstate = wxPyBeginAllowThreads();
|
PyThreadState* __tstate = wxPyBeginAllowThreads();
|
||||||
result = (wxMask *)new wxMask((wxBitmap const &)*arg1,(wxColour const &)*arg2);
|
result = (wxMask *)new_wxMask((wxBitmap const &)*arg1,(wxColour const &)*arg2);
|
||||||
|
|
||||||
wxPyEndAllowThreads(__tstate);
|
wxPyEndAllowThreads(__tstate);
|
||||||
if (PyErr_Occurred()) SWIG_fail;
|
if (PyErr_Occurred()) SWIG_fail;
|
||||||
@@ -17804,7 +17785,6 @@ static PyMethodDef SwigMethods[] = {
|
|||||||
{ (char *)"Bitmap_SetDepth", (PyCFunction) _wrap_Bitmap_SetDepth, METH_VARARGS | METH_KEYWORDS },
|
{ (char *)"Bitmap_SetDepth", (PyCFunction) _wrap_Bitmap_SetDepth, METH_VARARGS | METH_KEYWORDS },
|
||||||
{ (char *)"Bitmap_swigregister", Bitmap_swigregister, METH_VARARGS },
|
{ (char *)"Bitmap_swigregister", Bitmap_swigregister, METH_VARARGS },
|
||||||
{ (char *)"new_Mask", (PyCFunction) _wrap_new_Mask, METH_VARARGS | METH_KEYWORDS },
|
{ (char *)"new_Mask", (PyCFunction) _wrap_new_Mask, METH_VARARGS | METH_KEYWORDS },
|
||||||
{ (char *)"new_MaskColour", (PyCFunction) _wrap_new_MaskColour, METH_VARARGS | METH_KEYWORDS },
|
|
||||||
{ (char *)"Mask_swigregister", Mask_swigregister, METH_VARARGS },
|
{ (char *)"Mask_swigregister", Mask_swigregister, METH_VARARGS },
|
||||||
{ (char *)"new_Icon", (PyCFunction) _wrap_new_Icon, METH_VARARGS | METH_KEYWORDS },
|
{ (char *)"new_Icon", (PyCFunction) _wrap_new_Icon, METH_VARARGS | METH_KEYWORDS },
|
||||||
{ (char *)"delete_Icon", (PyCFunction) _wrap_delete_Icon, METH_VARARGS | METH_KEYWORDS },
|
{ (char *)"delete_Icon", (PyCFunction) _wrap_delete_Icon, METH_VARARGS | METH_KEYWORDS },
|
||||||
|
@@ -42,7 +42,6 @@ wxBitmapFromXPMData = wx.gdi.BitmapFromXPMData
|
|||||||
wxBitmapFromBits = wx.gdi.BitmapFromBits
|
wxBitmapFromBits = wx.gdi.BitmapFromBits
|
||||||
wxMask = wx.gdi.Mask
|
wxMask = wx.gdi.Mask
|
||||||
wxMaskPtr = wx.gdi.MaskPtr
|
wxMaskPtr = wx.gdi.MaskPtr
|
||||||
wxMaskColour = wx.gdi.MaskColour
|
|
||||||
wxIcon = wx.gdi.Icon
|
wxIcon = wx.gdi.Icon
|
||||||
wxIconPtr = wx.gdi.IconPtr
|
wxIconPtr = wx.gdi.IconPtr
|
||||||
wxEmptyIcon = wx.gdi.EmptyIcon
|
wxEmptyIcon = wx.gdi.EmptyIcon
|
||||||
@@ -592,5 +591,6 @@ wxMirrorDC_old = wx.gdi.MirrorDC_old
|
|||||||
wxPostScriptDC_old = wx.gdi.PostScriptDC_old
|
wxPostScriptDC_old = wx.gdi.PostScriptDC_old
|
||||||
wxMetaFileDC_old = wx.gdi.MetaFileDC_old
|
wxMetaFileDC_old = wx.gdi.MetaFileDC_old
|
||||||
wxPrinterDC_old = wx.gdi.PrinterDC_old
|
wxPrinterDC_old = wx.gdi.PrinterDC_old
|
||||||
|
wxMaskColour = wx.gdi.MaskColour
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user