{
GtkWidget *menuItem;
+ wxString text;
+#ifndef __WXGTK20__
+ GtkLabel* label;
+#endif
+
if ( mitem->IsSeparator() )
{
#ifdef __WXGTK20__
// TODO
menuItem = gtk_menu_item_new();
#endif
- if (pos == -1)
- gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
- else
- gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
- }
- else if ( mitem->IsSubMenu() )
- {
- // text has "_" instead of "&" after mitem->SetText()
- wxString text( mitem->GetText() );
-
-#ifdef __WXGTK20__
- menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
-#else
- menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
- // set new text
- gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
-#endif
-
- gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );
- if (pos == -1)
- gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
- else
- gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
-
- gtk_widget_show( 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);
-
- m_prevRadio = NULL;
}
else if (mitem->GetBitmap().Ok())
{
- wxString text = mitem->GetText();
+ text = mitem->GetText();
const wxBitmap *bitmap = &mitem->GetBitmap();
#ifdef __WXGTK20__
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem), image );
- gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
- GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
- (gpointer)this );
-
- if (pos == -1)
- gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
- else
- gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
#else
GdkPixmap *gdk_pixmap = bitmap->GetPixmap();
GdkBitmap *gdk_bitmap = bitmap->GetMask() ? bitmap->GetMask()->GetBitmap() : (GdkBitmap*) NULL;
menuItem = gtk_pixmap_menu_item_new ();
- GtkWidget *label = gtk_accel_label_new ( wxGTK_CONV( text ) );
+ label = GTK_LABEL(gtk_accel_label_new ( wxGTK_CONV( text ) ));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_container_add (GTK_CONTAINER (menuItem), label);
+ gtk_container_add (GTK_CONTAINER (menuItem), GTK_WIDGET(label));
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuItem);
- guint accel_key;
- GdkModifierType accel_mods;
-
- // accelerator for the item, as specified by its label
- // (ex. Ctrl+O for open)
- gtk_accelerator_parse(GetGtkHotKey(*mitem).c_str(), &accel_key,
- &accel_mods);
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- m_accel,
- accel_key, accel_mods,
- GTK_ACCEL_VISIBLE);
- }
-
- // accelerator for the underlined char (ex ALT+F for the File menu)
- accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU (m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
- gtk_widget_show (label);
+ gtk_widget_show (GTK_WIDGET(label));
- mitem->SetLabelWidget(label);
+ mitem->SetLabelWidget(GTK_WIDGET(label));
GtkWidget* pixmap = gtk_pixmap_new( gdk_pixmap, gdk_bitmap );
gtk_widget_show(pixmap);
gtk_pixmap_menu_item_set_pixmap(GTK_PIXMAP_MENU_ITEM( menuItem ), pixmap);
- gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
- GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
- (gpointer)this );
-
- if (pos == -1)
- gtk_menu_append( GTK_MENU(m_menu), menuItem );
- else
- gtk_menu_insert( GTK_MENU(m_menu), menuItem, pos );
- gtk_widget_show( menuItem );
#endif
m_prevRadio = NULL;
else // a normal item
{
// text has "_" instead of "&" after mitem->SetText() so don't use it
- wxString text( mitem->GetText() );
+ text = mitem->GetText() ;
switch ( mitem->GetKind() )
{
menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
#else
menuItem = gtk_check_menu_item_new_with_label( wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
+ label = GTK_LABEL( GTK_BIN(menuItem)->child );
// set new text
gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
#endif
m_prevRadio = NULL;
break;
m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
#else
m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
+ label = GTK_LABEL( GTK_BIN(menuItem)->child );
// set new text
gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
#endif
}
else // continue the radio group
#else
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
- // set new text
- gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
+ label = GTK_LABEL( GTK_BIN(menuItem)->child );
#endif
}
break;
menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
#else
menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
- // set new text
- gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
+ label = GTK_LABEL( GTK_BIN(menuItem)->child );
#endif
m_prevRadio = NULL;
break;
}
}
- gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
- GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
- (gpointer)this );
-
- if (pos == -1)
- gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
- else
- gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
}
guint accel_key;
GTK_ACCEL_VISIBLE);
}
+ if (pos == -1)
+ gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
+ else
+ gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
+
gtk_widget_show( menuItem );
if ( !mitem->IsSeparator() )
gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
(gpointer)this );
+
+ if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK )
+ {
+ gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );
+
+ gtk_widget_show( 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
+ {
+ gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
+ GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
+ (gpointer)this );
+ }
+#ifndef __WXGTK20__
+ guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
+ if (accel_key != GDK_VoidSymbol)
+ {
+ gtk_widget_add_accelerator (menuItem,
+ "activate_item",
+ gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
+ accel_key,
+ GDK_MOD1_MASK,
+ GTK_ACCEL_LOCKED);
+ }
+#endif
}
mitem->SetMenuItem(menuItem);
{
GtkWidget *menuItem;
+ wxString text;
+#ifndef __WXGTK20__
+ GtkLabel* label;
+#endif
+
if ( mitem->IsSeparator() )
{
#ifdef __WXGTK20__
// TODO
menuItem = gtk_menu_item_new();
#endif
- if (pos == -1)
- gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
- else
- gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
- }
- else if ( mitem->IsSubMenu() )
- {
- // text has "_" instead of "&" after mitem->SetText()
- wxString text( mitem->GetText() );
-
-#ifdef __WXGTK20__
- menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
-#else
- menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
- // set new text
- gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
-#endif
-
- gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );
- if (pos == -1)
- gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
- else
- gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
-
- gtk_widget_show( 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);
-
- m_prevRadio = NULL;
}
else if (mitem->GetBitmap().Ok())
{
- wxString text = mitem->GetText();
+ text = mitem->GetText();
const wxBitmap *bitmap = &mitem->GetBitmap();
#ifdef __WXGTK20__
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(menuItem), image );
- gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
- GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
- (gpointer)this );
-
- if (pos == -1)
- gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
- else
- gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
#else
GdkPixmap *gdk_pixmap = bitmap->GetPixmap();
GdkBitmap *gdk_bitmap = bitmap->GetMask() ? bitmap->GetMask()->GetBitmap() : (GdkBitmap*) NULL;
menuItem = gtk_pixmap_menu_item_new ();
- GtkWidget *label = gtk_accel_label_new ( wxGTK_CONV( text ) );
+ label = GTK_LABEL(gtk_accel_label_new ( wxGTK_CONV( text ) ));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_container_add (GTK_CONTAINER (menuItem), label);
+ gtk_container_add (GTK_CONTAINER (menuItem), GTK_WIDGET(label));
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuItem);
- guint accel_key;
- GdkModifierType accel_mods;
-
- // accelerator for the item, as specified by its label
- // (ex. Ctrl+O for open)
- gtk_accelerator_parse(GetGtkHotKey(*mitem).c_str(), &accel_key,
- &accel_mods);
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- m_accel,
- accel_key, accel_mods,
- GTK_ACCEL_VISIBLE);
- }
-
- // accelerator for the underlined char (ex ALT+F for the File menu)
- accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU (m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
- gtk_widget_show (label);
+ gtk_widget_show (GTK_WIDGET(label));
- mitem->SetLabelWidget(label);
+ mitem->SetLabelWidget(GTK_WIDGET(label));
GtkWidget* pixmap = gtk_pixmap_new( gdk_pixmap, gdk_bitmap );
gtk_widget_show(pixmap);
gtk_pixmap_menu_item_set_pixmap(GTK_PIXMAP_MENU_ITEM( menuItem ), pixmap);
- gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
- GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
- (gpointer)this );
-
- if (pos == -1)
- gtk_menu_append( GTK_MENU(m_menu), menuItem );
- else
- gtk_menu_insert( GTK_MENU(m_menu), menuItem, pos );
- gtk_widget_show( menuItem );
#endif
m_prevRadio = NULL;
else // a normal item
{
// text has "_" instead of "&" after mitem->SetText() so don't use it
- wxString text( mitem->GetText() );
+ text = mitem->GetText() ;
switch ( mitem->GetKind() )
{
menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
#else
menuItem = gtk_check_menu_item_new_with_label( wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
+ label = GTK_LABEL( GTK_BIN(menuItem)->child );
// set new text
gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
#endif
m_prevRadio = NULL;
break;
m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
#else
m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
+ label = GTK_LABEL( GTK_BIN(menuItem)->child );
// set new text
gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
#endif
}
else // continue the radio group
#else
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
- // set new text
- gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
+ label = GTK_LABEL( GTK_BIN(menuItem)->child );
#endif
}
break;
menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
#else
menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
- GtkLabel *label = GTK_LABEL( GTK_BIN(menuItem)->child );
- // set new text
- gtk_label_set_text( label, wxGTK_CONV( text ) );
- // reparse key accel
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
- if (accel_key != GDK_VoidSymbol)
- {
- gtk_widget_add_accelerator (menuItem,
- "activate_item",
- gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
- accel_key,
- GDK_MOD1_MASK,
- GTK_ACCEL_LOCKED);
- }
+ label = GTK_LABEL( GTK_BIN(menuItem)->child );
#endif
m_prevRadio = NULL;
break;
}
}
- gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
- GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
- (gpointer)this );
-
- if (pos == -1)
- gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
- else
- gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
}
guint accel_key;
GTK_ACCEL_VISIBLE);
}
+ if (pos == -1)
+ gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
+ else
+ gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);
+
gtk_widget_show( menuItem );
if ( !mitem->IsSeparator() )
gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
(gpointer)this );
+
+ if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK )
+ {
+ gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );
+
+ gtk_widget_show( 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
+ {
+ gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
+ GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
+ (gpointer)this );
+ }
+#ifndef __WXGTK20__
+ guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
+ if (accel_key != GDK_VoidSymbol)
+ {
+ gtk_widget_add_accelerator (menuItem,
+ "activate_item",
+ gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
+ accel_key,
+ GDK_MOD1_MASK,
+ GTK_ACCEL_LOCKED);
+ }
+#endif
}
mitem->SetMenuItem(menuItem);