entry.accelerator = (gchar*) NULL;
entry.callback = (GtkItemFactoryCallback) NULL;
entry.callback_action = 0;
- entry.item_type = "<Branch>";
+ entry.item_type = (char *)"<Branch>";
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
/* in order to get the pointer to the item we need the item text _without_ underscores */
static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
{
- if (g_isIdle) wxapp_install_idle_handler();
+ if (g_isIdle)
+ wxapp_install_idle_handler();
int id = menu->FindMenuIdByMenuItem(widget);
/* should find it for normal (not popup) menu */
- wxASSERT( (id != -1) || (menu->GetInvokingWindow() != NULL) );
+ wxASSERT_MSG( (id != -1) || (menu->GetInvokingWindow() != NULL),
+ _T("menu item not found in gtk_menu_clicked_callback") );
if (!menu->IsEnabled(id))
return;
}
}
- wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, id );
- event.SetEventObject( menu );
- if (item->IsCheckable())
- event.SetInt( item->IsChecked() );
-
-#if wxUSE_MENU_CALLBACK
- if (menu->GetCallback())
- {
- (void) (*(menu->GetCallback())) (*menu, event);
- return;
- }
-#endif // wxUSE_MENU_CALLBACK
-
- if (menu->GetEventHandler()->ProcessEvent(event))
- return;
-
- wxWindow *win = menu->GetInvokingWindow();
- if (win)
- win->GetEventHandler()->ProcessEvent( event );
+ menu->SendEvent(item->GetId(), item->IsCheckable() ? item->IsChecked() : -1);
}
//-----------------------------------------------------------------------------
wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
{
wxString label;
-#if (GTK_MINOR_VERSION > 0)
+
for ( const wxChar *pc = text.c_str(); *pc; pc++ )
{
- if ( *pc == wxT('_') || *pc == wxT('&') )
+ if ( *pc == wxT('_') )
{
- // '_' is the escape character for GTK+ and '&' is the one for
- // wxWindows - skip both of them
+ // wxGTK escapes "xxx_xxx" to "xxx__xxx"
+ pc++;
+ label += *pc;
+ continue;
+ }
+
+ if ( *pc == wxT('&') )
+ {
+ // wxMSW escapes &
continue;
}
label += *pc;
}
-#else // GTK+ 1.0
- label = text;
-#endif // GTK+ 1.2/1.0
return label;
}
wxString wxMenuItem::GetFactoryPath() const
{
- /* in order to get the pointer to the item we need the item text _without_
- underscores */
+ /* in order to get the pointer to the item we need the item text
+ _without_ underscores */
wxString path( wxT("<main>/") );
- path += GetLabel();
+ for ( const wxChar *pc = m_text.c_str(); *pc; pc++ )
+ {
+ if ( *pc == wxT('_') || *pc == wxT('&') )
+ {
+ // remove '_' and '&' unconditionally
+ continue;
+ }
+
+ path += *pc;
+ }
+
return path;
}
if(m_style & wxMENU_TEAROFF)
{
GtkItemFactoryEntry entry;
- entry.path = "/tearoff";
+ entry.path = (char *)"/tearoff";
entry.callback = (GtkItemFactoryCallback) NULL;
entry.callback_action = 0;
- entry.item_type = "<Tearoff>";
+ entry.item_type = (char *)"<Tearoff>";
entry.accelerator = (gchar*) NULL;
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
//GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, "<main>/tearoff" );
{
#if (GTK_MINOR_VERSION > 0)
GtkItemFactoryEntry entry;
- entry.path = "/sep";
+ entry.path = (char *)"/sep";
entry.callback = (GtkItemFactoryCallback) NULL;
entry.callback_action = 0;
- entry.item_type = "<Separator>";
+ entry.item_type = (char *)"<Separator>";
entry.accelerator = (gchar*) NULL;
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
entry.path = buf;
entry.callback = (GtkItemFactoryCallback) 0;
entry.callback_action = 0;
- entry.item_type = "<Branch>";
+ entry.item_type = (char *)"<Branch>";
entry.accelerator = (gchar*) NULL;
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
entry.callback_action = 0;
if ( mitem->IsCheckable() )
- entry.item_type = "<CheckItem>";
+ entry.item_type = (char *)"<CheckItem>";
else
- entry.item_type = "<Item>";
+ entry.item_type = (char *)"<Item>";
entry.accelerator = (gchar*) NULL;
#if wxUSE_ACCEL
#include <gtk/gtkmenu.h>
#include <gtk/gtkcontainer.h>
+extern "C"
+{
+
static void gtk_pixmap_menu_item_class_init (GtkPixmapMenuItemClass *klass);
static void gtk_pixmap_menu_item_init (GtkPixmapMenuItem *menu_item);
static void gtk_pixmap_menu_item_draw (GtkWidget *widget,
static GtkMenuItemClass *parent_class = NULL;
+}
+
#define BORDER_SPACING 3
#define PMAP_WIDTH 20
{
GtkTypeInfo pixmap_menu_item_info =
{
- "GtkPixmapMenuItem",
+ (char *)"GtkPixmapMenuItem",
sizeof (GtkPixmapMenuItem),
sizeof (GtkPixmapMenuItemClass),
(GtkClassInitFunc) gtk_pixmap_menu_item_class_init,