// Modified by:
// Created: 26.10.99
// RCS-ID: $Id$
-// Copyright: (c) wxWindows team
+// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
m_parentMenu = parentMenu;
m_subMenu = subMenu;
- m_isEnabled = TRUE;
- m_isChecked = FALSE;
+ m_isEnabled = true;
+ m_isChecked = false;
m_id = id;
m_kind = kind;
if (m_id == wxID_ANY)
// specified
wxAcceleratorEntry *wxGetAccelFromString(const wxString& label)
{
+ // wxPrintf( wxT("label %s\n"), label.c_str() );
+
// check for accelerators: they are given after '\t'
int posTab = label.Find(wxT('\t'));
if ( posTab != wxNOT_FOUND ) {
#endif // wxUSE_ACCEL
+bool wxMenuBase::ms_locked = true;
+
// ----------------------------------------------------------------------------
// wxMenu ctor and dtor
// ----------------------------------------------------------------------------
{
wxCHECK_RET( submenu, _T("can't add a NULL submenu") );
- if ( m_menuBar )
- {
- submenu->Attach(m_menuBar);
- }
-
submenu->SetParent((wxMenu *)this);
}
}
else
{
- wxCHECK_MSG( pos < GetMenuItemCount(), FALSE,
+ wxCHECK_MSG( pos < GetMenuItemCount(), NULL,
wxT("invalid index in wxMenu::Insert") );
return DoInsert(pos, item);
wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Insert()") );
wxMenuItemList::compatibility_iterator node = m_items.Item(pos);
- wxCHECK_MSG( node, FALSE, wxT("invalid index in wxMenu::Insert()") );
+ wxCHECK_MSG( node, NULL, wxT("invalid index in wxMenu::Insert()") );
m_items.Insert(node, item);
item->SetMenu((wxMenu*)this);
if ( submenu )
{
submenu->SetParent((wxMenu *)NULL);
+ if ( submenu->IsAttached() )
+ submenu->Detach();
}
return item;
bool wxMenuBase::Delete(wxMenuItem *item)
{
- wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Delete") );
+ wxCHECK_MSG( item, false, wxT("invalid item in wxMenu::Delete") );
return DoDelete(item);
}
bool wxMenuBase::DoDelete(wxMenuItem *item)
{
wxMenuItem *item2 = DoRemove(item);
- wxCHECK_MSG( item2, FALSE, wxT("failed to delete menu item") );
+ wxCHECK_MSG( item2, false, wxT("failed to delete menu item") );
// don't delete the submenu
item2->SetSubMenu((wxMenu *)NULL);
delete item2;
- return TRUE;
+ return true;
}
bool wxMenuBase::Destroy(wxMenuItem *item)
{
- wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Destroy") );
+ wxCHECK_MSG( item, false, wxT("invalid item in wxMenu::Destroy") );
return DoDestroy(item);
}
bool wxMenuBase::DoDestroy(wxMenuItem *item)
{
wxMenuItem *item2 = DoRemove(item);
- wxCHECK_MSG( item2, FALSE, wxT("failed to delete menu item") );
+ wxCHECK_MSG( item2, false, wxT("failed to delete menu item") );
delete item2;
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
// wxMenu searching for items
// ----------------------------------------------------------------------------
-// Finds the item id matching the given string, -1 if not found.
+// Finds the item id matching the given string, wxNOT_FOUND if not found.
int wxMenuBase::FindItem(const wxString& text) const
{
wxString label = wxMenuItem::GetLabelFromText(text);
// window will be used.
void wxMenuBase::UpdateUI(wxEvtHandler* source)
{
+ if (GetInvokingWindow())
+ {
+ // Don't update menus if the parent
+ // frame is about to get deleted
+ wxWindow *tlw = wxGetTopLevelParent( GetInvokingWindow() );
+ if (tlw && wxPendingDelete.Member(tlw))
+ return;
+ }
+
if ( !source && GetInvokingWindow() )
source = GetInvokingWindow()->GetEventHandler();
if ( !source )
event.SetEventObject(this);
event.SetInt(checked);
- bool processed = FALSE;
+ bool processed = false;
// Try the menu's event handler
if ( !processed )
// wxMenu attaching/detaching to/from menu bar
// ----------------------------------------------------------------------------
+wxMenuBar* wxMenuBase::GetMenuBar() const
+{
+ if(GetParent())
+ return GetParent()->GetMenuBar();
+ return m_menuBar;
+}
+
void wxMenuBase::Attach(wxMenuBarBase *menubar)
{
// use Detach() instead!
{
wxMenuItem *item = FindItem(id);
- wxCHECK_MSG( item, FALSE, wxT("wxMenu::IsEnabled: no such item") );
+ wxCHECK_MSG( item, false, wxT("wxMenu::IsEnabled: no such item") );
return item->IsEnabled();
}
{
wxMenuItem *item = FindItem(id);
- wxCHECK_MSG( item, FALSE, wxT("wxMenu::IsChecked: no such item") );
+ wxCHECK_MSG( item, false, wxT("wxMenu::IsChecked: no such item") );
return item->IsChecked();
}
bool wxMenuBarBase::Append(wxMenu *menu, const wxString& WXUNUSED(title))
{
- wxCHECK_MSG( menu, FALSE, wxT("can't append NULL menu") );
+ wxCHECK_MSG( menu, false, wxT("can't append NULL menu") );
m_menus.Append(menu);
menu->Attach(this);
- return TRUE;
+ return true;
}
bool wxMenuBarBase::Insert(size_t pos, wxMenu *menu,
}
else // not at the end
{
- wxCHECK_MSG( menu, FALSE, wxT("can't insert NULL menu") );
+ wxCHECK_MSG( menu, false, wxT("can't insert NULL menu") );
wxMenuList::compatibility_iterator node = m_menus.Item(pos);
- wxCHECK_MSG( node, FALSE, wxT("bad index in wxMenuBar::Insert()") );
+ wxCHECK_MSG( node, false, wxT("bad index in wxMenuBar::Insert()") );
m_menus.Insert(node, menu);
menu->Attach(this);
- return TRUE;
+ return true;
}
}
{
wxMenuItem *item = FindItem(id);
- wxCHECK_MSG( item, FALSE, wxT("wxMenuBar::IsChecked(): no such item") );
+ wxCHECK_MSG( item, false, wxT("wxMenuBar::IsChecked(): no such item") );
return item->IsChecked();
}
{
wxMenuItem *item = FindItem(id);
- wxCHECK_MSG( item, FALSE, wxT("wxMenuBar::IsEnabled(): no such item") );
+ wxCHECK_MSG( item, false, wxT("wxMenuBar::IsEnabled(): no such item") );
return item->IsEnabled();
}