]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/frame.cpp
matrix compile fix
[wxWidgets.git] / src / os2 / frame.cpp
index 26b4572eec102310cb61cf09fad603622b0b4eb7..4c0870f57707e00e505a16c977306d67dc44f872 100644 (file)
@@ -55,7 +55,9 @@ extern wxList WXDLLEXPORT wxPendingDelete;
 extern wxChar wxFrameClassName[];
 extern wxMenu *wxCurrentPopupMenu;
 
-extern void  wxAssociateWinWithHandle( HWND hWnd,wxWindow* pWin);
+extern void  wxAssociateWinWithHandle( HWND      hWnd
+                                      ,wxWindow* pWin
+                                     );
 
 // ----------------------------------------------------------------------------
 // event tables
@@ -630,7 +632,7 @@ void wxFrame::InternalSetMenuBar()
         sError = wxPMErrorToStr(vError);
         wxLogError("Error setting parent for submenu. Error: %s\n", sError);
     }
-    WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
+    ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
 } // end of wxFrame::InternalSetMenuBar
 
 //
@@ -706,9 +708,9 @@ bool wxFrame::ShowFullScreen(
 
         if (lStyle & wxFULLSCREEN_NOMENUBAR)
         {
-            ::WinSetParent(m_hMenu, GetHWND(), FALSE);
-            ::WinSetOwner(m_hMenu, GetHWND());
-            ::WinSendMsg((HWND)GetHWND(), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
+            ::WinSetParent(m_hMenu, m_hFrame, FALSE);
+            ::WinSetOwner(m_hMenu, m_hFrame);
+            ::WinSendMsg((HWND)m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
         }
 
 #if wxUSE_STATUSBAR
@@ -732,16 +734,16 @@ bool wxFrame::ShowFullScreen(
         //
         // Save the 'normal' window style
         //
-        m_lFsOldWindowStyle = ::WinQueryWindowULong((HWND)GetHWND(), QWL_STYLE);
+        m_lFsOldWindowStyle = ::WinQueryWindowULong(m_hFrame, QWL_STYLE);
 
         //
-           // Save the old position, width & height, maximize state
+        // Save the old position, width & height, maximize state
         //
         m_vFsOldSize = GetRect();
         m_bFsIsMaximized = IsMaximized();
 
         //
-            // Decide which window style flags to turn off
+        // Decide which window style flags to turn off
         //
         LONG                        lNewStyle = m_lFsOldWindowStyle;
         LONG                        lOffFlags = 0;
@@ -756,7 +758,7 @@ bool wxFrame::ShowFullScreen(
         //
         // Change our window style to be compatible with full-screen mode
         //
-        ::WinSetWindowULong((HWND)GetHWND(), QWL_STYLE, (ULONG)lNewStyle);
+        ::WinSetWindowULong((HWND)m_hFrame, QWL_STYLE, (ULONG)lNewStyle);
 
         //
         // Resize to the size of the desktop
@@ -827,13 +829,13 @@ bool wxFrame::ShowFullScreen(
 
         if ((m_lFsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
         {
-            ::WinSetParent(m_hMenu, GetHWND(), FALSE);
-            ::WinSetOwner(m_hMenu, GetHWND());
-            ::WinSendMsg((HWND)GetHWND(), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
+            ::WinSetParent(m_hMenu, m_hFrame, FALSE);
+            ::WinSetOwner(m_hMenu, m_hFrame);
+            ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
         }
         Maximize(m_bFsIsMaximized);
 
-        ::WinSetWindowULong( (HWND)GetHWND()
+        ::WinSetWindowULong( m_hFrame
                             ,QWL_STYLE
                             ,(ULONG)m_lFsOldWindowStyle
                            );
@@ -1253,7 +1255,7 @@ bool wxFrame::HandlePaint()
             HPOINTER                hIcon;
 
             if (m_icon.Ok())
-                hIcon = (HPOINTER)::WinSendMsg(GetHWND(), WM_QUERYICON, 0L, 0L);
+                hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L);
             else
                 hIcon = (HPOINTER)m_hDefaultIcon;
 
@@ -1553,13 +1555,6 @@ MRESULT EXPENTRY wxFrameWndProc(
     // When we get the first message for the HWND we just created, we associate
     // it with wxWindow stored in wxWndHook
     //
-//    if (!pWnd && wxWndHook)
-//    {
-//        wxAssociateWinWithHandle(hWnd, wxWndHook);
-//        pWnd = wxWndHook;
-//        wxWndHook = NULL;
-//        pWnd->SetHWND((WXHWND)hWnd);
-//    }
 
     MRESULT                         rc = (MRESULT)0;
     bool                            bProcessed = FALSE;
@@ -1575,87 +1570,10 @@ MRESULT EXPENTRY wxFrameWndProc(
     }
     else
     {
-        switch (ulMsg)
-        {
-            case WM_CLOSE:
-                //
-                // If we can't close, tell the system that we processed the
-                // message - otherwise it would close us
-                //
-                bProcessed = !pWnd->Close();
-                break;
-
-            case WM_PAINT:
-                {
-                    HPS                             hPS;
-                    RECTL                           vRect;
-
-                    hPS = WinBeginPaint(hWnd, 0L, &vRect);
-                    WinFillRect(hPS, &vRect,  CLR_BLUE  /* SYSCLR_WINDOW */);
-                    WinEndPaint(hPS);
-                    rc = FALSE;
-                    break;
-                }
-                break;
-
-            case WM_COMMAND:
-                {
-                    WORD                wId;
-                    WORD                wCmd;
-                    WXHWND              hWnd;
-
-                    pWnd->UnpackCommand( (WXWPARAM)wParam
-                                        ,(WXLPARAM)lParam
-                                        ,&wId
-                                        ,&hWnd
-                                        ,&wCmd
-                                       );
-                    rc = (MRESULT) pWnd->HandleCommand( wId
-                                                       ,wCmd
-                                                       ,(WXHWND)hWnd
-                                                      );
-                }
-                break;
-
-            case WM_MENUSELECT:
-                {
-                    WXWORD              wItem;
-                    WXWORD              wFlags;
-                    WXHMENU             hMenu;
-
-                    pWnd->UnpackMenuSelect( wParam
-                                           ,lParam
-                                           ,&wItem
-                                           ,&wFlags
-                                           ,&hMenu
-                                          );
-                    bProcessed = pWnd->HandleMenuSelect( wItem
-                                                        ,wFlags
-                                                        ,hMenu
-                                                       );
-                    rc = (MRESULT)TRUE;
-                }
-                break;
-
-            case WM_SIZE:
-                {
-                    SHORT           nScxold = SHORT1FROMMP(wParam); // Old horizontal size.
-                    SHORT           nScyold = SHORT2FROMMP(wParam); // Old vertical size.
-                    SHORT           nScxnew = SHORT1FROMMP(lParam); // New horizontal size.
-                    SHORT           nScynew = SHORT2FROMMP(lParam); // New vertical size.
-
-                    lParam = MRFROM2SHORT( nScxnew - 20
-                                          ,nScynew - 30
-                                         );
-                }
-
-                bProcessed = pWnd->HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam);
-                rc = (MRESULT)FALSE;
-                break;
-
-            default:
-                rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
-        }
+        if (pWnd)
+            rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam);
+        else
+            rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
     }
     return rc;
 } // end of wxFrameWndProc
@@ -1679,6 +1597,23 @@ MRESULT wxFrame::OS2WindowProc(
             bProcessed = !Close();
             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);
+
+                mRc = (MRESULT)FALSE;
+                vEvent.SetEventObject(this);
+                GetEventHandler()->ProcessEvent(vEvent);
+                bProcessed = TRUE;
+            }
+            break;
+
         case WM_COMMAND:
             {
                 WORD                wId;
@@ -1686,11 +1621,11 @@ MRESULT wxFrame::OS2WindowProc(
                 WXHWND              hWnd;
 
                 UnpackCommand( (WXWPARAM)wParam
-                            ,(WXLPARAM)lParam
-                            ,&wId
-                            ,&hWnd
-                            ,&wCmd
-                           );
+                              ,(WXLPARAM)lParam
+                              ,&wId
+                              ,&hWnd
+                              ,&wCmd
+                             );
 
                 bProcessed = HandleCommand( wId
                                            ,wCmd
@@ -1719,8 +1654,19 @@ MRESULT wxFrame::OS2WindowProc(
             }
             break;
 
-        case WM_PAINT:
-            bProcessed = HandlePaint();
+        case WM_SIZE:
+            {
+                SHORT               nScxold = SHORT1FROMMP(wParam); // Old horizontal size.
+                SHORT               nScyold = SHORT2FROMMP(wParam); // Old vertical size.
+                SHORT               nScxnew = SHORT1FROMMP(lParam); // New horizontal size.
+                SHORT               nScynew = SHORT2FROMMP(lParam); // New vertical size.
+
+                lParam = MRFROM2SHORT( nScxnew - 20
+                                      ,nScynew - 30
+                                     );
+            }
+            bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam);
+            mRc = (MRESULT)FALSE;
             break;
 
         case WM_ERASEBACKGROUND:
@@ -1744,91 +1690,6 @@ MRESULT wxFrame::OS2WindowProc(
                 bProcessed = mRc != 0;
             }
             break;
-
-        case WM_SIZE:
-            bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam);
-            break;
-
-        case WM_QUERYFRAMECTLCOUNT:
-            {
-                USHORT itemCount = SHORT1FROMMR(OS2GetOldWndProc()(GetHWND(), uMessage, wParam, lParam));
-#if wxUSE_STATUSBAR
-                if(m_frameStatusBar)
-                   ++itemCount;
-#endif //wxUSE_STATUSBAR
-
-                bProcessed = TRUE;
-                mRc = MRFROMSHORT( itemCount );
-            }
-            break;
-
-        case WM_FORMATFRAME:
-            {
-                PSWP   pSWP     = 0;
-                USHORT usClient = 0;
-                SWP    swp;
-                USHORT itemCount;
-                char   s[128];
-
-                itemCount = SHORT1FROMMR(OS2GetOldWndProc()(GetHWND(), uMessage, wParam, lParam));
-                pSWP = (PSWP)PVOIDFROMMP( wParam );
-
-                while(pSWP[usClient].hwnd != WinWindowFromID(GetHWND(), FID_CLIENT)
-                     && usClient < itemCount)
-                    usClient++;
-
-#if wxUSE_STATUSBAR
-                if(m_frameStatusBar)
-                {
-                   int height;
-
-                   m_frameStatusBar->GetSize(NULL, &height);
-
-                   if(usClient == itemCount)
-                   {
-                      // frame has no client window
-                      // using another method of calculation
-                      RECTL wRectl;
-
-                      ::WinQueryWindowRect(GetHWND(), &wRectl);
-                      ::WinMapWindowPoints(GetHWND(), HWND_DESKTOP, (PPOINTL)&wRectl, 2);
-                      ::WinCalcFrameRect(GetHWND(), &wRectl, TRUE);
-                      ::WinMapWindowPoints(HWND_DESKTOP, GetHWND(), (PPOINTL)&wRectl, 2);
-
-                      pSWP[itemCount].x    = wRectl.xLeft;
-                      pSWP[itemCount].y    = wRectl.yBottom;
-                      pSWP[itemCount].cx   = wRectl.xRight - wRectl.xLeft - 1;
-                      pSWP[itemCount].cy   = height;
-                      pSWP[itemCount].fl   = SWP_SIZE |
-                                             SWP_MOVE |
-                                             SWP_SHOW;
-                      pSWP[itemCount].hwnd = m_frameStatusBar->GetHWND();
-                      pSWP[itemCount].hwndInsertBehind = HWND_TOP;
-                      ++itemCount;
-                   }
-                   else
-                   {
-                       pSWP[itemCount].x    = pSWP[usClient].x;
-                       pSWP[itemCount].y    = pSWP[usClient].y;
-                       pSWP[itemCount].cx   = pSWP[usClient].cx;
-                       pSWP[itemCount].cy   = height;
-                       pSWP[itemCount].fl   = SWP_SIZE |
-                                              SWP_MOVE |
-                                              SWP_SHOW;
-                       pSWP[itemCount].hwnd = m_frameStatusBar->GetHWND();
-                       pSWP[itemCount].hwndInsertBehind = HWND_TOP;
-                       pSWP[usClient].cy -= height;
-                       pSWP[usClient].y  += height;
-
-                       ++itemCount;
-                   }
-                }
-#endif //wxUSE_STATUSBAR
-
-                bProcessed = TRUE;
-                mRc = MRFROMSHORT(itemCount);
-            }
-            break;
     }
 
     if (!bProcessed )
@@ -1865,7 +1726,7 @@ void wxFrame::SetClient(
         pOldClient->Show( FALSE );
         ::WinSetWindowUShort(pOldClient->GetHWND(), QWS_ID, (USHORT)pOldClient->GetId());
         // to avoid OS/2 bug need to update frame
-        ::WinSendMsg((HWND)this->GetHWND(), WM_UPDATEFRAME, (MPARAM)~0, 0);
+        ::WinSendMsg((HWND)this->GetFrame(), WM_UPDATEFRAME, (MPARAM)~0, 0);
         return;
     }
 
@@ -1890,11 +1751,11 @@ void wxFrame::SetClient(
     if( this->IsShown() )
     {
         this->Show();
-        ::WinSendMsg(GetHWND(), WM_UPDATEFRAME, (MPARAM)~0, 0);
+        ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
     }
 }
 
 wxWindow* wxFrame::GetClient()
 {
-    return wxFindWinFromHandle((WXHWND)::WinWindowFromID(GetHWND(), FID_CLIENT));
+    return wxFindWinFromHandle((WXHWND)::WinWindowFromID(m_hFrame, FID_CLIENT));
 }