]>
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 wxMenuItem
* wxMenu::DoAppend(
422 wxCHECK_MSG( pItem
, NULL
, _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 wxMenuItem
* wxMenu::DoInsert(
491 if ( wxMenuBase::DoInsert( nPos
493 DoInsertOrAppend( pItem
499 } // end of wxMenu::DoInsert
501 wxMenuItem
* wxMenu::DoRemove(
506 // We need to find the items position in the child list
509 wxMenuItemList::Node
* pNode
= GetMenuItems().GetFirst();
511 for (nPos
= 0; pNode
; nPos
++)
513 if (pNode
->GetData() == pItem
)
515 pNode
= pNode
->GetNext();
519 // DoRemove() (unlike Remove) can only be called for existing item!
521 wxCHECK_MSG(pNode
, NULL
, wxT("bug in wxMenu::Remove logic"));
525 // Remove the corresponding accel from the accel table
527 int n
= FindAccel(pItem
->GetId());
529 if (n
!= wxNOT_FOUND
)
532 m_vAccels
.RemoveAt(n
);
535 #endif // wxUSE_ACCEL
537 // Remove the item from the menu
539 ::WinSendMsg( GetHmenu()
541 ,MPFROM2SHORT(pItem
->GetId(), TRUE
)
544 if (IsAttached() && m_menuBar
->IsAttached())
547 // Otherwise, the chane won't be visible
549 m_menuBar
->Refresh();
553 // And from internal data structures
555 return wxMenuBase::DoRemove(pItem
);
556 } // end of wxMenu::DoRemove
558 // ---------------------------------------------------------------------------
559 // accelerator helpers
560 // ---------------------------------------------------------------------------
565 // Create the wxAcceleratorEntries for our accels and put them into provided
566 // array - return the number of accels we have
568 size_t wxMenu::CopyAccels(
569 wxAcceleratorEntry
* pAccels
572 size_t nCount
= GetAccelCount();
574 for (size_t n
= 0; n
< nCount
; n
++)
576 *pAccels
++ = *m_vAccels
[n
];
579 } // end of wxMenu::CopyAccels
581 #endif // wxUSE_ACCEL
583 // ---------------------------------------------------------------------------
585 // ---------------------------------------------------------------------------
587 void wxMenu::SetTitle(
588 const wxString
& rLabel
591 bool bHasNoTitle
= m_title
.IsEmpty();
592 HWND hMenu
= GetHmenu();
597 if (!rLabel
.IsEmpty())
599 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
601 wxLogLastError("SetMenuTitle");
607 if (rLabel
.IsEmpty() )
609 ::WinSendMsg( GetHmenu()
611 ,MPFROM2SHORT(hMenu
, TRUE
)
620 if (!::WinSetWindowText(hMenu
, rLabel
.c_str()))
622 wxLogLastError("SetMenuTitle");
626 } // end of wxMenu::SetTitle
628 // ---------------------------------------------------------------------------
630 // ---------------------------------------------------------------------------
632 bool wxMenu::OS2Command(
633 WXUINT
WXUNUSED(uParam
)
638 // Ignore commands from the menu title
641 if (vId
!= (WXWORD
)idMenuTitle
)
644 ,(int)::WinSendMsg( GetHmenu()
652 } // end of wxMenu::OS2Command
654 // ---------------------------------------------------------------------------
656 // ---------------------------------------------------------------------------
658 wxWindow
* wxMenu::GetWindow() const
660 if (m_invokingWindow
!= NULL
)
661 return m_invokingWindow
;
662 else if ( m_menuBar
!= NULL
)
663 return m_menuBar
->GetFrame();
666 } // end of wxMenu::GetWindow
668 // recursive search for item by id
669 wxMenuItem
* wxMenu::FindItem(
672 , wxMenu
** ppItemMenu
678 wxMenuItem
* pItem
= NULL
;
680 for ( wxMenuItemList::Node
*node
= m_items
.GetFirst();
682 node
= node
->GetNext() )
684 pItem
= node
->GetData();
686 if ( pItem
->GetId() == nItemId
&& pItem
->m_vMenuData
.hItem
== hItem
)
689 *ppItemMenu
= (wxMenu
*)this;
691 else if ( pItem
->IsSubMenu() )
693 pItem
= pItem
->GetSubMenu()->FindItem( nItemId
702 // don't exit the loop
707 } // end of wxMenu::FindItem
709 // ---------------------------------------------------------------------------
711 // ---------------------------------------------------------------------------
713 void wxMenuBar::Init()
715 m_eventHandler
= this;
716 m_menuBarFrame
= NULL
;
718 } // end of wxMenuBar::Init
720 wxMenuBar::wxMenuBar()
723 } // end of wxMenuBar::wxMenuBar
725 wxMenuBar::wxMenuBar(
726 long WXUNUSED(lStyle
)
730 } // end of wxMenuBar::wxMenuBar
732 wxMenuBar::wxMenuBar(
735 , const wxString sTitles
[]
740 m_titles
.Alloc(nCount
);
741 for ( int i
= 0; i
< nCount
; i
++ )
743 m_menus
.Append(vMenus
[i
]);
744 m_titles
.Add(sTitles
[i
]);
745 vMenus
[i
]->Attach(this);
747 } // end of wxMenuBar::wxMenuBar
749 wxMenuBar::~wxMenuBar()
752 // We should free PM's resources only if PM doesn't do it for us
753 // which happens if we're attached to a frame
755 if (m_hMenu
&& !IsAttached())
757 ::WinDestroyWindow((HMENU
)m_hMenu
);
758 m_hMenu
= (WXHMENU
)NULL
;
760 } // end of wxMenuBar::~wxMenuBar
762 // ---------------------------------------------------------------------------
764 // ---------------------------------------------------------------------------
766 void wxMenuBar::Refresh()
768 wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );
770 WinSendMsg(GetWinHwnd(m_menuBarFrame
), WM_UPDATEFRAME
, (MPARAM
)FCF_MENU
, (MPARAM
)0);
771 } // end of wxMenuBar::Refresh
773 WXHMENU
wxMenuBar::Create()
781 wxCHECK_MSG(!m_hMenu
, TRUE
, wxT("menubar already created"));
784 // Menubars should be associated with a frame otherwise they are popups
786 if (m_menuBarFrame
!= NULL
)
787 hFrame
= GetWinHwnd(m_menuBarFrame
);
789 hFrame
= HWND_DESKTOP
;
791 // Create an empty menu and then fill it with insertions
793 if ((m_hMenu
= ::WinCreateWindow( hFrame
796 ,MS_ACTIONBAR
| WS_SYNCPAINT
| WS_VISIBLE
808 wxLogLastError("WinLoadMenu");
812 size_t nCount
= GetMenuCount();
814 for (size_t i
= 0; i
< nCount
; i
++)
822 // Set the parent and owner of the submenues to be the menubar, not the desktop
824 hSubMenu
= m_menus
[i
]->m_vMenuData
.hwndSubMenu
;
825 if (!::WinSetParent(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
, FALSE
))
827 vError
= ::WinGetLastError(vHabmain
);
828 sError
= wxPMErrorToStr(vError
);
829 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
833 if (!::WinSetOwner(m_menus
[i
]->m_vMenuData
.hwndSubMenu
, m_hMenu
))
835 vError
= ::WinGetLastError(vHabmain
);
836 sError
= wxPMErrorToStr(vError
);
837 wxLogError("Error setting parent for submenu. Error: %s\n", sError
.c_str());
841 m_menus
[i
]->m_vMenuData
.iPosition
= i
;
843 rc
= (APIRET
)::WinSendMsg(m_hMenu
, MM_INSERTITEM
, (MPARAM
)&m_menus
[i
]->m_vMenuData
, (MPARAM
)m_titles
[i
].c_str());
844 if (rc
== MIT_MEMERROR
|| rc
== MIT_ERROR
)
846 vError
= ::WinGetLastError(vHabmain
);
847 sError
= wxPMErrorToStr(vError
);
848 wxLogError("Error inserting or appending a menuitem. Error: %s\n", sError
.c_str());
854 } // end of wxMenuBar::Create
856 // ---------------------------------------------------------------------------
857 // wxMenuBar functions to work with the top level submenus
858 // ---------------------------------------------------------------------------
861 // NB: we don't support owner drawn top level items for now, if we do these
862 // functions would have to be changed to use wxMenuItem as well
864 void wxMenuBar::EnableTop(
869 wxCHECK_RET(IsAttached(), wxT("doesn't work with unattached menubars"));
874 uFlag
= MIA_DISABLED
;
876 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
877 if (nId
== MIT_ERROR
)
879 wxLogLastError("LogLastError");
882 ::WinSendMsg((HWND
)m_hMenu
, MM_SETITEMATTR
, MPFROM2SHORT(nId
, TRUE
), MPFROM2SHORT(MIA_DISABLED
, uFlag
));
884 } // end of wxMenuBar::EnableTop
886 void wxMenuBar::SetLabelTop(
888 , const wxString
& rLabel
894 wxCHECK_RET(nPos
< GetMenuCount(), wxT("invalid menu index"));
895 m_titles
[nPos
] = rLabel
;
902 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
903 if (nId
== MIT_ERROR
)
905 wxLogLastError("LogLastError");
908 if(!::WinSendMsg( (HWND
)m_hMenu
910 ,MPFROM2SHORT(nId
, TRUE
)
914 wxLogLastError("QueryItem");
918 if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT
, MPFROMSHORT(nId
), (MPARAM
)rLabel
.c_str()));
920 wxLogLastError("ModifyMenu");
923 } // end of wxMenuBar::SetLabelTop
925 wxString
wxMenuBar::GetLabelTop(
929 wxCHECK_MSG( nPos
< GetMenuCount(), wxEmptyString
,
930 wxT("invalid menu index in wxMenuBar::GetLabelTop") );
931 return m_titles
[nPos
];
932 } // end of wxMenuBar::GetLabelTop
934 // ---------------------------------------------------------------------------
935 // wxMenuBar construction
936 // ---------------------------------------------------------------------------
938 wxMenu
* wxMenuBar::Replace(
941 , const wxString
& rTitle
945 wxString sTitle
= TextToLabel(rTitle
);
946 wxMenu
* pMenuOld
= wxMenuBarBase::Replace( nPos
952 nId
= SHORT1FROMMR(::WinSendMsg((HWND
)m_hMenu
, MM_ITEMIDFROMPOSITION
, MPFROMSHORT(nPos
), (MPARAM
)0));
953 if (nId
== MIT_ERROR
)
955 wxLogLastError("LogLastError");
960 m_titles
[nPos
] = sTitle
;
963 ::WinSendMsg((HWND
)m_hMenu
, MM_REMOVEITEM
, MPFROM2SHORT(nId
, TRUE
), (MPARAM
)0);
964 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)sTitle
.c_str());
967 if (pMenuOld
->HasAccels() || pMenu
->HasAccels())
970 // Need to rebuild accell table
974 #endif // wxUSE_ACCEL
978 } // end of wxMenuBar::Replace
980 bool wxMenuBar::Insert(
983 , const wxString
& rTitle
986 wxString sTitle
= TextToLabel(rTitle
);
988 if (!wxMenuBarBase::Insert( nPos
994 m_titles
.Insert( sTitle
1000 pMenu
->m_vMenuData
.iPosition
= nPos
;
1001 ::WinSendMsg( (HWND
)m_hMenu
1003 ,(MPARAM
)&pMenu
->m_vMenuData
1004 ,(MPARAM
)sTitle
.c_str()
1007 if (pMenu
->HasAccels())
1009 // need to rebuild accell table
1010 RebuildAccelTable();
1012 #endif // wxUSE_ACCEL
1016 } // end of wxMenuBar::Insert
1018 bool wxMenuBar::Append(
1020 , const wxString
& rsTitle
1023 WXHMENU hSubmenu
= pMenu
? pMenu
->GetHMenu() : 0;
1025 wxCHECK_MSG(hSubmenu
, FALSE
, wxT("can't append invalid menu to menubar"));
1027 wxString sTitle
= TextToLabel(rsTitle
);
1029 if (!wxMenuBarBase::Append(pMenu
, sTitle
))
1032 m_titles
.Add(sTitle
);
1036 pMenu
->m_vMenuData
.iPosition
= MIT_END
;
1037 ::WinSendMsg((HWND
)m_hMenu
, MM_INSERTITEM
, (MPARAM
)&pMenu
->m_vMenuData
, (MPARAM
)sTitle
.c_str());
1039 if (pMenu
->HasAccels())
1042 // Need to rebuild accell table
1044 RebuildAccelTable();
1046 #endif // wxUSE_ACCEL
1050 } // end of wxMenuBar::Append
1052 wxMenu
* wxMenuBar::Remove(
1056 wxMenu
* pMenu
= wxMenuBarBase::Remove(nPos
);
1062 nId
= SHORT1FROMMR(::WinSendMsg( (HWND
)GetHmenu()
1063 ,MM_ITEMIDFROMPOSITION
1067 if (nId
== MIT_ERROR
)
1069 wxLogLastError("LogLastError");
1074 ::WinSendMsg( (HWND
)GetHmenu()
1076 ,MPFROM2SHORT(nId
, TRUE
)
1081 if (pMenu
->HasAccels())
1084 // Need to rebuild accell table
1086 RebuildAccelTable();
1088 #endif // wxUSE_ACCEL
1091 m_titles
.Remove(nPos
);
1093 } // end of wxMenuBar::Remove
1097 void wxMenuBar::RebuildAccelTable()
1100 // Merge the accelerators of all menus into one accel table
1102 size_t nAccelCount
= 0;
1104 size_t nCount
= GetMenuCount();
1106 for (i
= 0; i
< nCount
; i
++)
1108 nAccelCount
+= m_menus
[i
]->GetAccelCount();
1113 wxAcceleratorEntry
* pAccelEntries
= new wxAcceleratorEntry
[nAccelCount
];
1116 for (i
= 0; i
< nCount
; i
++)
1118 nAccelCount
+= m_menus
[i
]->CopyAccels(&pAccelEntries
[nAccelCount
]);
1120 m_vAccelTable
= wxAcceleratorTable( nAccelCount
1123 delete [] pAccelEntries
;
1125 } // end of wxMenuBar::RebuildAccelTable
1127 #endif // wxUSE_ACCEL
1129 void wxMenuBar::Attach(
1133 wxMenuBarBase::Attach(pFrame
);
1136 RebuildAccelTable();
1138 // Ensure the accelerator table is set to the frame (not the client!)
1140 if (!::WinSetAccelTable( vHabmain
1141 ,m_vAccelTable
.GetHACCEL()
1142 ,(HWND
)pFrame
->GetFrame()
1144 wxLogLastError("WinSetAccelTable");
1145 #endif // wxUSE_ACCEL
1146 } // end of wxMenuBar::Attach
1148 void wxMenuBar::Detach()
1150 ::WinDestroyWindow((HWND
)m_hMenu
);
1151 m_hMenu
= (WXHMENU
)NULL
;
1152 m_menuBarFrame
= NULL
;
1153 } // end of wxMenuBar::Detach
1155 // ---------------------------------------------------------------------------
1156 // wxMenuBar searching for menu items
1157 // ---------------------------------------------------------------------------
1160 // Find the itemString in menuString, and return the item id or wxNOT_FOUND
1162 int wxMenuBar::FindMenuItem(
1163 const wxString
& rMenuString
1164 , const wxString
& rItemString
1167 wxString sMenuLabel
= wxStripMenuCodes(rMenuString
);
1168 size_t nCount
= GetMenuCount();
1170 for (size_t i
= 0; i
< nCount
; i
++)
1172 wxString sTitle
= wxStripMenuCodes(m_titles
[i
]);
1174 if (rMenuString
== sTitle
)
1175 return m_menus
[i
]->FindItem(rItemString
);
1178 } // end of wxMenuBar::FindMenuItem
1180 wxMenuItem
* wxMenuBar::FindItem(
1182 , wxMenu
** ppItemMenu
1188 wxMenuItem
* pItem
= NULL
;
1189 size_t nCount
= GetMenuCount();
1191 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1193 pItem
= m_menus
[i
]->FindItem( nId
1198 } // end of wxMenuBar::FindItem
1200 wxMenuItem
* wxMenuBar::FindItem(
1203 , wxMenu
** ppItemMenu
1209 wxMenuItem
* pItem
= NULL
;
1210 size_t nCount
= GetMenuCount();
1212 for (size_t i
= 0; !pItem
&& (i
< nCount
); i
++)
1214 pItem
= m_menus
[i
]->FindItem( nId
1220 } // end of wxMenuBar::FindItem