X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e39af974ef7846e26686ae39d74e4696c1fef0c3..c81fc3344d20fd3335ccea52557834d2c859944d:/src/univ/menu.cpp diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index a4e1176552..ac1b1a3e91 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "univmenuitem.h" #pragma implementation "univmenu.h" #endif @@ -75,7 +75,7 @@ public: m_width = 0; } - void SetEnabled(bool enabled = TRUE) { m_isEnabled = enabled; } + void SetEnabled(bool enabled = true) { m_isEnabled = enabled; } // accessors @@ -123,7 +123,7 @@ class wxPopupMenuWindow : public wxPopupTransientWindow { public: wxPopupMenuWindow(wxWindow *parent, wxMenu *menu); - + ~wxPopupMenuWindow(); // override the base class version to select the first item initially @@ -136,7 +136,7 @@ public: 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 @@ -145,7 +145,7 @@ public: } // find the menu item at given position - wxMenuItemList::Node *GetMenuItemFromPoint(const wxPoint& pt) const; + wxMenuItemList::compatibility_iterator GetMenuItemFromPoint(const wxPoint& pt) const; // refresh the given item void RefreshItem(wxMenuItem *item); @@ -153,7 +153,7 @@ public: // 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 @@ -183,13 +183,14 @@ protected: void ResetCurrent(); // set the current node and item withotu refreshing anything - void SetCurrent(wxMenuItemList::Node *node); + void SetCurrent(wxMenuItemList::compatibility_iterator node); + virtual bool SetCurrent(bool doit = true){return wxPopupTransientWindow::SetCurrent(doit);}; // change the current item refreshing the old and new items - void ChangeCurrent(wxMenuItemList::Node *node); + 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); @@ -216,23 +217,23 @@ protected: bool HasOpenSubmenu() const { return m_hasOpenSubMenu; } // get previous node after the current one - wxMenuItemList::Node *GetPrevNode() const; + wxMenuItemList::compatibility_iterator GetPrevNode() const; // get previous node before the given one, wrapping if it's the first one - wxMenuItemList::Node *GetPrevNode(wxMenuItemList::Node *node) const; + wxMenuItemList::compatibility_iterator GetPrevNode(wxMenuItemList::compatibility_iterator node) const; // get next node after the current one - wxMenuItemList::Node *GetNextNode() const; + wxMenuItemList::compatibility_iterator GetNextNode() const; // get next node after the given one, wrapping if it's the last one - wxMenuItemList::Node *GetNextNode(wxMenuItemList::Node *node) const; + wxMenuItemList::compatibility_iterator GetNextNode(wxMenuItemList::compatibility_iterator node) const; private: // the menu we show wxMenu *m_menu; // the menu node corresponding to the current item - wxMenuItemList::Node *m_nodeCurrent; + wxMenuItemList::compatibility_iterator m_nodeCurrent; // do we currently have an opened submenu? bool m_hasOpenSubMenu; @@ -257,8 +258,8 @@ public: } else { - // return FALSE; - + // return false; + return wxEvtHandler::ProcessEvent(event); } } @@ -303,7 +304,7 @@ END_EVENT_TABLE() wxPopupMenuWindow::wxPopupMenuWindow(wxWindow *parent, wxMenu *menu) { m_menu = menu; - m_hasOpenSubMenu = FALSE; + m_hasOpenSubMenu = false; ResetCurrent(); @@ -328,19 +329,23 @@ wxPopupMenuWindow::~wxPopupMenuWindow() void wxPopupMenuWindow::ResetCurrent() { - SetCurrent(NULL); +#if wxUSE_STL + SetCurrent(wxMenuItemList::compatibility_iterator()); +#else + SetCurrent((wxwxMenuItemListNode *)NULL); +#endif } -void wxPopupMenuWindow::SetCurrent(wxMenuItemList::Node *node) +void wxPopupMenuWindow::SetCurrent(wxMenuItemList::compatibility_iterator node) { m_nodeCurrent = node; } -void wxPopupMenuWindow::ChangeCurrent(wxMenuItemList::Node *node) +void wxPopupMenuWindow::ChangeCurrent(wxMenuItemList::compatibility_iterator node) { if ( node != m_nodeCurrent ) { - wxMenuItemList::Node *nodeOldCurrent = m_nodeCurrent; + wxMenuItemList::compatibility_iterator nodeOldCurrent = m_nodeCurrent; m_nodeCurrent = node; @@ -364,15 +369,15 @@ void wxPopupMenuWindow::ChangeCurrent(wxMenuItemList::Node *node) } } -wxMenuItemList::Node *wxPopupMenuWindow::GetPrevNode() const +wxMenuItemList::compatibility_iterator wxPopupMenuWindow::GetPrevNode() const { // return the last node if there had been no previously selected one return m_nodeCurrent ? GetPrevNode(m_nodeCurrent) : m_menu->GetMenuItems().GetLast(); } -wxMenuItemList::Node * -wxPopupMenuWindow::GetPrevNode(wxMenuItemList::Node *node) const +wxMenuItemList::compatibility_iterator +wxPopupMenuWindow::GetPrevNode(wxMenuItemList::compatibility_iterator node) const { if ( node ) { @@ -387,15 +392,15 @@ wxPopupMenuWindow::GetPrevNode(wxMenuItemList::Node *node) const return node; } -wxMenuItemList::Node *wxPopupMenuWindow::GetNextNode() const +wxMenuItemList::compatibility_iterator wxPopupMenuWindow::GetNextNode() const { // return the first node if there had been no previously selected one return m_nodeCurrent ? GetNextNode(m_nodeCurrent) : m_menu->GetMenuItems().GetFirst(); } -wxMenuItemList::Node * -wxPopupMenuWindow::GetNextNode(wxMenuItemList::Node *node) const +wxMenuItemList::compatibility_iterator +wxPopupMenuWindow::GetNextNode(wxMenuItemList::compatibility_iterator node) const { if ( node ) { @@ -468,7 +473,7 @@ void wxPopupMenuWindow::OnDismiss() { // 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) @@ -481,14 +486,14 @@ void wxPopupMenuWindow::HandleDismiss(bool dismissParent) void wxPopupMenuWindow::DismissAndNotify() { Dismiss(); - HandleDismiss(TRUE); + HandleDismiss(true); } // ---------------------------------------------------------------------------- // wxPopupMenuWindow geometry // ---------------------------------------------------------------------------- -wxMenuItemList::Node * +wxMenuItemList::compatibility_iterator wxPopupMenuWindow::GetMenuItemFromPoint(const wxPoint& pt) const { // we only use the y coord normally, but still check x in case the point is @@ -496,7 +501,7 @@ wxPopupMenuWindow::GetMenuItemFromPoint(const wxPoint& pt) const if ( wxWindow::HitTest(pt) == wxHT_WINDOW_INSIDE ) { wxCoord y = 0; - for ( wxMenuItemList::Node *node = m_menu->GetMenuItems().GetFirst(); + for ( wxMenuItemList::compatibility_iterator node = m_menu->GetMenuItems().GetFirst(); node; node = node->GetNext() ) { @@ -510,7 +515,11 @@ wxPopupMenuWindow::GetMenuItemFromPoint(const wxPoint& pt) const } } +#if wxUSE_STL + return wxMenuItemList::compatibility_iterator(); +#else return NULL; +#endif } // ---------------------------------------------------------------------------- @@ -544,7 +553,7 @@ void wxPopupMenuWindow::DoDraw(wxControlRenderer *renderer) wxCoord y = 0; const wxMenuGeometryInfo& gi = m_menu->GetGeometryInfo(); - for ( wxMenuItemList::Node *node = m_menu->GetMenuItems().GetFirst(); + for ( wxMenuItemList::compatibility_iterator node = m_menu->GetMenuItems().GetFirst(); node; node = node->GetNext() ) { @@ -576,6 +585,21 @@ void wxPopupMenuWindow::DoDraw(wxControlRenderer *renderer) if ( item == GetCurrentItem() ) flags |= wxCONTROL_SELECTED; + wxBitmap bmp; + + if ( !item->IsEnabled() ) + { + bmp = item->GetDisabledBitmap(); + } + + if ( !bmp.Ok() ) + { + // strangely enough, for unchecked item we use the + // "checked" bitmap because this is the default one - this + // explains this strange boolean expression + bmp = item->GetBitmap(!item->IsCheckable() || item->IsChecked()); + } + rend->DrawMenuItem ( dc, @@ -583,10 +607,7 @@ void wxPopupMenuWindow::DoDraw(wxControlRenderer *renderer) gi, item->GetLabel(), item->GetAccelString(), - // strangely enough, for unchecked item we use the - // "checked" bitmap because this is the default one - this - // explains this strange boolean expression - item->GetBitmap(!item->IsCheckable() || item->IsChecked()), + bmp, flags, item->GetAccelIndex() ); @@ -611,7 +632,7 @@ void wxPopupMenuWindow::ClickItem(wxMenuItem *item) // close all menus DismissAndNotify(); - + menu->ClickItem(item); } @@ -627,7 +648,7 @@ void wxPopupMenuWindow::OpenSubmenu(wxMenuItem *item, InputMethod how) 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) @@ -635,7 +656,7 @@ 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 @@ -650,10 +671,10 @@ bool wxPopupMenuWindow::ActivateItem(wxMenuItem *item, InputMethod how) } else // separator, can't activate { - return FALSE; + return false; } - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -675,24 +696,24 @@ bool wxPopupMenuWindow::ProcessLeftDown(wxMouseEvent& event) { 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) { - wxMenuItemList::Node *node = GetMenuItemFromPoint(event.GetPosition()); + wxMenuItemList::compatibility_iterator node = GetMenuItemFromPoint(event.GetPosition()); if ( node ) { ActivateItem(node->GetData(), WithMouse); @@ -726,7 +747,7 @@ void wxPopupMenuWindow::OnMouseMove(wxMouseEvent& event) void wxPopupMenuWindow::ProcessMouseMove(const wxPoint& pt) { - wxMenuItemList::Node *node = GetMenuItemFromPoint(pt); + wxMenuItemList::compatibility_iterator node = GetMenuItemFromPoint(pt); // don't reset current to NULL here, we only do it when the mouse leaves // the window (see below) @@ -812,12 +833,16 @@ void wxPopupMenuWindow::OnMouseLeave(wxMouseEvent& event) else { // this menu is the last opened - resetCurrent = TRUE; + resetCurrent = true; } if ( resetCurrent ) { +#if wxUSE_STL + ChangeCurrent(wxMenuItemList::compatibility_iterator()); +#else ChangeCurrent(NULL); +#endif } } @@ -841,14 +866,14 @@ bool wxPopupMenuWindow::ProcessKeyDown(int key) // 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 @@ -860,7 +885,7 @@ bool wxPopupMenuWindow::ProcessKeyDown(int key) // menubar if ( !m_menu->GetParent() ) { - processed = FALSE; + processed = false; break; } @@ -869,7 +894,7 @@ bool wxPopupMenuWindow::ProcessKeyDown(int key) case WXK_ESCAPE: // close just this menu Dismiss(); - HandleDismiss(FALSE); + HandleDismiss(false); break; case WXK_RETURN: @@ -889,9 +914,9 @@ bool wxPopupMenuWindow::ProcessKeyDown(int key) { bool up = key == WXK_UP; - wxMenuItemList::Node *nodeStart = up ? GetPrevNode() + wxMenuItemList::compatibility_iterator nodeStart = up ? GetPrevNode() : GetNextNode(), - *node = nodeStart; + node = nodeStart; while ( node && node->GetData()->IsSeparator() ) { node = up ? GetPrevNode(node) : GetNextNode(node); @@ -900,7 +925,11 @@ bool wxPopupMenuWindow::ProcessKeyDown(int key) { // nothing but separators and disabled items in this // menu, break out +#if wxUSE_STL + node = wxMenuItemList::compatibility_iterator(); +#else node = NULL; +#endif } } @@ -910,7 +939,7 @@ bool wxPopupMenuWindow::ProcessKeyDown(int key) } else { - processed = FALSE; + processed = false; } } break; @@ -923,7 +952,7 @@ bool wxPopupMenuWindow::ProcessKeyDown(int key) } else { - processed = FALSE; + processed = false; } break; @@ -934,18 +963,22 @@ bool wxPopupMenuWindow::ProcessKeyDown(int key) // we want to start from the item after this one because // if we're already on the item with the given accel we want to // go to the next one, not to stay in place - wxMenuItemList::Node *nodeStart = GetNextNode(); + 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); // loop through all items searching for the item with this // accel - wxMenuItemList::Node *node = nodeStart, - *nodeFound = NULL; + wxMenuItemList::compatibility_iterator node = nodeStart, +#if wxUSE_STL + nodeFound = wxMenuItemList::compatibility_iterator(); +#else + nodeFound = NULL; +#endif for ( ;; ) { item = node->GetData(); @@ -965,7 +998,7 @@ bool wxPopupMenuWindow::ProcessKeyDown(int 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 @@ -998,12 +1031,12 @@ bool wxPopupMenuWindow::ProcessKeyDown(int key) //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; @@ -1089,10 +1122,8 @@ void wxMenu::EndRadioGroup() m_startRadioGroup = -1; } -bool wxMenu::DoAppend(wxMenuItem *item) +wxMenuItem* wxMenu::DoAppend(wxMenuItem *item) { - bool check = FALSE; - if ( item->GetKind() == wxITEM_RADIO ) { int count = GetMenuItemCount(); @@ -1105,15 +1136,12 @@ bool wxMenu::DoAppend(wxMenuItem *item) // for now it has just one element item->SetAsRadioGroupStart(); item->SetRadioGroupEnd(m_startRadioGroup); - - // ensure that we have a checked item in the radio group - check = TRUE; } else // extend the current radio group { // we need to update its end item item->SetRadioGroupStart(m_startRadioGroup); - wxMenuItemList::Node *node = GetMenuItems().Item(m_startRadioGroup); + wxMenuItemList::compatibility_iterator node = GetMenuItems().Item(m_startRadioGroup); if ( node ) { @@ -1131,21 +1159,21 @@ bool wxMenu::DoAppend(wxMenuItem *item) } if ( !wxMenuBase::DoAppend(item) ) - return FALSE; + return NULL; OnItemAdded(item); - return TRUE; + return item; } -bool wxMenu::DoInsert(size_t pos, wxMenuItem *item) +wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item) { if ( !wxMenuBase::DoInsert(pos, item) ) - return FALSE; + return NULL; OnItemAdded(item); - return TRUE; + return item; } wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) @@ -1196,10 +1224,10 @@ void wxMenu::Detach() wxWindow *wxMenu::GetRootWindow() const { - if ( m_menuBar ) + if ( GetMenuBar() ) { // simple case - a normal menu attached to the menubar - return m_menuBar; + return GetMenuBar(); } // we're a popup menu but the trouble is that only the top level popup menu @@ -1218,7 +1246,7 @@ wxWindow *wxMenu::GetRootWindow() const // We are a submenu of a menu of a menubar if (menu->GetMenuBar()) return menu->GetMenuBar(); - + win = menu->GetInvokingWindow(); if ( win ) break; @@ -1229,7 +1257,7 @@ wxWindow *wxMenu::GetRootWindow() const // we're probably going to crash in the caller anyhow, but try to detect // this error as soon as possible wxASSERT_MSG( win, _T("menu without any associated window?") ); - + // also remember it in this menu so that we don't have to search for it the // next time wxConstCast(this, wxMenu)->m_invokingWindow = win; @@ -1291,7 +1319,7 @@ void wxMenu::OnDismiss(bool dismissParent) { // dismissParent is recursive m_menuParent->Dismiss(); - m_menuParent->OnDismiss(TRUE); + m_menuParent->OnDismiss(true); } } else // no parent menu @@ -1306,7 +1334,7 @@ void wxMenu::OnDismiss(bool dismissParent) wxCHECK_RET( m_invokingWindow, _T("what kind of menu is this?") ); m_invokingWindow->DismissPopupMenu(); - + // Why reset it here? We need it for sending the event to... // SetInvokingWindow(NULL); } @@ -1326,7 +1354,7 @@ void wxMenu::Popup(const wxPoint& pos, const wxSize& size, bool selectFirst) { m_popupMenu->SelectFirst(); } - + // the geometry might have changed since the last time we were shown, so // always resize m_popupMenu->SetClientSize(GetGeometryInfo().GetSize()); @@ -1357,7 +1385,7 @@ void wxMenu::Dismiss() 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); @@ -1378,7 +1406,7 @@ bool wxMenu::ClickItem(wxMenuItem *item) // not applicabled isChecked = -1; } - + return SendEvent(item->GetId(), isChecked); } @@ -1398,7 +1426,7 @@ bool wxMenu::ProcessAccelEvent(const wxKeyEvent& event) } // try our submenus - for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + for ( wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); node; node = node->GetNext() ) { @@ -1408,12 +1436,12 @@ bool wxMenu::ProcessAccelEvent(const wxKeyEvent& event) // try its elements if ( item->GetSubMenu()->ProcessAccelEvent(event) ) { - return TRUE; + return true; } } } - return FALSE; + return false; } void wxMenu::AddAccelFor(wxMenuItem *item) @@ -1455,10 +1483,12 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu, : 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; UpdateAccelInfo(); } @@ -1584,12 +1614,12 @@ void wxMenuItem::Check(bool check) } // also uncheck all the other items in this radio group - wxMenuItemList::Node *node = items.Item(start); + wxMenuItemList::compatibility_iterator node = items.Item(start); for ( int n = start; n <= end && node; n++ ) { if ( n != pos ) { - node->GetData()->m_isChecked = FALSE; + node->GetData()->m_isChecked = false; } node = node->GetNext(); } @@ -1605,7 +1635,7 @@ void wxMenuItem::Check(bool check) void wxMenuItem::SetAsRadioGroupStart() { - m_isRadioGroupStart = TRUE; + m_isRadioGroupStart = true; } void wxMenuItem::SetRadioGroupStart(int start) @@ -1636,9 +1666,7 @@ void wxMenuBar::Init() m_menuShown = NULL; - m_shouldShowMenu = FALSE; - - m_windowStyle |= wxNO_FULL_REPAINT_ON_RESIZE; + m_shouldShowMenu = false; } void wxMenuBar::Attach(wxFrame *frame) @@ -1662,14 +1690,14 @@ 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 @@ -1704,14 +1732,14 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title) 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) @@ -1775,7 +1803,7 @@ void wxMenuBar::EnableTop(size_t pos, bool enable) 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(); } @@ -1986,7 +2014,7 @@ void wxMenuBar::DoSelectMenu(size_t pos) if ( IsShowingMenu() ) { // restore m_shouldShowMenu flag after DismissMenu() which resets - // it to FALSE + // it to false bool old = m_shouldShowMenu; DismissMenu(); @@ -2055,14 +2083,14 @@ void wxMenuBar::OnLeftDown(wxMouseEvent& event) } 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 */); } } } @@ -2089,7 +2117,7 @@ bool wxMenuBar::ProcessMouseEvent(const wxPoint& pt) static wxPoint s_ptLast; if ( pt == s_ptLast ) { - return FALSE; + return false; } s_ptLast = pt; @@ -2098,7 +2126,7 @@ bool wxMenuBar::ProcessMouseEvent(const wxPoint& pt) int currentNew = GetMenuFromPoint(pt); if ( (currentNew == -1) || (currentNew == m_current) ) { - return FALSE; + return false; } // select the new active item @@ -2109,10 +2137,10 @@ bool wxMenuBar::ProcessMouseEvent(const wxPoint& pt) 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) @@ -2264,7 +2292,7 @@ int wxMenuBar::FindNextItemForAccel(int idxStart, int key, bool *unique) const // 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); @@ -2304,7 +2332,7 @@ int wxMenuBar::FindNextItemForAccel(int idxStart, int key, bool *unique) const 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 @@ -2335,7 +2363,7 @@ int wxMenuBar::FindNextItemForAccel(int idxStart, int key, bool *unique) const bool wxMenuBar::ProcessAccelEvent(const wxKeyEvent& event) { size_t n = 0; - for ( wxMenuList::Node *node = m_menus.GetFirst(); + for ( wxMenuList::compatibility_iterator node = m_menus.GetFirst(); node; node = node->GetNext(), n++ ) { @@ -2345,13 +2373,13 @@ bool wxMenuBar::ProcessAccelEvent(const wxKeyEvent& event) if ( node->GetData()->ProcessAccelEvent(event) ) { // menu processed it - return TRUE; + return true; } } } // not found - return FALSE; + return false; } #endif // wxUSE_ACCEL @@ -2368,7 +2396,7 @@ void wxMenuBar::PopupCurrentMenu(bool selectFirst) 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) ) { @@ -2383,6 +2411,8 @@ void wxMenuBar::PopupCurrentMenu(bool selectFirst) // 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); @@ -2406,7 +2436,7 @@ void wxMenuBar::DismissMenu() void wxMenuBar::OnDismissMenu(bool dismissMenuBar) { - m_shouldShowMenu = FALSE; + m_shouldShowMenu = false; m_menuShown = NULL; if ( dismissMenuBar ) { @@ -2446,7 +2476,7 @@ wxEventLoop *wxWindow::ms_evtLoopPopup = NULL; 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__ @@ -2473,9 +2503,9 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) #endif // 0 menu->SetInvokingWindow(this); - + // wxLogDebug( "Name of invoking window %s", menu->GetInvokingWindow()->GetName().c_str() ); - + menu->Popup(ClientToScreen(wxPoint(x, y)), wxSize(0, 0)); // this is not very useful if the menu was popped up because of the mouse @@ -2496,7 +2526,7 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) ms_evtLoopPopup = NULL; // remove the handler - PopEventHandler(TRUE /* delete it */); + PopEventHandler(true /* delete it */); menu->SetInvokingWindow(NULL); @@ -2504,13 +2534,13 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) SetCursor(cursorOld); #endif // __WXMSW__ - return TRUE; + return true; } void wxWindow::DismissPopupMenu() { wxCHECK_RET( ms_evtLoopPopup, _T("no popup menu shown") ); - + ms_evtLoopPopup->Exit(); }