X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5fad19e3194e58f2d2e2bb0233801da48b4663a1..9e477492e29e03c02827b1e42a16cb09a13f5149:/wxPython/src/_menu.i?ds=sidebyside diff --git a/wxPython/src/_menu.i b/wxPython/src/_menu.i index dc6f3baa21..1bbb3a56e4 100644 --- a/wxPython/src/_menu.i +++ b/wxPython/src/_menu.i @@ -33,7 +33,7 @@ public: // append any kind of item (normal/check/radio/separator) wxMenuItem* Append(int id, - const wxString& text, + const wxString& text = wxPyEmptyString, const wxString& help = wxPyEmptyString, wxItemKind kind = wxITEM_NORMAL); @@ -55,20 +55,28 @@ public: wxMenu *submenu, const wxString& help = wxPyEmptyString)); + wxMenuItem* AppendSubMenu(wxMenu *submenu, + const wxString& text, + const wxString& help = wxPyEmptyString); + + %disownarg(wxMenuItem*); // the most generic form of Append() - append anything %Rename(AppendItem, wxMenuItem*, Append(wxMenuItem *item)); + // insert an item before given position + %Rename(InsertItem, wxMenuItem*, Insert(size_t pos, wxMenuItem *item)); + // prepend an item to the menu + %Rename(PrependItem, wxMenuItem*, Prepend(wxMenuItem *item)); + %cleardisown(wxMenuItem*); + // insert a break in the menu (only works when appending the items, not // inserting them) virtual void Break(); - // insert an item before given position - %Rename(InsertItem, wxMenuItem*, Insert(size_t pos, wxMenuItem *item)); - // insert an item before given position wxMenuItem* Insert(size_t pos, int id, - const wxString& text, + const wxString& text = wxPyEmptyString, const wxString& help = wxPyEmptyString, wxItemKind kind = wxITEM_NORMAL); @@ -94,12 +102,9 @@ public: wxMenu *submenu, const wxString& help = wxPyEmptyString)); - // prepend an item to the menu - %Rename(PrependItem, wxMenuItem*, Prepend(wxMenuItem *item)); - // prepend any item to the menu wxMenuItem* Prepend(int id, - const wxString& text, + const wxString& text = wxPyEmptyString, const wxString& help = wxPyEmptyString, wxItemKind kind = wxITEM_NORMAL); @@ -122,9 +127,11 @@ public: wxMenu *submenu, const wxString& help = wxPyEmptyString)); + // detach an item from the menu, but don't delete it so that it can be // added back later (but if it's not, the caller is responsible for // deleting it!) + %newobject Remove; wxMenuItem *Remove(int id); %Rename(RemoveItem, wxMenuItem*, Remove(wxMenuItem *item)); @@ -133,10 +140,20 @@ public: bool Delete(int id); %Rename(DeleteItem, bool, Delete(wxMenuItem *item)); - // delete the item from menu and destroy it (if it's a submenu) + %pythonPrepend Destroy "args[0].this.own(False)" %extend { void Destroy() { delete self; } } - %Rename(DestroyId, bool, Destroy(int id)); - %Rename(DestroyItem, bool, Destroy(wxMenuItem *item)); + + // delete the item from menu and destroy it (if it's a submenu) + %pythonPrepend Destroy ""; + DocDeclStrName( + bool , Destroy(int id), + "", "", + DestroyId); + + DocDeclStrName( + bool , Destroy(wxMenuItem *item), + "", "", + DestroyItem); // get the items @@ -205,6 +222,17 @@ public: // set/get the parent of this menu void SetParent(wxMenu *parent); wxMenu *GetParent() const; + + %property(EventHandler, GetEventHandler, SetEventHandler, doc="See `GetEventHandler` and `SetEventHandler`"); + %property(HelpString, GetHelpString, SetHelpString, doc="See `GetHelpString` and `SetHelpString`"); + %property(InvokingWindow, GetInvokingWindow, SetInvokingWindow, doc="See `GetInvokingWindow` and `SetInvokingWindow`"); + %property(MenuBar, GetMenuBar, doc="See `GetMenuBar`"); + %property(MenuItemCount, GetMenuItemCount, doc="See `GetMenuItemCount`"); + %property(MenuItems, GetMenuItems, doc="See `GetMenuItems`"); + %property(Parent, GetParent, SetParent, doc="See `GetParent` and `SetParent`"); + %property(Style, GetStyle, doc="See `GetStyle`"); + %property(Title, GetTitle, SetTitle, doc="See `GetTitle` and `SetTitle`"); + }; //--------------------------------------------------------------------------- @@ -299,6 +327,38 @@ public: // called before deleting the menubar normally virtual void Detach(); + + // update all menu item states in all menus + virtual void UpdateMenus(); + +#ifdef __WXMAC__ + static void SetAutoWindowMenu( bool enable ); + static bool GetAutoWindowMenu(); +#else + %extend { + static void SetAutoWindowMenu( bool enable ) {} + static bool GetAutoWindowMenu() { return false; } + } +#endif + + %pythoncode { + def GetMenus(self): + """Return a list of (menu, label) items for the menus in the MenuBar. """ + return [(self.GetMenu(i), self.GetLabelTop(i)) + for i in range(self.GetMenuCount())] + + def SetMenus(self, items): + """Clear and add new menus to the MenuBar from a list of (menu, label) items. """ + for i in range(self.GetMenuCount()-1, -1, -1): + self.Remove(i) + for m, l in items: + self.Append(m, l) + } + + %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`"); }; //--------------------------------------------------------------------------- @@ -306,12 +366,20 @@ public: class wxMenuItem : public wxObject { public: + // turn off this typemap + %typemap(out) wxMenuItem*; + wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_ANY, const wxString& text = wxPyEmptyString, const wxString& help = wxPyEmptyString, wxItemKind kind = wxITEM_NORMAL, wxMenu* subMenu = NULL); + ~wxMenuItem(); + // Turn it back on again + %typemap(out) wxEvtHandler* { $result = wxPyMake_wxObject($1, $owner); } + + // the menu we're in wxMenu *GetMenu() const; void SetMenu(wxMenu* menu); @@ -364,7 +432,9 @@ public: // SetText() virtual void SetAccel(wxAcceleratorEntry *accel); - + void SetBitmap(const wxBitmap& bitmap); + const wxBitmap& GetBitmap(); + // wxOwnerDrawn methods #ifdef __WXMSW__ void SetFont(const wxFont& font); @@ -395,8 +465,10 @@ public: wxColour GetTextColour() { return wxNullColour; } void SetBackgroundColour(const wxColour& colBack) {} wxColour GetBackgroundColour() { return wxNullColour; } + void SetBitmaps(const wxBitmap& bmpChecked, - const wxBitmap& bmpUnchecked = wxNullBitmap) {} + const wxBitmap& bmpUnchecked = wxNullBitmap) + { self->SetBitmap( bmpChecked ); } void SetDisabledBitmap( const wxBitmap& bmpDisabled ) {} const wxBitmap& GetDisabledBitmap() const { return wxNullBitmap; } @@ -410,8 +482,21 @@ public: } #endif - void SetBitmap(const wxBitmap& bitmap); - const wxBitmap& GetBitmap(); + %property(Accel, GetAccel, SetAccel, doc="See `GetAccel` and `SetAccel`"); + %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`"); + %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`"); + %property(DisabledBitmap, GetDisabledBitmap, SetDisabledBitmap, doc="See `GetDisabledBitmap` and `SetDisabledBitmap`"); + %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`"); + %property(Help, GetHelp, SetHelp, doc="See `GetHelp` and `SetHelp`"); + %property(Id, GetId, SetId, doc="See `GetId` and `SetId`"); + %property(Kind, GetKind, SetKind, doc="See `GetKind` and `SetKind`"); + %property(Label, GetLabel, doc="See `GetLabel`"); + %property(MarginWidth, GetMarginWidth, SetMarginWidth, doc="See `GetMarginWidth` and `SetMarginWidth`"); + %property(Menu, GetMenu, SetMenu, doc="See `GetMenu` and `SetMenu`"); + %property(SubMenu, GetSubMenu, SetSubMenu, doc="See `GetSubMenu` and `SetSubMenu`"); + %property(Text, GetText, SetText, doc="See `GetText` and `SetText`"); + %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`"); + }; //---------------------------------------------------------------------------