]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/window.cpp
VA needs FALSE not false
[wxWidgets.git] / src / os2 / window.cpp
index 76ab3ba44081eb04b069c73614fcaef591b6681b..c1ea3d70685fcda3826b8eca8647f524e43cfcd3 100644 (file)
@@ -153,6 +153,7 @@ BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
     EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
     EVT_INIT_DIALOG(wxWindow::OnInitDialog)
     EVT_IDLE(wxWindow::OnIdle)
+    EVT_SET_FOCUS(wxWindow::OnSetFocus)
 END_EVENT_TABLE()
 
 // ===========================================================================
@@ -309,8 +310,6 @@ wxWindow::~wxWindow()
 
     if (m_hWnd)
     {
-//      UnsubclassWin();
-
         if(!::WinDestroyWindow(GetHWND()))
             wxLogLastError(wxT("DestroyWindow"));
         //
@@ -359,6 +358,12 @@ bool wxWindow::Create(
     // set in those class create procs.  PM's basic windows styles are
     // very limited.
     //
+    ulCreateFlags |=  WS_VISIBLE;
+
+
+    if ( lStyle & wxCLIP_SIBLINGS )
+        ulCreateFlags |= WS_CLIPSIBLINGS;
+
     if (lStyle & wxCLIP_CHILDREN )
         ulCreateFlags |= WS_CLIPCHILDREN;
 
@@ -715,19 +720,12 @@ void wxWindow::SubclassWin(
     HWND                            hwnd = (HWND)hWnd;
 
     wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") );
-
     wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") );
-
-//  wxAssociateWinWithHandle(hwnd, this);
-
     m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc);
-//    ::WinSetWindowULong(hwnd, QWL_USER, (ULONG)wxWndProc);
 } // end of wxWindow::SubclassWin
 
 void wxWindow::UnsubclassWin()
 {
-//    wxRemoveHandleAssociation(this);
-
     //
     // Restore old Window proc
     //
@@ -735,11 +733,10 @@ void wxWindow::UnsubclassWin()
 
     if (m_hWnd)
     {
-//        m_hWnd = 0;
-
         wxCHECK_RET( ::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in UnsubclassWin") );
 
         PFNWP                       fnProc = (PFNWP)::WinQueryWindowPtr(hwnd, QWP_PFNWP);
+
         if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc))
         {
             WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc);
@@ -1100,7 +1097,10 @@ void wxWindow::DoGetClientSize(
     RECTL                           vRect;
 
     hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
-    ::WinQueryWindowRect(hWndClient, &vRect);
+    if( hWndClient == NULLHANDLE)
+       ::WinQueryWindowRect(GetHwnd(), &vRect);
+    else
+       ::WinQueryWindowRect(hWndClient, &vRect);
 
     if (pWidth)
         *pWidth  = vRect.xRight;
@@ -1324,10 +1324,12 @@ int wxWindow::GetCharHeight() const
     hPs = ::WinGetPS(GetHwnd());
 
     if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
+    {
+        ::WinReleasePS(hPs);
         return (0);
-    else
-        return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender);
+    }
     ::WinReleasePS(hPs);
+    return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender);
 } // end of wxWindow::GetCharHeight
 
 int wxWindow::GetCharWidth() const
@@ -1338,10 +1340,12 @@ int wxWindow::GetCharWidth() const
     hPs = ::WinGetPS(GetHwnd());
 
     if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
+    {
+        ::WinReleasePS(hPs);
         return (0);
-    else
-        return(vFontMetrics.lAveCharWidth);
+    }
     ::WinReleasePS(hPs);
+    return(vFontMetrics.lAveCharWidth);
 } // end of wxWindow::GetCharWidth
 
 void wxWindow::GetTextExtent(
@@ -1703,7 +1707,11 @@ bool wxWindow::OS2TranslateMessage(
   WXMSG*                            pMsg
 )
 {
-    return m_acceleratorTable.Translate(m_hWnd, pMsg);
+#if wxUSE_ACCEL
+  return m_acceleratorTable.Translate(m_hWnd, pMsg);
+#else
+  return FALSE;
+#endif //wxUSE_ACCEL
 } // end of wxWindow::OS2TranslateMessage
 
 // ---------------------------------------------------------------------------
@@ -1718,11 +1726,6 @@ void wxWindow::UnpackCommand(
 , WORD*                             pCmd
 )
 {
-/*
-    *pId = LOWORD(wParam);
-    *phWnd = (WXHWND)lParam;
-    *pCmd = HIWORD(wParam);
-*/
     *pId = LOWORD(wParam);
     *phWnd = NULL;  // or may be GetHWND() ?
     *pCmd = LOWORD(lParam);
@@ -1849,17 +1852,6 @@ MRESULT wxWindow::OS2WindowProc(
     WXHICON                         hIcon;
     WXHBRUSH                        hBrush;
 
-    //
-    // The return value
-    //
-//  union
-//  {
-//      bool                        bAllow;
-//      MRESULT                     mResult;
-//      WXHICON                     hIcon;
-//      WXHBRUSH                    hBrush;
-//  } vRc;
-
     //
     // For most messages we should return 0 when we do process the message
     //
@@ -2196,14 +2188,16 @@ MRESULT wxWindow::OS2WindowProc(
             }
             break;
     }
-
     if (!bProcessed)
     {
 #ifdef __WXDEBUG__
         wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
                    wxGetMessageName(uMsg));
 #endif // __WXDEBUG__
-        mResult = OS2DefWindowProc(uMsg, wParam, lParam);
+        if (IsKindOf(CLASSINFO(wxFrame)))
+            mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam);
+        else
+            mResult = OS2DefWindowProc(uMsg, wParam, lParam);
     }
     return mResult;
 } // end of wxWindow::OS2WindowProc
