1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMenu, wxMenuBar, wxMenuItem
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "menu.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
29 #include "wx/ownerdrw.h"
32 #include "wx/os2/private.h"
34 // other standard headers
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 extern wxMenu
* wxCurrentPopupMenu
;
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
48 // The (popup) menu title has this special id
50 static const int idMenuTitle
= -2;
53 // The unique ID for Menus
56 USHORT
wxMenu::m_nextMenuId
= 0;
58 static USHORT
wxMenu::m_nextMenuId
= 0;
61 // ----------------------------------------------------------------------------
63 // ----------------------------------------------------------------------------
65 IMPLEMENT_DYNAMIC_CLASS(wxMenu
, wxEvtHandler
)
66 IMPLEMENT_DYNAMIC_CLASS(wxMenuBar
, wxEvtHandler
)
68 // ----------------------------------------------------------------------------
69 // static function for translating menu labels
70 // ----------------------------------------------------------------------------
72 static wxString
TextToLabel(const wxString
& rTitle
)
76 for (pc
= rTitle
; *pc
!= wxT('\0'); pc
++ )
80 if (*(pc
+1) == wxT('&'))
88 // else if (*pc == wxT('/'))
90 // Title << wxT('\\');
94 if ( *pc
== wxT('~') )
96 // tildes must be doubled to prevent them from being
97 // interpreted as accelerator character prefix by PM ???
106 // ============================================================================
108 // ============================================================================
110 // ---------------------------------------------------------------------------
111 // wxMenu construction, adding and removing menu items
112 // ---------------------------------------------------------------------------
115 // Construct a menu with optional title (then use append)
122 // Create the menu (to be used as a submenu or a popup)
124 if ((m_hMenu
= ::WinCreateWindow( HWND_DESKTOP
139 wxLogLastError("WinLoadMenu");
141 m_vMenuData
.iPosition
= 0;
142 m_vMenuData
.afStyle
= MIS_SUBMENU
| MIS_TEXT
;
143 m_vMenuData
.afAttribute
= (USHORT
)0;
144 m_vMenuData
.id
= m_nextMenuId
++;
145 m_vMenuData
.hwndSubMenu
= m_hMenu
;
146 m_vMenuData
.hItem
= NULLHANDLE
;
149 // If we have a title, insert it in the beginning of the menu
151 if (!m_title
.IsEmpty())
158 } // end of wxMenu::Init
161 // The wxWindow destructor will take care of deleting the submenus.
166 // We should free PM resources only if PM doesn't do it for us
167 // which happens if we're attached to a menubar or a submenu of another
169 if (!IsAttached() && !GetParent())
171 if (!::WinDestroyWindow((HWND
)GetHmenu()) )
173 wxLogLastError("WinDestroyWindow");
181 #if (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
182 WX_CLEAR_ARRAY(m_vAccels
);
184 #endif // wxUSE_ACCEL
185 } // end of wxMenu::~wxMenu
189 // this will take effect during the next call to Append()
191 } // end of wxMenu::Break
195 int wxMenu::FindAccel(
200 size_t nCount
= m_vAccels
.GetCount();
202 for (n
= 0; n
< nCount
; n
++)
204 if (m_vAccels
[n
]->m_command
== nId
)
208 } // end of wxMenu::FindAccel
210 void wxMenu::UpdateAccel(
215 // Find the (new) accel for this item
217 wxAcceleratorEntry
* pAccel
= wxGetAccelFromString(pItem
->GetText());
220 pAccel
->m_command
= pItem
->GetId();
225 int n
= FindAccel(pItem
->GetId());
227 if (n
== wxNOT_FOUND
)
230 // No old, add new if any
233 m_vAccels
.Add(pAccel
);
235 return; // skipping RebuildAccelTable() below
240 // Replace old with new or just remove the old one if no new
245 m_vAccels
[n
] = pAccel
;
252 m_menuBar
->RebuildAccelTable();
254 } // wxMenu::UpdateAccel
256 #endif // wxUSE_ACCEL
259 // Append a new item or submenu to the menu
261 bool wxMenu::DoInsertOrAppend(
271 #endif // wxUSE_ACCEL
274 // rItem is the member MENUITEM for the menu items and the submenu's
275 // MENUITEM for submenus as required by ::MM_INSERTITEM message API
278 wxMenu
* pSubmenu
= pItem
->GetSubMenu();
279 MENUITEM
& rItem
= (pSubmenu
!= NULL
)?pSubmenu
->m_vMenuData
:
283 wxASSERT_MSG(pSubmenu
->GetHMenu(), wxT("invalid submenu"));
284 pSubmenu
->SetParent(this);
285 rItem
.afStyle
|= MIS_SUBMENU
| MIS_TEXT
;
289 // If "Break" has just been called, insert a menu break before this item
290 // (and don't forget to reset the flag)
294 rItem
.afStyle
|= MIS_BREAK
;
298 if (pItem
->IsSeparator())
300 rItem
.afStyle
|= MIS_SEPARATOR
;
304 // Id is the numeric id for normal menu items and HMENU for submenus as
305 // required by ::MM_INSERTITEM message API
308 if (pSubmenu
!= NULL
)
310 wxASSERT_MSG(pSubmenu
->GetHMenu(), wxT("invalid submenu"));
311 pSubmenu
->SetParent(this);
313 rItem
.iPosition
= 0; // submenus have a 0 position
314 rItem
.id
= (USHORT
)pSubmenu
->GetHMenu();
315 rItem
.afStyle
|= MIS_SUBMENU
| MIS_TEXT
;
319 rItem
.id
= pItem
->GetId();
324 #if wxUSE_OWNER_DRAWN
325 if (pItem
->IsOwnerDrawn())
328 // Want to get {Measure|Draw}Item messages?
329 // item draws itself, passing pointer to data doesn't work in OS/2
330 // Will eventually need to set the image handle somewhere into vItem.hItem
332 rItem
.afStyle
|= MIS_OWNERDRAW
;
334 rItem
.hItem
= (HBITMAP
)pItem
->GetBitmap().GetHBITMAP();
335 pItem
->m_vMenuData
.afStyle
= rItem
.afStyle
;
336 pItem
->m_vMenuData
.hItem
= rItem
.hItem
;
342 // Menu is just a normal string (passed in data parameter)
344 rItem
.afStyle
|= MIS_TEXT
;
345 pData
= (char*)pItem
->GetText().c_str();
348 if (nPos
== (size_t)-1)
350 rItem
.iPosition
= MIT_END
;
354 rItem
.iPosition
= nPos
;
359 rc
= (APIRET
)::WinSendMsg( GetHmenu()
364 #if wxUSE_OWNER_DRAWN
365 if (pItem
->IsOwnerDrawn())
370 ::WinSendMsg( GetHmenu()
372 ,MPFROM2SHORT( (USHORT
)pItem
->GetId()
379 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
381 vError
= ::WinGetLastError(vHabmain
);
382 sError
= wxPMErrorToStr(vError
);
383 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
);
384 wxLogLastError("Insert or AppendMenu");
390 // If we're already attached to the menubar, we must update it
392 if (IsAttached() && m_menuBar
->IsAttached())
394 m_menuBar
->Refresh();
399 } // end of wxMenu::DoInsertOrAppend
401 bool wxMenu::DoAppend(
405 return wxMenuBase::DoAppend(pItem
) && DoInsertOrAppend(pItem
);
408 bool wxMenu::DoInsert(
413 return ( wxMenuBase::DoInsert( nPos
415 DoInsertOrAppend( pItem
418 } // end of wxMenu::DoInsert
420 wxMenuItem
* wxMenu::DoRemove(
425 // We need to find the items position in the child list
428 wxMenuItemList::Node
* pNode
= GetMenuItems().GetFirst();
430 for (nPos
= 0; pNode
; nPos
++)
432 if (pNode
->GetData() == pItem
)
434 pNode
= pNode
->GetNext();
438 // DoRemove() (unlike Remove) can only be called for existing item!
440 wxCHECK_MSG(pNode
, NULL
, wxT("bug in wxMenu::Remove logic"));
444 // Remove the corresponding accel from the accel table
446 int n
= FindAccel(pItem
->GetId());
448 if (n
!= wxNOT_FOUND
)
454 #endif // wxUSE_ACCEL
456 // Remove the item from the menu
458 ::WinSendMsg( GetHmenu()
460 ,MPFROM2SHORT(pItem
->GetId(), TRUE
)
463 if (IsAttached() && m_menuBar
->IsAttached())
466 // Otherwise, the chane won't be visible
468 m_menuBar
->Refresh();
472 // And from internal data structures
474 return wxMenuBase::DoRemove(pItem
);
475 } // end of wxMenu::DoRemove
477 // ---------------------------------------------------------------------------
478 // accelerator helpers
479 // ---------------------------------------------------------------------------
484 // Create the wxAcceleratorEntries for our accels and put them into provided
485 // array - return the number of accels we have
487 size_t wxMenu::CopyAccels(
488 wxAcceleratorEntry
* pAccels
491 size_t nCount
= GetAccelCount();
493 for (size_t n
= 0; n
< nCount
; n
++)
495 *pAccels
++ = *m_vAccels
[n
];
498 } // end of wxMenu::CopyAccels
500 #endif // wxUSE_ACCEL
502 // ---------------------------------------------------------------------------
504 // ---------------------------------------------------------------------------
506 void wxMenu::SetTitle(
507 const wxString
& rLabel
510 bool bHasNoTitle
= m_title
.IsEmpty();
511 HWND hMenu
= GetHmenu();
516 if (!rLabel
.IsEmpty())
518 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
520 wxLogLastError("SetMenuTitle");
526 if (rLabel
.IsEmpty() )
528 ::WinSendMsg( GetHmenu()
530 ,MPFROM2SHORT(hMenu
, TRUE
)
539 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
541 wxLogLastError("SetMenuTitle");
545 } // end of wxMenu::SetTitle
547 // ---------------------------------------------------------------------------
549 // ---------------------------------------------------------------------------
551 bool wxMenu::OS2Command(
552 WXUINT
WXUNUSED(uParam
)
557 // Ignore commands from the menu title
560 if (vId
!= (WXWORD
)idMenuTitle
)
562 wxCommandEvent
vEvent(wxEVT_COMMAND_MENU_SELECTED
);
564 vEvent
.SetEventObject(this);
567 ProcessCommand(vEvent
);
570 } // end of wxMenu::OS2Command
572 bool wxMenu::ProcessCommand(
573 wxCommandEvent
& rEvent
576 bool bProcessed
= FALSE
;
578 #if wxUSE_MENU_CALLBACK
584 (void)(*(m_callback
))(*this, rEvent
);
587 #endif // wxUSE_MENU_CALLBACK
590 // Try the menu's event handler
592 if (!bProcessed
&& GetEventHandler())
594 bProcessed
= GetEventHandler()->ProcessEvent(rEvent
);
598 // Try the window the menu was popped up from (and up through the
600 wxWindow
* pWin
= GetInvokingWindow();
602 if (!bProcessed
&& pWin
)
603 bProcessed
= pWin
->GetEventHandler()->ProcessEvent(rEvent
);
605 } // end of wxMenu::ProcessCommand
607 // ---------------------------------------------------------------------------
609 // ---------------------------------------------------------------------------
616 // Menu can be in at most one menubar because otherwise they would both
617 // delete the menu pointer
619 wxASSERT_MSG(!m_menuBar
, wxT("menu belongs to 2 menubars, expect a crash"));
620 m_menuBar
= pMenubar
;
623 void wxMenu::Detach()
625 wxASSERT_MSG( m_menuBar
, wxT("can't detach menu if it's not attached") );
627 } // end of wxMenu::Detach
629 wxWindow
* wxMenu::GetWindow() const
631 if (m_invokingWindow
!= NULL
)
632 return m_invokingWindow
;
633 else if ( m_menuBar
!= NULL
)
634 return m_menuBar
->GetFrame();
637 } // end of wxMenu::GetWindow
639 // recursive search for item by id
640 wxMenuItem
* wxMenu::FindItem(
643 , wxMenu
** ppItemMenu
649 wxMenuItem
* pItem
= NULL
;
651 for ( wxMenuItemList::Node
*node
= m_items
.GetFirst();
653 node
= node
->GetNext() )
655 pItem
= node
->GetData();
657 if ( pItem
->GetId() == nItemId
&& pItem
->m_vMenuData
.hItem
== hItem
)
660 *ppItemMenu
= (wxMenu
*)this;
662 else if ( pItem
->IsSubMenu() )
664 pItem
= pItem
->GetSubMenu()->FindItem(nItemId
, hItem
, ppItemMenu
);
668 // don't exit the loop
673 } // end of wxMenu::FindItem
675 // ---------------------------------------------------------------------------
677 // ---------------------------------------------------------------------------
679 void wxMenuBar::Init()
681 m_eventHandler
= this;
682 m_pMenuBarFrame
= NULL
;
684 } // end of wxMenuBar::Init
686 wxMenuBar::wxMenuBar()
689 } // end of wxMenuBar::wxMenuBar
691 wxMenuBar::wxMenuBar(
692 long WXUNUSED(lStyle
)
696 } // end of wxMenuBar::wxMenuBar
698 wxMenuBar::wxMenuBar(
701 , const wxString sTitles
[]
706 m_titles
.Alloc(nCount
);
707 for ( int i
= 0; i
< nCount
; i
++ )
709 m_menus
.Append(vMenus
[i
]);
710 m_titles
.Add(sTitles
[i
]);
711 vMenus
[i
]->Attach(this);
713 } // end of wxMenuBar::wxMenuBar
715 wxMenuBar::~wxMenuBar()
717 } // end of wxMenuBar::~wxMenuBar
719 // ---------------------------------------------------------------------------
721 // ---------------------------------------------------------------------------
723 void wxMenuBar::Refresh()
725 wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );
727 WinSendMsg(GetWinHwnd(m_pMenuBarFrame
), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
728 } // end of wxMenuBar::Refresh
730 WXHMENU
wxMenuBar::Create()
738 wxCHECK_MSG(!m_hMenu
, TRUE
, wxT("menubar already created"));
741 // Menubars should be associated with a frame otherwise they are popups
743 if (m_pMenuBarFrame
!= NULL
)
744 hFrame
= GetWinHwnd(m_pMenuBarFrame
);
746 hFrame
= HWND_DESKTOP
;
748 // Create an empty menu and then fill it with insertions
750 if ((m_hMenu
= ::WinCreateWindow( hFrame
753 ,MS_ACTIONBAR
| WS_SYNCPAINT
| WS_VISIBLE
765 wxLogLastError("WinLoadMenu");
769 size_t nCount
= GetMenuCount();
771 for (size_t i
= 0; i
< nCount
; i
++)
779 // Set the parent and owner of the submenues to be the menubar, not the desktop
781 hSubMenu
= m_menus
[i
]->m_vMenuData
.hwndSubMenu
;
782 if (!::WinSetParent(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
, FALSE
))
784 vError
= ::WinGetLastError(vHabmain
);
785 sError
= wxPMErrorToStr(vError
);
786 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
790 if (!::WinSetOwner(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
))
792 vError
= ::WinGetLastError(vHabmain
);
793 sError
= wxPMErrorToStr(vError
);
794 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
798 m_menus
[i
]->m_vMenuData
.iPosition
= i
;
800 rc
= (APIRET
)::WinSendMsg(m_hMenu
, MM_INSERTITEM
, (MPARAM
)&m_menus
[i
]->m_vMenuData
, (MPARAM
)m_titles
[i
].c_str());
801 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
803 vError
= ::WinGetLastError(vHabmain
);
804 sError
= wxPMErrorToStr(vError
);
805 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
);
811 } // end of wxMenuBar::Create
813 // ---------------------------------------------------------------------------
814 // wxMenuBar functions to work with the top level submenus
815 // ---------------------------------------------------------------------------
818 // NB: we don't support owner drawn top level items for now, if we do these
819 // functions would have to be changed to use wxMenuItem as well
821 void wxMenuBar::EnableTop(
826 wxCHECK_RET(IsAttached(), wxT("doesn't work with unattached menubars"));
831 uFlag
= MIA_DISABLED
;
833 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
834 if (nId
== MIT_ERROR
)
836 wxLogLastError("LogLastError");
839 ::WinSendMsg((HWND
)m_hMenu
, MM_SETITEMATTR
, MPFROM2SHORT(nId
, TRUE
), MPFROM2SHORT(MIA_DISABLED
, uFlag
));
841 } // end of wxMenuBar::EnableTop
843 void wxMenuBar::SetLabelTop(
845 , const wxString
& rLabel
851 wxCHECK_RET(nPos
< GetMenuCount(), wxT("invalid menu index"));
852 m_titles
[nPos
] = rLabel
;
859 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
860 if (nId
== MIT_ERROR
)
862 wxLogLastError("LogLastError");
865 if(!::WinSendMsg( (HWND
)m_hMenu
867 ,MPFROM2SHORT(nId
, TRUE
)
871 wxLogLastError("QueryItem");
875 if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT
, MPFROMSHORT(nId
), (MPARAM
)rLabel
.c_str()));
877 wxLogLastError("ModifyMenu");
880 } // end of wxMenuBar::SetLabelTop
882 wxString
wxMenuBar::GetLabelTop(
886 wxCHECK_MSG( nPos
< GetMenuCount(), wxEmptyString
,
887 wxT("invalid menu index in wxMenuBar::GetLabelTop") );
888 return m_titles
[nPos
];
889 } // end of wxMenuBar::GetLabelTop
891 // ---------------------------------------------------------------------------
892 // wxMenuBar construction
893 // ---------------------------------------------------------------------------
895 wxMenu
* wxMenuBar::Replace(
898 , const wxString
& rTitle
902 wxString Title
= TextToLabel(rTitle
);
903 wxMenu
* pMenuOld
= wxMenuBarBase::Replace( nPos
909 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
910 if (nId
== MIT_ERROR
)
912 wxLogLastError("LogLastError");
917 m_titles
[nPos
] = Title
;
920 ::WinSendMsg((HWND
)m_hMenu
, MM_REMOVEITEM
, MPFROM2SHORT(nId
, TRUE
), (MPARAM
)0);
921 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)Title
.c_str());
924 if (pMenuOld
->HasAccels() || pMenu
->HasAccels())
927 // Need to rebuild accell table
931 #endif // wxUSE_ACCEL
935 } // end of wxMenuBar::Replace
937 bool wxMenuBar::Insert(
940 , const wxString
& rTitle
943 wxString Title
= TextToLabel(rTitle
);
944 if (!wxMenuBarBase::Insert( nPos
950 m_titles
.Insert( Title
958 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)Title
.c_str());
960 if (pMenu
->HasAccels())
962 // need to rebuild accell table
965 #endif // wxUSE_ACCEL
969 } // end of wxMenuBar::Insert
971 bool wxMenuBar::Append(
973 , const wxString
& rTitle
976 WXHMENU hSubmenu
= pMenu
? pMenu
->GetHMenu() : 0;
978 wxCHECK_MSG(hSubmenu
, FALSE
, wxT("can't append invalid menu to menubar"));
980 wxString Title
= TextToLabel(rTitle
);
981 if (!wxMenuBarBase::Append(pMenu
, Title
))
989 pMenu
->m_vMenuData
.iPosition
= MIT_END
;
990 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)Title
.c_str());
992 if (pMenu
->HasAccels())
995 // Need to rebuild accell table
999 #endif // wxUSE_ACCEL
1003 } // end of wxMenuBar::Append
1005 wxMenu
* wxMenuBar::Remove(
1009 wxMenu
* pMenu
= wxMenuBarBase::Remove(nPos
);
1015 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)GetHmenu(), MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
1016 if (nId
== MIT_ERROR
)
1018 wxLogLastError("LogLastError");
1023 ::WinSendMsg((HWND
)GetHmenu(), MM_REMOVEITEM
, MPFROM2SHORT(nId
, TRUE
), (MPARAM
)0);
1027 if (pMenu
->HasAccels())
1030 // Need to rebuild accell table
1032 RebuildAccelTable();
1034 #endif // wxUSE_ACCEL
1037 m_titles
.Remove(nPos
);
1039 } // end of wxMenuBar::Remove
1043 void wxMenuBar::RebuildAccelTable()
1046 // Merge the accelerators of all menus into one accel table
1048 size_t nAccelCount
= 0;
1050 size_t nCount
= GetMenuCount();
1052 for (i
= 0; i
< nCount
; i
++)
1054 nAccelCount
+= m_menus
[i
]->GetAccelCount();
1059 wxAcceleratorEntry
* pAccelEntries
= new wxAcceleratorEntry
[nAccelCount
];
1062 for (i
= 0; i
< nCount
; i
++)
1064 nAccelCount
+= m_menus
[i
]->CopyAccels(&pAccelEntries
[nAccelCount
]);
1066 m_vAccelTable
= wxAcceleratorTable( nAccelCount
1069 delete [] pAccelEntries
;
1071 } // end of wxMenuBar::RebuildAccelTable
1073 #endif // wxUSE_ACCEL
1075 void wxMenuBar::Attach(
1079 wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") );
1080 m_pMenuBarFrame
= pFrame
;
1083 RebuildAccelTable();
1085 // Ensure the accelerator table is set to the frame (not the client!)
1087 if (!::WinSetAccelTable( vHabmain
1088 ,(HWND
)pFrame
->GetHWND()
1089 ,m_vAccelTable
.GetHACCEL()
1091 wxLogLastError("WinSetAccelTable");
1092 #endif // wxUSE_ACCEL
1093 } // end of wxMenuBar::Attach
1095 void wxMenuBar::Detach()
1097 ::WinDestroyWindow((HWND
)m_hMenu
);
1098 m_hMenu
= (WXHMENU
)NULL
;
1099 m_pMenuBarFrame
= NULL
;
1100 } // end of wxMenuBar::Detach
1102 // ---------------------------------------------------------------------------
1103 // wxMenuBar searching for menu items
1104 // ---------------------------------------------------------------------------
1107 // Find the itemString in menuString, and return the item id or wxNOT_FOUND
1109 int wxMenuBar::FindMenuItem(
1110 const wxString
& rMenuString
1111 , const wxString
& rItemString
1114 wxString sMenuLabel
= wxStripMenuCodes(rMenuString
);
1115 size_t nCount
= GetMenuCount();
1117 for (size_t i
= 0; i
< nCount
; i
++)
1119 wxString sTitle
= wxStripMenuCodes(m_titles
[i
]);
1121 if (rMenuString
== sTitle
)
1122 return m_menus
[i
]->FindItem(rItemString
);
1125 } // end of wxMenuBar::FindMenuItem
1127 wxMenuItem
* wxMenuBar::FindItem(
1129 , wxMenu
** ppItemMenu
1135 wxMenuItem
* pItem
= NULL
;
1136 size_t nCount
= GetMenuCount();
1138 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1140 pItem
= m_menus
[i
]->FindItem( nId
1145 } // end of wxMenuBar::FindItem
1147 wxMenuItem
* wxMenuBar::FindItem(
1150 , wxMenu
** ppItemMenu
1156 wxMenuItem
* pItem
= NULL
;
1157 size_t nCount
= GetMenuCount();
1159 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1161 pItem
= m_menus
[i
]->FindItem( nId
1167 } // end of wxMenuBar::FindItem