]> git.saurik.com Git - wxWidgets.git/commitdiff
Lots of things to make menus and submenus work.
authorRobert Roebling <robert@roebling.de>
Thu, 28 Feb 2002 22:42:14 +0000 (22:42 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 28 Feb 2002 22:42:14 +0000 (22:42 +0000)
  Also added wxPopTransientWindow::CanDismiss() which will
    be needed for pop-up menus, although that actually
    still has to be done...

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/popupwin.h
src/common/popupcmn.cpp
src/univ/button.cpp
src/univ/menu.cpp
src/x11/app.cpp

index 2de6e2e50db9e24c91b29875355d77551ec02589..0bef727d28b2e6cb0777dee4cd324ac0e568cbcc 100644 (file)
@@ -86,6 +86,10 @@ public:
 
     // hide the window
     virtual void Dismiss();
+    
+
+    virtual bool CanDismiss()
+        { return TRUE; }
 
     // called when a mouse is pressed while the popup is shown: return TRUE
     // from here to prevent its normal processing by the popup (which consists
index db3250b429b5df64b2ab6fba369a635abfa3155b..7da199a713f50435b6fb8f8ed782070433954f7d 100644 (file)
@@ -427,8 +427,6 @@ void wxPopupFocusHandler::OnKillFocus(wxFocusEvent& event)
         win = win->GetParent();
     }
     
-    printf( "Dismiss now.\n" );
-    
     m_popup->DismissAndNotify();
 }
 
index 05c25ef66b7cc18bb8ea664413ef543e40e92802..eaf7fea91bd05ef5d1f7256f7fe60f4419d41060 100644 (file)
@@ -45,7 +45,7 @@
 // ----------------------------------------------------------------------------
 
 // default margins around the image
-static const wxCoord DEFAULT_BTN_MARGIN_X = 0;
+static const wxCoord DEFAULT_BTN_MARGIN_X = 0;  // We should give space for the border, at least.
 static const wxCoord DEFAULT_BTN_MARGIN_Y = 0;
 
 // ============================================================================
index a880d500379f99f0c818e756bd052bb79e9971dd..e78fc96cd9361dc18e7e775a03b526eab1f0a82e 100644 (file)
@@ -123,6 +123,8 @@ class wxPopupMenuWindow : public wxPopupTransientWindow
 {
 public:
     wxPopupMenuWindow(wxWindow *parent, wxMenu *menu);
+    
+    ~wxPopupMenuWindow();
 
     // override the base class version to select the first item initially
     virtual void Popup(wxWindow *focus = NULL);
@@ -308,6 +310,10 @@ wxPopupMenuWindow::wxPopupMenuWindow(wxWindow *parent, wxMenu *menu)
     SetCursor(wxCURSOR_ARROW);
 }
 
+wxPopupMenuWindow::~wxPopupMenuWindow()
+{
+}
+
 // ----------------------------------------------------------------------------
 // wxPopupMenuWindow current item/node handling
 // ----------------------------------------------------------------------------
@@ -1154,6 +1160,10 @@ wxWindow *wxMenu::GetRootWindow() const
     wxMenu *menu = GetParent();
     while ( menu )
     {
+        // We are a submenu of a menu of a menubar
+        if (menu->GetMenuBar())
+           return menu->GetMenuBar();
+    
         win = menu->GetInvokingWindow();
         if ( win )
             break;
@@ -1164,7 +1174,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;
@@ -2379,6 +2389,9 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
 void wxWindow::DismissPopupMenu()
 {
     wxCHECK_RET( ms_evtLoopPopup, _T("no popup menu shown") );
+    
+    char *crash = NULL;
+    (*crash) = 0;
 
     ms_evtLoopPopup->Exit();
 }
index 9dc4c4243bf980352c384690dd03e7723d7504ee..91b39edbb77f651b598dba815b4149a8b5fd20c9 100644 (file)
@@ -647,23 +647,32 @@ void wxApp::ProcessXEvent(WXEvent* _event)
                 tlw = tlw->GetParent();
             if (tlw && !tlw->IsEnabled())
                 return;
-            
+                
             if (event->type == ButtonPress)
             {
                 if ((win != wxWindow::FindFocus()) && win->AcceptsFocus())
                 {
                     // This might actually be done in wxWindow::SetFocus()
-                    // and not here.
+                    // and not here. TODO.
                     g_prevFocus = wxWindow::FindFocus();
                     g_nextFocus = win;
                     
                     win->SetFocus();
                 }
             }
-
+            
+#if !wxUSE_NANOX
+            if (event->type == LeaveNotify || event->type == EnterNotify)
+            {
+                // Throw out NotifyGrab and NotifyUngrab
+                if (event->xcrossing.mode != NotifyNormal)
+                    return;
+            }
+#endif
             wxMouseEvent wxevent;
             wxTranslateMouseEvent(wxevent, win, window, event);
             win->GetEventHandler()->ProcessEvent( wxevent );
+                
             return;
         }
         case FocusIn: