1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMenu, wxMenuBar, wxMenuItem
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 // ============================================================================
14 // headers & declarations
15 // ============================================================================
21 #pragma implementation "menu.h"
22 #pragma implementation "menuitem.h"
27 #include "wx/menuitem.h"
28 #include "wx/window.h"
32 #include "wx/mac/uma.h"
34 // other standard headers
35 // ----------------------
38 #if !USE_SHARED_LIBRARY
39 IMPLEMENT_DYNAMIC_CLASS(wxMenu
, wxEvtHandler
)
40 IMPLEMENT_DYNAMIC_CLASS(wxMenuBar
, wxEvtHandler
)
43 // the (popup) menu title has this special id
44 static const int idMenuTitle
= -2;
45 static int formerHelpMenuItems
= 0 ;
47 const short kwxMacMenuBarResource
= 1 ;
48 const short kwxMacAppleMenuId
= 1 ;
50 // ============================================================================
52 // ============================================================================
57 // Construct a menu with optional title (then use append)
60 short wxMenu::s_macNextMenuId
= 3 ;
62 short wxMenu::s_macNextMenuId
= 2 ;
71 wxMenuItem::MacBuildMenuString( label
, NULL
, NULL
, m_title
, false );
72 m_macMenuId
= s_macNextMenuId
++;
73 wxCHECK_RET( s_macNextMenuId
< 236 , "menu ids > 235 cannot be used for submenus on mac" );
74 m_hMenu
= UMANewMenu(m_macMenuId
, label
);
78 wxLogLastError("CreatePopupMenu");
81 // if we have a title, insert it in the beginning of the menu
84 Append(idMenuTitle
, m_title
) ;
92 UMADisposeMenu(m_hMenu
);
96 WX_CLEAR_ARRAY(m_accels
);
102 // not available on the mac platform
107 int wxMenu::FindAccel(int id
) const
109 size_t n
, count
= m_accels
.GetCount();
110 for ( n
= 0; n
< count
; n
++ )
112 if ( m_accels
[n
]->m_command
== id
)
119 void wxMenu::UpdateAccel(wxMenuItem
*item
)
121 // find the (new) accel for this item
122 wxAcceleratorEntry
*accel
= wxGetAccelFromString(item
->GetText());
124 accel
->m_command
= item
->GetId();
127 int n
= FindAccel(item
->GetId());
128 if ( n
== wxNOT_FOUND
)
130 // no old, add new if any
134 return; // skipping RebuildAccelTable() below
138 // replace old with new or just remove the old one if no new
148 m_menuBar
->RebuildAccelTable();
152 #endif // wxUSE_ACCEL
154 // function appends a new item or submenu to the menu
155 // append a new item or submenu to the menu
156 bool wxMenu::DoInsertOrAppend(wxMenuItem
*pItem
, size_t pos
)
158 wxASSERT_MSG( pItem
!= NULL
, "can't append NULL item to the menu" );
161 #endif // wxUSE_ACCEL
163 if ( pItem
->IsSeparator() )
165 if ( pos
== (size_t)-1 )
167 MacAppendMenu(m_hMenu
, "\p-");
171 MacInsertMenuItem(m_hMenu
, "\p-" , pos
);
176 wxMenu
*pSubMenu
= pItem
->GetSubMenu() ;
177 if ( pSubMenu
!= NULL
)
180 wxASSERT_MSG( pSubMenu
->m_hMenu
!= NULL
, "invalid submenu added");
181 pSubMenu
->m_menuParent
= this ;
182 wxMenuItem::MacBuildMenuString( label
, NULL
, NULL
, pItem
->GetText() ,false);
184 if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar
)
186 UMAInsertMenu( pSubMenu
->m_hMenu
, -1 ) ;
189 if ( pos
== (size_t)-1 )
191 UMAAppendSubMenuItem(m_hMenu
, label
, pSubMenu
->m_macMenuId
);
195 UMAInsertSubMenuItem(m_hMenu
, label
, pos
, pSubMenu
->m_macMenuId
);
203 wxMenuItem::MacBuildMenuString( label
, &key
, &modifiers
, pItem
->GetText(), pItem
->GetId() == wxApp::s_macAboutMenuItemId
);
206 // we cannot add empty menus on mac
210 if ( pos
== (size_t)-1 )
212 UMAAppendMenuItem(m_hMenu
, label
,key
,modifiers
);
216 UMAInsertMenuItem(m_hMenu
, label
, pos
,key
,modifiers
);
218 if ( pItem
->GetId() == idMenuTitle
)
220 if ( pos
== (size_t)-1 )
222 UMADisableMenuItem( m_hMenu
, CountMenuItems( m_hMenu
) ) ;
226 UMADisableMenuItem( m_hMenu
, pos
+ 1 ) ;
231 // if we're already attached to the menubar, we must update it
234 m_menuBar
->Refresh();
239 bool wxMenu::DoAppend(wxMenuItem
*item
)
241 return wxMenuBase::DoAppend(item
) && DoInsertOrAppend(item
);
244 bool wxMenu::DoInsert(size_t pos
, wxMenuItem
*item
)
246 return wxMenuBase::DoInsert(pos
, item
) && DoInsertOrAppend(item
, pos
);
249 wxMenuItem
*wxMenu::DoRemove(wxMenuItem
*item
)
251 // we need to find the items position in the child list
253 wxMenuItemList::Node
*node
= GetMenuItems().GetFirst();
254 for ( pos
= 0; node
; pos
++ )
256 if ( node
->GetData() == item
)
259 node
= node
->GetNext();
262 // DoRemove() (unlike Remove) can only be called for existing item!
263 wxCHECK_MSG( node
, NULL
, wxT("bug in wxMenu::Remove logic") );
266 // remove the corresponding accel from the accel table
267 int n
= FindAccel(item
->GetId());
268 if ( n
!= wxNOT_FOUND
)
274 //else: this item doesn't have an accel, nothing to do
275 #endif // wxUSE_ACCEL
277 ::DeleteMenuItem( m_hMenu
, pos
+ 1);
281 // otherwise, the chane won't be visible
282 m_menuBar
->Refresh();
285 // and from internal data structures
286 return wxMenuBase::DoRemove(item
);
289 // ---------------------------------------------------------------------------
290 // accelerator helpers
291 // ---------------------------------------------------------------------------
295 // create the wxAcceleratorEntries for our accels and put them into provided
296 // array - return the number of accels we have
297 size_t wxMenu::CopyAccels(wxAcceleratorEntry
*accels
) const
299 size_t count
= GetAccelCount();
300 for ( size_t n
= 0; n
< count
; n
++ )
302 *accels
++ = *m_accels
[n
];
308 #endif // wxUSE_ACCEL
310 void wxMenu::SetTitle(const wxString
& label
)
314 wxMenuItem::MacBuildMenuString( title
, NULL
, NULL
, label
, false );
315 UMASetMenuTitle( m_hMenu
, title
) ;
317 bool wxMenu::ProcessCommand(wxCommandEvent
& event
)
319 bool processed
= FALSE
;
321 #if WXWIN_COMPATIBILITY
325 (void)(*(m_callback
))(*this, event
);
328 #endif WXWIN_COMPATIBILITY
330 // Try the menu's event handler
331 if ( !processed
&& GetEventHandler())
333 processed
= GetEventHandler()->ProcessEvent(event
);
336 // Try the window the menu was popped up from (and up through the
338 wxWindow
*win
= GetInvokingWindow();
339 if ( !processed
&& win
)
340 processed
= win
->GetEventHandler()->ProcessEvent(event
);
346 // ---------------------------------------------------------------------------
348 // ---------------------------------------------------------------------------
350 void wxMenu::Attach(wxMenuBar
*menubar
)
352 // menu can be in at most one menubar because otherwise they would both
353 // delete the menu pointer
354 wxASSERT_MSG( !m_menuBar
, wxT("menu belongs to 2 menubars, expect a crash") );
359 void wxMenu::Detach()
361 wxASSERT_MSG( m_menuBar
, wxT("can't detach menu if it's not attached") );
366 wxWindow
*wxMenu::GetWindow() const
368 if ( m_invokingWindow
!= NULL
)
369 return m_invokingWindow
;
370 else if ( m_menuBar
!= NULL
)
371 return (wxWindow
*) m_menuBar
->GetFrame();
376 // helper functions returning the mac menu position for a certain item, note that this is
377 // mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0
379 int wxMenu::MacGetIndexFromId( int id
)
382 wxMenuItemList::Node
*node
= GetMenuItems().GetFirst();
383 for ( pos
= 0; node
; pos
++ )
385 if ( node
->GetData()->GetId() == id
)
388 node
= node
->GetNext();
397 int wxMenu::MacGetIndexFromItem( wxMenuItem
*pItem
)
400 wxMenuItemList::Node
*node
= GetMenuItems().GetFirst();
401 for ( pos
= 0; node
; pos
++ )
403 if ( node
->GetData() == pItem
)
406 node
= node
->GetNext();
415 void wxMenu::MacEnableMenu( bool bDoEnable
)
418 UMAEnableMenuItem( m_hMenu
, 0 ) ;
420 UMADisableMenuItem( m_hMenu
, 0 ) ;
425 bool wxMenu::MacMenuSelect( wxEvtHandler
* handler
, long when
, int macMenuId
, int macMenuItemNum
)
430 if ( m_macMenuId
== macMenuId
)
432 node
= GetMenuItems().Nth(macMenuItemNum
-1);
435 wxMenuItem
*pItem
= (wxMenuItem
*)node
->Data();
437 if (pItem
->IsCheckable())
438 pItem
->Check(! pItem
->IsChecked());
440 wxCommandEvent
event(wxEVT_COMMAND_MENU_SELECTED
, pItem
->GetId());
441 event
.m_timeStamp
= when
;
442 event
.SetEventObject(handler
);
443 event
.SetInt( pItem
->GetId() );
445 bool processed
= false ;
447 #if WXWIN_COMPATIBILITY
451 (void) (*(m_callback
)) (*this, event
);
455 // Try the menu's event handler
456 if ( !processed
&& handler
)
458 processed
= handler
->ProcessEvent(event
);
461 // Try the window the menu was popped up from (and up
462 // through the hierarchy)
463 if ( !processed
&& GetInvokingWindow())
464 processed
= GetInvokingWindow()->GetEventHandler()->ProcessEvent(event
);
470 else if ( macMenuId
== kHMHelpMenuID
)
472 int menuItem
= formerHelpMenuItems
;
473 for (pos
= 0, node
= GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
475 wxMenuItem
* pItem
= (wxMenuItem
*) node
->Data() ;
477 wxMenu
*pSubMenu
= pItem
->GetSubMenu() ;
478 if ( pSubMenu
!= NULL
)
483 if ( pItem
->GetId() != wxApp::s_macAboutMenuItemId
)
486 if ( menuItem
== macMenuItemNum
)
488 wxCommandEvent
event(wxEVT_COMMAND_MENU_SELECTED
, pItem
->GetId());
489 event
.m_timeStamp
= when
;
490 event
.SetEventObject(handler
);
491 event
.SetInt( pItem
->GetId() );
493 bool processed
= false ;
494 #if WXWIN_COMPATIBILITY
498 (void) (*(m_callback
)) (*this, event
);
502 // Try the menu's event handler
503 if ( !processed
&& handler
)
505 processed
= handler
->ProcessEvent(event
);
508 // Try the window the menu was popped up from (and up
509 // through the hierarchy)
510 if ( !processed
&& GetInvokingWindow())
511 processed
= GetInvokingWindow()->GetEventHandler()->ProcessEvent(event
);
518 #endif // __WXMAC_X__
520 for (pos
= 0, node
= GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
522 wxMenuItem
* pItem
= (wxMenuItem
*) node
->Data() ;
524 wxMenu
*pSubMenu
= pItem
->GetSubMenu() ;
525 if ( pSubMenu
!= NULL
)
527 if ( pSubMenu
->MacMenuSelect( handler
, when
, macMenuId
, macMenuItemNum
) )
539 Mac Implementation note :
541 The Mac has only one global menubar, so we attempt to install the currently
542 active menubar from a frame, we currently don't take into account mdi-frames
543 which would ask for menu-merging
545 Secondly there is no mac api for changing a menubar that is not the current
546 menubar, so we have to wait for preparing the actual menubar until the
547 wxMenubar is to be used
549 We can in subsequent versions use MacInstallMenuBar to provide some sort of
550 auto-merge for MDI in case this will be necessary
554 wxMenuBar
* wxMenuBar::s_macInstalledMenuBar
= NULL
;
556 void wxMenuBar::Init()
558 m_eventHandler
= this;
559 m_menuBarFrame
= NULL
;
562 wxMenuBar::wxMenuBar()
567 wxMenuBar::wxMenuBar( long WXUNUSED(style
) )
573 wxMenuBar::wxMenuBar(int count
, wxMenu
*menus
[], const wxString titles
[])
577 m_titles
.Alloc(count
);
579 for ( int i
= 0; i
< count
; i
++ )
581 m_menus
.Append(menus
[i
]);
582 m_titles
.Add(titles
[i
]);
584 menus
[i
]->Attach(this);
588 wxMenuBar::~wxMenuBar()
590 if (s_macInstalledMenuBar
== this)
593 s_macInstalledMenuBar
= NULL
;
598 void wxMenuBar::Refresh()
600 wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );
607 void wxMenuBar::RebuildAccelTable()
609 // merge the accelerators of all menus into one accel table
610 size_t nAccelCount
= 0;
611 size_t i
, count
= GetMenuCount();
612 for ( i
= 0; i
< count
; i
++ )
614 nAccelCount
+= m_menus
[i
]->GetAccelCount();
619 wxAcceleratorEntry
*accelEntries
= new wxAcceleratorEntry
[nAccelCount
];
622 for ( i
= 0; i
< count
; i
++ )
624 nAccelCount
+= m_menus
[i
]->CopyAccels(&accelEntries
[nAccelCount
]);
627 m_accelTable
= wxAcceleratorTable(nAccelCount
, accelEntries
);
629 delete [] accelEntries
;
633 #endif // wxUSE_ACCEL
636 void wxMenuBar::MacInstallMenuBar()
638 if ( s_macInstalledMenuBar
== this )
641 Handle menubar
= ::GetNewMBar( kwxMacMenuBarResource
) ;
643 wxCHECK_RET( menubar
!= NULL
, "can't read MBAR resource" );
644 ::SetMenuBar( menubar
) ;
645 ::DisposeHandle( menubar
) ;
647 MenuHandle menu
= ::GetMenuHandle( kwxMacAppleMenuId
) ;
648 ::AppendResMenu(menu
, 'DRVR');
650 for (int i
= 0; i
< m_menus
.GetCount(); i
++)
656 wxMenu
* menu
= m_menus
[i
] , *subMenu
= NULL
;
659 /* the help menu does not exist in CARBON anymore */
660 if( m_titles
[i
] == "?" || m_titles
[i
] == "&?" || m_titles
[i
] == wxApp::s_macHelpMenuTitleName
)
662 MenuHandle mh
= NULL
;
663 if ( HMGetHelpMenuHandle( &mh
) != noErr
)
667 if ( formerHelpMenuItems
== 0 )
670 formerHelpMenuItems
= CountMenuItems( mh
) ;
673 for (pos
= 0 , node
= menu
->GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
675 item
= (wxMenuItem
*)node
->Data();
676 subMenu
= item
->GetSubMenu() ;
679 // we don't support hierarchical menus in the help menu yet
683 if ( item
->IsSeparator() )
686 UMAAppendMenuItem(mh
, "\p-" );
693 wxMenuItem::MacBuildMenuString( label
, &key
, &modifiers
, item
->GetText(), item
->GetId() != wxApp::s_macAboutMenuItemId
); // no shortcut in about menu
696 // we cannot add empty menus on mac
700 if ( item
->GetId() == wxApp::s_macAboutMenuItemId
)
702 UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId
) , 1 , label
);
703 UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId
) , 1 );
708 UMAAppendMenuItem(mh
, label
, key
, modifiers
);
715 if( m_titles
[i
] == "?" || m_titles
[i
] == "&?" || m_titles
[i
] == wxApp::s_macHelpMenuTitleName
)
717 wxMenuItem::MacBuildMenuString( label
, NULL
, NULL
, m_titles
[i
] , false );
718 UMASetMenuTitle( menu
->GetHMenu() , label
) ;
720 for (pos
= 0 , node
= menu
->GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
722 item
= (wxMenuItem
*)node
->Data();
723 subMenu
= item
->GetSubMenu() ;
726 UMAInsertMenu( subMenu
->GetHMenu() , -1 ) ;
730 if ( item
->GetId() == wxApp::s_macAboutMenuItemId
)
735 wxMenuItem::MacBuildMenuString( label
, &key
, &modifiers
, item
->GetText(), item
->GetId() != wxApp::s_macAboutMenuItemId
); // no shortcut in about menu
736 UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId
) , 1 , label
);
737 UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId
) , 1 );
741 UMAInsertMenu(m_menus
[i
]->GetHMenu(), 0);
746 wxMenuItem::MacBuildMenuString( label
, NULL
, NULL
, m_titles
[i
] , false );
747 UMASetMenuTitle( menu
->GetHMenu() , label
) ;
748 for (pos
= 0, node
= menu
->GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
750 item
= (wxMenuItem
*)node
->Data();
751 subMenu
= item
->GetSubMenu() ;
754 UMAInsertMenu( subMenu
->GetHMenu() , -1 ) ;
757 UMAInsertMenu(m_menus
[i
]->GetHMenu(), 0);
762 s_macInstalledMenuBar
= this;
765 void wxMenuBar::EnableTop(size_t pos
, bool enable
)
767 wxCHECK_RET( IsAttached(), wxT("doesn't work with unattached menubars") );
768 m_menus
[pos
]->MacEnableMenu( enable
) ;
772 void wxMenuBar::SetLabelTop(size_t pos
, const wxString
& label
)
774 wxCHECK_RET( pos
< GetMenuCount(), wxT("invalid menu index") );
776 m_titles
[pos
] = label
;
783 m_menus
[pos
]->SetTitle( label
) ;
784 if (wxMenuBar::s_macInstalledMenuBar
== this) // are we currently installed ?
786 ::SetMenuBar( GetMenuBar() ) ;
791 wxString
wxMenuBar::GetLabelTop(size_t pos
) const
793 wxCHECK_MSG( pos
< GetMenuCount(), wxEmptyString
,
794 wxT("invalid menu index in wxMenuBar::GetLabelTop") );
796 return m_titles
[pos
];
799 int wxMenuBar::FindMenu(const wxString
& title
)
801 wxString menuTitle
= wxStripMenuCodes(title
);
803 size_t count
= GetMenuCount();
804 for ( size_t i
= 0; i
< count
; i
++ )
806 wxString title
= wxStripMenuCodes(m_titles
[i
]);
807 if ( menuTitle
== title
)
816 // ---------------------------------------------------------------------------
817 // wxMenuBar construction
818 // ---------------------------------------------------------------------------
820 // ---------------------------------------------------------------------------
821 // wxMenuBar construction
822 // ---------------------------------------------------------------------------
824 wxMenu
*wxMenuBar::Replace(size_t pos
, wxMenu
*menu
, const wxString
& title
)
826 wxMenu
*menuOld
= wxMenuBarBase::Replace(pos
, menu
, title
);
829 m_titles
[pos
] = title
;
833 if (s_macInstalledMenuBar
== this)
835 UMADeleteMenu( menuOld
->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
838 wxMenuItem::MacBuildMenuString( label
, NULL
, NULL
, title
, false );
839 UMASetMenuTitle( menu
->GetHMenu() , label
) ;
840 if ( pos
== m_menus
.GetCount() - 1)
842 UMAInsertMenu( menu
->GetHMenu() , 0 ) ;
846 UMAInsertMenu( menu
->GetHMenu() , m_menus
[pos
+1]->MacGetMenuId() ) ;
853 if ( menuOld
->HasAccels() || menu
->HasAccels() )
855 // need to rebuild accell table
858 #endif // wxUSE_ACCEL
866 bool wxMenuBar::Insert(size_t pos
, wxMenu
*menu
, const wxString
& title
)
868 if ( !wxMenuBarBase::Insert(pos
, menu
, title
) )
871 m_titles
.Insert(title
, pos
);
877 if ( pos
== (size_t) -1 )
879 ::InsertMenu( menu
->GetHMenu() , 0 ) ;
883 ::InsertMenu( menu
->GetHMenu() , m_menus
[pos
+1]->MacGetMenuId() ) ;
887 if ( menu
->HasAccels() )
889 // need to rebuild accell table
892 #endif // wxUSE_ACCEL
900 void wxMenuBar::MacMenuSelect(wxEvtHandler
* handler
, long when
, int macMenuId
, int macMenuItemNum
)
902 // first scan fast for direct commands, i.e. menus which have these commands directly in their own list
904 if ( macMenuId
== kwxMacAppleMenuId
&& macMenuItemNum
== 1 )
906 wxCommandEvent
event(wxEVT_COMMAND_MENU_SELECTED
, wxApp::s_macAboutMenuItemId
);
907 event
.m_timeStamp
= when
;
908 event
.SetEventObject(handler
);
909 event
.SetInt( wxApp::s_macAboutMenuItemId
);
910 handler
->ProcessEvent(event
);
914 for (int i
= 0; i
< m_menus
.GetCount() ; i
++)
916 if ( m_menus
[i
]->MacGetMenuId() == macMenuId
919 ( macMenuId
== kHMHelpMenuID
&& ( m_titles
[i
] == "?" || m_titles
[i
] == "&?" || m_titles
[i
] == wxApp::s_macHelpMenuTitleName
) )
923 if ( m_menus
[i
]->MacMenuSelect( handler
, when
, macMenuId
, macMenuItemNum
) )
927 //TODO flag this as an error since it must contain the item
933 for (int i
= 0; i
< m_menus
.GetCount(); i
++)
935 if ( m_menus
[i
]->MacMenuSelect( handler
, when
, macMenuId
, macMenuItemNum
) )
943 wxMenu
*wxMenuBar::Remove(size_t pos
)
945 wxMenu
*menu
= wxMenuBarBase::Remove(pos
);
951 if (s_macInstalledMenuBar
== this)
953 ::DeleteMenu( menu
->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
959 if ( menu
->HasAccels() )
961 // need to rebuild accell table
964 #endif // wxUSE_ACCEL
969 m_titles
.Remove(pos
);
974 bool wxMenuBar::Append(wxMenu
*menu
, const wxString
& title
)
976 WXHMENU submenu
= menu
? menu
->GetHMenu() : 0;
977 wxCHECK_MSG( submenu
, FALSE
, wxT("can't append invalid menu to menubar") );
979 if ( !wxMenuBarBase::Append(menu
, title
) )
988 if (s_macInstalledMenuBar
== this)
990 ::InsertMenu( menu
->GetHMenu() , 0 ) ;
994 if ( menu
->HasAccels() )
996 // need to rebuild accell table
999 #endif // wxUSE_ACCEL
1007 void wxMenuBar::Attach(wxFrame
*frame
)
1009 // wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") );
1011 m_menuBarFrame
= frame
;
1014 RebuildAccelTable();
1015 #endif // wxUSE_ACCEL
1017 // ---------------------------------------------------------------------------
1018 // wxMenuBar searching for menu items
1019 // ---------------------------------------------------------------------------
1021 // Find the itemString in menuString, and return the item id or wxNOT_FOUND
1022 int wxMenuBar::FindMenuItem(const wxString
& menuString
,
1023 const wxString
& itemString
) const
1025 wxString menuLabel
= wxStripMenuCodes(menuString
);
1026 size_t count
= GetMenuCount();
1027 for ( size_t i
= 0; i
< count
; i
++ )
1029 wxString title
= wxStripMenuCodes(m_titles
[i
]);
1030 if ( menuString
== title
)
1031 return m_menus
[i
]->FindItem(itemString
);
1037 wxMenuItem
*wxMenuBar::FindItem(int id
, wxMenu
**itemMenu
) const
1042 wxMenuItem
*item
= NULL
;
1043 size_t count
= GetMenuCount();
1044 for ( size_t i
= 0; !item
&& (i
< count
); i
++ )
1046 item
= m_menus
[i
]->FindItem(id
, itemMenu
);