#ifdef __GNUG__
#pragma implementation "menu.h"
+#pragma implementation "menuitem.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include <string.h>
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxWindow)
-IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxWindow)
+IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
+IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
#endif
// ============================================================================
// function appends a new item or submenu to the menu
void wxMenu::Append(wxMenuItem *pItem)
{
- wxCHECK( pItem != NULL );
+ wxCHECK_RET( pItem != NULL, "can't append NULL item to the menu" );
m_menuItems.Append(pItem);
UINT id;
wxMenu *SubMenu = pItem->GetSubMenu();
if ( SubMenu != NULL ) {
- wxASSERT( SubMenu->m_hMenu != NULL );
+ wxASSERT( SubMenu->m_hMenu != (WXHMENU) NULL );
id = (UINT)SubMenu->m_hMenu;
void wxMenu::Enable(int Id, bool Flag)
{
wxMenuItem *item = FindItemForId(Id);
- wxCHECK( item != NULL );
+ wxCHECK_RET( item != NULL, "can't enable non-existing menu item" );
item->Enable(Flag);
}
bool wxMenu::Enabled(int Id) const
{
wxMenuItem *item = FindItemForId(Id);
- wxCHECK_RET( item != NULL, FALSE );
+ wxCHECK( item != NULL, FALSE );
return item->IsEnabled();
}
void wxMenu::Check(int Id, bool Flag)
{
wxMenuItem *item = FindItemForId(Id);
- wxCHECK( item != NULL );
+ wxCHECK_RET( item != NULL, "can't get status of non-existing menu item" );
item->Check(Flag);
}
bool wxMenu::Checked(int Id) const
{
wxMenuItem *item = FindItemForId(Id);
- wxCHECK_RET( item != NULL, FALSE );
+ wxCHECK( item != NULL, FALSE );
return item->IsChecked();
}
(UINT)-2, (const char *)m_title);
}
-const wxString& wxMenu::GetTitle() const
+const wxString wxMenu::GetTitle() const
{
return m_title;
}
return wxString(tmp) ;
}
-bool wxMenu::MSWCommand(const WXUINT WXUNUSED(param), const WXWORD id)
+bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id)
{
wxCommandEvent event(wxEVENT_TYPE_MENU_COMMAND);
event.SetEventObject( this );
return -1;
}
-wxMenuItem *wxMenu::FindItemForId(const int itemId, wxMenu ** itemMenu) const
+wxMenuItem *wxMenu::FindItemForId(int itemId, wxMenu ** itemMenu) const
{
if (itemMenu)
*itemMenu = NULL;
return NULL;
}
-void wxMenu::SetHelpString(const int itemId, const wxString& helpString)
+void wxMenu::SetHelpString(int itemId, const wxString& helpString)
{
wxMenuItem *item = FindItemForId (itemId);
if (item)
item->SetHelp(helpString);
}
-wxString wxMenu::GetHelpString (const int itemId) const
+wxString wxMenu::GetHelpString (int itemId) const
{
wxMenuItem *item = FindItemForId (itemId);
wxString str("");
}
extern wxMenu *wxCurrentPopupMenu;
-bool wxWindow::PopupMenu(wxMenu *menu, const int x, const int y)
+bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
{
menu->SetInvokingWindow(this);
m_hMenu = 0;
}
-wxMenuBar::wxMenuBar(const int N, wxMenu *Menus[], const wxString Titles[])
+wxMenuBar::wxMenuBar(int N, wxMenu *Menus[], const wxString Titles[])
{
m_eventHandler = this;
m_menuCount = N;
// Must only be used AFTER menu has been attached to frame,
// otherwise use individual menus to enable/disable items
-void wxMenuBar::Enable(const int Id, const bool Flag)
+void wxMenuBar::Enable(int Id, bool Flag)
{
int ms_flag;
if (Flag)
}
-void wxMenuBar::EnableTop(const int pos, const bool flag)
+void wxMenuBar::EnableTop(int pos, bool flag)
{
int ms_flag;
if (flag)
// Must only be used AFTER menu has been attached to frame,
// otherwise use individual menus
-void wxMenuBar::Check(const int Id, const bool Flag)
+void wxMenuBar::Check(int Id, bool Flag)
{
wxMenu *itemMenu = NULL;
wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
// CheckMenuItem((HMENU)m_hMenu, Id, MF_BYCOMMAND | ms_flag);
}
-bool wxMenuBar::Checked(const int Id) const
+bool wxMenuBar::Checked(int Id) const
{
wxMenu *itemMenu = NULL;
wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
return FALSE ;
}
-bool wxMenuBar::Enabled(const int Id) const
+bool wxMenuBar::Enabled(int Id) const
{
wxMenu *itemMenu = NULL;
wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
}
-void wxMenuBar::SetLabel(const int Id, const wxString& label)
+void wxMenuBar::SetLabel(int Id, const wxString& label)
{
wxMenu *itemMenu = NULL;
wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
}
}
-wxString wxMenuBar::GetLabel(const int Id) const
+wxString wxMenuBar::GetLabel(int Id) const
{
wxMenu *itemMenu = NULL;
wxMenuItem *item = FindItemForId(Id, &itemMenu) ;
return wxString(tmp) ;
}
-void wxMenuBar::SetLabelTop(const int pos, const wxString& label)
+void wxMenuBar::SetLabelTop(int pos, const wxString& label)
{
UINT was_flag = GetMenuState((HMENU)m_hMenu,pos,MF_BYPOSITION) ;
if (was_flag&MF_POPUP)
ModifyMenu((HMENU)m_hMenu,pos,MF_BYPOSITION|MF_STRING|was_flag,pos,(const char *)label) ;
}
-wxString wxMenuBar::GetLabelTop(const int pos) const
+wxString wxMenuBar::GetLabelTop(int pos) const
{
static char tmp[128] ;
int len = GetMenuString((HMENU)m_hMenu,pos,tmp,127,MF_BYPOSITION) ;
return wxString(tmp);
}
-bool wxMenuBar::OnDelete(wxMenu *a_menu, const int pos)
+bool wxMenuBar::OnDelete(wxMenu *a_menu, int pos)
{
if (!m_menuBarFrame)
return TRUE;
((wxMenu *)menu)->SetParent(this);
}
-void wxMenuBar::Delete(wxMenu * menu, const int i)
+void wxMenuBar::Delete(wxMenu * menu, int i)
{
int j;
int ii = (int) i;
return -1;
}
-wxMenuItem *wxMenuBar::FindItemForId (const int Id, wxMenu ** itemMenu) const
+wxMenuItem *wxMenuBar::FindItemForId (int Id, wxMenu ** itemMenu) const
{
if (itemMenu)
*itemMenu = NULL;
return NULL;
}
-void wxMenuBar::SetHelpString (const int Id, const wxString& helpString)
+void wxMenuBar::SetHelpString (int Id, const wxString& helpString)
{
int i;
for (i = 0; i < m_menuCount; i++)
}
}
-wxString wxMenuBar::GetHelpString (const int Id) const
+wxString wxMenuBar::GetHelpString (int Id) const
{
int i;
for (i = 0; i < m_menuCount; i++)