X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/383562174efd81f3f6046dc9d45c5b3242c25b76..32485259c1342115488d219776dfebeb3d4d81b1:/wxPython/src/_menu.i?ds=inline diff --git a/wxPython/src/_menu.i b/wxPython/src/_menu.i index 8144d66ace..f547e9f1bf 100644 --- a/wxPython/src/_menu.i +++ b/wxPython/src/_menu.i @@ -17,13 +17,20 @@ %newgroup +MustHaveApp(wxMenu); + class wxMenu : public wxEvtHandler { public: - %addtofunc wxMenu "self._setOORInfo(self)" + %pythonAppend wxMenu "self._setOORInfo(self)" + %typemap(out) wxMenu*; // turn off this typemap + wxMenu(const wxString& title = wxPyEmptyString, long style = 0); + // Turn it back on again + %typemap(out) wxMenu* { $result = wxPyMake_wxObject($1, $owner); } + // append any kind of item (normal/check/radio/separator) wxMenuItem* Append(int id, const wxString& text, @@ -43,20 +50,20 @@ public: const wxString& text, const wxString& help = wxPyEmptyString); // append a submenu - %name(AppendMenu) wxMenuItem* Append(int id, - const wxString& text, - wxMenu *submenu, - const wxString& help = wxPyEmptyString); + %Rename(AppendMenu, wxMenuItem*, Append(int id, + const wxString& text, + wxMenu *submenu, + const wxString& help = wxPyEmptyString)); // the most generic form of Append() - append anything - %name(AppendItem) wxMenuItem* Append(wxMenuItem *item); + %Rename(AppendItem, wxMenuItem*, Append(wxMenuItem *item)); // insert a break in the menu (only works when appending the items, not // inserting them) virtual void Break(); // insert an item before given position - %name(InsertItem) wxMenuItem* Insert(size_t pos, wxMenuItem *item); + %Rename(InsertItem, wxMenuItem*, Insert(size_t pos, wxMenuItem *item)); // insert an item before given position wxMenuItem* Insert(size_t pos, @@ -81,14 +88,14 @@ public: const wxString& help = wxPyEmptyString); // insert a submenu - %name(InsertMenu) wxMenuItem* Insert(size_t pos, + %Rename(InsertMenu, wxMenuItem*, Insert(size_t pos, int id, const wxString& text, wxMenu *submenu, - const wxString& help = wxPyEmptyString); + const wxString& help = wxPyEmptyString)); // prepend an item to the menu - %name(PrependItem) wxMenuItem* Prepend(wxMenuItem *item); + %Rename(PrependItem, wxMenuItem*, Prepend(wxMenuItem *item)); // prepend any item to the menu wxMenuItem* Prepend(int id, @@ -110,26 +117,26 @@ public: const wxString& help = wxPyEmptyString); // prepend a submenu - %name(PrependMenu) wxMenuItem* Prepend(int id, + %Rename(PrependMenu, wxMenuItem*, Prepend(int id, const wxString& text, wxMenu *submenu, - const wxString& help = wxPyEmptyString); + 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!) wxMenuItem *Remove(int id); - %name(RemoveItem) wxMenuItem *Remove(wxMenuItem *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); - %name(DeleteItem) bool Delete(wxMenuItem *item); + %Rename(DeleteItem, bool, Delete(wxMenuItem *item)); // delete the item from menu and destroy it (if it's a submenu) %extend { void Destroy() { delete self; } } - %name(DestroyId) bool Destroy(int id); - %name(DestroyItem) bool Destroy(wxMenuItem *item); + %Rename(DestroyId, bool, Destroy(int id)); + %Rename(DestroyItem, bool, Destroy(wxMenuItem *item)); // get the items @@ -143,7 +150,7 @@ public: // search int FindItem(const wxString& item) const; - %name(FindItemById) wxMenuItem* FindItem(int id /*, wxMenu **menu = NULL*/) const; + %Rename(FindItemById, wxMenuItem*, FindItem(int id /*, wxMenu **menu = NULL*/) const); // find by position wxMenuItem* FindItemByPosition(size_t position) const; @@ -203,12 +210,18 @@ public: //--------------------------------------------------------------------------- %newgroup +MustHaveApp(wxMenuBar); + class wxMenuBar : public wxWindow { public: - %addtofunc wxMenuBar "self._setOORInfo(self)" + %pythonAppend wxMenuBar "self._setOORInfo(self)" + %typemap(out) wxMenuBar*; // turn off this typemap + wxMenuBar(long style = 0); + // Turn it back on again + %typemap(out) wxMenuBar* { $result = wxPyMake_wxObject($1, $owner); } // append a menu to the end of menubar, return True if ok virtual bool Append(wxMenu *menu, const wxString& title); @@ -236,7 +249,7 @@ public: virtual void EnableTop(size_t pos, bool enable); // is the menu enabled? - virtual bool IsEnabledTop(size_t WXUNUSED(pos)) const { return True; } + virtual bool IsEnabledTop(size_t pos) const; // get or change the label of the menu at given position virtual void SetLabelTop(size_t pos, const wxString& label); @@ -250,10 +263,10 @@ public: // find item by id (in any menu), returns NULL if not found // // if menu is !NULL, it will be filled with wxMenu this item belongs to - %name(FindItemById) virtual wxMenuItem* FindItem(int id /*, wxMenu **menu = NULL*/) const; + %Rename(FindItemById, virtual wxMenuItem*, FindItem(int id /*, wxMenu **menu = NULL*/) const); // find menu by its caption, return wxNOT_FOUND on failure - int FindMenu(const wxString& title) const; + int FindMenu(const wxString& title); // all these functions just use FindItem() and then call an appropriate @@ -266,7 +279,8 @@ public: void Check(int id, bool check); bool IsChecked(int id) const; bool IsEnabled(int id) const; - + // TODO: bool IsEnabled() const; + void SetLabel(int id, const wxString &label); wxString GetLabel(int id) const; @@ -285,6 +299,16 @@ public: // called before deleting the menubar normally virtual void Detach(); + +#ifdef __WXMAC__ + static void SetAutoWindowMenu( bool enable ); + static bool GetAutoWindowMenu(); +#else + %extend { + static void SetAutoWindowMenu( bool enable ) {} + static bool GetAutoWindowMenu() { return false; } + } +#endif }; //--------------------------------------------------------------------------- @@ -292,7 +316,7 @@ public: class wxMenuItem : public wxObject { public: - wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_SEPARATOR, + wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_ANY, const wxString& text = wxPyEmptyString, const wxString& help = wxPyEmptyString, wxItemKind kind = wxITEM_NORMAL, @@ -322,6 +346,7 @@ public: // what kind of menu item we are wxItemKind GetKind() const; + void SetKind(wxItemKind kind); virtual void SetCheckable(bool checkable); bool IsCheckable() const; @@ -331,10 +356,10 @@ public: wxMenu *GetSubMenu() const; // state - virtual void Enable(bool enable = True); + virtual void Enable(bool enable = true); virtual bool IsEnabled() const; - virtual void Check(bool check = True); + virtual void Check(bool check = true); virtual bool IsChecked() const; void Toggle(); @@ -370,12 +395,28 @@ public: bool IsOwnerDrawn(); // switch on/off owner-drawing the item - void SetOwnerDrawn(bool ownerDrawn = True); + void SetOwnerDrawn(bool ownerDrawn = true); void ResetOwnerDrawn(); #else - // just to keep the global renamers in sync %extend { + void SetFont(const wxFont& font) {} + wxFont GetFont() { return wxNullFont; } + void SetTextColour(const wxColour& colText) {} + wxColour GetTextColour() { return wxNullColour; } + void SetBackgroundColour(const wxColour& colBack) {} + wxColour GetBackgroundColour() { return wxNullColour; } + void SetBitmaps(const wxBitmap& bmpChecked, + const wxBitmap& bmpUnchecked = wxNullBitmap) {} + + void SetDisabledBitmap( const wxBitmap& bmpDisabled ) {} + const wxBitmap& GetDisabledBitmap() const { return wxNullBitmap; } + + void SetMarginWidth(int nWidth) {} + int GetMarginWidth() { return 0; } static int GetDefaultMarginWidth() { return 0; } + bool IsOwnerDrawn() { return false; } + void SetOwnerDrawn(bool ownerDrawn = true) {} + void ResetOwnerDrawn() {} } #endif