]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/frame.cpp
Next attempt at dynlib.cpp
[wxWidgets.git] / src / msw / frame.cpp
index a616ad14a173215e37355ab8c5a0a871523b6197..a45bf2ea6b2ae92b0c388cfd7ab07d8700ae0691 100644 (file)
@@ -47,6 +47,7 @@
 extern wxList wxModelessWindows;
 extern wxList wxPendingDelete;
 extern char wxFrameClassName[];
+extern wxMenu *wxCurrentPopupMenu;
 
 #if !USE_SHARED_LIBRARY
 BEGIN_EVENT_TABLE(wxFrame, wxWindow)
@@ -111,8 +112,11 @@ bool wxFrame::Create(wxWindow *parent,
   int height = size.y;
 
   m_iconized = FALSE;
-  MSWCreate(m_windowId, (wxWindow *)parent, wxFrameClassName, this, (char *)(const char *)title,
-                   x, y, width, height, style);
+
+  // we pass NULL as parent to MSWCreate because frames with parents behave
+  // very strangely under Win95 shell
+  MSWCreate(m_windowId, NULL, wxFrameClassName, this, title,
+            x, y, width, height, style);
 
   wxModelessWindows.Append(this);
   return TRUE;
@@ -479,6 +483,7 @@ void wxFrame::SetMenuBar(wxMenuBar *menu_bar)
   menu_bar->m_menuBarFrame = this;
 }
 
+#if 0
 bool wxFrame::LoadAccelerators(const wxString& table)
 {
   m_acceleratorTable = (WXHANDLE)
@@ -498,6 +503,7 @@ bool wxFrame::LoadAccelerators(const wxString& table)
 
   return (m_acceleratorTable != (WXHANDLE) NULL);
 }
+#endif
 
 void wxFrame::Fit(void)
 {
@@ -676,13 +682,28 @@ void wxFrame::MSWOnSize(int x, int y, WXUINT id)
 #endif
   switch (id)
   {
-    case SIZEFULLSCREEN:
     case SIZENORMAL:
+      // only do it it if we were iconized before, otherwise resizing the
+      // parent frame has a curious side effect of bringing it under it's
+      // children
+      if ( !m_iconized )
+        break;
+
+      // restore all child frames too
+      IconizeChildFrames(FALSE);
+
+      // fall through
+
+    case SIZEFULLSCREEN:
       m_iconized = FALSE;
-    break;
+      break;
+
     case SIZEICONIC:
+      // iconize all child frames too
+      IconizeChildFrames(TRUE);
+
       m_iconized = TRUE;
-    break;
+      break;
   }
 
  if (!m_iconized)
@@ -728,6 +749,14 @@ bool wxFrame::MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control)
     if (win)
       return win->MSWCommand(cmd, id);
 
+    if (wxCurrentPopupMenu)
+    {
+        wxMenu *popupMenu = wxCurrentPopupMenu;
+        wxCurrentPopupMenu = NULL;
+        if (popupMenu->MSWCommand(cmd, id))
+            return TRUE;
+    }
+
     if (GetMenuBar() && GetMenuBar()->FindItemForId(id))
     {
       ProcessCommand(id);
@@ -758,8 +787,13 @@ void wxFrame::MSWOnMenuHighlight(WXWORD nItem, WXWORD nFlags, WXHMENU hSysMenu)
 
 bool wxFrame::MSWProcessMessage(WXMSG* pMsg)
 {
-  if (m_acceleratorTable != 0 &&
-          ::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable, (MSG *)pMsg))
+  return FALSE;
+}
+
+bool wxFrame::MSWTranslateMessage(WXMSG* pMsg)
+{
+  if (m_acceleratorTable.Ok() &&
+          ::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable.GetHACCEL(), (MSG *)pMsg))
     return TRUE;
   
   return FALSE;
@@ -961,8 +995,6 @@ wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& n
 
 void wxFrame::PositionToolBar(void)
 {
-    int cw, ch;
-
     RECT rect;
     ::GetClientRect((HWND) GetHWND(), &rect);
 
@@ -991,3 +1023,15 @@ void wxFrame::PositionToolBar(void)
     }
 }
 
+// propagate our state change to all child frames
+void wxFrame::IconizeChildFrames(bool bIconize)
+{
+  wxWindow *child = NULL;
+  for ( wxNode *node = GetChildren()->First(); node; node = node->Next() ) {
+    wxWindow *win = (wxWindow *)node->Data();
+    if ( win->IsKindOf(CLASSINFO(wxFrame)) ) {
+      ((wxFrame *)win)->Iconize(bIconize);
+    }
+  }
+}
+