// Modified by:
// Created: 26.10.99
// RCS-ID: $Id$
-// Copyright: (c) wxWindows team
+// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
m_isChecked = FALSE;
m_id = id;
m_kind = kind;
+ if (m_id == wxID_ANY)
+ m_id = wxNewId();
+ if (m_id == wxID_SEPARATOR)
+ m_kind = wxITEM_SEPARATOR;
}
wxMenuItemBase::~wxMenuItemBase()
// 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 ) {
current.clear();
}
else {
- current += wxTolower(label[n]);
+ current += (wxChar) wxTolower(label[n]);
}
}
keyCode = WXK_DELETE;
else if ( current == wxT("DELETE") )
keyCode = WXK_DELETE;
+ else if ( current == wxT("BACK") )
+ keyCode = WXK_BACK;
else if ( current == wxT("INS") )
keyCode = WXK_INSERT;
else if ( current == wxT("INSERT") )
#endif // wxUSE_ACCEL
+bool wxMenuBase::ms_locked = true;
+
// ----------------------------------------------------------------------------
// wxMenu ctor and dtor
// ----------------------------------------------------------------------------
wxMenuBase::~wxMenuBase()
{
WX_CLEAR_LIST(wxMenuItemList, m_items);
-
+
// Actually, in GTK, the submenus have to get deleted first.
}
{
wxCHECK_RET( submenu, _T("can't add a NULL submenu") );
- if ( m_menuBar )
- {
- submenu->Attach(m_menuBar);
- }
-
submenu->SetParent((wxMenu *)this);
}
-bool wxMenuBase::DoAppend(wxMenuItem *item)
+wxMenuItem* wxMenuBase::DoAppend(wxMenuItem *item)
{
- wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Append()") );
+ wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Append()") );
m_items.Append(item);
item->SetMenu((wxMenu*)this);
AddSubMenu(item->GetSubMenu());
}
- return TRUE;
+ return item;
}
-bool wxMenuBase::Insert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenuBase::Insert(size_t pos, wxMenuItem *item)
{
- wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Insert") );
+ wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Insert") );
if ( pos == GetMenuItemCount() )
{
}
}
-bool wxMenuBase::DoInsert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenuBase::DoInsert(size_t pos, wxMenuItem *item)
{
- wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Insert()") );
+ 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()") );
AddSubMenu(item->GetSubMenu());
}
- return TRUE;
+ return item;
}
wxMenuItem *wxMenuBase::Remove(wxMenuItem *item)
// 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 )
// 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!