}
}
- return GetEventHandler()->ProcessEvent(commandEvent);
+ GetEventHandler()->ProcessEvent(commandEvent);
+ return TRUE;
#else // !wxUSE_MENUS
return FALSE;
#endif // wxUSE_MENUS/!wxUSE_MENUS
wxMenuEvent event( wxEVT_MENU_OPEN, -1 );
event.SetEventObject( menu );
- if (menu->GetEventHandler()->ProcessEvent(event))
+ wxEvtHandler* handler = menu->GetEventHandler();
+ if (handler && handler->ProcessEvent(event))
return;
wxWindow *win = menu->GetInvokingWindow();
buf << wxT('/') << str.c_str();
// local buffer in multibyte form
- char cbuf[400];
+ char cbuf[400];
strcpy(cbuf, wxGTK_CONV(buf) );
GtkItemFactoryEntry entry;
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
+ // in order to get the pointer to the item we need the item text _without_ underscores
wxString tmp = wxT("<main>/");
const wxChar *pc;
for ( pc = str; *pc != wxT('\0'); pc++ )
else
menucopy->Append (itemid, text, CopyMenu(submenu),
menu->GetHelpString(itemid));
-
+
node = node->GetNext();
}
-
+
return menucopy;
}
if (!menu->IsEnabled(id))
return;
- wxMenuItem* item = menu->FindChildItem( id );
- wxCHECK_RET( item, wxT("error in menu item callback") );
-
- if (item->IsCheckable())
+ if ( menu->IsAttached() ) // is this menu on a menubar?
{
- bool isReallyChecked = item->IsChecked(),
- isInternallyChecked = item->wxMenuItemBase::IsChecked();
-
- // ensure that the internal state is always consistent with what is
- // shown on the screen
- item->wxMenuItemBase::Check(isReallyChecked);
+ wxFrame* frame = menu->GetMenuBar()->GetFrame();
+ frame->ProcessCommand(id);
+ }
+ else
+ {
+ wxMenuItem* item = menu->FindChildItem( id );
+ wxCHECK_RET( item, wxT("error in menu item callback") );
- // we must not report the events for the radio button going up nor the
- // events resulting from the calls to wxMenuItem::Check()
- if ( (item->GetKind() == wxITEM_RADIO && !isReallyChecked) ||
- (isInternallyChecked == isReallyChecked) )
+ if (item->IsCheckable())
{
- return;
+ bool isReallyChecked = item->IsChecked(),
+ isInternallyChecked = item->wxMenuItemBase::IsChecked();
+
+ // ensure that the internal state is always consistent with what is
+ // shown on the screen
+ item->wxMenuItemBase::Check(isReallyChecked);
+
+ // we must not report the events for the radio button going up nor the
+ // events resulting from the calls to wxMenuItem::Check()
+ if ( (item->GetKind() == wxITEM_RADIO && !isReallyChecked) ||
+ (isInternallyChecked == isReallyChecked) )
+ {
+ return;
+ }
+
+ // the user pressed on the menu item: report the event below
}
- // the user pressed on the menu item: report the event below
+ menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
}
-
- menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
}
//-----------------------------------------------------------------------------
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
event.SetEventObject( menu );
- if (menu->GetEventHandler()->ProcessEvent(event))
+ wxEvtHandler* handler = menu->GetEventHandler();
+ if (handler && handler->ProcessEvent(event))
return;
wxWindow *win = menu->GetInvokingWindow();
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 );
event.SetEventObject( menu );
- if (menu->GetEventHandler()->ProcessEvent(event))
+ wxEvtHandler* handler = menu->GetEventHandler();
+ if (handler && handler->ProcessEvent(event))
return;
wxWindow *win = menu->GetInvokingWindow();
// "&" is doubled to indicate "&" instead of accelerator
continue;
}
-
+
label += *pc;
}
-
+
// wxPrintf( L"text %s label %s\n", text.c_str(), label.c_str() );
return label;
wxString label1 = wxStripMenuCodes(str.BeforeFirst('\t'));
if (oldLabel == label1)
return;
-
+
DoSetText(str);
if (m_menuItem)
if (m_text[n] != wxT('\\'))
tmp += m_text[n];
}
-
+
gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(tmp) );
#else
// set new text
}
++pc;
}
-
+
// wxPrintf( L"str %s m_text %s\n", str.c_str(), m_text.c_str() );
-
+
m_hotKey = wxT("");
if(*pc == wxT('\t'))
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
(gpointer)this );
-
+
gtk_menu_append( GTK_MENU(m_menu), menuItem );
gtk_widget_show( menuItem );
wxString path( mitem->GetFactoryPath() );
menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) );
-
+
if (!menuItem)
wxLogError( wxT("Wrong menu path: %s\n"), path.c_str() );
}
if ( !mitem->IsSeparator() )
{
wxASSERT_MSG( menuItem, wxT("invalid menuitem") );
-
+
gtk_signal_connect( GTK_OBJECT(menuItem), "select",
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
(gpointer)this );
wxMenuEvent event( wxEVT_MENU_OPEN, -1 );
event.SetEventObject( menu );
- if (menu->GetEventHandler()->ProcessEvent(event))
+ wxEvtHandler* handler = menu->GetEventHandler();
+ if (handler && handler->ProcessEvent(event))
return;
wxWindow *win = menu->GetInvokingWindow();
buf << wxT('/') << str.c_str();
// local buffer in multibyte form
- char cbuf[400];
+ char cbuf[400];
strcpy(cbuf, wxGTK_CONV(buf) );
GtkItemFactoryEntry entry;
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
+ // in order to get the pointer to the item we need the item text _without_ underscores
wxString tmp = wxT("<main>/");
const wxChar *pc;
for ( pc = str; *pc != wxT('\0'); pc++ )
else
menucopy->Append (itemid, text, CopyMenu(submenu),
menu->GetHelpString(itemid));
-
+
node = node->GetNext();
}
-
+
return menucopy;
}
if (!menu->IsEnabled(id))
return;
- wxMenuItem* item = menu->FindChildItem( id );
- wxCHECK_RET( item, wxT("error in menu item callback") );
-
- if (item->IsCheckable())
+ if ( menu->IsAttached() ) // is this menu on a menubar?
{
- bool isReallyChecked = item->IsChecked(),
- isInternallyChecked = item->wxMenuItemBase::IsChecked();
-
- // ensure that the internal state is always consistent with what is
- // shown on the screen
- item->wxMenuItemBase::Check(isReallyChecked);
+ wxFrame* frame = menu->GetMenuBar()->GetFrame();
+ frame->ProcessCommand(id);
+ }
+ else
+ {
+ wxMenuItem* item = menu->FindChildItem( id );
+ wxCHECK_RET( item, wxT("error in menu item callback") );
- // we must not report the events for the radio button going up nor the
- // events resulting from the calls to wxMenuItem::Check()
- if ( (item->GetKind() == wxITEM_RADIO && !isReallyChecked) ||
- (isInternallyChecked == isReallyChecked) )
+ if (item->IsCheckable())
{
- return;
+ bool isReallyChecked = item->IsChecked(),
+ isInternallyChecked = item->wxMenuItemBase::IsChecked();
+
+ // ensure that the internal state is always consistent with what is
+ // shown on the screen
+ item->wxMenuItemBase::Check(isReallyChecked);
+
+ // we must not report the events for the radio button going up nor the
+ // events resulting from the calls to wxMenuItem::Check()
+ if ( (item->GetKind() == wxITEM_RADIO && !isReallyChecked) ||
+ (isInternallyChecked == isReallyChecked) )
+ {
+ return;
+ }
+
+ // the user pressed on the menu item: report the event below
}
- // the user pressed on the menu item: report the event below
+ menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
}
-
- menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
}
//-----------------------------------------------------------------------------
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
event.SetEventObject( menu );
- if (menu->GetEventHandler()->ProcessEvent(event))
+ wxEvtHandler* handler = menu->GetEventHandler();
+ if (handler && handler->ProcessEvent(event))
return;
wxWindow *win = menu->GetInvokingWindow();
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 );
event.SetEventObject( menu );
- if (menu->GetEventHandler()->ProcessEvent(event))
+ wxEvtHandler* handler = menu->GetEventHandler();
+ if (handler && handler->ProcessEvent(event))
return;
wxWindow *win = menu->GetInvokingWindow();
// "&" is doubled to indicate "&" instead of accelerator
continue;
}
-
+
label += *pc;
}
-
+
// wxPrintf( L"text %s label %s\n", text.c_str(), label.c_str() );
return label;
wxString label1 = wxStripMenuCodes(str.BeforeFirst('\t'));
if (oldLabel == label1)
return;
-
+
DoSetText(str);
if (m_menuItem)
if (m_text[n] != wxT('\\'))
tmp += m_text[n];
}
-
+
gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(tmp) );
#else
// set new text
}
++pc;
}
-
+
// wxPrintf( L"str %s m_text %s\n", str.c_str(), m_text.c_str() );
-
+
m_hotKey = wxT("");
if(*pc == wxT('\t'))
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
(gpointer)this );
-
+
gtk_menu_append( GTK_MENU(m_menu), menuItem );
gtk_widget_show( menuItem );
wxString path( mitem->GetFactoryPath() );
menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) );
-
+
if (!menuItem)
wxLogError( wxT("Wrong menu path: %s\n"), path.c_str() );
}
if ( !mitem->IsSeparator() )
{
wxASSERT_MSG( menuItem, wxT("invalid menuitem") );
-
+
gtk_signal_connect( GTK_OBJECT(menuItem), "select",
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
(gpointer)this );
void wxApp::MacHandleMenuCommand( wxUint32 id )
{
- wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
- wxMenu* menu = NULL ;
- wxMenuItem* item = NULL ;
- if ( mbar )
- {
- item = mbar->FindItem( id , &menu ) ;
- }
- wxCHECK_RET( item != NULL && menu != NULL && mbar != NULL, wxT("error in menu item callback") );
-
- if (item->IsCheckable())
- {
- item->Check( !item->IsChecked() ) ;
- }
-
- menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
+ wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
+ wxFrame* frame = mbar->GetFrame();
+ wxCHECK_RET( mbar != NULL && frame != NULL, wxT("error in menu item callback") );
+ if ( frame )
+ {
+ frame->ProcessCommand(id);
+ }
}
#if !TARGET_CARBON
void wxApp::MacHandleMenuCommand( wxUint32 id )
{
- wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
- wxMenu* menu = NULL ;
- wxMenuItem* item = NULL ;
- if ( mbar )
- {
- item = mbar->FindItem( id , &menu ) ;
- }
- wxCHECK_RET( item != NULL && menu != NULL && mbar != NULL, wxT("error in menu item callback") );
-
- if (item->IsCheckable())
- {
- item->Check( !item->IsChecked() ) ;
- }
-
- menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
+ wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
+ wxFrame* frame = mbar->GetFrame();
+ wxCHECK_RET( mbar != NULL && frame != NULL, wxT("error in menu item callback") );
+ if ( frame )
+ {
+ frame->ProcessCommand(id);
+ }
}
#if !TARGET_CARBON