X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/96fd301f0ec23e7a5e9a72aa80c5fccadd8eeb37..fc008f25922fe85d2308d4335c3cbc0ad436c60d:/src/gtk1/menu.cpp diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 2e1002c982..93bc49891b 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -15,6 +15,7 @@ #include "wx/menu.h" #include "wx/log.h" +#include "wx/intl.h" //----------------------------------------------------------------------------- // wxMenuBar @@ -48,11 +49,11 @@ void wxMenuBar::Append( wxMenu *menu, const wxString &title ) m_menus.Append( menu ); menu->m_title = title; // ?????? - size_t pos; + int pos; do { pos = menu->m_title.First( '&' ); - if (pos != wxString::npos) menu->m_title.Remove( pos, 1 ); - } while (pos != wxString::npos); + if (pos != -1) menu->m_title.Remove( pos, 1 ); + } while (pos != -1); GtkWidget *root_menu; root_menu = gtk_menu_item_new_with_label( WXSTRINGCAST(menu->m_title) ); @@ -122,19 +123,31 @@ wxMenuItem* wxMenuBar::FindMenuItemById( int id ) const return result; } -bool wxMenuBar::IsChecked( int id ) const +void wxMenuBar::Check( int id, bool check ) +{ + wxMenuItem* item = FindMenuItemById( id ); + if (item) item->Check(check); +}; + +bool wxMenuBar::Checked( int id ) const { wxMenuItem* item = FindMenuItemById( id ); if (item) return item->IsChecked(); return FALSE; -} +}; -bool wxMenuBar::IsEnabled( int id ) const +void wxMenuBar::Enable( int id, bool enable ) +{ + wxMenuItem* item = FindMenuItemById( id ); + if (item) item->Enable(enable); +}; + +bool wxMenuBar::Enabled( int id ) const { wxMenuItem* item = FindMenuItemById( id ); if (item) return item->IsEnabled(); return FALSE; -} +}; //----------------------------------------------------------------------------- // wxMenu @@ -154,7 +167,7 @@ void gtk_menu_clicked_callback( GtkWidget *widget, gpointer data ) event.SetEventObject( menu ); event.SetInt(id ); wxWindow *win = menu->GetInvokingWindow(); - if (win) win->ProcessEvent( event ); + if (win) win->GetEventHandler()->ProcessEvent( event ); }; IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject) @@ -171,6 +184,7 @@ wxMenuItem::wxMenuItem() void wxMenuItem::SetText(const wxString& str) { + m_text = ""; for ( const char *pc = str; *pc != '\0'; pc++ ) { if ( *pc == '&' ) pc++; // skip it @@ -181,7 +195,7 @@ void wxMenuItem::SetText(const wxString& str) void wxMenuItem::Check( bool check ) { - wxCHECK_RET( IsCheckable(), "can't check uncheckable item!" ) + wxCHECK_RET( IsCheckable(), _("Can't check uncheckable item!") ) m_isChecked = check; gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check ); @@ -262,11 +276,11 @@ int wxMenu::FindItem( const wxString itemString ) const { wxString s( itemString ); - size_t pos; + int pos; do { pos = s.First( '&' ); - if (pos != wxString::npos) s.Remove( pos, 1 ); - } while (pos != wxString::npos); + if (pos != -1) s.Remove( pos, 1 ); + } while (pos != -1); wxNode *node = m_items.First(); while (node) @@ -343,7 +357,7 @@ wxMenuItem *wxMenu::FindItem(int id) const node = node->Next(); }; - wxLogDebug("wxMenu::FindItem: item %d not found.", id); + wxLogDebug(_("wxMenu::FindItem: item %d not found."), id); return NULL; }