]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/menu.cpp
cleanup - reformat
[wxWidgets.git] / src / univ / menu.cpp
index c5622fc30c51ff76bd75d3416a40a7e39e51ed23..ae7eab4f2ac293d3919a9420607faafbb979045e 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "univmenuitem.h"
-    #pragma implementation "univmenu.h"
-#endif
-
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
@@ -138,6 +133,13 @@ public:
     // called when a submenu is dismissed
     void OnSubmenuDismiss(bool dismissParent);
 
+    // the default wxMSW wxPopupTransientWindow::OnIdle disables the capture
+    // when the cursor is inside the popup, which dsables the menu tracking
+    // so override it to do nothing
+#ifdef __WXMSW__
+    void OnIdle(wxIdleEvent& WXUNUSED(event)) { }
+#endif
+
     // get the currently selected item (may be NULL)
     wxMenuItem *GetCurrentItem() const
     {
@@ -282,6 +284,9 @@ BEGIN_EVENT_TABLE(wxPopupMenuWindow, wxPopupTransientWindow)
     EVT_LEFT_UP(wxPopupMenuWindow::OnLeftUp)
     EVT_MOTION(wxPopupMenuWindow::OnMouseMove)
     EVT_LEAVE_WINDOW(wxPopupMenuWindow::OnMouseLeave)
+#ifdef __WXMSW__
+    EVT_IDLE(wxPopupMenuWindow::OnIdle)
+#endif
 END_EVENT_TABLE()
 
 BEGIN_EVENT_TABLE(wxMenuBar, wxMenuBarBase)
@@ -428,6 +433,11 @@ void wxPopupMenuWindow::Popup(wxWindow *focus)
 
     wxPopupTransientWindow::Popup(focus);
 
+    // the base class no-longer captures the mouse automatically when Popup
+    // is called, so do it here to allow the menu tracking to work
+    if ( !HasCapture() )
+        CaptureMouse();
+
 #ifdef __WXMSW__
     // ensure that this window is really on top of everything: without using
     // SetWindowPos() it can be covered by its parent menu which is not
@@ -467,6 +477,8 @@ void wxPopupMenuWindow::Dismiss()
     }
 
     wxPopupTransientWindow::Dismiss();
+
+    ResetCurrent();
 }
 
 void wxPopupMenuWindow::OnDismiss()
@@ -476,19 +488,13 @@ void wxPopupMenuWindow::OnDismiss()
     HandleDismiss(true);
 }
 
-void wxPopupMenuWindow::OnSubmenuDismiss(bool dismissParent)
+void wxPopupMenuWindow::OnSubmenuDismiss(bool WXUNUSED(dismissParent))
 {
     m_hasOpenSubMenu = false;
-
-    // we are closing whole menu so remove current highlight
-    if ( dismissParent )
-        ResetCurrent();
 }
 
 void wxPopupMenuWindow::HandleDismiss(bool dismissParent)
 {
-    ResetCurrent();
-
     m_menu->OnDismiss(dismissParent);
 }
 
@@ -860,7 +866,13 @@ void wxPopupMenuWindow::OnMouseLeave(wxMouseEvent& event)
 
 void wxPopupMenuWindow::OnKeyDown(wxKeyEvent& event)
 {
-    if ( !ProcessKeyDown(event.GetKeyCode()) )
+    wxMenuBar *menubar = m_menu->GetMenuBar();
+
+    if ( menubar )
+    {
+        menubar->ProcessEvent(event);
+    }
+    else if ( !ProcessKeyDown(event.GetKeyCode()) )
     {
         event.Skip();
     }
@@ -2465,7 +2477,7 @@ void wxMenuBar::OnDismiss()
 {
     if ( ReleaseMouseCapture() )
         wxLogTrace(_T("mousecapture"), _T("Releasing mouse from wxMenuBar::OnDismiss"));
-    
+
     if ( m_current != -1 )
     {
         size_t current = m_current;
@@ -2498,7 +2510,7 @@ bool wxMenuBar::ReleaseMouseCapture()
 
         if ( had )
             ReleaseMouse();
-            
+
         capture->CaptureMouse();
 
         return had;