]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/frame.cpp
corrected use of Print Manager Session APIs for Carbon targets
[wxWidgets.git] / src / os2 / frame.cpp
index 18fc488fd0de9de3cb67bed1c723d97d23e03a3e..838197f4d40cb3df3eb1d6b03c085c9500d8782a 100644 (file)
@@ -243,6 +243,13 @@ void wxFrame::DoGetClientSize(
 {
     RECTL                           vRect;
     ::WinQueryWindowRect(GetHwnd(), &vRect);
 {
     RECTL                           vRect;
     ::WinQueryWindowRect(GetHwnd(), &vRect);
+
+    //
+    // No need to use statusbar code as in WIN32 as the FORMATFRAME
+    // window procedure ensures PM knows about the new frame client
+    // size internally.  A ::WinQueryWindowRect is all that is needed!
+    //
+
     if (pX)
         *pX = vRect.xRight - vRect.xLeft;
     if (pY)
     if (pX)
         *pX = vRect.xRight - vRect.xLeft;
     if (pY)
@@ -334,15 +341,9 @@ void wxFrame::DoGetPosition(
     POINTL                          vPoint;
 
     ::WinQueryWindowRect(m_hFrame, &vRect);
     POINTL                          vPoint;
 
     ::WinQueryWindowRect(m_hFrame, &vRect);
-    vPoint.x = vRect.xLeft;
-
-    //
-    // OS/2 is backwards [WIN32 it is vRect.yTop]
-    //
-    vPoint.y = vRect.yBottom;
 
 
-    *pX = vPoint.x;
-    *pY = vPoint.y;
+    *pX = vRect.xRight - vRect.xLeft;
+    *pY = vRect.yTop - vRect.yBottom;
 } // end of wxFrame::DoGetPosition
 
 // ----------------------------------------------------------------------------
 } // end of wxFrame::DoGetPosition
 
 // ----------------------------------------------------------------------------
@@ -1053,27 +1054,51 @@ void wxFrame::OnActivate(
   wxActivateEvent&                  rEvent
 )
 {
   wxActivateEvent&                  rEvent
 )
 {
-    for (wxWindowList::Node* pNode = GetChildren().GetFirst();
-         pNode;
-         pNode = pNode->GetNext())
+    if ( rEvent.GetActive() )
+    {
+        // restore focus to the child which was last focused
+        wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
+
+        wxWindow*                           pParent = m_pWinLastFocused ? m_pWinLastFocused->GetParent()
+                                            : NULL;
+        if (!pParent)
+        {
+            pParent = this;
+        }
+
+        wxSetFocusToChild( pParent
+                          ,&m_pWinLastFocused
+                         );
+    }
+    else // deactivating
     {
     {
-        // FIXME all this is totally bogus - we need to do the same as wxPanel,
-        //       but how to do it without duplicating the code?
+        //
+        // Remember the last focused child if it is our child
+        //
+        m_pWinLastFocused = FindFocus();
 
 
-        // restore focus
-        wxWindow*                   pChild = pNode->GetData();
+        for (wxWindowList::Node* pNode = GetChildren().GetFirst();
+             pNode;
+             pNode = pNode->GetNext())
+        {
+            // FIXME all this is totally bogus - we need to do the same as wxPanel,
+            //       but how to do it without duplicating the code?
 
 
-        if (!pChild->IsTopLevel()
+            // restore focus
+            wxWindow*                   pChild = pNode->GetData();
+
+            if (!pChild->IsTopLevel()
 #if wxUSE_TOOLBAR
 #if wxUSE_TOOLBAR
-             && !wxDynamicCast(pChild, wxToolBar)
+                 && !wxDynamicCast(pChild, wxToolBar)
 #endif // wxUSE_TOOLBAR
 #if wxUSE_STATUSBAR
 #endif // wxUSE_TOOLBAR
 #if wxUSE_STATUSBAR
-             && !wxDynamicCast(pChild, wxStatusBar)
+                 && !wxDynamicCast(pChild, wxStatusBar)
 #endif // wxUSE_STATUSBAR
 #endif // wxUSE_STATUSBAR
-           )
-        {
-            pChild->SetFocus();
-            return;
+               )
+            {
+                pChild->SetFocus();
+                return;
+            }
         }
     }
 } // end of wxFrame::OnActivate
         }
     }
 } // end of wxFrame::OnActivate
@@ -1156,12 +1181,12 @@ void wxFrame::PositionToolBar()
     }
 #endif // wxUSE_STATUSBAR
 
     }
 #endif // wxUSE_STATUSBAR
 
-    if ( GetToolBar() )
+    if ( m_frameToolBar )
     {
         int                         nToolbarWidth;
         int                         nToolbarHeight;
 
     {
         int                         nToolbarWidth;
         int                         nToolbarHeight;
 
-        GetToolBar()->GetSize( &nToolbarWidth
+        m_frameToolBar->GetSize( &nToolbarWidth
                               ,&nToolbarHeight
                              );
 
                               ,&nToolbarHeight
                              );
 
@@ -1325,6 +1350,7 @@ bool wxFrame::HandleSize(
             // restore all child frames too
             //
             IconizeChildFrames(FALSE);
             // restore all child frames too
             //
             IconizeChildFrames(FALSE);
+            (void)SendIconizeEvent(FALSE);
 
             //
             // fall through
 
             //
             // fall through
@@ -1339,6 +1365,7 @@ bool wxFrame::HandleSize(
             // Iconize all child frames too
             //
             IconizeChildFrames(TRUE);
             // Iconize all child frames too
             //
             IconizeChildFrames(TRUE);
+            (void)SendIconizeEvent();
             m_bIconized = TRUE;
             break;
     }
             m_bIconized = TRUE;
             break;
     }