]>
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(
73 const wxString
& rsTitle
79 for (zPc
= rsTitle
.c_str(); *zPc
!= wxT('\0'); zPc
++ )
81 if (*zPc
== wxT('&') )
83 if (*(zPc
+ 1) == wxT('&'))
93 if ( *zPc
== wxT('~') )
96 // Tildes must be doubled to prevent them from being
97 // interpreted as accelerator character prefix by PM ???
105 } // end of TextToLabel
107 // ============================================================================
109 // ============================================================================
111 // ---------------------------------------------------------------------------
112 // wxMenu construction, adding and removing menu items
113 // ---------------------------------------------------------------------------
116 // Construct a menu with optional title (then use append)
121 m_nStartRadioGroup
= -1;
124 // Create the menu (to be used as a submenu or a popup)
126 if ((m_hMenu
= ::WinCreateWindow( HWND_DESKTOP
141 wxLogLastError("WinLoadMenu");
143 m_vMenuData
.iPosition
= 0;
144 m_vMenuData
.afStyle
= MIS_SUBMENU
| MIS_TEXT
;
145 m_vMenuData
.afAttribute
= (USHORT
)0;
146 m_vMenuData
.id
= m_nextMenuId
++;
147 m_vMenuData
.hwndSubMenu
= m_hMenu
;
148 m_vMenuData
.hItem
= NULLHANDLE
;
151 // If we have a title, insert it in the beginning of the menu
153 if (!m_title
.IsEmpty())
162 } // end of wxMenu::Init
165 // The wxWindow destructor will take care of deleting the submenus.
170 // We should free PM resources only if PM doesn't do it for us
171 // which happens if we're attached to a menubar or a submenu of another
173 if (!IsAttached() && !GetParent())
175 if (!::WinDestroyWindow((HWND
)GetHmenu()) )
177 wxLogLastError("WinDestroyWindow");
185 WX_CLEAR_ARRAY(m_vAccels
);
186 #endif // wxUSE_ACCEL
187 } // end of wxMenu::~wxMenu
191 // this will take effect during the next call to Append()
193 } // end of wxMenu::Break
196 wxMenuBarBase
* pMenubar
199 wxMenuBase::Attach(pMenubar
);
201 } // end of wxMenu::Break;
205 int wxMenu::FindAccel(
210 size_t nCount
= m_vAccels
.GetCount();
212 for (n
= 0; n
< nCount
; n
++)
213 if (m_vAccels
[n
]->m_command
== nId
)
216 } // end of wxMenu::FindAccel
218 void wxMenu::UpdateAccel(
222 if (pItem
->IsSubMenu())
224 wxMenu
* pSubmenu
= pItem
->GetSubMenu();
225 wxMenuItemList::Node
* pNode
= pSubmenu
->GetMenuItems().GetFirst();
229 UpdateAccel(pNode
->GetData());
230 pNode
= pNode
->GetNext();
233 else if (!pItem
->IsSeparator())
236 // Find the (new) accel for this item
238 wxAcceleratorEntry
* pAccel
= wxGetAccelFromString(pItem
->GetText());
241 pAccel
->m_command
= pItem
->GetId();
246 size_t n
= FindAccel(pItem
->GetId());
248 if (n
== wxNOT_FOUND
)
251 // No old, add new if any
254 m_vAccels
.Add(pAccel
);
261 // Replace old with new or just remove the old one if no new
265 m_vAccels
[n
] = pAccel
;
267 m_vAccels
.RemoveAt(n
);
272 m_menuBar
->RebuildAccelTable();
275 } // wxMenu::UpdateAccel
277 #endif // wxUSE_ACCEL
280 // Append a new item or submenu to the menu
282 bool wxMenu::DoInsertOrAppend(
287 wxMenu
* pSubmenu
= pItem
->GetSubMenu();
288 MENUITEM
& rItem
= (pSubmenu
!= NULL
)?pSubmenu
->m_vMenuData
:
296 #endif // wxUSE_ACCEL
299 // If "Break" has just been called, insert a menu break before this item
300 // (and don't forget to reset the flag)
304 rItem
.afStyle
|= MIS_BREAK
;
308 if (pItem
->IsSeparator())
310 rItem
.afStyle
|= MIS_SEPARATOR
;
314 // Id is the numeric id for normal menu items and HMENU for submenus as
315 // required by ::MM_INSERTITEM message API
318 if (pSubmenu
!= NULL
)
320 wxASSERT_MSG(pSubmenu
->GetHMenu(), wxT("invalid submenu"));
321 pSubmenu
->SetParent(this);
323 rItem
.iPosition
= 0; // submenus have a 0 position
324 rItem
.id
= (USHORT
)pSubmenu
->GetHMenu();
325 rItem
.afStyle
|= MIS_SUBMENU
| MIS_TEXT
;
329 rItem
.id
= pItem
->GetId();
334 #if wxUSE_OWNER_DRAWN
335 if (pItem
->IsOwnerDrawn())
338 // Want to get {Measure|Draw}Item messages?
339 // item draws itself, passing pointer to data doesn't work in OS/2
340 // Will eventually need to set the image handle somewhere into vItem.hItem
342 rItem
.afStyle
|= MIS_OWNERDRAW
;
344 rItem
.hItem
= (HBITMAP
)pItem
->GetBitmap().GetHBITMAP();
345 pItem
->m_vMenuData
.afStyle
= rItem
.afStyle
;
346 pItem
->m_vMenuData
.hItem
= rItem
.hItem
;
352 // Menu is just a normal string (passed in data parameter)
354 rItem
.afStyle
|= MIS_TEXT
;
355 pData
= (char*)pItem
->GetText().c_str();
358 if (nPos
== (size_t)-1)
360 rItem
.iPosition
= MIT_END
;
364 rItem
.iPosition
= nPos
;
369 rc
= (APIRET
)::WinSendMsg( GetHmenu()
374 #if wxUSE_OWNER_DRAWN
375 if (pItem
->IsOwnerDrawn())
380 ::WinSendMsg( GetHmenu()
382 ,MPFROM2SHORT( (USHORT
)pItem
->GetId()
389 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
391 vError
= ::WinGetLastError(vHabmain
);
392 sError
= wxPMErrorToStr(vError
);
393 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
);
394 wxLogLastError("Insert or AppendMenu");
400 // If we're already attached to the menubar, we must update it
402 if (IsAttached() && m_menuBar
->IsAttached())
404 m_menuBar
->Refresh();
409 } // end of wxMenu::DoInsertOrAppend
411 void wxMenu::EndRadioGroup()
414 // We're not inside a radio group any longer
416 m_nStartRadioGroup
= -1;
417 } // end of wxMenu::EndRadioGroup
419 bool wxMenu::DoAppend(
423 wxCHECK_MSG( pItem
, FALSE
, _T("NULL item in wxMenu::DoAppend") );
427 if (pItem
->GetKind() == wxITEM_RADIO
)
429 int nCount
= GetMenuItemCount();
431 if (m_nStartRadioGroup
== -1)
434 // Start a new radio group
436 m_nStartRadioGroup
= nCount
;
439 // For now it has just one element
441 pItem
->SetAsRadioGroupStart();
442 pItem
->SetRadioGroupEnd(m_nStartRadioGroup
);
445 // Ensure that we have a checked item in the radio group
449 else // extend the current radio group
452 // We need to update its end item
454 pItem
->SetRadioGroupStart(m_nStartRadioGroup
);
456 wxMenuItemList::Node
* pNode
= GetMenuItems().Item(m_nStartRadioGroup
);
460 pNode
->GetData()->SetRadioGroupEnd(nCount
);
464 wxFAIL_MSG( _T("where is the radio group start item?") );
468 else // not a radio item
473 if (!wxMenuBase::DoAppend(pItem
) || !DoInsertOrAppend(pItem
))
480 // Check the item initially
485 } // end of wxMenu::DoAppend
487 bool wxMenu::DoInsert(
492 return ( wxMenuBase::DoInsert( nPos
494 DoInsertOrAppend( pItem
498 } // end of wxMenu::DoInsert
500 wxMenuItem
* wxMenu::DoRemove(
505 // We need to find the items position in the child list
508 wxMenuItemList::Node
* pNode
= GetMenuItems().GetFirst();
510 for (nPos
= 0; pNode
; nPos
++)
512 if (pNode
->GetData() == pItem
)
514 pNode
= pNode
->GetNext();
518 // DoRemove() (unlike Remove) can only be called for existing item!
520 wxCHECK_MSG(pNode
, NULL
, wxT("bug in wxMenu::Remove logic"));
524 // Remove the corresponding accel from the accel table
526 int n
= FindAccel(pItem
->GetId());
528 if (n
!= wxNOT_FOUND
)
531 m_vAccels
.RemoveAt(n
);
534 #endif // wxUSE_ACCEL
536 // Remove the item from the menu
538 ::WinSendMsg( GetHmenu()
540 ,MPFROM2SHORT(pItem
->GetId(), TRUE
)
543 if (IsAttached() && m_menuBar
->IsAttached())
546 // Otherwise, the chane won't be visible
548 m_menuBar
->Refresh();
552 // And from internal data structures
554 return wxMenuBase::DoRemove(pItem
);
555 } // end of wxMenu::DoRemove
557 // ---------------------------------------------------------------------------
558 // accelerator helpers
559 // ---------------------------------------------------------------------------
564 // Create the wxAcceleratorEntries for our accels and put them into provided
565 // array - return the number of accels we have
567 size_t wxMenu::CopyAccels(
568 wxAcceleratorEntry
* pAccels
571 size_t nCount
= GetAccelCount();
573 for (size_t n
= 0; n
< nCount
; n
++)
575 *pAccels
++ = *m_vAccels
[n
];
578 } // end of wxMenu::CopyAccels
580 #endif // wxUSE_ACCEL
582 // ---------------------------------------------------------------------------
584 // ---------------------------------------------------------------------------
586 void wxMenu::SetTitle(
587 const wxString
& rLabel
590 bool bHasNoTitle
= m_title
.IsEmpty();
591 HWND hMenu
= GetHmenu();
596 if (!rLabel
.IsEmpty())
598 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
600 wxLogLastError("SetMenuTitle");
606 if (rLabel
.IsEmpty() )
608 ::WinSendMsg( GetHmenu()
610 ,MPFROM2SHORT(hMenu
, TRUE
)
619 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
621 wxLogLastError("SetMenuTitle");
625 } // end of wxMenu::SetTitle
627 // ---------------------------------------------------------------------------
629 // ---------------------------------------------------------------------------
631 bool wxMenu::OS2Command(
632 WXUINT
WXUNUSED(uParam
)
637 // Ignore commands from the menu title
640 if (vId
!= (WXWORD
)idMenuTitle
)
643 ,(int)::WinSendMsg( GetHmenu()
651 } // end of wxMenu::OS2Command
653 // ---------------------------------------------------------------------------
655 // ---------------------------------------------------------------------------
657 wxWindow
* wxMenu::GetWindow() const
659 if (m_invokingWindow
!= NULL
)
660 return m_invokingWindow
;
661 else if ( m_menuBar
!= NULL
)
662 return m_menuBar
->GetFrame();
665 } // end of wxMenu::GetWindow
667 // recursive search for item by id
668 wxMenuItem
* wxMenu::FindItem(
671 , wxMenu
** ppItemMenu
677 wxMenuItem
* pItem
= NULL
;
679 for ( wxMenuItemList::Node
*node
= m_items
.GetFirst();
681 node
= node
->GetNext() )
683 pItem
= node
->GetData();
685 if ( pItem
->GetId() == nItemId
&& pItem
->m_vMenuData
.hItem
== hItem
)
688 *ppItemMenu
= (wxMenu
*)this;
690 else if ( pItem
->IsSubMenu() )
692 pItem
= pItem
->GetSubMenu()->FindItem( nItemId
701 // don't exit the loop
706 } // end of wxMenu::FindItem
708 // ---------------------------------------------------------------------------
710 // ---------------------------------------------------------------------------
712 void wxMenuBar::Init()
714 m_eventHandler
= this;
715 m_menuBarFrame
= NULL
;
717 } // end of wxMenuBar::Init
719 wxMenuBar::wxMenuBar()
722 } // end of wxMenuBar::wxMenuBar
724 wxMenuBar::wxMenuBar(
725 long WXUNUSED(lStyle
)
729 } // end of wxMenuBar::wxMenuBar
731 wxMenuBar::wxMenuBar(
734 , const wxString sTitles
[]
739 m_titles
.Alloc(nCount
);
740 for ( int i
= 0; i
< nCount
; i
++ )
742 m_menus
.Append(vMenus
[i
]);
743 m_titles
.Add(sTitles
[i
]);
744 vMenus
[i
]->Attach(this);
746 } // end of wxMenuBar::wxMenuBar
748 wxMenuBar::~wxMenuBar()
750 } // end of wxMenuBar::~wxMenuBar
752 // ---------------------------------------------------------------------------
754 // ---------------------------------------------------------------------------
756 void wxMenuBar::Refresh()
758 wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );
760 WinSendMsg(GetWinHwnd(m_menuBarFrame
), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
761 } // end of wxMenuBar::Refresh
763 WXHMENU
wxMenuBar::Create()
771 wxCHECK_MSG(!m_hMenu
, TRUE
, wxT("menubar already created"));
774 // Menubars should be associated with a frame otherwise they are popups
776 if (m_menuBarFrame
!= NULL
)
777 hFrame
= GetWinHwnd(m_menuBarFrame
);
779 hFrame
= HWND_DESKTOP
;
781 // Create an empty menu and then fill it with insertions
783 if ((m_hMenu
= ::WinCreateWindow( hFrame
786 ,MS_ACTIONBAR
| WS_SYNCPAINT
| WS_VISIBLE
798 wxLogLastError("WinLoadMenu");
802 size_t nCount
= GetMenuCount();
804 for (size_t i
= 0; i
< nCount
; i
++)
812 // Set the parent and owner of the submenues to be the menubar, not the desktop
814 hSubMenu
= m_menus
[i
]->m_vMenuData
.hwndSubMenu
;
815 if (!::WinSetParent(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
, FALSE
))
817 vError
= ::WinGetLastError(vHabmain
);
818 sError
= wxPMErrorToStr(vError
);
819 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
823 if (!::WinSetOwner(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
))
825 vError
= ::WinGetLastError(vHabmain
);
826 sError
= wxPMErrorToStr(vError
);
827 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
831 m_menus
[i
]->m_vMenuData
.iPosition
= i
;
833 rc
= (APIRET
)::WinSendMsg(m_hMenu
, MM_INSERTITEM
, (MPARAM
)&m_menus
[i
]->m_vMenuData
, (MPARAM
)m_titles
[i
].c_str());
834 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
836 vError
= ::WinGetLastError(vHabmain
);
837 sError
= wxPMErrorToStr(vError
);
838 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
);
844 } // end of wxMenuBar::Create
846 // ---------------------------------------------------------------------------
847 // wxMenuBar functions to work with the top level submenus
848 // ---------------------------------------------------------------------------
851 // NB: we don't support owner drawn top level items for now, if we do these
852 // functions would have to be changed to use wxMenuItem as well
854 void wxMenuBar::EnableTop(
859 wxCHECK_RET(IsAttached(), wxT("doesn't work with unattached menubars"));
864 uFlag
= MIA_DISABLED
;
866 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
867 if (nId
== MIT_ERROR
)
869 wxLogLastError("LogLastError");
872 ::WinSendMsg((HWND
)m_hMenu
, MM_SETITEMATTR
, MPFROM2SHORT(nId
, TRUE
), MPFROM2SHORT(MIA_DISABLED
, uFlag
));
874 } // end of wxMenuBar::EnableTop
876 void wxMenuBar::SetLabelTop(
878 , const wxString
& rLabel
884 wxCHECK_RET(nPos
< GetMenuCount(), wxT("invalid menu index"));
885 m_titles
[nPos
] = rLabel
;
892 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
893 if (nId
== MIT_ERROR
)
895 wxLogLastError("LogLastError");
898 if(!::WinSendMsg( (HWND
)m_hMenu
900 ,MPFROM2SHORT(nId
, TRUE
)
904 wxLogLastError("QueryItem");
908 if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT
, MPFROMSHORT(nId
), (MPARAM
)rLabel
.c_str()));
910 wxLogLastError("ModifyMenu");
913 } // end of wxMenuBar::SetLabelTop
915 wxString
wxMenuBar::GetLabelTop(
919 wxCHECK_MSG( nPos
< GetMenuCount(), wxEmptyString
,
920 wxT("invalid menu index in wxMenuBar::GetLabelTop") );
921 return m_titles
[nPos
];
922 } // end of wxMenuBar::GetLabelTop
924 // ---------------------------------------------------------------------------
925 // wxMenuBar construction
926 // ---------------------------------------------------------------------------
928 wxMenu
* wxMenuBar::Replace(
931 , const wxString
& rTitle
935 wxString sTitle
= TextToLabel(rTitle
);
936 wxMenu
* pMenuOld
= wxMenuBarBase::Replace( nPos
942 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
943 if (nId
== MIT_ERROR
)
945 wxLogLastError("LogLastError");
950 m_titles
[nPos
] = sTitle
;
953 ::WinSendMsg((HWND
)m_hMenu
, MM_REMOVEITEM
, MPFROM2SHORT(nId
, TRUE
), (MPARAM
)0);
954 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)sTitle
.c_str());
957 if (pMenuOld
->HasAccels() || pMenu
->HasAccels())
960 // Need to rebuild accell table
964 #endif // wxUSE_ACCEL
968 } // end of wxMenuBar::Replace
970 bool wxMenuBar::Insert(
973 , const wxString
& rTitle
976 wxString sTitle
= TextToLabel(rTitle
);
978 if (!wxMenuBarBase::Insert( nPos
984 m_titles
.Insert( sTitle
990 pMenu
->m_vMenuData
.iPosition
= nPos
;
991 ::WinSendMsg( (HWND
)m_hMenu
993 ,(MPARAM
)&pMenu
->m_vMenuData
994 ,(MPARAM
)sTitle
.c_str()
997 if (pMenu
->HasAccels())
999 // need to rebuild accell table
1000 RebuildAccelTable();
1002 #endif // wxUSE_ACCEL
1006 } // end of wxMenuBar::Insert
1008 bool wxMenuBar::Append(
1010 , const wxString
& rsTitle
1013 WXHMENU hSubmenu
= pMenu
? pMenu
->GetHMenu() : 0;
1015 wxCHECK_MSG(hSubmenu
, FALSE
, wxT("can't append invalid menu to menubar"));
1017 wxString sTitle
= TextToLabel(rsTitle
);
1019 if (!wxMenuBarBase::Append(pMenu
, sTitle
))
1022 m_titles
.Add(sTitle
);
1026 pMenu
->m_vMenuData
.iPosition
= MIT_END
;
1027 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)sTitle
.c_str());
1029 if (pMenu
->HasAccels())
1032 // Need to rebuild accell table
1034 RebuildAccelTable();
1036 #endif // wxUSE_ACCEL
1040 } // end of wxMenuBar::Append
1042 wxMenu
* wxMenuBar::Remove(
1046 wxMenu
* pMenu
= wxMenuBarBase::Remove(nPos
);
1052 nId
= SHORT1FROMMR(::WinSendMsg( (HWND
)GetHmenu()
1053 ,MM_ITEMIDFROMPOSITION
1057 if (nId
== MIT_ERROR
)
1059 wxLogLastError("LogLastError");
1064 ::WinSendMsg( (HWND
)GetHmenu()
1066 ,MPFROM2SHORT(nId
, TRUE
)
1071 if (pMenu
->HasAccels())
1074 // Need to rebuild accell table
1076 RebuildAccelTable();
1078 #endif // wxUSE_ACCEL
1081 m_titles
.Remove(nPos
);
1083 } // end of wxMenuBar::Remove
1087 void wxMenuBar::RebuildAccelTable()
1090 // Merge the accelerators of all menus into one accel table
1092 size_t nAccelCount
= 0;
1094 size_t nCount
= GetMenuCount();
1096 for (i
= 0; i
< nCount
; i
++)
1098 nAccelCount
+= m_menus
[i
]->GetAccelCount();
1103 wxAcceleratorEntry
* pAccelEntries
= new wxAcceleratorEntry
[nAccelCount
];
1106 for (i
= 0; i
< nCount
; i
++)
1108 nAccelCount
+= m_menus
[i
]->CopyAccels(&pAccelEntries
[nAccelCount
]);
1110 m_vAccelTable
= wxAcceleratorTable( nAccelCount
1113 delete [] pAccelEntries
;
1115 } // end of wxMenuBar::RebuildAccelTable
1117 #endif // wxUSE_ACCEL
1119 void wxMenuBar::Attach(
1123 wxMenuBarBase::Attach(pFrame
);
1126 RebuildAccelTable();
1128 // Ensure the accelerator table is set to the frame (not the client!)
1130 if (!::WinSetAccelTable( vHabmain
1131 ,m_vAccelTable
.GetHACCEL()
1132 ,(HWND
)pFrame
->GetFrame()
1134 wxLogLastError("WinSetAccelTable");
1135 #endif // wxUSE_ACCEL
1136 } // end of wxMenuBar::Attach
1138 void wxMenuBar::Detach()
1140 ::WinDestroyWindow((HWND
)m_hMenu
);
1141 m_hMenu
= (WXHMENU
)NULL
;
1142 m_menuBarFrame
= NULL
;
1143 } // end of wxMenuBar::Detach
1145 // ---------------------------------------------------------------------------
1146 // wxMenuBar searching for menu items
1147 // ---------------------------------------------------------------------------
1150 // Find the itemString in menuString, and return the item id or wxNOT_FOUND
1152 int wxMenuBar::FindMenuItem(
1153 const wxString
& rMenuString
1154 , const wxString
& rItemString
1157 wxString sMenuLabel
= wxStripMenuCodes(rMenuString
);
1158 size_t nCount
= GetMenuCount();
1160 for (size_t i
= 0; i
< nCount
; i
++)
1162 wxString sTitle
= wxStripMenuCodes(m_titles
[i
]);
1164 if (rMenuString
== sTitle
)
1165 return m_menus
[i
]->FindItem(rItemString
);
1168 } // end of wxMenuBar::FindMenuItem
1170 wxMenuItem
* wxMenuBar::FindItem(
1172 , wxMenu
** ppItemMenu
1178 wxMenuItem
* pItem
= NULL
;
1179 size_t nCount
= GetMenuCount();
1181 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1183 pItem
= m_menus
[i
]->FindItem( nId
1188 } // end of wxMenuBar::FindItem
1190 wxMenuItem
* wxMenuBar::FindItem(
1193 , wxMenu
** ppItemMenu
1199 wxMenuItem
* pItem
= NULL
;
1200 size_t nCount
= GetMenuCount();
1202 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1204 pItem
= m_menus
[i
]->FindItem( nId
1210 } // end of wxMenuBar::FindItem