From 662bd31e1277e28ad9a4c8838f9aa5dd75bde745 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 29 Sep 2004 21:18:28 +0000 Subject: [PATCH] Overridable CreatePopupMenu in TaskBarIcon git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29550 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/_taskbar.i | 80 +++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/wxPython/src/_taskbar.i b/wxPython/src/_taskbar.i index a43322bb81..88fd35bae9 100644 --- a/wxPython/src/_taskbar.i +++ b/wxPython/src/_taskbar.i @@ -58,64 +58,58 @@ enum { #else -// // Otherwise make a class that can virtualize CreatePopupMenu -// class wxPyTaskBarIcon : public wxTaskBarIcon -// { -// DECLARE_ABSTRACT_CLASS(wxPyTaskBarIcon); -// public: -// wxPyTaskBarIcon() : wxTaskBarIcon() -// {} +// Otherwise make a class that can virtualize CreatePopupMenu +class wxPyTaskBarIcon : public wxTaskBarIcon +{ + DECLARE_ABSTRACT_CLASS(wxPyTaskBarIcon); +public: + wxPyTaskBarIcon() : wxTaskBarIcon() + {} -// wxMenu* CreatePopupMenu() { -// wxMenu *rval = NULL; -// bool found; -// bool blocked = wxPyBeginBlockThreads(); -// if ((found = wxPyCBH_findCallback(m_myInst, "CreatePopupMenu"))) { -// PyObject* ro; -// wxMenu* ptr; -// ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); -// if (ro) { -// if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxMenu"))) -// rval = ptr; -// Py_DECREF(ro); -// } -// } -// wxPyEndBlockThreads(blocked); -// if (! found) -// rval = wxTaskBarIcon::CreatePopupMenu(); -// return rval; -// } + wxMenu* CreatePopupMenu() { + wxMenu *rval = NULL; + bool found; + bool blocked = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "CreatePopupMenu"))) { + PyObject* ro; + wxMenu* ptr; + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); + if (ro) { + if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxMenu"))) + rval = ptr; + Py_DECREF(ro); + } + } + wxPyEndBlockThreads(blocked); + if (! found) + rval = wxTaskBarIcon::CreatePopupMenu(); + return rval; + } -// PYPRIVATE; -// }; + PYPRIVATE; +}; -// IMPLEMENT_ABSTRACT_CLASS(wxPyTaskBarIcon, wxTaskBarIcon); +IMPLEMENT_ABSTRACT_CLASS(wxPyTaskBarIcon, wxTaskBarIcon); #endif %} -// NOTE: TaskbarIcon has not yet been changed to be able to virtualize the -// CreatePopupMenu method because it is just before a release and I worry that -// there will be a problem in this case with it holding a reference to itself -// (since it depends on the dtor for cleanup.) Better safe than sorry! -// -// Perhaps a better mechanism for wxPython would be to turn CreatePopupMenu -// into an event... +MustHaveApp(wxPyTaskBarIcon); -MustHaveApp(wxTaskBarIcon); - -class wxTaskBarIcon : public wxEvtHandler +%name(TaskBarIcon)class wxPyTaskBarIcon : public wxEvtHandler { public: - wxTaskBarIcon(); - ~wxTaskBarIcon(); + %pythonAppend wxPyTaskBarIcon "self._setCallbackInfo(self, TaskBarIcon, 0)" + + wxPyTaskBarIcon(); + + void _setCallbackInfo(PyObject* self, PyObject* _class, int incref); %extend { void Destroy() { - #ifndef __WXMAC__ self->RemoveIcon(); - #endif + delete self; } }