]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_menu.i
HACK: Add PLATFORM_MACOS as an option
[wxWidgets.git] / wxPython / src / _menu.i
index a26d2103fdf148afa45acb87b04e04d41e5a4b8d..e1407bad00fcb1a20283e5fa4202d9327d123103 100644 (file)
 %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)
-    void Append(int id,
-                const wxString& text,
-                const wxString& help = wxPyEmptyString,
-                wxItemKind kind = wxITEM_NORMAL);
+    wxMenuItem* Append(int id,
+                       const wxString& text,
+                       const wxString& help = wxPyEmptyString,
+                       wxItemKind kind = wxITEM_NORMAL);
 
     // append a separator to the menu
-    void AppendSeparator();
+    wxMenuItem* AppendSeparator();
 
     // append a check item
-    void AppendCheckItem(int id,
-                         const wxString& text,
-                         const wxString& help = wxPyEmptyString);
+    wxMenuItem* AppendCheckItem(int id,
+                                const wxString& text,
+                                const wxString& help = wxPyEmptyString);
 
     // append a radio item
-    void AppendRadioItem(int id,
-                         const wxString& text,
-                         const wxString& help = wxPyEmptyString);
+    wxMenuItem* AppendRadioItem(int id,
+                                const wxString& text,
+                                const wxString& help = wxPyEmptyString);
     // append a submenu
-    %name(AppendMenu)void Append(int id,
-                                 const wxString& text,
-                                 wxMenu *submenu,
-                                 const wxString& help = wxPyEmptyString);
+    %name(AppendMenu) wxMenuItem* Append(int id,
+                                         const wxString& text,
+                                         wxMenu *submenu,
+                                         const wxString& help = wxPyEmptyString);
 
     // the most generic form of Append() - append anything
-    %name(AppendItem) void Append(wxMenuItem *item);
+    %name(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) bool Insert(size_t pos, wxMenuItem *item);
+    %name(InsertItem) wxMenuItem* Insert(size_t pos, wxMenuItem *item);
 
     // insert an item before given position
-    void Insert(size_t pos,
-                int id,
-                const wxString& text,
-                const wxString& help = wxPyEmptyString,
-                wxItemKind kind = wxITEM_NORMAL);
+    wxMenuItem* Insert(size_t pos,
+                       int id,
+                       const wxString& text,
+                       const wxString& help = wxPyEmptyString,
+                       wxItemKind kind = wxITEM_NORMAL);
 
     // insert a separator
-    void InsertSeparator(size_t pos);
+    wxMenuItem* InsertSeparator(size_t pos);
 
     // insert a check item
-    void InsertCheckItem(size_t pos,
-                         int id,
-                         const wxString& text,
-                         const wxString& help = wxPyEmptyString);
+    wxMenuItem* InsertCheckItem(size_t pos,
+                                int id,
+                                const wxString& text,
+                                const wxString& help = wxPyEmptyString);
 
     // insert a radio item
-    void InsertRadioItem(size_t pos,
-                         int id,
-                         const wxString& text,
-                         const wxString& help = wxPyEmptyString);
+    wxMenuItem* InsertRadioItem(size_t pos,
+                                int id,
+                                const wxString& text,
+                                const wxString& help = wxPyEmptyString);
 
     // insert a submenu
-    %name(InsertMenu) void Insert(size_t pos,
-                                  int id,
-                                  const wxString& text,
-                                  wxMenu *submenu,
-                                  const wxString& help = wxPyEmptyString);
+    %name(InsertMenu) wxMenuItem* Insert(size_t pos,
+                                         int id,
+                                         const wxString& text,
+                                         wxMenu *submenu,
+                                         const wxString& help = wxPyEmptyString);
 
     // prepend an item to the menu
-    %name(PrependItem)void Prepend(wxMenuItem *item);
+    %name(PrependItem) wxMenuItem* Prepend(wxMenuItem *item);
 
     // prepend any item to the menu
-    void Prepend(int id,
-                 const wxString& text,
-                 const wxString& help = wxPyEmptyString,
-                 wxItemKind kind = wxITEM_NORMAL);
+    wxMenuItem* Prepend(int id,
+                        const wxString& text,
+                        const wxString& help = wxPyEmptyString,
+                        wxItemKind kind = wxITEM_NORMAL);
 
     // prepend a separator
-    void PrependSeparator();
+    wxMenuItem*  PrependSeparator();
 
     // prepend a check item
-    void PrependCheckItem(int id,
-                          const wxString& text,
-                          const wxString& help = wxPyEmptyString);
+    wxMenuItem* PrependCheckItem(int id,
+                                 const wxString& text,
+                                 const wxString& help = wxPyEmptyString);
 
     // prepend a radio item
-    void PrependRadioItem(int id,
-                          const wxString& text,
-                          const wxString& help = wxPyEmptyString);
+    wxMenuItem*  PrependRadioItem(int id,
+                                  const wxString& text,
+                                  const wxString& help = wxPyEmptyString);
 
     // prepend a submenu
-    %name(PrependMenu)void Prepend(int id,
-                                   const wxString& text,
-                                   wxMenu *submenu,
-                                   const wxString& help = wxPyEmptyString);
+    %name(PrependMenu) wxMenuItem* Prepend(int id,
+                                           const wxString& text,
+                                           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
@@ -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 WXUNUSED(pos)) const { return true; }
 
     // get or change the label of the menu at given position
     virtual void SetLabelTop(size_t pos, const wxString& label);
@@ -292,7 +305,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 +335,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 +345,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,7 +384,7 @@ 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