// 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);
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);
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);
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));
bool Delete(int id);
%Rename(DeleteItem, bool, Delete(wxMenuItem *item));
- // delete the item from menu and destroy it (if it's a submenu)
+ %pythonAppend Destroy "args[0].thisown = 0"
%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));
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);
%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
// 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(Menus, GetMenus, SetMenus);
+
};
//---------------------------------------------------------------------------
const wxString& help = wxPyEmptyString,
wxItemKind kind = wxITEM_NORMAL,
wxMenu* subMenu = NULL);
+ ~wxMenuItem();
// the menu we're in
wxMenu *GetMenu() const;
// SetText()
virtual void SetAccel(wxAcceleratorEntry *accel);
-
+ void SetBitmap(const wxBitmap& bitmap);
+ const wxBitmap& GetBitmap();
+
// wxOwnerDrawn methods
#ifdef __WXMSW__
void SetFont(const wxFont& font);
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; }
void ResetOwnerDrawn() {}
}
#endif
-
- void SetBitmap(const wxBitmap& bitmap);
- const wxBitmap& GetBitmap();
};
//---------------------------------------------------------------------------