]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/frame.cpp
More scrolling stuff.
[wxWidgets.git] / src / os2 / frame.cpp
index 4c0870f57707e00e505a16c977306d67dc44f872..dbc1e6be9811e0737f368cf323278dc4001fb065 100644 (file)
@@ -243,6 +243,13 @@ void wxFrame::DoGetClientSize(
 {
     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)
@@ -984,6 +991,22 @@ bool wxFrame::OS2Create(
     wxAssociateWinWithHandle(m_hWnd, this);
     wxAssociateWinWithHandle(m_hFrame, this);
 
+    m_backgroundColour.Set(wxString("GREY"));
+
+    LONG                            lColor = (LONG)m_backgroundColour.GetPixel();
+
+    if (!::WinSetPresParam( m_hWnd
+                           ,PP_BACKGROUNDCOLOR
+                           ,sizeof(LONG)
+                           ,(PVOID)&lColor
+                          ))
+    {
+        vError = ::WinGetLastError(vHabmain);
+        sError = wxPMErrorToStr(vError);
+        wxLogError("Error creating frame. Error: %s\n", sError);
+        return FALSE;
+    }
+
     //
     // Now need to subclass window.  Instead of calling the SubClassWin in wxWindow
     // we manually subclass here because we don't want to use the main wxWndProc
@@ -1014,10 +1037,10 @@ bool wxFrame::OS2Create(
     //
     if (!::WinSetWindowPos( m_hWnd
                            ,HWND_TOP
-                           ,nX + 20
-                           ,nY + 20
-                           ,nWidth - 60
-                           ,nHeight - 60
+                           ,nX // + 20
+                           ,nY // + 20
+                           ,nWidth // - 60
+                           ,nHeight // - 60
                            ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_ZORDER
                           ))
     {
@@ -1026,20 +1049,6 @@ bool wxFrame::OS2Create(
         wxLogError("Error sizing client. Error: %s\n", sError);
         return FALSE;
     }
-
-/*
-    uCtlCount = SHORT1FROMMP(::WinSendMsg(GetHWND(), WM_FORMATFRAME, (MPARAM)vSwp, (MPARAM)vRect));
-    for (int i = 0; i < uCtlCount; i++)
-    {
-        if (vSwp[i].hwnd == GetHWND())
-            memcpy(&m_vSwp, &vSwp[i], sizeof(SWP));
-        else if (vSwp[i].hwnd == m_hVScroll)
-            memcpy(&m_vSwpVScroll, &vSwp[i], sizeof(SWP));
-        else if (vSwp[i].hwnd == m_hHScroll)
-            memcpy(&m_vSwpVScroll, &vSwp[i], sizeof(SWP));
-        else if (vSwp[i].hwnd == m_hTitleBar)
-            memcpy(&m_vSwpTitleBar, &vSwp[i], sizeof(SWP));
-    }*/
     return TRUE;
 } // end of wxFrame::OS2Create
 
@@ -1051,27 +1060,51 @@ void wxFrame::OnActivate(
   wxActivateEvent&                  rEvent
 )
 {
-    for (wxWindowList::Node* pNode = GetChildren().GetFirst();
-         pNode;
-         pNode = pNode->GetNext())
+    if ( rEvent.GetActive() )
     {
-        // FIXME all this is totally bogus - we need to do the same as wxPanel,
-        //       but how to do it without duplicating the code?
+        // restore focus to the child which was last focused
+        wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
 
-        // restore focus
-        wxWindow*                   pChild = pNode->GetData();
+        wxWindow*                           pParent = m_pWinLastFocused ? m_pWinLastFocused->GetParent()
+                                            : NULL;
+        if (!pParent)
+        {
+            pParent = this;
+        }
 
-        if (!pChild->IsTopLevel()
+        wxSetFocusToChild( pParent
+                          ,&m_pWinLastFocused
+                         );
+    }
+    else // deactivating
+    {
+        //
+        // Remember the last focused child if it is our child
+        //
+        m_pWinLastFocused = FindFocus();
+
+        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?
+
+            // restore focus
+            wxWindow*                   pChild = pNode->GetData();
+
+            if (!pChild->IsTopLevel()
 #if wxUSE_TOOLBAR
-             && !wxDynamicCast(pChild, wxToolBar)
+                 && !wxDynamicCast(pChild, wxToolBar)
 #endif // wxUSE_TOOLBAR
 #if wxUSE_STATUSBAR
-             && !wxDynamicCast(pChild, wxStatusBar)
+                 && !wxDynamicCast(pChild, wxStatusBar)
 #endif // wxUSE_STATUSBAR
-           )
-        {
-            pChild->SetFocus();
-            return;
+               )
+            {
+                pChild->SetFocus();
+                return;
+            }
         }
     }
 } // end of wxFrame::OnActivate
@@ -1154,12 +1187,12 @@ void wxFrame::PositionToolBar()
     }
 #endif // wxUSE_STATUSBAR
 
-    if ( GetToolBar() )
+    if ( m_frameToolBar )
     {
         int                         nToolbarWidth;
         int                         nToolbarHeight;
 
-        GetToolBar()->GetSize( &nToolbarWidth
+        m_frameToolBar->GetSize( &nToolbarWidth
                               ,&nToolbarHeight
                              );
 
@@ -1290,7 +1323,7 @@ bool wxFrame::HandlePaint()
         }
         else
         {
-            return wxWindow::HandlePaint();
+            return(wxWindow::HandlePaint());
         }
     }
     else
@@ -1598,23 +1631,22 @@ MRESULT wxFrame::OS2WindowProc(
             break;
 
         case WM_PAINT:
-            {
-                HPS                             hPS;
-                RECTL                           vRect;
-                wxPaintEvent                    vEvent;
-
-                hPS = WinBeginPaint(m_hWnd, 0L, &vRect);
-                ::WinFillRect(hPS, &vRect,  CLR_BLUE  /* SYSCLR_WINDOW */);
-                ::WinEndPaint(hPS);
+            bProcessed = HandlePaint();
+            mRc = (MRESULT)FALSE;
+            break;
 
-                mRc = (MRESULT)FALSE;
-                vEvent.SetEventObject(this);
-                GetEventHandler()->ProcessEvent(vEvent);
-                bProcessed = TRUE;
-            }
+         case WM_ERASEBACKGROUND:
+            //
+            // Returning TRUE to requests PM to paint the window background
+            // in SYSCLR_WINDOW. We capture this here because the PS returned
+            // in Frames is the PS for the whole frame, which we can't really
+            // use at all. If you want to paint a different background, do it
+            // in an OnPaint using a wxPaintDC.
+            //
+            mRc = (MRESULT)(TRUE);
             break;
 
-        case WM_COMMAND:
+      case WM_COMMAND:
             {
                 WORD                wId;
                 WORD                wCmd;
@@ -1669,15 +1701,6 @@ MRESULT wxFrame::OS2WindowProc(
             mRc = (MRESULT)FALSE;
             break;
 
-        case WM_ERASEBACKGROUND:
-            //
-            // Return TRUE to request PM to paint the window background
-            // in SYSCLR_WINDOW.
-            //
-            bProcessed = TRUE;
-            mRc = (MRESULT)(TRUE);
-            break;
-
         case CM_QUERYDRAGIMAGE:
             {
                 HPOINTER                hIcon;