From 7248a051efaaac399499e661e4fd3677a17fb2e2 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 8 Mar 2002 23:04:56 +0000 Subject: [PATCH] Added a wxIconFromBitmap "constructor" for wxIcon. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14499 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/gdi.i | 7 +++++++ wxPython/src/msw/gdi.cpp | 41 ++++++++++++++++++++++++++++++++++++++++ wxPython/src/msw/gdi.py | 5 +++++ 3 files changed, 53 insertions(+) diff --git a/wxPython/src/gdi.i b/wxPython/src/gdi.i index 7544659159..0e75af1efe 100644 --- a/wxPython/src/gdi.i +++ b/wxPython/src/gdi.i @@ -234,6 +234,7 @@ public: // Declarations of some alternate "constructors" %new wxIcon* wxEmptyIcon(); %new wxIcon* wxIconFromXPMData(PyObject* listOfStrings); +%new wxIcon* wxIconFromBitmap(const wxBitmap& bmp); %{ // Implementations of some alternate "constructors" wxIcon* wxEmptyIcon() { @@ -251,6 +252,12 @@ public: delete [] cArray; return icon; } + + wxIcon* wxIconFromBitmap(const wxBitmap& bmp) { + wxIcon* icon = new wxIcon(); + icon->CopyFromBitmap(bmp); + return icon; + } %} //--------------------------------------------------------------------------- diff --git a/wxPython/src/msw/gdi.cpp b/wxPython/src/msw/gdi.cpp index 1db4199671..df8157be1c 100644 --- a/wxPython/src/msw/gdi.cpp +++ b/wxPython/src/msw/gdi.cpp @@ -172,6 +172,12 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { delete [] cArray; return icon; } + + wxIcon* wxIconFromBitmap(const wxBitmap& bmp) { + wxIcon* icon = new wxIcon(); + icon->CopyFromBitmap(bmp); + return icon; + } // Alternate 'constructor' wxCursor* wxPyStockCursor(int id) { return new wxCursor(id); @@ -488,6 +494,40 @@ static PyObject *_wrap_wxIconFromXPMData(PyObject *self, PyObject *args, PyObjec return _resultobj; } +static PyObject *_wrap_wxIconFromBitmap(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxIcon * _result; + wxBitmap * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "bmp", NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxIconFromBitmap",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxBitmap_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxIconFromBitmap. Expected _wxBitmap_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (wxIcon *)wxIconFromBitmap(*_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxIcon_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } + return _resultobj; +} + static PyObject *_wrap_wxStockCursor(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; wxCursor * _result; @@ -13449,6 +13489,7 @@ static PyMethodDef gdicMethods[] = { { "wxMemoryDCFromDC", (PyCFunction) _wrap_wxMemoryDCFromDC, METH_VARARGS | METH_KEYWORDS }, { "wxNamedColour", (PyCFunction) _wrap_wxNamedColour, METH_VARARGS | METH_KEYWORDS }, { "wxStockCursor", (PyCFunction) _wrap_wxStockCursor, METH_VARARGS | METH_KEYWORDS }, + { "wxIconFromBitmap", (PyCFunction) _wrap_wxIconFromBitmap, METH_VARARGS | METH_KEYWORDS }, { "wxIconFromXPMData", (PyCFunction) _wrap_wxIconFromXPMData, METH_VARARGS | METH_KEYWORDS }, { "wxEmptyIcon", (PyCFunction) _wrap_wxEmptyIcon, METH_VARARGS | METH_KEYWORDS }, { "wxMaskColour", (PyCFunction) _wrap_wxMaskColour, METH_VARARGS | METH_KEYWORDS }, diff --git a/wxPython/src/msw/gdi.py b/wxPython/src/msw/gdi.py index 2b4388988a..101a9b12ce 100644 --- a/wxPython/src/msw/gdi.py +++ b/wxPython/src/msw/gdi.py @@ -1401,6 +1401,11 @@ def wxIconFromXPMData(*_args, **_kwargs): if val: val = wxIconPtr(val); val.thisown = 1 return val +def wxIconFromBitmap(*_args, **_kwargs): + val = apply(gdic.wxIconFromBitmap,_args,_kwargs) + if val: val = wxIconPtr(val); val.thisown = 1 + return val + def wxStockCursor(*_args, **_kwargs): val = apply(gdic.wxStockCursor,_args,_kwargs) if val: val = wxCursorPtr(val); val.thisown = 1 -- 2.47.2