bool wxMenuBar::Append( wxMenu *menu, const wxString &title ) { if ( !wxMenuBarBase::Append( menu, title ) ) return false; return GtkAppend(menu, title); }
wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item) { if ( !GtkAppend(item, (int)pos) ) return NULL; return wxMenuBase::DoInsert(pos, item); }
wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem) { if (!GtkAppend(mitem)) return NULL; return wxMenuBase::DoAppend(mitem); }
wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item) { if (wxMenuBase::DoInsert(pos, item)) { GtkAppend(item, int(pos)); return item; } return NULL; }
wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem) { if (wxMenuBase::DoAppend(mitem)) { GtkAppend(mitem); return mitem; } return NULL; }
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) { if (wxMenuBarBase::Insert(pos, menu, title)) { GtkAppend(menu, title, int(pos)); return true; } return false; }
bool wxMenuBar::Append( wxMenu *menu, const wxString &title ) { if (wxMenuBarBase::Append(menu, title)) { GtkAppend(menu, title); return true; } return false; }
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; }
void wxMenuBar::GtkAppend(wxMenu* menu, const wxString& title, int pos) { menu->SetLayoutDirection(GetLayoutDirection()); #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 // if the menu has only one item, append it directly to the top level menu // instead of inserting a useless submenu if ( menu->GetMenuItemCount() == 1 ) { wxMenuItem * const item = menu->FindItemByPosition(0); // remove both mnemonics and accelerator: neither is useful under Maemo const wxString str(wxStripMenuCodes(item->GetItemLabel())); if ( item->IsSubMenu() ) { GtkAppend(item->GetSubMenu(), str, pos); return; } menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) ); g_signal_connect(menu->m_owner, "activate", G_CALLBACK(menuitem_activate), item); item->SetMenuItem(menu->m_owner); } else #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 { const wxString str(wxConvertMnemonicsToGTK(title)); // This doesn't have much effect right now. menu->SetTitle( str ); // The "m_owner" is the "menu item" menu->m_owner = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( str ) ); gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu ); } g_object_ref(menu->m_owner); gtk_widget_show( menu->m_owner ); if (pos == -1) gtk_menu_shell_append( GTK_MENU_SHELL(m_menubar), menu->m_owner ); else gtk_menu_shell_insert( GTK_MENU_SHELL(m_menubar), menu->m_owner, pos ); if ( m_menuBarFrame ) AttachToFrame( menu, m_menuBarFrame ); }