}
PostCreation();
+
+ ApplyWidgetStyle();
}
wxMenuBar::wxMenuBar()
m_widget = GTK_WIDGET(m_menubar);
PostCreation();
+
+ ApplyWidgetStyle();
}
wxMenuBar::~wxMenuBar()
{
menu->SetInvokingWindow( win );
-#if (GTK_MINOR_VERSION > 0)
+#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native hot keys */
- gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
+ GtkObject *obj = GTK_OBJECT(top_frame->m_widget);
+ if ( !g_slist_find( menu->m_accel->attach_objects, obj ) )
+ gtk_accel_group_attach( menu->m_accel, obj );
#endif
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
top_frame = top_frame->GetParent();
/* support for native key accelerators indicated by underscroes */
- gtk_accel_group_attach( m_accel, GTK_OBJECT(top_frame->m_widget) );
+ GtkObject *obj = GTK_OBJECT(top_frame->m_widget);
+ if ( !g_slist_find( m_accel->attach_objects, obj ) )
+ gtk_accel_group_attach( m_accel, obj );
#endif
wxMenuList::Node *node = m_menus.GetFirst();
if ( !GtkAppend(menu, title) )
return FALSE;
+ if (pos+1 >= m_menus.GetCount())
+ return TRUE;
+
GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget);
gpointer data = g_list_last(menu_shell->children)->data;
menu_shell->children = g_list_remove(menu_shell->children, data);
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
{
- if ( !wxMenuBarBase::Replace(pos, menu, title) )
- return (wxMenu*) NULL;
-
// remove the old item and insert a new one
wxMenu *menuOld = Remove(pos);
if ( menuOld && !Insert(pos, menu, title) )
if ( !menu )
return (wxMenu*) NULL;
+/*
GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget);
+
printf( "factory entries before %d\n", (int)g_slist_length(m_factory->items) );
printf( "menu shell entries before %d\n", (int)g_list_length( menu_shell->children ) );
-
+*/
+
// unparent calls unref() and that would delete the widget so we raise
// the ref count to 2 artificially before invoking unparent.
gtk_widget_ref( menu->m_menu );
gtk_widget_unparent( menu->m_menu );
-
+
gtk_widget_destroy( menu->m_owner );
-
+
+/*
printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) );
printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) );
-
+*/
+
return menu;
}
}
// return the menu item text without any menu accels
-wxString wxMenuItem::GetLabel() const
+/* static */
+wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
{
wxString label;
#if (GTK_MINOR_VERSION > 0)
- for ( const wxChar *pc = m_text.c_str(); *pc; pc++ )
+ for ( const wxChar *pc = text.c_str(); *pc; pc++ )
{
- if ( *pc == wxT('_') )
+ if ( *pc == wxT('_') || *pc == wxT('&') )
{
- // this is the escape character for GTK+ - skip it
+ // '_' is the escape character for GTK+ and '&' is the one for
+ // wxWindows - skip both of them
continue;
}
label += *pc;
}
#else // GTK+ 1.0
- label = m_text;
+ label = text;
#endif // GTK+ 1.2/1.0
return label;
#endif // GTK 1.2/1.0
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );
+
+ // if adding a submenu to a menu already existing in the menu bar, we
+ // must set invoking window to allow processing events from this
+ // submenu
+ if ( m_invokingWindow )
+ wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow);
}
else // a normal item
{
#else // GTK < 1.2
// this should be easy to do...
wxFAIL_MSG( wxT("not implemented") );
-#endif // GTK 1.2/1.0
return FALSE;
+#endif // GTK 1.2/1.0
}
wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)