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
= ::NewMenu(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 ::DisposeMenu(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
143 m_accels
.RemoveAt(n
);
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 ::InsertMenu( 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
)
272 m_accels
.RemoveAt(n
);
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 wxWindow
*wxMenu::GetWindow() const
352 if ( m_invokingWindow
!= NULL
)
353 return m_invokingWindow
;
354 else if ( m_menuBar
!= NULL
)
355 return (wxWindow
*) m_menuBar
->GetFrame();
360 // helper functions returning the mac menu position for a certain item, note that this is
361 // mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0
363 int wxMenu::MacGetIndexFromId( int id
)
366 wxMenuItemList::Node
*node
= GetMenuItems().GetFirst();
367 for ( pos
= 0; node
; pos
++ )
369 if ( node
->GetData()->GetId() == id
)
372 node
= node
->GetNext();
381 int wxMenu::MacGetIndexFromItem( wxMenuItem
*pItem
)
384 wxMenuItemList::Node
*node
= GetMenuItems().GetFirst();
385 for ( pos
= 0; node
; pos
++ )
387 if ( node
->GetData() == pItem
)
390 node
= node
->GetNext();
399 void wxMenu::MacEnableMenu( bool bDoEnable
)
402 UMAEnableMenuItem( m_hMenu
, 0 ) ;
404 UMADisableMenuItem( m_hMenu
, 0 ) ;
409 bool wxMenu::MacMenuSelect( wxEvtHandler
* handler
, long when
, int macMenuId
, int macMenuItemNum
)
414 if ( m_macMenuId
== macMenuId
)
416 node
= GetMenuItems().Nth(macMenuItemNum
-1);
419 wxMenuItem
*pItem
= (wxMenuItem
*)node
->Data();
421 if (pItem
->IsCheckable())
422 pItem
->Check(! pItem
->IsChecked());
424 wxCommandEvent
event(wxEVT_COMMAND_MENU_SELECTED
, pItem
->GetId());
425 event
.m_timeStamp
= when
;
426 event
.SetEventObject(handler
);
427 event
.SetInt( pItem
->GetId() );
429 bool processed
= false ;
431 #if WXWIN_COMPATIBILITY
435 (void) (*(m_callback
)) (*this, event
);
439 // Try the menu's event handler
440 if ( !processed
&& handler
)
442 processed
= handler
->ProcessEvent(event
);
445 // Try the window the menu was popped up from (and up
446 // through the hierarchy)
447 if ( !processed
&& GetInvokingWindow())
448 processed
= GetInvokingWindow()->GetEventHandler()->ProcessEvent(event
);
454 else if ( macMenuId
== kHMHelpMenuID
)
456 int menuItem
= formerHelpMenuItems
;
457 for (pos
= 0, node
= GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
459 wxMenuItem
* pItem
= (wxMenuItem
*) node
->Data() ;
461 wxMenu
*pSubMenu
= pItem
->GetSubMenu() ;
462 if ( pSubMenu
!= NULL
)
467 if ( pItem
->GetId() != wxApp::s_macAboutMenuItemId
)
470 if ( menuItem
== macMenuItemNum
)
472 wxCommandEvent
event(wxEVT_COMMAND_MENU_SELECTED
, pItem
->GetId());
473 event
.m_timeStamp
= when
;
474 event
.SetEventObject(handler
);
475 event
.SetInt( pItem
->GetId() );
477 bool processed
= false ;
478 #if WXWIN_COMPATIBILITY
482 (void) (*(m_callback
)) (*this, event
);
486 // Try the menu's event handler
487 if ( !processed
&& handler
)
489 processed
= handler
->ProcessEvent(event
);
492 // Try the window the menu was popped up from (and up
493 // through the hierarchy)
494 if ( !processed
&& GetInvokingWindow())
495 processed
= GetInvokingWindow()->GetEventHandler()->ProcessEvent(event
);
504 for (pos
= 0, node
= GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
506 wxMenuItem
* pItem
= (wxMenuItem
*) node
->Data() ;
508 wxMenu
*pSubMenu
= pItem
->GetSubMenu() ;
509 if ( pSubMenu
!= NULL
)
511 if ( pSubMenu
->MacMenuSelect( handler
, when
, macMenuId
, macMenuItemNum
) )
523 Mac Implementation note :
525 The Mac has only one global menubar, so we attempt to install the currently
526 active menubar from a frame, we currently don't take into account mdi-frames
527 which would ask for menu-merging
529 Secondly there is no mac api for changing a menubar that is not the current
530 menubar, so we have to wait for preparing the actual menubar until the
531 wxMenubar is to be used
533 We can in subsequent versions use MacInstallMenuBar to provide some sort of
534 auto-merge for MDI in case this will be necessary
538 wxMenuBar
* wxMenuBar::s_macInstalledMenuBar
= NULL
;
540 void wxMenuBar::Init()
542 m_eventHandler
= this;
543 m_menuBarFrame
= NULL
;
546 wxMenuBar::wxMenuBar()
551 wxMenuBar::wxMenuBar( long WXUNUSED(style
) )
557 wxMenuBar::wxMenuBar(int count
, wxMenu
*menus
[], const wxString titles
[])
561 m_titles
.Alloc(count
);
563 for ( int i
= 0; i
< count
; i
++ )
565 m_menus
.Append(menus
[i
]);
566 m_titles
.Add(titles
[i
]);
568 menus
[i
]->Attach(this);
572 wxMenuBar::~wxMenuBar()
574 if (s_macInstalledMenuBar
== this)
577 s_macInstalledMenuBar
= NULL
;
582 void wxMenuBar::Refresh()
584 wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );
591 void wxMenuBar::RebuildAccelTable()
593 // merge the accelerators of all menus into one accel table
594 size_t nAccelCount
= 0;
595 size_t i
, count
= GetMenuCount();
596 for ( i
= 0; i
< count
; i
++ )
598 nAccelCount
+= m_menus
[i
]->GetAccelCount();
603 wxAcceleratorEntry
*accelEntries
= new wxAcceleratorEntry
[nAccelCount
];
606 for ( i
= 0; i
< count
; i
++ )
608 nAccelCount
+= m_menus
[i
]->CopyAccels(&accelEntries
[nAccelCount
]);
611 m_accelTable
= wxAcceleratorTable(nAccelCount
, accelEntries
);
613 delete [] accelEntries
;
617 #endif // wxUSE_ACCEL
620 void wxMenuBar::MacInstallMenuBar()
622 if ( s_macInstalledMenuBar
== this )
625 Handle menubar
= ::GetNewMBar( kwxMacMenuBarResource
) ;
627 wxCHECK_RET( menubar
!= NULL
, "can't read MBAR resource" );
628 ::SetMenuBar( menubar
) ;
629 ::DisposeHandle( menubar
) ;
631 MenuHandle menu
= ::GetMenuHandle( kwxMacAppleMenuId
) ;
632 ::AppendResMenu(menu
, 'DRVR');
634 for (int i
= 0; i
< m_menus
.GetCount(); i
++)
640 wxMenu
* menu
= m_menus
[i
] , *subMenu
= NULL
;
643 /* the help menu does not exist in CARBON anymore */
644 if( m_titles
[i
] == "?" || m_titles
[i
] == "&?" || m_titles
[i
] == wxApp::s_macHelpMenuTitleName
)
646 MenuHandle mh
= NULL
;
647 if ( HMGetHelpMenuHandle( &mh
) != noErr
)
651 if ( formerHelpMenuItems
== 0 )
654 formerHelpMenuItems
= CountMenuItems( mh
) ;
657 for (pos
= 0 , node
= menu
->GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
659 item
= (wxMenuItem
*)node
->Data();
660 subMenu
= item
->GetSubMenu() ;
663 // we don't support hierarchical menus in the help menu yet
667 if ( item
->IsSeparator() )
670 UMAAppendMenuItem(mh
, "\p-" );
677 wxMenuItem::MacBuildMenuString( label
, &key
, &modifiers
, item
->GetText(), item
->GetId() != wxApp::s_macAboutMenuItemId
); // no shortcut in about menu
680 // we cannot add empty menus on mac
684 if ( item
->GetId() == wxApp::s_macAboutMenuItemId
)
686 ::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId
) , 1 , label
);
687 UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId
) , 1 );
692 UMAAppendMenuItem(mh
, label
, key
, modifiers
);
699 if( m_titles
[i
] == "?" || m_titles
[i
] == "&?" || m_titles
[i
] == wxApp::s_macHelpMenuTitleName
)
701 wxMenuItem::MacBuildMenuString( label
, NULL
, NULL
, m_titles
[i
] , false );
702 UMASetMenuTitle( menu
->GetHMenu() , label
) ;
704 for (pos
= 0 , node
= menu
->GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
706 item
= (wxMenuItem
*)node
->Data();
707 subMenu
= item
->GetSubMenu() ;
710 ::InsertMenu( subMenu
->GetHMenu() , -1 ) ;
714 if ( item
->GetId() == wxApp::s_macAboutMenuItemId
)
719 wxMenuItem::MacBuildMenuString( label
, &key
, &modifiers
, item
->GetText(), item
->GetId() != wxApp::s_macAboutMenuItemId
); // no shortcut in about menu
720 ::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId
) , 1 , label
);
721 UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId
) , 1 );
725 ::InsertMenu(m_menus
[i
]->GetHMenu(), 0);
730 wxMenuItem::MacBuildMenuString( label
, NULL
, NULL
, m_titles
[i
] , false );
731 UMASetMenuTitle( menu
->GetHMenu() , label
) ;
732 for (pos
= 0, node
= menu
->GetMenuItems().First(); node
; node
= node
->Next(), pos
++)
734 item
= (wxMenuItem
*)node
->Data();
735 subMenu
= item
->GetSubMenu() ;
738 ::InsertMenu( subMenu
->GetHMenu() , -1 ) ;
741 ::InsertMenu(m_menus
[i
]->GetHMenu(), 0);
746 s_macInstalledMenuBar
= this;
749 void wxMenuBar::EnableTop(size_t pos
, bool enable
)
751 wxCHECK_RET( IsAttached(), wxT("doesn't work with unattached menubars") );
752 m_menus
[pos
]->MacEnableMenu( enable
) ;
756 void wxMenuBar::SetLabelTop(size_t pos
, const wxString
& label
)
758 wxCHECK_RET( pos
< GetMenuCount(), wxT("invalid menu index") );
760 m_titles
[pos
] = label
;
767 m_menus
[pos
]->SetTitle( label
) ;
768 if (wxMenuBar::s_macInstalledMenuBar
== this) // are we currently installed ?
770 ::SetMenuBar( GetMenuBar() ) ;
775 wxString
wxMenuBar::GetLabelTop(size_t pos
) const
777 wxCHECK_MSG( pos
< GetMenuCount(), wxEmptyString
,
778 wxT("invalid menu index in wxMenuBar::GetLabelTop") );
780 return m_titles
[pos
];
783 int wxMenuBar::FindMenu(const wxString
& title
)
785 wxString menuTitle
= wxStripMenuCodes(title
);
787 size_t count
= GetMenuCount();
788 for ( size_t i
= 0; i
< count
; i
++ )
790 wxString title
= wxStripMenuCodes(m_titles
[i
]);
791 if ( menuTitle
== title
)
800 // ---------------------------------------------------------------------------
801 // wxMenuBar construction
802 // ---------------------------------------------------------------------------
804 // ---------------------------------------------------------------------------
805 // wxMenuBar construction
806 // ---------------------------------------------------------------------------
808 wxMenu
*wxMenuBar::Replace(size_t pos
, wxMenu
*menu
, const wxString
& title
)
810 wxMenu
*menuOld
= wxMenuBarBase::Replace(pos
, menu
, title
);
813 m_titles
[pos
] = title
;
817 if (s_macInstalledMenuBar
== this)
819 ::DeleteMenu( menuOld
->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
822 wxMenuItem::MacBuildMenuString( label
, NULL
, NULL
, title
, false );
823 UMASetMenuTitle( menu
->GetHMenu() , label
) ;
824 if ( pos
== m_menus
.GetCount() - 1)
826 ::InsertMenu( menu
->GetHMenu() , 0 ) ;
830 ::InsertMenu( menu
->GetHMenu() , m_menus
[pos
+1]->MacGetMenuId() ) ;
837 if ( menuOld
->HasAccels() || menu
->HasAccels() )
839 // need to rebuild accell table
842 #endif // wxUSE_ACCEL
850 bool wxMenuBar::Insert(size_t pos
, wxMenu
*menu
, const wxString
& title
)
852 if ( !wxMenuBarBase::Insert(pos
, menu
, title
) )
855 m_titles
.Insert(title
, pos
);
861 if ( pos
== (size_t) -1 )
863 ::InsertMenu( menu
->GetHMenu() , 0 ) ;
867 ::InsertMenu( menu
->GetHMenu() , m_menus
[pos
+1]->MacGetMenuId() ) ;
871 if ( menu
->HasAccels() )
873 // need to rebuild accell table
876 #endif // wxUSE_ACCEL
884 void wxMenuBar::MacMenuSelect(wxEvtHandler
* handler
, long when
, int macMenuId
, int macMenuItemNum
)
886 // first scan fast for direct commands, i.e. menus which have these commands directly in their own list
888 if ( macMenuId
== kwxMacAppleMenuId
&& macMenuItemNum
== 1 )
890 wxCommandEvent
event(wxEVT_COMMAND_MENU_SELECTED
, wxApp::s_macAboutMenuItemId
);
891 event
.m_timeStamp
= when
;
892 event
.SetEventObject(handler
);
893 event
.SetInt( wxApp::s_macAboutMenuItemId
);
894 handler
->ProcessEvent(event
);
898 for (int i
= 0; i
< m_menus
.GetCount() ; i
++)
900 if ( m_menus
[i
]->MacGetMenuId() == macMenuId
903 ( macMenuId
== kHMHelpMenuID
&& ( m_titles
[i
] == "?" || m_titles
[i
] == "&?" || m_titles
[i
] == wxApp::s_macHelpMenuTitleName
) )
907 if ( m_menus
[i
]->MacMenuSelect( handler
, when
, macMenuId
, macMenuItemNum
) )
911 //TODO flag this as an error since it must contain the item
917 for (int i
= 0; i
< m_menus
.GetCount(); i
++)
919 if ( m_menus
[i
]->MacMenuSelect( handler
, when
, macMenuId
, macMenuItemNum
) )
927 wxMenu
*wxMenuBar::Remove(size_t pos
)
929 wxMenu
*menu
= wxMenuBarBase::Remove(pos
);
935 if (s_macInstalledMenuBar
== this)
937 ::DeleteMenu( menu
->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
943 if ( menu
->HasAccels() )
945 // need to rebuild accell table
948 #endif // wxUSE_ACCEL
953 m_titles
.Remove(pos
);
958 bool wxMenuBar::Append(wxMenu
*menu
, const wxString
& title
)
960 WXHMENU submenu
= menu
? menu
->GetHMenu() : 0;
961 wxCHECK_MSG( submenu
, FALSE
, wxT("can't append invalid menu to menubar") );
963 if ( !wxMenuBarBase::Append(menu
, title
) )
970 if (s_macInstalledMenuBar
== this)
972 ::InsertMenu( menu
->GetHMenu() , 0 ) ;
976 if ( menu
->HasAccels() )
978 // need to rebuild accell table
981 #endif // wxUSE_ACCEL
989 void wxMenuBar::Detach()
991 wxMenuBarBase::Detach() ;
994 void wxMenuBar::Attach(wxFrame
*frame
)
996 wxMenuBarBase::Attach( frame
) ;
1000 #endif // wxUSE_ACCEL
1002 // ---------------------------------------------------------------------------
1003 // wxMenuBar searching for menu items
1004 // ---------------------------------------------------------------------------
1006 // Find the itemString in menuString, and return the item id or wxNOT_FOUND
1007 int wxMenuBar::FindMenuItem(const wxString
& menuString
,
1008 const wxString
& itemString
) const
1010 wxString menuLabel
= wxStripMenuCodes(menuString
);
1011 size_t count
= GetMenuCount();
1012 for ( size_t i
= 0; i
< count
; i
++ )
1014 wxString title
= wxStripMenuCodes(m_titles
[i
]);
1015 if ( menuString
== title
)
1016 return m_menus
[i
]->FindItem(itemString
);
1022 wxMenuItem
*wxMenuBar::FindItem(int id
, wxMenu
**itemMenu
) const
1027 wxMenuItem
*item
= NULL
;
1028 size_t count
= GetMenuCount();
1029 for ( size_t i
= 0; !item
&& (i
< count
); i
++ )
1031 item
= m_menus
[i
]->FindItem(id
, itemMenu
);