From 04c883f8c963dbbb98a840c31abb6c05c438cc7d Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 12 Aug 2002 17:44:11 +0000 Subject: [PATCH] Added menu icon methods everywhere git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16464 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/wxListCtrl.py | 3 +- wxPython/src/gtk/windows.cpp | 75 ++++++++++++++++++++++++++++++++++++ wxPython/src/gtk/windows.py | 7 ++++ wxPython/src/windows.i | 12 +++--- 4 files changed, 89 insertions(+), 8 deletions(-) diff --git a/wxPython/demo/wxListCtrl.py b/wxPython/demo/wxListCtrl.py index d1b9cf245f..799b086228 100644 --- a/wxPython/demo/wxListCtrl.py +++ b/wxPython/demo/wxListCtrl.py @@ -269,8 +269,7 @@ class TestListCtrlPanel(wxPanel, wxColumnSorterMixin): # Show how to put an icon in the menu item = wxMenuItem(menu, tPopupID1,"One") - if wxPlatform == '__WXMSW__': - item.SetBitmap(images.getSmilesBitmap()) + item.SetBitmap(images.getSmilesBitmap()) menu.AppendItem(item) menu.Append(tPopupID2, "Two") diff --git a/wxPython/src/gtk/windows.cpp b/wxPython/src/gtk/windows.cpp index c970dccd9f..c89603067a 100644 --- a/wxPython/src/gtk/windows.cpp +++ b/wxPython/src/gtk/windows.cpp @@ -11264,7 +11264,82 @@ static PyObject *_wrap_wxMenuItem_GetLabelFromText(PyObject *self, PyObject *arg return _resultobj; } +#define wxMenuItem_SetBitmap(_swigobj,_swigarg0) (_swigobj->SetBitmap(_swigarg0)) +static PyObject *_wrap_wxMenuItem_SetBitmap(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxMenuItem * _arg0; + wxBitmap * _arg1; + PyObject * _argo0 = 0; + PyObject * _argo1 = 0; + char *_kwnames[] = { "self","bitmap", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxMenuItem_SetBitmap",_kwnames,&_argo0,&_argo1)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxMenuItem_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxMenuItem_SetBitmap. Expected _wxMenuItem_p."); + return NULL; + } + } + if (_argo1) { + if (_argo1 == Py_None) { _arg1 = NULL; } + else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxBitmap_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxMenuItem_SetBitmap. Expected _wxBitmap_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + wxMenuItem_SetBitmap(_arg0,*_arg1); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +#define wxMenuItem_GetBitmap(_swigobj) (_swigobj->GetBitmap()) +static PyObject *_wrap_wxMenuItem_GetBitmap(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + wxBitmap * _result; + wxMenuItem * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + char _ptemp[128]; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxMenuItem_GetBitmap",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxMenuItem_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxMenuItem_GetBitmap. Expected _wxMenuItem_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + const wxBitmap & _result_ref = wxMenuItem_GetBitmap(_arg0); + _result = (wxBitmap *) &_result_ref; + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +} if (_result) { + SWIG_MakePtr(_ptemp, (char *) _result,"_wxBitmap_p"); + _resultobj = Py_BuildValue("s",_ptemp); + } else { + Py_INCREF(Py_None); + _resultobj = Py_None; + } + return _resultobj; +} + static PyMethodDef windowscMethods[] = { + { "wxMenuItem_GetBitmap", (PyCFunction) _wrap_wxMenuItem_GetBitmap, METH_VARARGS | METH_KEYWORDS }, + { "wxMenuItem_SetBitmap", (PyCFunction) _wrap_wxMenuItem_SetBitmap, METH_VARARGS | METH_KEYWORDS }, { "wxMenuItem_GetLabelFromText", (PyCFunction) _wrap_wxMenuItem_GetLabelFromText, METH_VARARGS | METH_KEYWORDS }, { "wxMenuItem_SetAccel", (PyCFunction) _wrap_wxMenuItem_SetAccel, METH_VARARGS | METH_KEYWORDS }, { "wxMenuItem_GetAccel", (PyCFunction) _wrap_wxMenuItem_GetAccel, METH_VARARGS | METH_KEYWORDS }, diff --git a/wxPython/src/gtk/windows.py b/wxPython/src/gtk/windows.py index 1e1bc569d3..757dd2a53b 100644 --- a/wxPython/src/gtk/windows.py +++ b/wxPython/src/gtk/windows.py @@ -1098,6 +1098,13 @@ class wxMenuItemPtr(wxObjectPtr): def SetAccel(self, *_args, **_kwargs): val = apply(windowsc.wxMenuItem_SetAccel,(self,) + _args, _kwargs) return val + def SetBitmap(self, *_args, **_kwargs): + val = apply(windowsc.wxMenuItem_SetBitmap,(self,) + _args, _kwargs) + return val + def GetBitmap(self, *_args, **_kwargs): + val = apply(windowsc.wxMenuItem_GetBitmap,(self,) + _args, _kwargs) + if val: val = wxBitmapPtr(val) + return val def __repr__(self): return "" % (self.this,) class wxMenuItem(wxMenuItemPtr): diff --git a/wxPython/src/windows.i b/wxPython/src/windows.i index 630252fd01..702922d27b 100644 --- a/wxPython/src/windows.i +++ b/wxPython/src/windows.i @@ -827,18 +827,18 @@ public: wxColour GetBackgroundColour(); void SetBitmaps(const wxBitmap& bmpChecked, const wxBitmap& bmpUnchecked = wxNullBitmap); - void SetBitmap(const wxBitmap& bmpChecked); - wxBitmap GetBitmap(bool bChecked = TRUE); + //void SetBitmap(const wxBitmap& bmpChecked); + //wxBitmap GetBitmap(bool bChecked = TRUE); void SetMarginWidth(int nWidth); int GetMarginWidth(); static int GetDefaultMarginWidth(); - //void SetName(const wxString& strName); - //const wxString& GetName(); - //void SetCheckable(bool checkable); - //bool IsCheckable(); bool IsOwnerDrawn(); void ResetOwnerDrawn(); #endif + + void SetBitmap(const wxBitmap& bitmap); + const wxBitmap& GetBitmap(); + }; //--------------------------------------------------------------------------- -- 2.45.2