private:
// common part of Append and Insert
- bool GtkAppend(wxMenu *menu, const wxString& title, int pos=-1);
+ void GtkAppend(wxMenu* menu, const wxString& title, int pos = -1);
void Init(size_t n, wxMenu *menus[], const wxString titles[], long style);
void Init();
// common part of Append (if pos == -1) and Insert
- bool GtkAppend(wxMenuItem *item, int pos=-1);
+ void GtkAppend(wxMenuItem* item, int pos = -1);
DECLARE_DYNAMIC_CLASS(wxMenu)
bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
{
- if ( !wxMenuBarBase::Append( menu, title ) )
- return false;
-
- return GtkAppend(menu, title);
+ if (wxMenuBarBase::Append(menu, title))
+ {
+ GtkAppend(menu, title);
+ return true;
+ }
+ return false;
}
-bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title, int pos)
+void wxMenuBar::GtkAppend(wxMenu* menu, const wxString& title, int pos)
{
menu->SetLayoutDirection(GetLayoutDirection());
const wxString str(wxStripMenuCodes(item->GetItemLabel()));
if ( item->IsSubMenu() )
- return GtkAppend(item->GetSubMenu(), str, pos);
+ {
+ GtkAppend(item->GetSubMenu(), str, pos);
+ return;
+ }
menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) );
if ( m_menuBarFrame )
AttachToFrame( menu, m_menuBarFrame );
-
- return true;
}
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
{
- if ( !wxMenuBarBase::Insert(pos, menu, title) )
- return false;
-
- // TODO
-
- if ( !GtkAppend(menu, title, (int)pos) )
- return false;
-
- return true;
+ if (wxMenuBarBase::Insert(pos, menu, title))
+ {
+ GtkAppend(menu, title, int(pos));
+ return true;
+ }
+ return false;
}
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
return wxConvertMnemonicsFromGTK(wxMenuBase::GetTitle());
}
-bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
+void wxMenu::GtkAppend(wxMenuItem* mitem, int pos)
{
GtkWidget *menuItem;
switch (mitem->GetKind())
wxMenuItem* radioGroupItem = NULL;
const size_t numItems = GetMenuItemCount();
- const size_t n = pos == -1 ? numItems
- : static_cast<size_t>(pos);
- if ( n > 0 )
+ const size_t n = pos == -1 ? numItems - 1 : size_t(pos);
+
+ if (n != 0)
{
wxMenuItem* const itemPrev = FindItemByPosition(n - 1);
if ( itemPrev->GetKind() == wxITEM_RADIO )
}
}
- if ( n < numItems )
+ if (radioGroupItem == NULL && n != numItems - 1)
{
- wxMenuItem* const itemNext = FindItemByPosition(n);
+ wxMenuItem* const itemNext = FindItemByPosition(n + 1);
if ( itemNext->GetKind() == wxITEM_RADIO )
{
// Inserting an item before an existing radio item
mitem);
}
}
-
- return true;
}
wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem)
{
- if (!GtkAppend(mitem))
- return NULL;
-
- return wxMenuBase::DoAppend(mitem);
+ if (wxMenuBase::DoAppend(mitem))
+ {
+ GtkAppend(mitem);
+ return mitem;
+ }
+ return NULL;
}
wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
{
- if ( !GtkAppend(item, (int)pos) )
- return NULL;
-
- return wxMenuBase::DoInsert(pos, item);
+ if (wxMenuBase::DoInsert(pos, item))
+ {
+ GtkAppend(item, int(pos));
+ return item;
+ }
+ return NULL;
}
wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)