@@ -2347,6 +2341,8 @@ bool wxWindow::OS2Create(
     long                            lWidth1  = 20L;
     long                            lHeight1 = 20L;
     int                             nControlId = 0;
+    int                             nNeedsubclass = 0;
+    PCSZ                            pszClass = zClass;
 
     //
     // Find parent's size, if it exists, to set up a possible default
@@ -2386,6 +2382,21 @@ bool wxWindow::OS2Create(
     {
             nControlId = ulId;
     }
+    else
+    {
+        // no standard controls
+        if(wxString (wxT("wxFrameClass")) == wxString(zClass) )
+        {
+            pszClass =  WC_FRAME;
+            nNeedsubclass = 1;
+        }
+        else
+        {
+            nControlId = ulId;
+            if(nControlId < 0)
+                nControlId = FID_CLIENT;
+        }
+    }
 
     //
     // We will either have a registered class via string name or a standard PM Class via a long
@@ -2398,9 +2409,9 @@ bool wxWindow::OS2Create(
                                        ,(LONG)lY1
                                        ,(LONG)lWidth
                                        ,(LONG)lHeight
-                                       ,NULLHANDLE
+                                       ,hOwner
                                        ,HWND_TOP
-                                       ,(ULONG)ulId
+                                       ,(ULONG)nControlId
                                        ,pCtlData
                                        ,pPresParams
                                       );
@@ -2434,9 +2445,14 @@ bool wxWindow::OS2Create(
     //
     // Now need to subclass window.
     //
-
-    SubclassWin(GetHWND());
-
+    if(!nNeedsubclass)
+    {
+         wxAssociateWinWithHandle((HWND)m_hWnd,this);
+    }
+    else
+    {
+        SubclassWin(GetHWND());
+    }
     return TRUE;
 } // end of wxWindow::OS2Create
 
@@ -2828,12 +2844,21 @@ bool wxWindow::HandlePaint()
          wxLogLastError("CreateRectRgn");
          return FALSE;
     }
+    //
+    // Debug code
+    //
+#ifdef __WXDEBUG__
+    {
+        HWND                        hWnd;
+        HWND                        hWnd0 = NULLHANDLE;
+
+        hWnd = GetHwnd();
+        if(hWnd != hWnd0)
+            printf("HandlePaint hWnd=%x  ",hWnd);
+    }
+#endif
+
     m_updateRegion = wxRegion(hRgn);
-/*
-    hPS = WinBeginPaint(GetHWND(), 0L, &vRect);
-    WinFillRect(hPS, &vRect, SYSCLR_WINDOW);
-    WinEndPaint(hPS);
-*/
     vEvent.SetEventObject(this);
     return (GetEventHandler()->ProcessEvent(vEvent));
 } // end of wxWindow::HandlePaint
@@ -3975,41 +4000,43 @@ static void TranslateKbdEventToMouse(
 
 // Find the wxWindow at the current mouse position, returning the mouse
 // position.
-wxWindow* wxFindWindowAtPointer(wxPoint& pt)
+wxWindow* wxFindWindowAtPointer(
+  wxPoint&                          rPt
+)
 {
     return wxFindWindowAtPoint(wxGetMousePosition());
 }
 
-wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
+wxWindow* wxFindWindowAtPoint(
+  const wxPoint&                    rPt
+)
 {
-#if 0
-    POINT pt2;
-    pt2.x = pt.x;
-    pt2.y = pt.y;
-    HWND hWndHit = ::WindowFromPoint(pt2);
+    POINTL                          vPt2;
+
+    vPt2.x = rPt.x;
+    vPt2.y = rPt.y;
 
-    wxWindow* win = wxFindWinFromHandle((WXHWND) hWndHit) ;
-    HWND hWnd = hWndHit;
+    HWND                            hWndHit = ::WinWindowFromPoint(HWND_DESKTOP, &vPt2, FALSE);
+    wxWindow*                       pWin = wxFindWinFromHandle((WXHWND)hWndHit) ;
+    HWND                            hWnd = hWndHit;
 
+    //
     // Try to find a window with a wxWindow associated with it
-    while (!win && (hWnd != 0))
+    //
+    while (!pWin && (hWnd != 0))
     {
-        hWnd = ::GetParent(hWnd);
-        win = wxFindWinFromHandle((WXHWND) hWnd) ;
+        hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
+        pWin = wxFindWinFromHandle((WXHWND)hWnd) ;
     }
-    return win;
-#endif
-    return (wxWindow*)NULL;
+    return pWin;
 }
 
 // Get the current mouse position.
 wxPoint wxGetMousePosition()
 {
-#if 0
-    POINT pt;
-    GetCursorPos( & pt );
-    return wxPoint(pt.x, pt.y);
-#endif
-    return wxPoint(0,0);
+    POINTL                          vPt;
+
+    ::WinQueryPointerPos(HWND_DESKTOP, &vPt);
+    return wxPoint(vPt.x, vPt.y);
 }