+ wxNode *node = m_menus.First();
+ while (node)
+ {
+ wxMenu *menu = (wxMenu*)node->Data();
+ int res = FindMenuItemRecursive( menu, menuString, itemString);
+ if (res != -1) return res;
+ node = node->Next();
+ }
+ return -1;
+}
+
+// Find a wxMenuItem using its id. Recurses down into sub-menus
+static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id)
+{
+ wxMenuItem* result = menu->FindItem(id);
+
+ wxNode *node = ((wxMenu *)menu)->GetItems().First(); // const_cast
+ while ( node && result == NULL )
+ {
+ wxMenuItem *item = (wxMenuItem*)node->Data();
+ if (item->IsSubMenu())
+ {
+ result = FindMenuItemByIdRecursive( item->GetSubMenu(), id );
+ }
+ node = node->Next();
+ }
+
+ return result;
+}
+
+wxMenuItem* wxMenuBar::FindItem( int id ) const
+{
+ wxMenuItem* result = 0;
+ wxNode *node = m_menus.First();
+ while (node && result == 0)
+ {
+ wxMenu *menu = (wxMenu*)node->Data();
+ result = FindMenuItemByIdRecursive( menu, id );
+ node = node->Next();
+ }
+
+ return result;
+}
+
+void wxMenuBar::Check( int id, bool check )
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ wxCHECK_RET( item, _T("wxMenuBar::Check: no such item") );
+
+ item->Check(check);
+}
+
+bool wxMenuBar::IsChecked( int id ) const
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ wxCHECK_MSG( item, FALSE, _T("wxMenuBar::IsChecked: no such item") );
+
+ return item->IsChecked();
+}
+
+void wxMenuBar::Enable( int id, bool enable )
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ wxCHECK_RET( item, _T("wxMenuBar::Enable: no such item") );
+
+ item->Enable(enable);
+}
+
+bool wxMenuBar::IsEnabled( int id ) const
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ wxCHECK_MSG( item, FALSE, _T("wxMenuBar::IsEnabled: no such item") );
+
+ return item->IsEnabled();
+}
+
+wxString wxMenuBar::GetLabel( int id ) const
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ wxCHECK_MSG( item, _T(""), _T("wxMenuBar::GetLabel: no such item") );
+
+ return item->GetText();
+}
+
+void wxMenuBar::SetLabel( int id, const wxString &label )
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ wxCHECK_RET( item, _T("wxMenuBar::SetLabel: no such item") );
+
+ item->SetText( label );
+}
+
+void wxMenuBar::EnableTop( int pos, bool flag )
+{
+ wxNode *node = m_menus.Nth( pos );
+
+ wxCHECK_RET( node, _T("menu not found") );
+
+ wxMenu* menu = (wxMenu*)node->Data();
+
+ if (menu->m_owner)
+ gtk_widget_set_sensitive( menu->m_owner, flag );
+}
+
+wxString wxMenuBar::GetLabelTop( int pos ) const
+{
+ wxNode *node = m_menus.Nth( pos );
+
+ wxCHECK_MSG( node, _T("invalid"), _T("menu not found") );
+
+ wxMenu* menu = (wxMenu*)node->Data();
+
+ return menu->GetTitle();
+}
+
+void wxMenuBar::SetLabelTop( int pos, const wxString& label )
+{
+ wxNode *node = m_menus.Nth( pos );
+
+ wxCHECK_RET( node, _T("menu not found") );
+
+ wxMenu* menu = (wxMenu*)node->Data();
+
+ menu->SetTitle( label );
+}
+
+void wxMenuBar::SetHelpString( int id, const wxString& helpString )
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ wxCHECK_RET( item, _T("wxMenuBar::SetHelpString: no such item") );
+
+ item->SetHelp( helpString );
+}
+
+wxString wxMenuBar::GetHelpString( int id ) const
+{
+ wxMenuItem* item = FindMenuItemById( id );
+
+ wxCHECK_MSG( item, _T(""), _T("wxMenuBar::GetHelpString: no such item") );
+
+ return item->GetHelp();
+}