X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/203bfdca0c885d6ac295e4ffea1c95d80fe75b85..26ee65c723cf55822c540506f064ec11d9b26858:/wxPython/src/_menu.i diff --git a/wxPython/src/_menu.i b/wxPython/src/_menu.i index 50a3f6e7fc..db3c33ce71 100644 --- a/wxPython/src/_menu.i +++ b/wxPython/src/_menu.i @@ -133,19 +133,38 @@ public: // deleting it!) %newobject Remove; wxMenuItem *Remove(int id); - %Rename(RemoveItem, wxMenuItem*, Remove(wxMenuItem *item)); + %feature("shadow") Remove(wxMenuItem *item) %{ + def RemoveItem(self, item): + """RemoveItem(self, MenuItem item) -> MenuItem""" + #// The return object is always the parameter, so return that + #// proxy instead of the new one + val = _core_.Menu_RemoveItem(self, item) + item.this.own(val.this.own()) + val.this.disown() + return item + %} + %Rename(RemoveItem, wxMenuItem*, Remove(wxMenuItem *item)); + // delete an item from the menu (submenus are not destroyed by this // function, see Destroy) bool Delete(int id); %Rename(DeleteItem, bool, Delete(wxMenuItem *item)); - %pythonAppend Destroy "args[0].thisown = 0" + %pythonPrepend Destroy "args[0].this.own(False)" %extend { void Destroy() { delete self; } } // delete the item from menu and destroy it (if it's a submenu) - %Rename(DestroyId, bool, Destroy(int id)); - %Rename(DestroyItem, bool, Destroy(wxMenuItem *item)); + %pythonPrepend Destroy ""; + DocDeclStrName( + bool , Destroy(int id), + "", "", + DestroyId); + + DocDeclStrName( + bool , Destroy(wxMenuItem *item), + "", "", + DestroyItem); // get the items @@ -348,7 +367,6 @@ public: } %property(Frame, GetFrame, doc="See `GetFrame`"); - %property(Menu, GetMenu, doc="See `GetMenu`"); %property(MenuCount, GetMenuCount, doc="See `GetMenuCount`"); %property(Menus, GetMenus, SetMenus, doc="See `GetMenus` and `SetMenus`"); }; @@ -358,13 +376,23 @@ public: class wxMenuItem : public wxObject { public: - wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_ANY, + // turn off this typemap + %typemap(out) wxMenuItem*; + + wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_SEPARATOR, const wxString& text = wxPyEmptyString, const wxString& help = wxPyEmptyString, wxItemKind kind = wxITEM_NORMAL, wxMenu* subMenu = NULL); ~wxMenuItem(); + // Turn it back on again + %typemap(out) wxMenuItem* { $result = wxPyMake_wxObject($1, $owner); } + + // Make Destroy a NOP. The destruction will be handled by SWIG. + %pythoncode { def Destroy(self): pass } + + // the menu we're in wxMenu *GetMenu() const; void SetMenu(wxMenu* menu);