]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/frame.cpp
Various changes to make pop up menus work
[wxWidgets.git] / src / msw / frame.cpp
index 814f3bd2544317516a62ef0abd0eebe12b660bcb..c4ab391cd81bbc8be94c6ffe94cf9feacc86c5d3 100644 (file)
@@ -78,7 +78,7 @@ BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
     EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
 END_EVENT_TABLE()
 
-IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
+IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
 
 // ============================================================================
 // implementation
@@ -128,7 +128,7 @@ bool wxFrame::Create(wxWindow *parent,
     if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
         return FALSE;
 
-    SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
 
     wxModelessWindows.Append(this);
 
@@ -157,6 +157,11 @@ void wxFrame::DoSetClientSize(int width, int height)
     }
 #endif // wxUSE_STATUSBAR
 
+    // call GetClientAreaOrigin() to take the toolbar into account
+    wxPoint pt = GetClientAreaOrigin();
+    width += pt.x;
+    height += pt.y;
+
     wxTopLevelWindow::DoSetClientSize(width, height);
 }
 
@@ -165,6 +170,14 @@ void wxFrame::DoGetClientSize(int *x, int *y) const
 {
     wxTopLevelWindow::DoGetClientSize(x, y);
 
+    // account for the possible toolbar
+    wxPoint pt = GetClientAreaOrigin();
+    if ( x )
+        *x -= pt.x;
+
+    if ( y )
+        *y -= pt.y;
+
 #if wxUSE_STATUSBAR
     // adjust client area height to take the status bar into account
     if ( y )
@@ -294,7 +307,7 @@ void wxFrame::InternalSetMenuBar()
 // Responds to colour changes, and passes event on to children.
 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
-    SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
     Refresh();
 
 #if wxUSE_STATUSBAR
@@ -750,7 +763,17 @@ bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
     }
 
     wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
-    event.SetEventObject( this );
+    event.SetEventObject(this);
+
+    return GetEventHandler()->ProcessEvent(event);
+}
+
+bool wxFrame::HandleMenuLoop(const wxEventType& evtType, WXWORD isPopup)
+{
+    // we don't have the menu id here, so we use the id to specify if the event
+    // was from a popup menu or a normal one
+    wxMenuEvent event(evtType, isPopup ? -1 : 0);
+    event.SetEventObject(this);
 
     return GetEventHandler()->ProcessEvent(event);
 }
@@ -772,6 +795,10 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
             processed = !Close();
             break;
 
+        case WM_SIZE:
+            processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
+            break;
+
         case WM_COMMAND:
             {
                 WORD id, cmd;
@@ -783,6 +810,10 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
             }
             break;
 
+        case WM_PAINT:
+            processed = HandlePaint();
+            break;
+
 #ifndef __WXMICROWIN__
         case WM_MENUSELECT:
             {
@@ -793,13 +824,17 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
                 processed = HandleMenuSelect(item, flags, hmenu);
             }
             break;
-#endif
 
-        case WM_PAINT:
-            processed = HandlePaint();
+#ifndef __WIN16__
+        case WM_ENTERMENULOOP:
+            processed = HandleMenuLoop(wxEVT_MENU_OPEN, wParam);
             break;
 
-#ifndef __WXMICROWIN__
+        case WM_EXITMENULOOP:
+            processed = HandleMenuLoop(wxEVT_MENU_CLOSE, wParam);
+            break;
+#endif // __WIN16__
+
         case WM_QUERYDRAGICON:
             {
                 HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon)
@@ -808,11 +843,7 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
                 processed = rc != 0;
             }
             break;
-#endif
-
-        case WM_SIZE:
-            processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
-            break;
+#endif // !__WXMICROWIN__
     }
 
     if ( !processed )