]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/menu.cpp
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
.c_str(); *pc
!= wxT('\0'); pc
++ )
80 if (*(pc
+1) == wxT('&'))
90 if ( *pc
== wxT('~') )
92 // tildes must be doubled to prevent them from being
93 // interpreted as accelerator character prefix by PM ???
102 // ============================================================================
104 // ============================================================================
106 // ---------------------------------------------------------------------------
107 // wxMenu construction, adding and removing menu items
108 // ---------------------------------------------------------------------------
111 // Construct a menu with optional title (then use append)
118 // Create the menu (to be used as a submenu or a popup)
120 if ((m_hMenu
= ::WinCreateWindow( HWND_DESKTOP
135 wxLogLastError("WinLoadMenu");
137 m_vMenuData
.iPosition
= 0;
138 m_vMenuData
.afStyle
= MIS_SUBMENU
| MIS_TEXT
;
139 m_vMenuData
.afAttribute
= (USHORT
)0;
140 m_vMenuData
.id
= m_nextMenuId
++;
141 m_vMenuData
.hwndSubMenu
= m_hMenu
;
142 m_vMenuData
.hItem
= NULLHANDLE
;
145 // If we have a title, insert it in the beginning of the menu
147 if (!m_title
.IsEmpty())
154 } // end of wxMenu::Init
157 // The wxWindow destructor will take care of deleting the submenus.
162 // We should free PM resources only if PM doesn't do it for us
163 // which happens if we're attached to a menubar or a submenu of another
165 if (!IsAttached() && !GetParent())
167 if (!::WinDestroyWindow((HWND
)GetHmenu()) )
169 wxLogLastError("WinDestroyWindow");
177 #if (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
178 WX_CLEAR_ARRAY(m_vAccels
);
180 #endif // wxUSE_ACCEL
181 } // end of wxMenu::~wxMenu
185 // this will take effect during the next call to Append()
187 } // end of wxMenu::Break
191 void wxMenu::EndRadioGroup()
194 // We're not inside a radio group any longer
196 m_nStartRadioGroup
= -1;
197 } // end of wxMenu::EndRadioGroup
199 int wxMenu::FindAccel(
204 size_t nCount
= m_vAccels
.GetCount();
206 for (n
= 0; n
< nCount
; n
++)
208 if (m_vAccels
[n
]->m_command
== nId
)
212 } // end of wxMenu::FindAccel
214 void wxMenu::UpdateAccel(
219 // Find the (new) accel for this item
221 wxAcceleratorEntry
* pAccel
= wxGetAccelFromString(pItem
->GetText());
224 pAccel
->m_command
= pItem
->GetId();
229 int n
= FindAccel(pItem
->GetId());
231 if (n
== wxNOT_FOUND
)
234 // No old, add new if any
237 m_vAccels
.Add(pAccel
);
239 return; // skipping RebuildAccelTable() below
244 // Replace old with new or just remove the old one if no new
249 m_vAccels
[n
] = pAccel
;
251 m_vAccels
.RemoveAt(n
);
256 m_menuBar
->RebuildAccelTable();
258 } // wxMenu::UpdateAccel
260 #endif // wxUSE_ACCEL
263 // Append a new item or submenu to the menu
265 bool wxMenu::DoInsertOrAppend(
275 #endif // wxUSE_ACCEL
278 // rItem is the member MENUITEM for the menu items and the submenu's
279 // MENUITEM for submenus as required by ::MM_INSERTITEM message API
282 wxMenu
* pSubmenu
= pItem
->GetSubMenu();
283 MENUITEM
& rItem
= (pSubmenu
!= NULL
)?pSubmenu
->m_vMenuData
:
287 wxASSERT_MSG(pSubmenu
->GetHMenu(), wxT("invalid submenu"));
288 pSubmenu
->SetParent(this);
289 rItem
.afStyle
|= MIS_SUBMENU
| MIS_TEXT
;
293 // If "Break" has just been called, insert a menu break before this item
294 // (and don't forget to reset the flag)
298 rItem
.afStyle
|= MIS_BREAK
;
302 if (pItem
->IsSeparator())
304 rItem
.afStyle
|= MIS_SEPARATOR
;
308 // Id is the numeric id for normal menu items and HMENU for submenus as
309 // required by ::MM_INSERTITEM message API
312 if (pSubmenu
!= NULL
)
314 wxASSERT_MSG(pSubmenu
->GetHMenu(), wxT("invalid submenu"));
315 pSubmenu
->SetParent(this);
317 rItem
.iPosition
= 0; // submenus have a 0 position
318 rItem
.id
= (USHORT
)pSubmenu
->GetHMenu();
319 rItem
.afStyle
|= MIS_SUBMENU
| MIS_TEXT
;
323 rItem
.id
= pItem
->GetId();
328 #if wxUSE_OWNER_DRAWN
329 if (pItem
->IsOwnerDrawn())
332 // Want to get {Measure|Draw}Item messages?
333 // item draws itself, passing pointer to data doesn't work in OS/2
334 // Will eventually need to set the image handle somewhere into vItem.hItem
336 rItem
.afStyle
|= MIS_OWNERDRAW
;
338 rItem
.hItem
= (HBITMAP
)pItem
->GetBitmap().GetHBITMAP();
339 pItem
->m_vMenuData
.afStyle
= rItem
.afStyle
;
340 pItem
->m_vMenuData
.hItem
= rItem
.hItem
;
346 // Menu is just a normal string (passed in data parameter)
348 rItem
.afStyle
|= MIS_TEXT
;
349 pData
= (char*)pItem
->GetText().c_str();
352 if (nPos
== (size_t)-1)
354 rItem
.iPosition
= MIT_END
;
358 rItem
.iPosition
= nPos
;
363 rc
= (APIRET
)::WinSendMsg( GetHmenu()
368 #if wxUSE_OWNER_DRAWN
369 if (pItem
->IsOwnerDrawn())
374 ::WinSendMsg( GetHmenu()
376 ,MPFROM2SHORT( (USHORT
)pItem
->GetId()
383 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
385 vError
= ::WinGetLastError(vHabmain
);
386 sError
= wxPMErrorToStr(vError
);
387 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
);
388 wxLogLastError("Insert or AppendMenu");
394 // If we're already attached to the menubar, we must update it
396 if (IsAttached() && m_menuBar
->IsAttached())
398 m_menuBar
->Refresh();
403 } // end of wxMenu::DoInsertOrAppend
405 bool wxMenu::DoAppend(
409 wxCHECK_MSG( pItem
, FALSE
, _T("NULL item in wxMenu::DoAppend") );
413 if (pItem
->GetKind() == wxITEM_RADIO
)
415 int nCount
= GetMenuItemCount();
417 if (m_nStartRadioGroup
== -1)
420 // Start a new radio group
422 m_nStartRadioGroup
= nCount
;
425 // For now it has just one element
427 pItem
->SetAsRadioGroupStart();
428 pItem
->SetRadioGroupEnd(m_nStartRadioGroup
);
431 // Ensure that we have a checked item in the radio group
435 else // extend the current radio group
438 // We need to update its end item
440 pItem
->SetRadioGroupStart(m_nStartRadioGroup
);
441 wxMenuItemList::Node
* pNode
= GetMenuItems().Item(m_nStartRadioGroup
);
445 pNode
->GetData()->SetRadioGroupEnd(nCount
);
449 wxFAIL_MSG( _T("where is the radio group start item?") );
453 else // not a radio item
457 if (!wxMenuBase::DoAppend(pItem
) || !DoInsertOrAppend(pItem
))
466 } // end of wxMenu::DoInsert
468 bool wxMenu::DoInsert(
473 return ( wxMenuBase::DoInsert( nPos
475 DoInsertOrAppend( pItem
478 } // end of wxMenu::DoInsert
480 wxMenuItem
* wxMenu::DoRemove(
485 // We need to find the items position in the child list
488 wxMenuItemList::Node
* pNode
= GetMenuItems().GetFirst();
490 for (nPos
= 0; pNode
; nPos
++)
492 if (pNode
->GetData() == pItem
)
494 pNode
= pNode
->GetNext();
498 // DoRemove() (unlike Remove) can only be called for existing item!
500 wxCHECK_MSG(pNode
, NULL
, wxT("bug in wxMenu::Remove logic"));
504 // Remove the corresponding accel from the accel table
506 int n
= FindAccel(pItem
->GetId());
508 if (n
!= wxNOT_FOUND
)
511 m_vAccels
.RemoveAt(n
);
514 #endif // wxUSE_ACCEL
516 // Remove the item from the menu
518 ::WinSendMsg( GetHmenu()
520 ,MPFROM2SHORT(pItem
->GetId(), TRUE
)
523 if (IsAttached() && m_menuBar
->IsAttached())
526 // Otherwise, the chane won't be visible
528 m_menuBar
->Refresh();
532 // And from internal data structures
534 return wxMenuBase::DoRemove(pItem
);
535 } // end of wxMenu::DoRemove
537 // ---------------------------------------------------------------------------
538 // accelerator helpers
539 // ---------------------------------------------------------------------------
544 // Create the wxAcceleratorEntries for our accels and put them into provided
545 // array - return the number of accels we have
547 size_t wxMenu::CopyAccels(
548 wxAcceleratorEntry
* pAccels
551 size_t nCount
= GetAccelCount();
553 for (size_t n
= 0; n
< nCount
; n
++)
555 *pAccels
++ = *m_vAccels
[n
];
558 } // end of wxMenu::CopyAccels
560 #endif // wxUSE_ACCEL
562 // ---------------------------------------------------------------------------
564 // ---------------------------------------------------------------------------
566 void wxMenu::SetTitle(
567 const wxString
& rLabel
570 bool bHasNoTitle
= m_title
.IsEmpty();
571 HWND hMenu
= GetHmenu();
576 if (!rLabel
.IsEmpty())
578 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
580 wxLogLastError("SetMenuTitle");
586 if (rLabel
.IsEmpty() )
588 ::WinSendMsg( GetHmenu()
590 ,MPFROM2SHORT(hMenu
, TRUE
)
599 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
601 wxLogLastError("SetMenuTitle");
605 } // end of wxMenu::SetTitle
607 // ---------------------------------------------------------------------------
609 // ---------------------------------------------------------------------------
611 bool wxMenu::OS2Command(
612 WXUINT
WXUNUSED(uParam
)
617 // Ignore commands from the menu title
620 if (vId
!= (WXWORD
)idMenuTitle
)
623 ,(int)::WinSendMsg( GetHmenu()
631 } // end of wxMenu::OS2Command
633 // ---------------------------------------------------------------------------
635 // ---------------------------------------------------------------------------
637 wxWindow
* wxMenu::GetWindow() const
639 if (m_invokingWindow
!= NULL
)
640 return m_invokingWindow
;
641 else if ( m_menuBar
!= NULL
)
642 return m_menuBar
->GetFrame();
645 } // end of wxMenu::GetWindow
647 // recursive search for item by id
648 wxMenuItem
* wxMenu::FindItem(
651 , wxMenu
** ppItemMenu
657 wxMenuItem
* pItem
= NULL
;
659 for ( wxMenuItemList::Node
*node
= m_items
.GetFirst();
661 node
= node
->GetNext() )
663 pItem
= node
->GetData();
665 if ( pItem
->GetId() == nItemId
&& pItem
->m_vMenuData
.hItem
== hItem
)
668 *ppItemMenu
= (wxMenu
*)this;
670 else if ( pItem
->IsSubMenu() )
672 pItem
= pItem
->GetSubMenu()->FindItem( nItemId
681 // don't exit the loop
686 } // end of wxMenu::FindItem
688 // ---------------------------------------------------------------------------
690 // ---------------------------------------------------------------------------
692 void wxMenuBar::Init()
694 m_eventHandler
= this;
695 m_menuBarFrame
= NULL
;
697 } // end of wxMenuBar::Init
699 wxMenuBar::wxMenuBar()
702 } // end of wxMenuBar::wxMenuBar
704 wxMenuBar::wxMenuBar(
705 long WXUNUSED(lStyle
)
709 } // end of wxMenuBar::wxMenuBar
711 wxMenuBar::wxMenuBar(
714 , const wxString sTitles
[]
719 m_titles
.Alloc(nCount
);
720 for ( int i
= 0; i
< nCount
; i
++ )
722 m_menus
.Append(vMenus
[i
]);
723 m_titles
.Add(sTitles
[i
]);
724 vMenus
[i
]->Attach(this);
726 } // end of wxMenuBar::wxMenuBar
728 wxMenuBar::~wxMenuBar()
730 } // end of wxMenuBar::~wxMenuBar
732 // ---------------------------------------------------------------------------
734 // ---------------------------------------------------------------------------
736 void wxMenuBar::Refresh()
738 wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );
740 WinSendMsg(GetWinHwnd(m_menuBarFrame
), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
741 } // end of wxMenuBar::Refresh
743 WXHMENU
wxMenuBar::Create()
751 wxCHECK_MSG(!m_hMenu
, TRUE
, wxT("menubar already created"));
754 // Menubars should be associated with a frame otherwise they are popups
756 if (m_menuBarFrame
!= NULL
)
757 hFrame
= GetWinHwnd(m_menuBarFrame
);
759 hFrame
= HWND_DESKTOP
;
761 // Create an empty menu and then fill it with insertions
763 if ((m_hMenu
= ::WinCreateWindow( hFrame
766 ,MS_ACTIONBAR
| WS_SYNCPAINT
| WS_VISIBLE
778 wxLogLastError("WinLoadMenu");
782 size_t nCount
= GetMenuCount();
784 for (size_t i
= 0; i
< nCount
; i
++)
792 // Set the parent and owner of the submenues to be the menubar, not the desktop
794 hSubMenu
= m_menus
[i
]->m_vMenuData
.hwndSubMenu
;
795 if (!::WinSetParent(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
, FALSE
))
797 vError
= ::WinGetLastError(vHabmain
);
798 sError
= wxPMErrorToStr(vError
);
799 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
803 if (!::WinSetOwner(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
))
805 vError
= ::WinGetLastError(vHabmain
);
806 sError
= wxPMErrorToStr(vError
);
807 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
811 m_menus
[i
]->m_vMenuData
.iPosition
= i
;
813 rc
= (APIRET
)::WinSendMsg(m_hMenu
, MM_INSERTITEM
, (MPARAM
)&m_menus
[i
]->m_vMenuData
, (MPARAM
)m_titles
[i
].c_str());
814 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
816 vError
= ::WinGetLastError(vHabmain
);
817 sError
= wxPMErrorToStr(vError
);
818 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
);
824 } // end of wxMenuBar::Create
826 // ---------------------------------------------------------------------------
827 // wxMenuBar functions to work with the top level submenus
828 // ---------------------------------------------------------------------------
831 // NB: we don't support owner drawn top level items for now, if we do these
832 // functions would have to be changed to use wxMenuItem as well
834 void wxMenuBar::EnableTop(
839 wxCHECK_RET(IsAttached(), wxT("doesn't work with unattached menubars"));
844 uFlag
= MIA_DISABLED
;
846 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
847 if (nId
== MIT_ERROR
)
849 wxLogLastError("LogLastError");
852 ::WinSendMsg((HWND
)m_hMenu
, MM_SETITEMATTR
, MPFROM2SHORT(nId
, TRUE
), MPFROM2SHORT(MIA_DISABLED
, uFlag
));
854 } // end of wxMenuBar::EnableTop
856 void wxMenuBar::SetLabelTop(
858 , const wxString
& rLabel
864 wxCHECK_RET(nPos
< GetMenuCount(), wxT("invalid menu index"));
865 m_titles
[nPos
] = rLabel
;
872 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
873 if (nId
== MIT_ERROR
)
875 wxLogLastError("LogLastError");
878 if(!::WinSendMsg( (HWND
)m_hMenu
880 ,MPFROM2SHORT(nId
, TRUE
)
884 wxLogLastError("QueryItem");
888 if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT
, MPFROMSHORT(nId
), (MPARAM
)rLabel
.c_str()));
890 wxLogLastError("ModifyMenu");
893 } // end of wxMenuBar::SetLabelTop
895 wxString
wxMenuBar::GetLabelTop(
899 wxCHECK_MSG( nPos
< GetMenuCount(), wxEmptyString
,
900 wxT("invalid menu index in wxMenuBar::GetLabelTop") );
901 return m_titles
[nPos
];
902 } // end of wxMenuBar::GetLabelTop
904 // ---------------------------------------------------------------------------
905 // wxMenuBar construction
906 // ---------------------------------------------------------------------------
908 wxMenu
* wxMenuBar::Replace(
911 , const wxString
& rTitle
915 wxString Title
= TextToLabel(rTitle
);
916 wxMenu
* pMenuOld
= wxMenuBarBase::Replace( nPos
922 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
923 if (nId
== MIT_ERROR
)
925 wxLogLastError("LogLastError");
930 m_titles
[nPos
] = Title
;
933 ::WinSendMsg((HWND
)m_hMenu
, MM_REMOVEITEM
, MPFROM2SHORT(nId
, TRUE
), (MPARAM
)0);
934 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)Title
.c_str());
937 if (pMenuOld
->HasAccels() || pMenu
->HasAccels())
940 // Need to rebuild accell table
944 #endif // wxUSE_ACCEL
948 } // end of wxMenuBar::Replace
950 bool wxMenuBar::Insert(
953 , const wxString
& rTitle
956 wxString Title
= TextToLabel(rTitle
);
957 if (!wxMenuBarBase::Insert( nPos
963 m_titles
.Insert( Title
969 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)Title
.c_str());
971 if (pMenu
->HasAccels())
973 // need to rebuild accell table
976 #endif // wxUSE_ACCEL
980 } // end of wxMenuBar::Insert
982 bool wxMenuBar::Append(
984 , const wxString
& rTitle
987 WXHMENU hSubmenu
= pMenu
? pMenu
->GetHMenu() : 0;
989 wxCHECK_MSG(hSubmenu
, FALSE
, wxT("can't append invalid menu to menubar"));
991 wxString Title
= TextToLabel(rTitle
);
992 if (!wxMenuBarBase::Append(pMenu
, Title
))
999 pMenu
->m_vMenuData
.iPosition
= MIT_END
;
1000 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)Title
.c_str());
1002 if (pMenu
->HasAccels())
1005 // Need to rebuild accell table
1007 RebuildAccelTable();
1009 #endif // wxUSE_ACCEL
1013 } // end of wxMenuBar::Append
1015 wxMenu
* wxMenuBar::Remove(
1019 wxMenu
* pMenu
= wxMenuBarBase::Remove(nPos
);
1025 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)GetHmenu(), MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
1026 if (nId
== MIT_ERROR
)
1028 wxLogLastError("LogLastError");
1033 ::WinSendMsg((HWND
)GetHmenu(), MM_REMOVEITEM
, MPFROM2SHORT(nId
, TRUE
), (MPARAM
)0);
1036 if (pMenu
->HasAccels())
1039 // Need to rebuild accell table
1041 RebuildAccelTable();
1043 #endif // wxUSE_ACCEL
1046 m_titles
.Remove(nPos
);
1048 } // end of wxMenuBar::Remove
1052 void wxMenuBar::RebuildAccelTable()
1055 // Merge the accelerators of all menus into one accel table
1057 size_t nAccelCount
= 0;
1059 size_t nCount
= GetMenuCount();
1061 for (i
= 0; i
< nCount
; i
++)
1063 nAccelCount
+= m_menus
[i
]->GetAccelCount();
1068 wxAcceleratorEntry
* pAccelEntries
= new wxAcceleratorEntry
[nAccelCount
];
1071 for (i
= 0; i
< nCount
; i
++)
1073 nAccelCount
+= m_menus
[i
]->CopyAccels(&pAccelEntries
[nAccelCount
]);
1075 m_vAccelTable
= wxAcceleratorTable( nAccelCount
1078 delete [] pAccelEntries
;
1080 } // end of wxMenuBar::RebuildAccelTable
1082 #endif // wxUSE_ACCEL
1084 void wxMenuBar::Attach(
1088 wxASSERT_MSG( !IsAttached(), wxT("menubar already attached!") );
1091 RebuildAccelTable();
1093 // Ensure the accelerator table is set to the frame (not the client!)
1095 if (!::WinSetAccelTable( vHabmain
1096 ,(HWND
)pFrame
->GetHWND()
1097 ,m_vAccelTable
.GetHACCEL()
1099 wxLogLastError("WinSetAccelTable");
1100 #endif // wxUSE_ACCEL
1101 } // end of wxMenuBar::Attach
1103 void wxMenuBar::Detach()
1105 ::WinDestroyWindow((HWND
)m_hMenu
);
1106 m_hMenu
= (WXHMENU
)NULL
;
1107 m_menuBarFrame
= NULL
;
1108 } // end of wxMenuBar::Detach
1110 // ---------------------------------------------------------------------------
1111 // wxMenuBar searching for menu items
1112 // ---------------------------------------------------------------------------
1115 // Find the itemString in menuString, and return the item id or wxNOT_FOUND
1117 int wxMenuBar::FindMenuItem(
1118 const wxString
& rMenuString
1119 , const wxString
& rItemString
1122 wxString sMenuLabel
= wxStripMenuCodes(rMenuString
);
1123 size_t nCount
= GetMenuCount();
1125 for (size_t i
= 0; i
< nCount
; i
++)
1127 wxString sTitle
= wxStripMenuCodes(m_titles
[i
]);
1129 if (rMenuString
== sTitle
)
1130 return m_menus
[i
]->FindItem(rItemString
);
1133 } // end of wxMenuBar::FindMenuItem
1135 wxMenuItem
* wxMenuBar::FindItem(
1137 , wxMenu
** ppItemMenu
1143 wxMenuItem
* pItem
= NULL
;
1144 size_t nCount
= GetMenuCount();
1146 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1148 pItem
= m_menus
[i
]->FindItem( nId
1153 } // end of wxMenuBar::FindItem
1155 wxMenuItem
* wxMenuBar::FindItem(
1158 , wxMenu
** ppItemMenu
1164 wxMenuItem
* pItem
= NULL
;
1165 size_t nCount
= GetMenuCount();
1167 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1169 pItem
= m_menus
[i
]->FindItem( nId
1175 } // end of wxMenuBar::FindItem