]>
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)
116 m_nStartRadioGroup
= -1;
119 // Create the menu (to be used as a submenu or a popup)
121 if ((m_hMenu
= ::WinCreateWindow( HWND_DESKTOP
136 wxLogLastError("WinLoadMenu");
138 m_vMenuData
.iPosition
= 0;
139 m_vMenuData
.afStyle
= MIS_SUBMENU
| MIS_TEXT
;
140 m_vMenuData
.afAttribute
= (USHORT
)0;
141 m_vMenuData
.id
= m_nextMenuId
++;
142 m_vMenuData
.hwndSubMenu
= m_hMenu
;
143 m_vMenuData
.hItem
= NULLHANDLE
;
146 // If we have a title, insert it in the beginning of the menu
148 if (!m_title
.IsEmpty())
155 } // end of wxMenu::Init
158 // The wxWindow destructor will take care of deleting the submenus.
163 // We should free PM resources only if PM doesn't do it for us
164 // which happens if we're attached to a menubar or a submenu of another
166 if (!IsAttached() && !GetParent())
168 if (!::WinDestroyWindow((HWND
)GetHmenu()) )
170 wxLogLastError("WinDestroyWindow");
178 WX_CLEAR_ARRAY(m_vAccels
);
179 #endif // wxUSE_ACCEL
180 } // end of wxMenu::~wxMenu
184 // this will take effect during the next call to Append()
186 } // end of wxMenu::Break
189 wxMenuBarBase
* pMenubar
192 wxMenuBase::Attach(pMenubar
);
194 } // end of wxMenu::Break;
198 int wxMenu::FindAccel(
203 size_t nCount
= m_vAccels
.GetCount();
205 for (n
= 0; n
< nCount
; n
++)
206 if (m_vAccels
[n
]->m_command
== nId
)
209 } // end of wxMenu::FindAccel
211 void wxMenu::UpdateAccel(
215 if (pItem
->IsSubMenu())
217 wxMenu
* pSubmenu
= pItem
->GetSubMenu();
218 wxMenuItemList::Node
* pNode
= pSubmenu
->GetMenuItems().GetFirst();
222 UpdateAccel(pNode
->GetData());
223 pNode
= pNode
->GetNext();
226 else if (!pItem
->IsSeparator())
229 // Find the (new) accel for this item
231 wxAcceleratorEntry
* pAccel
= wxGetAccelFromString(pItem
->GetText());
234 pAccel
->m_command
= pItem
->GetId();
239 size_t n
= FindAccel(pItem
->GetId());
241 if (n
== wxNOT_FOUND
)
244 // No old, add new if any
247 m_vAccels
.Add(pAccel
);
254 // Replace old with new or just remove the old one if no new
258 m_vAccels
[n
] = pAccel
;
260 m_vAccels
.RemoveAt(n
);
265 m_menuBar
->RebuildAccelTable();
268 } // wxMenu::UpdateAccel
270 #endif // wxUSE_ACCEL
273 // Append a new item or submenu to the menu
275 bool wxMenu::DoInsertOrAppend(
280 wxMenu
* pSubmenu
= pItem
->GetSubMenu();
281 MENUITEM
& rItem
= (pSubmenu
!= NULL
)?pSubmenu
->m_vMenuData
:
289 #endif // wxUSE_ACCEL
292 // rItem is the member MENUITEM for the menu items and the submenu's
293 // MENUITEM for submenus as required by ::MM_INSERTITEM message API
298 wxASSERT_MSG(pSubmenu
->GetHMenu(), wxT("invalid submenu"));
299 pSubmenu
->SetParent(this);
300 rItem
.afStyle
|= MIS_SUBMENU
| MIS_TEXT
;
304 // If "Break" has just been called, insert a menu break before this item
305 // (and don't forget to reset the flag)
309 rItem
.afStyle
|= MIS_BREAK
;
313 if (pItem
->IsSeparator())
315 rItem
.afStyle
|= MIS_SEPARATOR
;
319 // Id is the numeric id for normal menu items and HMENU for submenus as
320 // required by ::MM_INSERTITEM message API
323 if (pSubmenu
!= NULL
)
325 wxASSERT_MSG(pSubmenu
->GetHMenu(), wxT("invalid submenu"));
326 pSubmenu
->SetParent(this);
328 rItem
.iPosition
= 0; // submenus have a 0 position
329 rItem
.id
= (USHORT
)pSubmenu
->GetHMenu();
330 rItem
.afStyle
|= MIS_SUBMENU
| MIS_TEXT
;
334 rItem
.id
= pItem
->GetId();
339 #if wxUSE_OWNER_DRAWN
340 if (pItem
->IsOwnerDrawn())
343 // Want to get {Measure|Draw}Item messages?
344 // item draws itself, passing pointer to data doesn't work in OS/2
345 // Will eventually need to set the image handle somewhere into vItem.hItem
347 rItem
.afStyle
|= MIS_OWNERDRAW
;
349 rItem
.hItem
= (HBITMAP
)pItem
->GetBitmap().GetHBITMAP();
350 pItem
->m_vMenuData
.afStyle
= rItem
.afStyle
;
351 pItem
->m_vMenuData
.hItem
= rItem
.hItem
;
357 // Menu is just a normal string (passed in data parameter)
359 rItem
.afStyle
|= MIS_TEXT
;
360 pData
= (char*)pItem
->GetText().c_str();
363 if (nPos
== (size_t)-1)
365 rItem
.iPosition
= MIT_END
;
369 rItem
.iPosition
= nPos
;
374 rc
= (APIRET
)::WinSendMsg( GetHmenu()
379 #if wxUSE_OWNER_DRAWN
380 if (pItem
->IsOwnerDrawn())
385 ::WinSendMsg( GetHmenu()
387 ,MPFROM2SHORT( (USHORT
)pItem
->GetId()
394 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
396 vError
= ::WinGetLastError(vHabmain
);
397 sError
= wxPMErrorToStr(vError
);
398 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
);
399 wxLogLastError("Insert or AppendMenu");
405 // If we're already attached to the menubar, we must update it
407 if (IsAttached() && m_menuBar
->IsAttached())
409 m_menuBar
->Refresh();
414 } // end of wxMenu::DoInsertOrAppend
416 void wxMenu::EndRadioGroup()
419 // We're not inside a radio group any longer
421 m_nStartRadioGroup
= -1;
422 } // end of wxMenu::EndRadioGroup
424 bool wxMenu::DoAppend(
428 wxCHECK_MSG( pItem
, FALSE
, _T("NULL item in wxMenu::DoAppend") );
432 if (pItem
->GetKind() == wxITEM_RADIO
)
434 int nCount
= GetMenuItemCount();
436 if (m_nStartRadioGroup
== -1)
439 // Start a new radio group
441 m_nStartRadioGroup
= nCount
;
444 // For now it has just one element
446 pItem
->SetAsRadioGroupStart();
447 pItem
->SetRadioGroupEnd(m_nStartRadioGroup
);
450 // Ensure that we have a checked item in the radio group
454 else // extend the current radio group
457 // We need to update its end item
459 pItem
->SetRadioGroupStart(m_nStartRadioGroup
);
461 wxMenuItemList::Node
* pNode
= GetMenuItems().Item(m_nStartRadioGroup
);
465 pNode
->GetData()->SetRadioGroupEnd(nCount
);
469 wxFAIL_MSG( _T("where is the radio group start item?") );
473 else // not a radio item
478 if (!wxMenuBase::DoAppend(pItem
) || !DoInsertOrAppend(pItem
))
485 // Check the item initially
490 } // end of wxMenu::DoAppend
492 bool wxMenu::DoInsert(
497 return ( wxMenuBase::DoInsert( nPos
499 DoInsertOrAppend( pItem
503 } // end of wxMenu::DoInsert
505 wxMenuItem
* wxMenu::DoRemove(
510 // We need to find the items position in the child list
513 wxMenuItemList::Node
* pNode
= GetMenuItems().GetFirst();
515 for (nPos
= 0; pNode
; nPos
++)
517 if (pNode
->GetData() == pItem
)
519 pNode
= pNode
->GetNext();
523 // DoRemove() (unlike Remove) can only be called for existing item!
525 wxCHECK_MSG(pNode
, NULL
, wxT("bug in wxMenu::Remove logic"));
529 // Remove the corresponding accel from the accel table
531 int n
= FindAccel(pItem
->GetId());
533 if (n
!= wxNOT_FOUND
)
536 m_vAccels
.RemoveAt(n
);
539 #endif // wxUSE_ACCEL
541 // Remove the item from the menu
543 ::WinSendMsg( GetHmenu()
545 ,MPFROM2SHORT(pItem
->GetId(), TRUE
)
548 if (IsAttached() && m_menuBar
->IsAttached())
551 // Otherwise, the chane won't be visible
553 m_menuBar
->Refresh();
557 // And from internal data structures
559 return wxMenuBase::DoRemove(pItem
);
560 } // end of wxMenu::DoRemove
562 // ---------------------------------------------------------------------------
563 // accelerator helpers
564 // ---------------------------------------------------------------------------
569 // Create the wxAcceleratorEntries for our accels and put them into provided
570 // array - return the number of accels we have
572 size_t wxMenu::CopyAccels(
573 wxAcceleratorEntry
* pAccels
576 size_t nCount
= GetAccelCount();
578 for (size_t n
= 0; n
< nCount
; n
++)
580 *pAccels
++ = *m_vAccels
[n
];
583 } // end of wxMenu::CopyAccels
585 #endif // wxUSE_ACCEL
587 // ---------------------------------------------------------------------------
589 // ---------------------------------------------------------------------------
591 void wxMenu::SetTitle(
592 const wxString
& rLabel
595 bool bHasNoTitle
= m_title
.IsEmpty();
596 HWND hMenu
= GetHmenu();
601 if (!rLabel
.IsEmpty())
603 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
605 wxLogLastError("SetMenuTitle");
611 if (rLabel
.IsEmpty() )
613 ::WinSendMsg( GetHmenu()
615 ,MPFROM2SHORT(hMenu
, TRUE
)
624 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
626 wxLogLastError("SetMenuTitle");
630 } // end of wxMenu::SetTitle
632 // ---------------------------------------------------------------------------
634 // ---------------------------------------------------------------------------
636 bool wxMenu::OS2Command(
637 WXUINT
WXUNUSED(uParam
)
642 // Ignore commands from the menu title
645 if (vId
!= (WXWORD
)idMenuTitle
)
648 ,(int)::WinSendMsg( GetHmenu()
656 } // end of wxMenu::OS2Command
658 // ---------------------------------------------------------------------------
660 // ---------------------------------------------------------------------------
662 wxWindow
* wxMenu::GetWindow() const
664 if (m_invokingWindow
!= NULL
)
665 return m_invokingWindow
;
666 else if ( m_menuBar
!= NULL
)
667 return m_menuBar
->GetFrame();
670 } // end of wxMenu::GetWindow
672 // recursive search for item by id
673 wxMenuItem
* wxMenu::FindItem(
676 , wxMenu
** ppItemMenu
682 wxMenuItem
* pItem
= NULL
;
684 for ( wxMenuItemList::Node
*node
= m_items
.GetFirst();
686 node
= node
->GetNext() )
688 pItem
= node
->GetData();
690 if ( pItem
->GetId() == nItemId
&& pItem
->m_vMenuData
.hItem
== hItem
)
693 *ppItemMenu
= (wxMenu
*)this;
695 else if ( pItem
->IsSubMenu() )
697 pItem
= pItem
->GetSubMenu()->FindItem( nItemId
706 // don't exit the loop
711 } // end of wxMenu::FindItem
713 // ---------------------------------------------------------------------------
715 // ---------------------------------------------------------------------------
717 void wxMenuBar::Init()
719 m_eventHandler
= this;
720 m_menuBarFrame
= NULL
;
722 } // end of wxMenuBar::Init
724 wxMenuBar::wxMenuBar()
727 } // end of wxMenuBar::wxMenuBar
729 wxMenuBar::wxMenuBar(
730 long WXUNUSED(lStyle
)
734 } // end of wxMenuBar::wxMenuBar
736 wxMenuBar::wxMenuBar(
739 , const wxString sTitles
[]
744 m_titles
.Alloc(nCount
);
745 for ( int i
= 0; i
< nCount
; i
++ )
747 m_menus
.Append(vMenus
[i
]);
748 m_titles
.Add(sTitles
[i
]);
749 vMenus
[i
]->Attach(this);
751 } // end of wxMenuBar::wxMenuBar
753 wxMenuBar::~wxMenuBar()
755 } // end of wxMenuBar::~wxMenuBar
757 // ---------------------------------------------------------------------------
759 // ---------------------------------------------------------------------------
761 void wxMenuBar::Refresh()
763 wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );
765 WinSendMsg(GetWinHwnd(m_menuBarFrame
), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
766 } // end of wxMenuBar::Refresh
768 WXHMENU
wxMenuBar::Create()
776 wxCHECK_MSG(!m_hMenu
, TRUE
, wxT("menubar already created"));
779 // Menubars should be associated with a frame otherwise they are popups
781 if (m_menuBarFrame
!= NULL
)
782 hFrame
= GetWinHwnd(m_menuBarFrame
);
784 hFrame
= HWND_DESKTOP
;
786 // Create an empty menu and then fill it with insertions
788 if ((m_hMenu
= ::WinCreateWindow( hFrame
791 ,MS_ACTIONBAR
| WS_SYNCPAINT
| WS_VISIBLE
803 wxLogLastError("WinLoadMenu");
807 size_t nCount
= GetMenuCount();
809 for (size_t i
= 0; i
< nCount
; i
++)
817 // Set the parent and owner of the submenues to be the menubar, not the desktop
819 hSubMenu
= m_menus
[i
]->m_vMenuData
.hwndSubMenu
;
820 if (!::WinSetParent(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
, FALSE
))
822 vError
= ::WinGetLastError(vHabmain
);
823 sError
= wxPMErrorToStr(vError
);
824 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
828 if (!::WinSetOwner(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
))
830 vError
= ::WinGetLastError(vHabmain
);
831 sError
= wxPMErrorToStr(vError
);
832 wxLogError("Error setting parent for submenu. Error: %s\n", sError
);
836 m_menus
[i
]->m_vMenuData
.iPosition
= i
;
838 rc
= (APIRET
)::WinSendMsg(m_hMenu
, MM_INSERTITEM
, (MPARAM
)&m_menus
[i
]->m_vMenuData
, (MPARAM
)m_titles
[i
].c_str());
839 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
841 vError
= ::WinGetLastError(vHabmain
);
842 sError
= wxPMErrorToStr(vError
);
843 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
);
849 } // end of wxMenuBar::Create
851 // ---------------------------------------------------------------------------
852 // wxMenuBar functions to work with the top level submenus
853 // ---------------------------------------------------------------------------
856 // NB: we don't support owner drawn top level items for now, if we do these
857 // functions would have to be changed to use wxMenuItem as well
859 void wxMenuBar::EnableTop(
864 wxCHECK_RET(IsAttached(), wxT("doesn't work with unattached menubars"));
869 uFlag
= MIA_DISABLED
;
871 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
872 if (nId
== MIT_ERROR
)
874 wxLogLastError("LogLastError");
877 ::WinSendMsg((HWND
)m_hMenu
, MM_SETITEMATTR
, MPFROM2SHORT(nId
, TRUE
), MPFROM2SHORT(MIA_DISABLED
, uFlag
));
879 } // end of wxMenuBar::EnableTop
881 void wxMenuBar::SetLabelTop(
883 , const wxString
& rLabel
889 wxCHECK_RET(nPos
< GetMenuCount(), wxT("invalid menu index"));
890 m_titles
[nPos
] = rLabel
;
897 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
898 if (nId
== MIT_ERROR
)
900 wxLogLastError("LogLastError");
903 if(!::WinSendMsg( (HWND
)m_hMenu
905 ,MPFROM2SHORT(nId
, TRUE
)
909 wxLogLastError("QueryItem");
913 if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT
, MPFROMSHORT(nId
), (MPARAM
)rLabel
.c_str()));
915 wxLogLastError("ModifyMenu");
918 } // end of wxMenuBar::SetLabelTop
920 wxString
wxMenuBar::GetLabelTop(
924 wxCHECK_MSG( nPos
< GetMenuCount(), wxEmptyString
,
925 wxT("invalid menu index in wxMenuBar::GetLabelTop") );
926 return m_titles
[nPos
];
927 } // end of wxMenuBar::GetLabelTop
929 // ---------------------------------------------------------------------------
930 // wxMenuBar construction
931 // ---------------------------------------------------------------------------
933 wxMenu
* wxMenuBar::Replace(
936 , const wxString
& rTitle
940 wxString Title
= TextToLabel(rTitle
);
941 wxMenu
* pMenuOld
= wxMenuBarBase::Replace( nPos
947 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
948 if (nId
== MIT_ERROR
)
950 wxLogLastError("LogLastError");
955 m_titles
[nPos
] = Title
;
958 ::WinSendMsg((HWND
)m_hMenu
, MM_REMOVEITEM
, MPFROM2SHORT(nId
, TRUE
), (MPARAM
)0);
959 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)Title
.c_str());
962 if (pMenuOld
->HasAccels() || pMenu
->HasAccels())
965 // Need to rebuild accell table
969 #endif // wxUSE_ACCEL
973 } // end of wxMenuBar::Replace
975 bool wxMenuBar::Insert(
978 , const wxString
& rTitle
981 wxString Title
= TextToLabel(rTitle
);
982 if (!wxMenuBarBase::Insert( nPos
988 m_titles
.Insert( Title
994 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)Title
.c_str());
996 if (pMenu
->HasAccels())
998 // need to rebuild accell table
1001 #endif // wxUSE_ACCEL
1005 } // end of wxMenuBar::Insert
1007 bool wxMenuBar::Append(
1009 , const wxString
& rTitle
1012 WXHMENU hSubmenu
= pMenu
? pMenu
->GetHMenu() : 0;
1014 wxCHECK_MSG(hSubmenu
, FALSE
, wxT("can't append invalid menu to menubar"));
1016 wxString Title
= TextToLabel(rTitle
);
1017 if (!wxMenuBarBase::Append(pMenu
, Title
))
1020 m_titles
.Add(Title
);
1024 pMenu
->m_vMenuData
.iPosition
= MIT_END
;
1025 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)Title
.c_str());
1027 if (pMenu
->HasAccels())
1030 // Need to rebuild accell table
1032 RebuildAccelTable();
1034 #endif // wxUSE_ACCEL
1038 } // end of wxMenuBar::Append
1040 wxMenu
* wxMenuBar::Remove(
1044 wxMenu
* pMenu
= wxMenuBarBase::Remove(nPos
);
1050 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)GetHmenu(), MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
1051 if (nId
== MIT_ERROR
)
1053 wxLogLastError("LogLastError");
1058 ::WinSendMsg((HWND
)GetHmenu(), MM_REMOVEITEM
, MPFROM2SHORT(nId
, TRUE
), (MPARAM
)0);
1061 if (pMenu
->HasAccels())
1064 // Need to rebuild accell table
1066 RebuildAccelTable();
1068 #endif // wxUSE_ACCEL
1071 m_titles
.Remove(nPos
);
1073 } // end of wxMenuBar::Remove
1077 void wxMenuBar::RebuildAccelTable()
1080 // Merge the accelerators of all menus into one accel table
1082 size_t nAccelCount
= 0;
1084 size_t nCount
= GetMenuCount();
1086 for (i
= 0; i
< nCount
; i
++)
1088 nAccelCount
+= m_menus
[i
]->GetAccelCount();
1093 wxAcceleratorEntry
* pAccelEntries
= new wxAcceleratorEntry
[nAccelCount
];
1096 for (i
= 0; i
< nCount
; i
++)
1098 nAccelCount
+= m_menus
[i
]->CopyAccels(&pAccelEntries
[nAccelCount
]);
1100 m_vAccelTable
= wxAcceleratorTable( nAccelCount
1103 delete [] pAccelEntries
;
1105 } // end of wxMenuBar::RebuildAccelTable
1107 #endif // wxUSE_ACCEL
1109 void wxMenuBar::Attach(
1113 wxMenuBarBase::Attach(pFrame
);
1116 RebuildAccelTable();
1118 // Ensure the accelerator table is set to the frame (not the client!)
1120 if (!::WinSetAccelTable( vHabmain
1121 ,m_vAccelTable
.GetHACCEL()
1122 ,(HWND
)pFrame
->GetFrame()
1124 wxLogLastError("WinSetAccelTable");
1125 #endif // wxUSE_ACCEL
1126 } // end of wxMenuBar::Attach
1128 void wxMenuBar::Detach()
1130 ::WinDestroyWindow((HWND
)m_hMenu
);
1131 m_hMenu
= (WXHMENU
)NULL
;
1132 m_menuBarFrame
= NULL
;
1133 } // end of wxMenuBar::Detach
1135 // ---------------------------------------------------------------------------
1136 // wxMenuBar searching for menu items
1137 // ---------------------------------------------------------------------------
1140 // Find the itemString in menuString, and return the item id or wxNOT_FOUND
1142 int wxMenuBar::FindMenuItem(
1143 const wxString
& rMenuString
1144 , const wxString
& rItemString
1147 wxString sMenuLabel
= wxStripMenuCodes(rMenuString
);
1148 size_t nCount
= GetMenuCount();
1150 for (size_t i
= 0; i
< nCount
; i
++)
1152 wxString sTitle
= wxStripMenuCodes(m_titles
[i
]);
1154 if (rMenuString
== sTitle
)
1155 return m_menus
[i
]->FindItem(rItemString
);
1158 } // end of wxMenuBar::FindMenuItem
1160 wxMenuItem
* wxMenuBar::FindItem(
1162 , wxMenu
** ppItemMenu
1168 wxMenuItem
* pItem
= NULL
;
1169 size_t nCount
= GetMenuCount();
1171 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1173 pItem
= m_menus
[i
]->FindItem( nId
1178 } // end of wxMenuBar::FindItem
1180 wxMenuItem
* wxMenuBar::FindItem(
1183 , wxMenu
** ppItemMenu
1189 wxMenuItem
* pItem
= NULL
;
1190 size_t nCount
= GetMenuCount();
1192 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1194 pItem
= m_menus
[i
]->FindItem( nId
1200 } // end of wxMenuBar::FindItem