// Created: 25.08.00
// RCS-ID: $Id$
// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
-// Licence: wxWidgets licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
m_width = 0;
}
- void SetEnabled(bool enabled = TRUE) { m_isEnabled = enabled; }
+ void SetEnabled(bool enabled = true) { m_isEnabled = enabled; }
// accessors
virtual void OnDismiss();
// called when a submenu is dismissed
- void OnSubmenuDismiss() { m_hasOpenSubMenu = FALSE; }
+ void OnSubmenuDismiss() { m_hasOpenSubMenu = false; }
// get the currently selected item (may be NULL)
wxMenuItem *GetCurrentItem() const
// preselect the first item
void SelectFirst() { SetCurrent(m_menu->GetMenuItems().GetFirst()); }
- // process the key event, return TRUE if done
+ // process the key event, return true if done
bool ProcessKeyDown(int key);
// process mouse move event
void ChangeCurrent(wxMenuItemList::compatibility_iterator node);
// activate item, i.e. call either ClickItem() or OpenSubmenu() depending
- // on what it is, return TRUE if something was done (i.e. it's not a
+ // on what it is, return true if something was done (i.e. it's not a
// separator...)
bool ActivateItem(wxMenuItem *item, InputMethod how = WithKeyboard);
}
else
{
- // return FALSE;
+ // return false;
return wxEvtHandler::ProcessEvent(event);
}
wxPopupMenuWindow::wxPopupMenuWindow(wxWindow *parent, wxMenu *menu)
{
m_menu = menu;
- m_hasOpenSubMenu = FALSE;
+ m_hasOpenSubMenu = false;
ResetCurrent();
{
// when we are dismissed because the user clicked elsewhere or we lost
// focus in any other way, hide the parent menu as well
- HandleDismiss(TRUE);
+ HandleDismiss(true);
}
void wxPopupMenuWindow::HandleDismiss(bool dismissParent)
void wxPopupMenuWindow::DismissAndNotify()
{
Dismiss();
- HandleDismiss(TRUE);
+ HandleDismiss(true);
}
// ----------------------------------------------------------------------------
wxSize(m_menu->GetGeometryInfo().GetSize().x, 0),
how == WithKeyboard /* preselect first item then */);
- m_hasOpenSubMenu = TRUE;
+ m_hasOpenSubMenu = true;
}
bool wxPopupMenuWindow::ActivateItem(wxMenuItem *item, InputMethod how)
// don't activate disabled items
if ( !item || !item->IsEnabled() )
{
- return FALSE;
+ return false;
}
// normal menu items generate commands, submenus can be opened and
}
else // separator, can't activate
{
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
{
wxPopupMenuWindow *win = menu->m_popupMenu;
- wxCHECK_MSG( win, FALSE, _T("parent menu not shown?") );
+ wxCHECK_MSG( win, false, _T("parent menu not shown?") );
pos = ClientToScreen(pos);
if ( win->GetMenuItemFromPoint(win->ScreenToClient(pos)) )
{
// eat the event
- return TRUE;
+ return true;
}
//else: it is outside the parent menu as well, do dismiss this one
}
}
- return FALSE;
+ return false;
}
void wxPopupMenuWindow::OnLeftUp(wxMouseEvent& event)
else
{
// this menu is the last opened
- resetCurrent = TRUE;
+ resetCurrent = true;
}
if ( resetCurrent )
// to open it inspit of this)
if ( HasOpenSubmenu() )
{
- wxCHECK_MSG( CanOpen(item), FALSE,
+ wxCHECK_MSG( CanOpen(item), false,
_T("has open submenu but another item selected?") );
if ( item->GetSubMenu()->ProcessKeyDown(key) )
- return TRUE;
+ return true;
}
- bool processed = TRUE;
+ bool processed = true;
// handle the up/down arrows, home, end, esc and return here, pass the
// left/right arrows to the menu bar except when the right arrow can be
// menubar
if ( !m_menu->GetParent() )
{
- processed = FALSE;
+ processed = false;
break;
}
case WXK_ESCAPE:
// close just this menu
Dismiss();
- HandleDismiss(FALSE);
+ HandleDismiss(false);
break;
case WXK_RETURN:
}
else
{
- processed = FALSE;
+ processed = false;
}
}
break;
}
else
{
- processed = FALSE;
+ processed = false;
}
break;
wxMenuItemList::compatibility_iterator nodeStart = GetNextNode();
// do we have more than one item with this accel?
- bool notUnique = FALSE;
+ bool notUnique = false;
// translate everything to lower case before comparing
wxChar chAccel = wxTolower(key);
}
else // we already had found such item
{
- notUnique = TRUE;
+ notUnique = true;
// no need to continue further, we won't find
// anything we don't already know
//else: just select it but don't activate as the user might
// have wanted to activate another item
- // skip "processed = FALSE" below
+ // skip "processed = false" below
break;
}
}
- processed = FALSE;
+ processed = false;
}
return processed;
wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
{
- #if 0
- // not used at all
- bool check = FALSE;
- #endif
-
if ( item->GetKind() == wxITEM_RADIO )
{
int count = GetMenuItemCount();
// for now it has just one element
item->SetAsRadioGroupStart();
item->SetRadioGroupEnd(m_startRadioGroup);
-
- // ensure that we have a checked item in the radio group
- #if 0
- // not used at all
- check = TRUE;
- #endif
}
else // extend the current radio group
{
{
// dismissParent is recursive
m_menuParent->Dismiss();
- m_menuParent->OnDismiss(TRUE);
+ m_menuParent->OnDismiss(true);
}
}
else // no parent menu
bool wxMenu::ProcessKeyDown(int key)
{
- wxCHECK_MSG( m_popupMenu, FALSE,
+ wxCHECK_MSG( m_popupMenu, false,
_T("can't process key events if not shown") );
return m_popupMenu->ProcessKeyDown(key);
// try its elements
if ( item->GetSubMenu()->ProcessAccelEvent(event) )
{
- return TRUE;
+ return true;
}
}
}
- return FALSE;
+ return false;
}
void wxMenu::AddAccelFor(wxMenuItem *item)
: wxMenuItemBase(parentMenu, id, text, help, kind, subMenu)
{
m_posY =
- m_height = -1;
+ m_height = wxDefaultCoord;
m_radioGroup.start = -1;
- m_isRadioGroupStart = FALSE;
+ m_isRadioGroupStart = false;
m_bmpDisabled = wxNullBitmap;
{
if ( n != pos )
{
- node->GetData()->m_isChecked = FALSE;
+ node->GetData()->m_isChecked = false;
}
node = node->GetNext();
}
void wxMenuItem::SetAsRadioGroupStart()
{
- m_isRadioGroupStart = TRUE;
+ m_isRadioGroupStart = true;
}
void wxMenuItem::SetRadioGroupStart(int start)
m_menuShown = NULL;
- m_shouldShowMenu = FALSE;
+ m_shouldShowMenu = false;
}
void wxMenuBar::Attach(wxFrame *frame)
else // not created yet, do it now
{
// we have no way to return the error from here anyhow :-(
- (void)Create(frame, -1);
+ (void)Create(frame, wxID_ANY);
SetCursor(wxCURSOR_ARROW);
SetFont(wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT));
// calculate and set our height (it won't be changed any more)
- SetSize(-1, GetBestSize().y);
+ SetSize(wxDefaultCoord, GetBestSize().y);
}
// remember the last frame which had us to avoid unnecessarily reparenting
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
{
if ( !wxMenuBarBase::Insert(pos, menu, title) )
- return FALSE;
+ return false;
wxMenuInfo *info = new wxMenuInfo(title);
m_menuInfos.Insert(info, pos);
RefreshAllItemsAfter(pos);
- return TRUE;
+ return true;
}
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
bool wxMenuBar::IsEnabledTop(size_t pos) const
{
- wxCHECK_MSG( pos < GetCount(), FALSE, _T("invalid index in IsEnabledTop") );
+ wxCHECK_MSG( pos < GetCount(), false, _T("invalid index in IsEnabledTop") );
return m_menuInfos[pos].IsEnabled();
}
if ( IsShowingMenu() )
{
// restore m_shouldShowMenu flag after DismissMenu() which resets
- // it to FALSE
+ // it to false
bool old = m_shouldShowMenu;
DismissMenu();
}
else // on item
{
- wxLogTrace(_T("mousecapture"), _T("Capturing mouse from wxMenuBar::OnLeftDown"));
+ wxLogTrace(_T("mousecapture"), _T("Capturing mouse from wxMenuBar::OnLeftDown"));
CaptureMouse();
// show it as selected
RefreshItem((size_t)m_current);
// show the menu
- PopupCurrentMenu(FALSE /* don't select first item - as Windows does */);
+ PopupCurrentMenu(false /* don't select first item - as Windows does */);
}
}
}
static wxPoint s_ptLast;
if ( pt == s_ptLast )
{
- return FALSE;
+ return false;
}
s_ptLast = pt;
int currentNew = GetMenuFromPoint(pt);
if ( (currentNew == -1) || (currentNew == m_current) )
{
- return FALSE;
+ return false;
}
// select the new active item
if ( m_shouldShowMenu && !m_menuShown)
{
// open the new menu if the old one we closed had been opened
- PopupCurrentMenu(FALSE /* don't select first item - as Windows does */);
+ PopupCurrentMenu(false /* don't select first item - as Windows does */);
}
- return TRUE;
+ return true;
}
void wxMenuBar::OnKeyDown(wxKeyEvent& event)
// do we have more than one item with this accel?
if ( unique )
- *unique = TRUE;
+ *unique = true;
// translate everything to lower case before comparing
wxChar chAccel = wxTolower(key);
else // we already had found such item
{
if ( unique )
- *unique = FALSE;
+ *unique = false;
// no need to continue further, we won't find
// anything we don't already know
if ( node->GetData()->ProcessAccelEvent(event) )
{
// menu processed it
- return TRUE;
+ return true;
}
}
}
// not found
- return FALSE;
+ return false;
}
#endif // wxUSE_ACCEL
wxASSERT_MSG( !m_menuShown, _T("shouldn't show two menus at once!") );
// in any case, we should show it - even if we won't
- m_shouldShowMenu = TRUE;
+ m_shouldShowMenu = true;
if ( IsEnabledTop(m_current) )
{
// item, not to the right of it
wxRect rectItem = GetItemRect(m_current);
+ m_menuShown->SetInvokingWindow(m_frameLast);
+
m_menuShown->Popup(ClientToScreen(rectItem.GetPosition()),
wxSize(0, rectItem.GetHeight()),
selectFirst);
void wxMenuBar::OnDismissMenu(bool dismissMenuBar)
{
- m_shouldShowMenu = FALSE;
+ m_shouldShowMenu = false;
m_menuShown = NULL;
if ( dismissMenuBar )
{
bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
{
- wxCHECK_MSG( !ms_evtLoopPopup, FALSE,
+ wxCHECK_MSG( !ms_evtLoopPopup, false,
_T("can't show more than one popup menu at a time") );
#ifdef __WXMSW__
ms_evtLoopPopup = NULL;
// remove the handler
- PopEventHandler(TRUE /* delete it */);
+ PopEventHandler(true /* delete it */);
menu->SetInvokingWindow(NULL);
SetCursor(cursorOld);
#endif // __WXMSW__
- return TRUE;
+ return true;
}
void wxWindow::DismissPopupMenu()