X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ab1f7d2aa9cb1857cf87e105ebbd36a92676bbde..32485259c1342115488d219776dfebeb3d4d81b1:/wxPython/src/_taskbar.i?ds=sidebyside diff --git a/wxPython/src/_taskbar.i b/wxPython/src/_taskbar.i index 3fbbbc660c..1b7540f52c 100644 --- a/wxPython/src/_taskbar.i +++ b/wxPython/src/_taskbar.i @@ -23,15 +23,15 @@ %{ -#ifdef __WXMAC__ -// implement dummy classes and such for wxMac +#ifndef wxHAS_TASK_BAR_ICON +// implement dummy classes for platforms that don't have it class wxTaskBarIcon : public wxEvtHandler { public: wxTaskBarIcon() { wxPyRaiseNotImplemented(); } }; - + class wxTaskBarIconEvent : public wxEvent { @@ -39,6 +39,11 @@ public: wxTaskBarIconEvent(wxEventType, wxTaskBarIcon *) { wxPyRaiseNotImplemented(); } virtual wxEvent* Clone() const { return NULL; } + bool IsOk() const { return false; } + bool IsIconInstalled() const { return false; } + bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxPyEmptyString) { return false; } + bool RemoveIcon() { return false; } + bool PopupMenu(wxMenu *menu) { return false; } }; enum { @@ -50,38 +55,73 @@ enum { wxEVT_TASKBAR_LEFT_DCLICK = 0, wxEVT_TASKBAR_RIGHT_DCLICK = 0, }; -#endif -%} +#else +// 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; + wxPyBlock_t 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; +}; -MustHaveApp(wxTaskBarIcon); +IMPLEMENT_ABSTRACT_CLASS(wxPyTaskBarIcon, wxTaskBarIcon); -class wxTaskBarIcon : public wxEvtHandler +#endif +%} + + +MustHaveApp(wxPyTaskBarIcon); + +%rename(TaskBarIcon) wxPyTaskBarIcon; +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; } } -#ifndef __WXMAC__ bool IsOk() const; %pythoncode { def __nonzero__(self): return self.IsOk() } - + bool IsIconInstalled() const; bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxPyEmptyString); - bool RemoveIcon(void); + bool RemoveIcon(); bool PopupMenu(wxMenu *menu); -#endif }; @@ -111,6 +151,6 @@ EVT_TASKBAR_RIGHT_DOWN = wx.PyEventBinder ( wxEVT_TASKBAR_RIGHT_DOWN ) EVT_TASKBAR_RIGHT_UP = wx.PyEventBinder ( wxEVT_TASKBAR_RIGHT_UP ) EVT_TASKBAR_LEFT_DCLICK = wx.PyEventBinder ( wxEVT_TASKBAR_LEFT_DCLICK ) EVT_TASKBAR_RIGHT_DCLICK = wx.PyEventBinder ( wxEVT_TASKBAR_RIGHT_DCLICK ) -} +} //---------------------------------------------------------------------------