]>
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
55 USHORT
wxMenu::m_nextMenuId
= 0;
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
61 IMPLEMENT_DYNAMIC_CLASS(wxMenu
, wxEvtHandler
)
62 IMPLEMENT_DYNAMIC_CLASS(wxMenuBar
, wxEvtHandler
)
64 // ----------------------------------------------------------------------------
65 // static function for translating menu labels
66 // ----------------------------------------------------------------------------
68 static wxString
TextToLabel(
69 const wxString
& rsTitle
75 if (rsTitle
.IsEmpty())
77 for (zPc
= rsTitle
.c_str(); *zPc
!= wxT('\0'); zPc
++ )
79 if (*zPc
== wxT('&') )
81 if (*(zPc
+ 1) == wxT('&'))
91 if ( *zPc
== wxT('~') )
94 // Tildes must be doubled to prevent them from being
95 // interpreted as accelerator character prefix by PM ???
103 } // end of TextToLabel
105 // ============================================================================
107 // ============================================================================
109 // ---------------------------------------------------------------------------
110 // wxMenu construction, adding and removing menu items
111 // ---------------------------------------------------------------------------
114 // Construct a menu with optional title (then use append)
119 m_nStartRadioGroup
= -1;
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())
160 } // end of wxMenu::Init
163 // The wxWindow destructor will take care of deleting the submenus.
168 // We should free PM resources only if PM doesn't do it for us
169 // which happens if we're attached to a menubar or a submenu of another
171 if (!IsAttached() && !GetParent())
173 if (!::WinDestroyWindow((HWND
)GetHmenu()) )
175 wxLogLastError("WinDestroyWindow");
183 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
194 wxMenuBarBase
* pMenubar
197 wxMenuBase::Attach(pMenubar
);
199 } // end of wxMenu::Break;
203 int wxMenu::FindAccel(
208 size_t nCount
= m_vAccels
.GetCount();
210 for (n
= 0; n
< nCount
; n
++)
211 if (m_vAccels
[n
]->m_command
== nId
)
214 } // end of wxMenu::FindAccel
216 void wxMenu::UpdateAccel(
220 if (pItem
->IsSubMenu())
222 wxMenu
* pSubmenu
= pItem
->GetSubMenu();
223 wxMenuItemList::Node
* pNode
= pSubmenu
->GetMenuItems().GetFirst();
227 UpdateAccel(pNode
->GetData());
228 pNode
= pNode
->GetNext();
231 else if (!pItem
->IsSeparator())
234 // Find the (new) accel for this item
236 wxAcceleratorEntry
* pAccel
= wxGetAccelFromString(pItem
->GetText());
239 pAccel
->m_command
= pItem
->GetId();
244 size_t n
= FindAccel(pItem
->GetId());
246 if (n
== wxNOT_FOUND
)
249 // No old, add new if any
252 m_vAccels
.Add(pAccel
);
259 // Replace old with new or just remove the old one if no new
263 m_vAccels
[n
] = pAccel
;
265 m_vAccels
.RemoveAt(n
);
270 m_menuBar
->RebuildAccelTable();
273 } // wxMenu::UpdateAccel
275 #endif // wxUSE_ACCEL
278 // Append a new item or submenu to the menu
280 bool wxMenu::DoInsertOrAppend(
285 wxMenu
* pSubmenu
= pItem
->GetSubMenu();
286 MENUITEM
& rItem
= (pSubmenu
!= NULL
)?pSubmenu
->m_vMenuData
:
295 #endif // wxUSE_ACCEL
298 // If "Break" has just been called, insert a menu break before this item
299 // (and don't forget to reset the flag)
303 rItem
.afStyle
|= MIS_BREAK
;
307 if (pItem
->IsSeparator())
309 rItem
.afStyle
|= MIS_SEPARATOR
;
313 // Id is the numeric id for normal menu items and HMENU for submenus as
314 // required by ::MM_INSERTITEM message API
317 if (pSubmenu
!= NULL
)
319 wxASSERT_MSG(pSubmenu
->GetHMenu(), wxT("invalid submenu"));
320 pSubmenu
->SetParent(this);
322 rItem
.iPosition
= 0; // submenus have a 0 position
323 rItem
.id
= (USHORT
)pSubmenu
->GetHMenu();
324 rItem
.afStyle
|= MIS_SUBMENU
| MIS_TEXT
;
328 rItem
.id
= pItem
->GetId();
333 #if wxUSE_OWNER_DRAWN
334 if (pItem
->IsOwnerDrawn())
337 // Want to get {Measure|Draw}Item messages?
338 // item draws itself, passing pointer to data doesn't work in OS/2
339 // Will eventually need to set the image handle somewhere into vItem.hItem
341 rItem
.afStyle
|= MIS_OWNERDRAW
;
343 rItem
.hItem
= (HBITMAP
)pItem
->GetBitmap().GetHBITMAP();
344 pItem
->m_vMenuData
.afStyle
= rItem
.afStyle
;
345 pItem
->m_vMenuData
.hItem
= rItem
.hItem
;
351 // Menu is just a normal string (passed in data parameter)
353 rItem
.afStyle
|= MIS_TEXT
;
354 pData
= (char*)pItem
->GetText().c_str();
357 if (nPos
== (size_t)-1)
359 rItem
.iPosition
= MIT_END
;
363 rItem
.iPosition
= nPos
;
368 rc
= (APIRET
)::WinSendMsg( GetHmenu()
373 #if wxUSE_OWNER_DRAWN
374 if (pItem
->IsOwnerDrawn())
379 ::WinSendMsg( GetHmenu()
381 ,MPFROM2SHORT( (USHORT
)pItem
->GetId()
388 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
390 vError
= ::WinGetLastError(vHabmain
);
391 sError
= wxPMErrorToStr(vError
);
392 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
.c_str());
393 wxLogLastError("Insert or AppendMenu");
399 // If we're already attached to the menubar, we must update it
401 if (IsAttached() && m_menuBar
->IsAttached())
403 m_menuBar
->Refresh();
408 } // end of wxMenu::DoInsertOrAppend
410 void wxMenu::EndRadioGroup()
413 // We're not inside a radio group any longer
415 m_nStartRadioGroup
= -1;
416 } // end of wxMenu::EndRadioGroup
418 bool wxMenu::DoAppend(
422 wxCHECK_MSG( pItem
, FALSE
, _T("NULL item in wxMenu::DoAppend") );
426 if (pItem
->GetKind() == wxITEM_RADIO
)
428 int nCount
= GetMenuItemCount();
430 if (m_nStartRadioGroup
== -1)
433 // Start a new radio group
435 m_nStartRadioGroup
= nCount
;
438 // For now it has just one element
440 pItem
->SetAsRadioGroupStart();
441 pItem
->SetRadioGroupEnd(m_nStartRadioGroup
);
444 // Ensure that we have a checked item in the radio group
448 else // extend the current radio group
451 // We need to update its end item
453 pItem
->SetRadioGroupStart(m_nStartRadioGroup
);
455 wxMenuItemList::Node
* pNode
= GetMenuItems().Item(m_nStartRadioGroup
);
459 pNode
->GetData()->SetRadioGroupEnd(nCount
);
463 wxFAIL_MSG( _T("where is the radio group start item?") );
467 else // not a radio item
472 if (!wxMenuBase::DoAppend(pItem
) || !DoInsertOrAppend(pItem
))
479 // Check the item initially
484 } // end of wxMenu::DoAppend
486 bool wxMenu::DoInsert(
491 return ( wxMenuBase::DoInsert( nPos
493 DoInsertOrAppend( pItem
497 } // end of wxMenu::DoInsert
499 wxMenuItem
* wxMenu::DoRemove(
504 // We need to find the items position in the child list
507 wxMenuItemList::Node
* pNode
= GetMenuItems().GetFirst();
509 for (nPos
= 0; pNode
; nPos
++)
511 if (pNode
->GetData() == pItem
)
513 pNode
= pNode
->GetNext();
517 // DoRemove() (unlike Remove) can only be called for existing item!
519 wxCHECK_MSG(pNode
, NULL
, wxT("bug in wxMenu::Remove logic"));
523 // Remove the corresponding accel from the accel table
525 int n
= FindAccel(pItem
->GetId());
527 if (n
!= wxNOT_FOUND
)
530 m_vAccels
.RemoveAt(n
);
533 #endif // wxUSE_ACCEL
535 // Remove the item from the menu
537 ::WinSendMsg( GetHmenu()
539 ,MPFROM2SHORT(pItem
->GetId(), TRUE
)
542 if (IsAttached() && m_menuBar
->IsAttached())
545 // Otherwise, the chane won't be visible
547 m_menuBar
->Refresh();
551 // And from internal data structures
553 return wxMenuBase::DoRemove(pItem
);
554 } // end of wxMenu::DoRemove
556 // ---------------------------------------------------------------------------
557 // accelerator helpers
558 // ---------------------------------------------------------------------------
563 // Create the wxAcceleratorEntries for our accels and put them into provided
564 // array - return the number of accels we have
566 size_t wxMenu::CopyAccels(
567 wxAcceleratorEntry
* pAccels
570 size_t nCount
= GetAccelCount();
572 for (size_t n
= 0; n
< nCount
; n
++)
574 *pAccels
++ = *m_vAccels
[n
];
577 } // end of wxMenu::CopyAccels
579 #endif // wxUSE_ACCEL
581 // ---------------------------------------------------------------------------
583 // ---------------------------------------------------------------------------
585 void wxMenu::SetTitle(
586 const wxString
& rLabel
589 bool bHasNoTitle
= m_title
.IsEmpty();
590 HWND hMenu
= GetHmenu();
595 if (!rLabel
.IsEmpty())
597 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
599 wxLogLastError("SetMenuTitle");
605 if (rLabel
.IsEmpty() )
607 ::WinSendMsg( GetHmenu()
609 ,MPFROM2SHORT(hMenu
, TRUE
)
618 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
620 wxLogLastError("SetMenuTitle");
624 } // end of wxMenu::SetTitle
626 // ---------------------------------------------------------------------------
628 // ---------------------------------------------------------------------------
630 bool wxMenu::OS2Command(
631 WXUINT
WXUNUSED(uParam
)
636 // Ignore commands from the menu title
639 if (vId
!= (WXWORD
)idMenuTitle
)
642 ,(int)::WinSendMsg( GetHmenu()
650 } // end of wxMenu::OS2Command
652 // ---------------------------------------------------------------------------
654 // ---------------------------------------------------------------------------
656 wxWindow
* wxMenu::GetWindow() const
658 if (m_invokingWindow
!= NULL
)
659 return m_invokingWindow
;
660 else if ( m_menuBar
!= NULL
)
661 return m_menuBar
->GetFrame();
664 } // end of wxMenu::GetWindow
666 // recursive search for item by id
667 wxMenuItem
* wxMenu::FindItem(
670 , wxMenu
** ppItemMenu
676 wxMenuItem
* pItem
= NULL
;
678 for ( wxMenuItemList::Node
*node
= m_items
.GetFirst();
680 node
= node
->GetNext() )
682 pItem
= node
->GetData();
684 if ( pItem
->GetId() == nItemId
&& pItem
->m_vMenuData
.hItem
== hItem
)
687 *ppItemMenu
= (wxMenu
*)this;
689 else if ( pItem
->IsSubMenu() )
691 pItem
= pItem
->GetSubMenu()->FindItem( nItemId
700 // don't exit the loop
705 } // end of wxMenu::FindItem
707 // ---------------------------------------------------------------------------
709 // ---------------------------------------------------------------------------
711 void wxMenuBar::Init()
713 m_eventHandler
= this;
714 m_menuBarFrame
= NULL
;
716 } // end of wxMenuBar::Init
718 wxMenuBar::wxMenuBar()
721 } // end of wxMenuBar::wxMenuBar
723 wxMenuBar::wxMenuBar(
724 long WXUNUSED(lStyle
)
728 } // end of wxMenuBar::wxMenuBar
730 wxMenuBar::wxMenuBar(
733 , const wxString sTitles
[]
738 m_titles
.Alloc(nCount
);
739 for ( int i
= 0; i
< nCount
; i
++ )
741 m_menus
.Append(vMenus
[i
]);
742 m_titles
.Add(sTitles
[i
]);
743 vMenus
[i
]->Attach(this);
745 } // end of wxMenuBar::wxMenuBar
747 wxMenuBar::~wxMenuBar()
750 // We should free PM's resources only if PM doesn't do it for us
751 // which happens if we're attached to a frame
753 if (m_hMenu
&& !IsAttached())
755 ::WinDestroyWindow((HMENU
)m_hMenu
);
756 m_hMenu
= (WXHMENU
)NULL
;
758 } // end of wxMenuBar::~wxMenuBar
760 // ---------------------------------------------------------------------------
762 // ---------------------------------------------------------------------------
764 void wxMenuBar::Refresh()
766 wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );
768 WinSendMsg(GetWinHwnd(m_menuBarFrame
), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
769 } // end of wxMenuBar::Refresh
771 WXHMENU
wxMenuBar::Create()
779 wxCHECK_MSG(!m_hMenu
, TRUE
, wxT("menubar already created"));
782 // Menubars should be associated with a frame otherwise they are popups
784 if (m_menuBarFrame
!= NULL
)
785 hFrame
= GetWinHwnd(m_menuBarFrame
);
787 hFrame
= HWND_DESKTOP
;
789 // Create an empty menu and then fill it with insertions
791 if ((m_hMenu
= ::WinCreateWindow( hFrame
794 ,MS_ACTIONBAR
| WS_SYNCPAINT
| WS_VISIBLE
806 wxLogLastError("WinLoadMenu");
810 size_t nCount
= GetMenuCount();
812 for (size_t i
= 0; i
< nCount
; i
++)
820 // Set the parent and owner of the submenues to be the menubar, not the desktop
822 hSubMenu
= m_menus
[i
]->m_vMenuData
.hwndSubMenu
;
823 if (!::WinSetParent(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
, FALSE
))
825 vError
= ::WinGetLastError(vHabmain
);
826 sError
= wxPMErrorToStr(vError
);
827 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
831 if (!::WinSetOwner(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
))
833 vError
= ::WinGetLastError(vHabmain
);
834 sError
= wxPMErrorToStr(vError
);
835 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
839 m_menus
[i
]->m_vMenuData
.iPosition
= i
;
841 rc
= (APIRET
)::WinSendMsg(m_hMenu
, MM_INSERTITEM
, (MPARAM
)&m_menus
[i
]->m_vMenuData
, (MPARAM
)m_titles
[i
].c_str());
842 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
844 vError
= ::WinGetLastError(vHabmain
);
845 sError
= wxPMErrorToStr(vError
);
846 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
.c_str());
852 } // end of wxMenuBar::Create
854 // ---------------------------------------------------------------------------
855 // wxMenuBar functions to work with the top level submenus
856 // ---------------------------------------------------------------------------
859 // NB: we don't support owner drawn top level items for now, if we do these
860 // functions would have to be changed to use wxMenuItem as well
862 void wxMenuBar::EnableTop(
867 wxCHECK_RET(IsAttached(), wxT("doesn't work with unattached menubars"));
872 uFlag
= MIA_DISABLED
;
874 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
875 if (nId
== MIT_ERROR
)
877 wxLogLastError("LogLastError");
880 ::WinSendMsg((HWND
)m_hMenu
, MM_SETITEMATTR
, MPFROM2SHORT(nId
, TRUE
), MPFROM2SHORT(MIA_DISABLED
, uFlag
));
882 } // end of wxMenuBar::EnableTop
884 void wxMenuBar::SetLabelTop(
886 , const wxString
& rLabel
892 wxCHECK_RET(nPos
< GetMenuCount(), wxT("invalid menu index"));
893 m_titles
[nPos
] = rLabel
;
900 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
901 if (nId
== MIT_ERROR
)
903 wxLogLastError("LogLastError");
906 if(!::WinSendMsg( (HWND
)m_hMenu
908 ,MPFROM2SHORT(nId
, TRUE
)
912 wxLogLastError("QueryItem");
916 if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT
, MPFROMSHORT(nId
), (MPARAM
)rLabel
.c_str()));
918 wxLogLastError("ModifyMenu");
921 } // end of wxMenuBar::SetLabelTop
923 wxString
wxMenuBar::GetLabelTop(
927 wxCHECK_MSG( nPos
< GetMenuCount(), wxEmptyString
,
928 wxT("invalid menu index in wxMenuBar::GetLabelTop") );
929 return m_titles
[nPos
];
930 } // end of wxMenuBar::GetLabelTop
932 // ---------------------------------------------------------------------------
933 // wxMenuBar construction
934 // ---------------------------------------------------------------------------
936 wxMenu
* wxMenuBar::Replace(
939 , const wxString
& rTitle
943 wxString sTitle
= TextToLabel(rTitle
);
944 wxMenu
* pMenuOld
= wxMenuBarBase::Replace( nPos
950 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
951 if (nId
== MIT_ERROR
)
953 wxLogLastError("LogLastError");
958 m_titles
[nPos
] = sTitle
;
961 ::WinSendMsg((HWND
)m_hMenu
, MM_REMOVEITEM
, MPFROM2SHORT(nId
, TRUE
), (MPARAM
)0);
962 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)sTitle
.c_str());
965 if (pMenuOld
->HasAccels() || pMenu
->HasAccels())
968 // Need to rebuild accell table
972 #endif // wxUSE_ACCEL
976 } // end of wxMenuBar::Replace
978 bool wxMenuBar::Insert(
981 , const wxString
& rTitle
984 wxString sTitle
= TextToLabel(rTitle
);
986 if (!wxMenuBarBase::Insert( nPos
992 m_titles
.Insert( sTitle
998 pMenu
->m_vMenuData
.iPosition
= nPos
;
999 ::WinSendMsg( (HWND
)m_hMenu
1001 ,(MPARAM
)&pMenu
->m_vMenuData
1002 ,(MPARAM
)sTitle
.c_str()
1005 if (pMenu
->HasAccels())
1007 // need to rebuild accell table
1008 RebuildAccelTable();
1010 #endif // wxUSE_ACCEL
1014 } // end of wxMenuBar::Insert
1016 bool wxMenuBar::Append(
1018 , const wxString
& rsTitle
1021 WXHMENU hSubmenu
= pMenu
? pMenu
->GetHMenu() : 0;
1023 wxCHECK_MSG(hSubmenu
, FALSE
, wxT("can't append invalid menu to menubar"));
1025 wxString sTitle
= TextToLabel(rsTitle
);
1027 if (!wxMenuBarBase::Append(pMenu
, sTitle
))
1030 m_titles
.Add(sTitle
);
1034 pMenu
->m_vMenuData
.iPosition
= MIT_END
;
1035 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)sTitle
.c_str());
1037 if (pMenu
->HasAccels())
1040 // Need to rebuild accell table
1042 RebuildAccelTable();
1044 #endif // wxUSE_ACCEL
1048 } // end of wxMenuBar::Append
1050 wxMenu
* wxMenuBar::Remove(
1054 wxMenu
* pMenu
= wxMenuBarBase::Remove(nPos
);
1060 nId
= SHORT1FROMMR(::WinSendMsg( (HWND
)GetHmenu()
1061 ,MM_ITEMIDFROMPOSITION
1065 if (nId
== MIT_ERROR
)
1067 wxLogLastError("LogLastError");
1072 ::WinSendMsg( (HWND
)GetHmenu()
1074 ,MPFROM2SHORT(nId
, TRUE
)
1079 if (pMenu
->HasAccels())
1082 // Need to rebuild accell table
1084 RebuildAccelTable();
1086 #endif // wxUSE_ACCEL
1089 m_titles
.Remove(nPos
);
1091 } // end of wxMenuBar::Remove
1095 void wxMenuBar::RebuildAccelTable()
1098 // Merge the accelerators of all menus into one accel table
1100 size_t nAccelCount
= 0;
1102 size_t nCount
= GetMenuCount();
1104 for (i
= 0; i
< nCount
; i
++)
1106 nAccelCount
+= m_menus
[i
]->GetAccelCount();
1111 wxAcceleratorEntry
* pAccelEntries
= new wxAcceleratorEntry
[nAccelCount
];
1114 for (i
= 0; i
< nCount
; i
++)
1116 nAccelCount
+= m_menus
[i
]->CopyAccels(&pAccelEntries
[nAccelCount
]);
1118 m_vAccelTable
= wxAcceleratorTable( nAccelCount
1121 delete [] pAccelEntries
;
1123 } // end of wxMenuBar::RebuildAccelTable
1125 #endif // wxUSE_ACCEL
1127 void wxMenuBar::Attach(
1131 wxMenuBarBase::Attach(pFrame
);
1134 RebuildAccelTable();
1136 // Ensure the accelerator table is set to the frame (not the client!)
1138 if (!::WinSetAccelTable( vHabmain
1139 ,m_vAccelTable
.GetHACCEL()
1140 ,(HWND
)pFrame
->GetFrame()
1142 wxLogLastError("WinSetAccelTable");
1143 #endif // wxUSE_ACCEL
1144 } // end of wxMenuBar::Attach
1146 void wxMenuBar::Detach()
1148 ::WinDestroyWindow((HWND
)m_hMenu
);
1149 m_hMenu
= (WXHMENU
)NULL
;
1150 m_menuBarFrame
= NULL
;
1151 } // end of wxMenuBar::Detach
1153 // ---------------------------------------------------------------------------
1154 // wxMenuBar searching for menu items
1155 // ---------------------------------------------------------------------------
1158 // Find the itemString in menuString, and return the item id or wxNOT_FOUND
1160 int wxMenuBar::FindMenuItem(
1161 const wxString
& rMenuString
1162 , const wxString
& rItemString
1165 wxString sMenuLabel
= wxStripMenuCodes(rMenuString
);
1166 size_t nCount
= GetMenuCount();
1168 for (size_t i
= 0; i
< nCount
; i
++)
1170 wxString sTitle
= wxStripMenuCodes(m_titles
[i
]);
1172 if (rMenuString
== sTitle
)
1173 return m_menus
[i
]->FindItem(rItemString
);
1176 } // end of wxMenuBar::FindMenuItem
1178 wxMenuItem
* wxMenuBar::FindItem(
1180 , wxMenu
** ppItemMenu
1186 wxMenuItem
* pItem
= NULL
;
1187 size_t nCount
= GetMenuCount();
1189 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1191 pItem
= m_menus
[i
]->FindItem( nId
1196 } // end of wxMenuBar::FindItem
1198 wxMenuItem
* wxMenuBar::FindItem(
1201 , wxMenu
** ppItemMenu
1207 wxMenuItem
* pItem
= NULL
;
1208 size_t nCount
= GetMenuCount();
1210 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1212 pItem
= m_menus
[i
]->FindItem( nId
1218 } // end of wxMenuBar::FindItem