]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/window.cpp
corrected path splitting for mac relative paths
[wxWidgets.git] / src / os2 / window.cpp
index 6cf27110d298365c13fb39fade95c176a013346d..c30bdb8ba473a66866005eda2ff68c537520797c 100644 (file)
     #include "wx/button.h"
     #include "wx/msgdlg.h"
     #include "wx/scrolwin.h"
     #include "wx/button.h"
     #include "wx/msgdlg.h"
     #include "wx/scrolwin.h"
-
+    #include "wx/radiobox.h"
+    #include "wx/slider.h"
+    #include "wx/statusbr.h"
+    #include "wx/toolbar.h"
+    #include "wx/settings.h"
     #include <stdio.h>
 #endif
 
     #include <stdio.h>
 #endif
 
@@ -102,9 +106,6 @@ QMSG                      s_currentMsg;
 wxMenu*                   wxCurrentPopupMenu = NULL;
 #endif // wxUSE_MENUS_NATIVE
 
 wxMenu*                   wxCurrentPopupMenu = NULL;
 #endif // wxUSE_MENUS_NATIVE
 
-#if !defined(__VISAGECPP__) || (__IBMCPP__ < 400)
-extern wxChar             wxCanvasClassName[];
-#endif
 wxList*                   wxWinHandleList = NULL;
 
 // ---------------------------------------------------------------------------
 wxList*                   wxWinHandleList = NULL;
 
 // ---------------------------------------------------------------------------
@@ -147,6 +148,9 @@ static void TranslateKbdEventToMouse( wxWindow* pWin
 //
 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; }
 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; }
 //
 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; }
 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; }
+
+static wxWindow*                    gpWinBeingCreated = NULL;
+
 // ---------------------------------------------------------------------------
 // event tables
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // event tables
 // ---------------------------------------------------------------------------
@@ -327,7 +331,6 @@ wxWindowOS2::~wxWindowOS2()
 {
     m_isBeingDeleted = TRUE;
 
 {
     m_isBeingDeleted = TRUE;
 
-    OS2DetachWindowMenu();
     for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
     {
         wxFrame*                    pFrame = wxDynamicCast(pWin, wxFrame);
     for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
     {
         wxFrame*                    pFrame = wxDynamicCast(pWin, wxFrame);
@@ -366,7 +369,6 @@ bool wxWindowOS2::Create(
 )
 {
     HWND                            hParent = NULLHANDLE;
 )
 {
     HWND                            hParent = NULLHANDLE;
-    wxPoint                         vPos = rPos; // The OS/2 position
     ULONG                           ulCreateFlags = 0;
     WXDWORD                         dwExStyle = 0;
 
     ULONG                           ulCreateFlags = 0;
     WXDWORD                         dwExStyle = 0;
 
@@ -439,23 +441,17 @@ bool wxWindowOS2::Create(
     }
 
     //
     }
 
     //
-    // Generic OS/2 Windows are created with no owner, no Z Order, no Control data,
-    // and no presentation parameters
+    // Generic OS/2 Windows have no Control Data but other classes
+    // that call OS2Create may have some.
     //
     //
-    OS2Create( hParent
-              ,(PSZ)wxCanvasClassName
+    OS2Create( (PSZ)wxCanvasClassName
               ,rName.c_str()
               ,ulCreateFlags
               ,rName.c_str()
               ,ulCreateFlags
-              ,vPos.x
-              ,vPos.y
-              ,WidthDefault(rSize.x)
-              ,HeightDefault(rSize.y)
-              ,NULLHANDLE
-              ,NULLHANDLE
-              ,m_windowId
-              ,NULL
-              ,NULL
+              ,rPos
+              ,rSize
+              ,NULL         // Control Data
               ,dwExStyle
               ,dwExStyle
+              ,TRUE         // Child
              );
 
     return(TRUE);
              );
 
     return(TRUE);
@@ -549,7 +545,7 @@ wxString wxWindowOS2::GetTitle() const
     return wxGetWindowText(GetHWND());
 } // end of wxWindowOS2::GetTitle
 
     return wxGetWindowText(GetHWND());
 } // end of wxWindowOS2::GetTitle
 
-void wxWindowOS2::CaptureMouse()
+void wxWindowOS2::DoCaptureMouse()
 {
     HWND                            hWnd = GetHwnd();
 
 {
     HWND                            hWnd = GetHwnd();
 
@@ -560,7 +556,7 @@ void wxWindowOS2::CaptureMouse()
     }
 } // end of wxWindowOS2::GetTitle
 
     }
 } // end of wxWindowOS2::GetTitle
 
-void wxWindowOS2::ReleaseMouse()
+void wxWindowOS2::DoReleaseMouse()
 {
     if (m_bWinCaptured)
     {
 {
     if (m_bWinCaptured)
     {
@@ -587,77 +583,11 @@ bool wxWindowOS2::SetFont(
 
     HWND                            hWnd = GetHwnd();
 
 
     HWND                            hWnd = GetHwnd();
 
-    if (hWnd != 0)
-    {
-        char                        zFont[128];
-        char                        zFacename[30];
-        char                        zWeight[30];
-        char                        zStyle[30];
-
-        //
-        // The fonts available for Presentation Params are just three
-        // outline fonts, the rest are available to the GPI, so we must
-        // map the families to one of these three
-        //
-        switch(rFont.GetFamily())
-        {
-            case wxSCRIPT:
-            case wxDECORATIVE:
-            case wxROMAN:
-                strcpy(zFacename,"Times New Roman");
-                break;
-
-            case wxTELETYPE:
-            case wxMODERN:
-                strcpy(zFacename, "Courier");
-                break;
-
-            case wxSWISS:
-            case wxDEFAULT:
-            default:
-                strcpy(zFacename, "Helvetica");
-                break;
-        }
-
-        switch(rFont.GetWeight())
-        {
-            default:
-            case wxNORMAL:
-            case wxLIGHT:
-                zWeight[0] = '\0';
-                break;
-
-            case wxBOLD:
-            case wxFONTWEIGHT_MAX:
-                strcpy(zWeight, "Bold");
-                break;
-        }
-        switch(rFont.GetStyle())
-        {
-            case wxITALIC:
-            case wxSLANT:
-                strcpy(zStyle, "Italic");
-                break;
-
-            default:
-                zStyle[0] = '\0';
-                break;
-        }
-        sprintf(zFont, "%d.%s", rFont.GetPointSize(), zFacename);
-        if (zWeight[0] != '\0')
-        {
-            strcat(zFont, " ");
-            strcat(zFont, zWeight);
-        }
-        if (zStyle[0] != '\0')
-        {
-            strcat(zFont, " ");
-            strcat(zFont, zStyle);
-        }
-        ::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont) + 1, (PVOID)zFont);
-    }
+    wxOS2SetFont( hWnd
+                 ,rFont
+                );
     return(TRUE);
     return(TRUE);
-}
+} // end of wxWindowOS2::SetFont
 
 bool wxWindowOS2::SetCursor(
   const wxCursor&                   rCursor
 
 bool wxWindowOS2::SetCursor(
   const wxCursor&                   rCursor
@@ -1055,9 +985,20 @@ void wxWindowOS2::SubclassWin(
 {
     HWND                            hwnd = (HWND)hWnd;
 
 {
     HWND                            hwnd = (HWND)hWnd;
 
-    wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") );
     wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") );
     wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") );
-    m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc);
+    wxAssociateWinWithHandle( hWnd
+                             ,(wxWindow*)this
+                            );
+    if (!wxCheckWindowWndProc( hWnd
+                              ,(WXFARPROC)wxWndProc
+                             ))
+    {
+        m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc);
+    }
+    else
+    {
+        m_fnOldWndProc = (WXFARPROC)NULL;
+    }
 } // end of wxWindowOS2::SubclassWin
 
 void wxWindowOS2::UnsubclassWin()
 } // end of wxWindowOS2::SubclassWin
 
 void wxWindowOS2::UnsubclassWin()
@@ -1081,6 +1022,19 @@ void wxWindowOS2::UnsubclassWin()
     }
 } // end of wxWindowOS2::UnsubclassWin
 
     }
 } // end of wxWindowOS2::UnsubclassWin
 
+bool wxCheckWindowWndProc(
+  WXHWND                            hWnd
+, WXFARPROC                         fnWndProc
+)
+{
+    static char                     zBuffer[512];
+    CLASSINFO                       vCls;
+
+    ::WinQueryClassName((HWND)hWnd, (LONG)512, (PCH)zBuffer);
+    ::WinQueryClassInfo(wxGetInstance(), (PSZ)zBuffer, &vCls);
+    return(fnWndProc == (WXFARPROC)vCls.pfnWindowProc);
+} // end of WinGuiBase_CheckWindowWndProc
+
 //
 // Make a Windows extended style from the given wxWindows window style
 //
 //
 // Make a Windows extended style from the given wxWindows window style
 //
@@ -1305,6 +1259,27 @@ void wxWindowOS2::Clear()
     vDc.Clear();
 } // end of wxWindowOS2::Clear
 
     vDc.Clear();
 } // end of wxWindowOS2::Clear
 
+void wxWindowOS2::Update()
+{
+    ::WinUpdateWindow(GetHwnd());
+} // end of wxWindowOS2::Update
+
+void wxWindowOS2::Freeze()
+{
+   ::WinSendMsg(GetHwnd(), WM_VRNDISABLED, (MPARAM)0, (MPARAM)0);
+} // end of wxWindowOS2::Freeze
+
+void wxWindowOS2::Thaw()
+{
+   ::WinSendMsg(GetHwnd(), WM_VRNENABLED, (MPARAM)TRUE, (MPARAM)0);
+
+    //
+    // We need to refresh everything or otherwise he invalidated area is not
+    // repainted.
+    //
+    Refresh();
+} // end of wxWindowOS2::Thaw
+
 void wxWindowOS2::Refresh(
   bool                              bEraseBack
 , const wxRect*                     pRect
 void wxWindowOS2::Refresh(
   bool                              bEraseBack
 , const wxRect*                     pRect
@@ -1392,9 +1367,17 @@ void wxWindowOS2::DoGetSize(
 , int*                              pHeight
 ) const
 {
 , int*                              pHeight
 ) const
 {
-    HWND                            hWnd = GetHwnd();
+    HWND                            hWnd;
     RECTL                           vRect;
 
     RECTL                           vRect;
 
+    if (IsKindOf(CLASSINFO(wxFrame)))
+    {
+        wxFrame*                    pFrame = wxDynamicCast(this, wxFrame);
+        hWnd = pFrame->GetFrame();
+    }
+    else
+        hWnd = GetHwnd();
+
     ::WinQueryWindowRect(hWnd, &vRect);
 
     if (pWidth)
     ::WinQueryWindowRect(hWnd, &vRect);
 
     if (pWidth)
@@ -1490,22 +1473,68 @@ void wxWindowOS2::DoGetClientSize(
 ) const
 {
     HWND                            hWnd = GetHwnd();
 ) const
 {
     HWND                            hWnd = GetHwnd();
-    HWND                            hWndClient;
     RECTL                           vRect;
 
     RECTL                           vRect;
 
-    if (IsKindOf(CLASSINFO(wxFrame)))
-        hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
-    else
-        hWndClient = NULLHANDLE;
-    if( hWndClient == NULLHANDLE)
-       ::WinQueryWindowRect(GetHwnd(), &vRect);
-    else
-       ::WinQueryWindowRect(hWndClient, &vRect);
+   ::WinQueryWindowRect(hWnd, &vRect);
+    if (IsKindOf(CLASSINFO(wxDialog)))
+    {
+        RECTL                       vTitle;
+        HWND                        hWndTitle;
+        //
+        // For a Dialog we have to explicitly request the client portion.
+        // For a Frame the hWnd IS the client window
+        //
+        hWndTitle = ::WinWindowFromID(hWnd, FID_TITLEBAR);
+        if (::WinQueryWindowRect(hWndTitle, &vTitle))
+        {
+            if (vTitle.yTop - vTitle.yBottom == 0)
+            {
+                //
+                // Dialog has not been created yet, use a default
+                //
+                vTitle.yTop = 20;
+            }
+            vRect.yTop -= (vTitle.yTop - vTitle.yBottom);
+        }
+
+        ULONG                       uStyle = ::WinQueryWindowULong(hWnd, QWL_STYLE);
 
 
+        //
+        // Deal with borders
+        //
+        if (uStyle & FCF_DLGBORDER)
+        {
+            vRect.xLeft += 4;
+            vRect.xRight -= 4;
+            vRect.yTop -= 4;
+            vRect.yBottom += 4;
+        }
+        else if (uStyle & FCF_SIZEBORDER)
+        {
+            vRect.xLeft += 4;
+            vRect.xRight -= 4;
+            vRect.yTop -= 4;
+            vRect.yBottom += 4;
+        }
+        else if (uStyle & FCF_BORDER)
+        {
+            vRect.xLeft += 2;
+            vRect.xRight -= 2;
+            vRect.yTop -= 2;
+            vRect.yBottom += 2;
+        }
+        else // make some kind of adjustment or top sizers ram into the titlebar!
+        {
+            vRect.xLeft += 3;
+            vRect.xRight -= 3;
+            vRect.yTop -= 3;
+            vRect.yBottom += 3;
+        }
+    }
     if (pWidth)
     if (pWidth)
-        *pWidth  = vRect.xRight;
+        *pWidth  = vRect.xRight - vRect.xLeft;
     if (pHeight)
     if (pHeight)
-        *pHeight = vRect.yTop;
+        *pHeight = vRect.yTop - vRect.yBottom;
 } // end of wxWindowOS2::DoGetClientSize
 
 void wxWindowOS2::DoMoveWindow(
 } // end of wxWindowOS2::DoGetClientSize
 
 void wxWindowOS2::DoMoveWindow(
@@ -1519,7 +1548,7 @@ void wxWindowOS2::DoMoveWindow(
     HWND                            hParent;
     wxWindow*                       pParent = GetParent();
 
     HWND                            hParent;
     wxWindow*                       pParent = GetParent();
 
-    if (pParent)
+    if (pParent && !IsKindOf(CLASSINFO(wxDialog)))
     {
         int                         nOS2Height = GetOS2ParentHeight(pParent);
 
     {
         int                         nOS2Height = GetOS2ParentHeight(pParent);
 
@@ -1572,8 +1601,29 @@ void wxWindowOS2::DoSetSize(
     GetPosition(&nCurrentX, &nCurrentY);
     GetSize(&nCurrentWidth, &nCurrentHeight);
 
     GetPosition(&nCurrentX, &nCurrentY);
     GetSize(&nCurrentWidth, &nCurrentHeight);
 
+    //
     // ... and don't do anything (avoiding flicker) if it's already ok
     // ... and don't do anything (avoiding flicker) if it's already ok
-    if (nX == nCurrentX && nY == nCurrentY &&
+    //
+    //
+    // Must convert Y coords to test for equality under OS/2
+    //
+    int                             nY2 = nY;
+    wxWindow*                       pParent = (wxWindow*)GetParent();
+
+    if (pParent && !IsKindOf(CLASSINFO(wxDialog)))
+    {
+        int                         nOS2Height = GetOS2ParentHeight(pParent);
+
+        nY2 = nOS2Height - (nY2 + nHeight);
+    }
+    else
+    {
+        RECTL                       vRect;
+
+        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+        nY2 = vRect.yTop - (nY2 + nHeight);
+    }
+    if (nX == nCurrentX && nY2 == nCurrentY &&
         nWidth == nCurrentWidth && nHeight == nCurrentHeight)
     {
         return;
         nWidth == nCurrentWidth && nHeight == nCurrentHeight)
     {
         return;
@@ -1802,6 +1852,26 @@ void wxWindowOS2::GetTextExtent(
     ::WinReleasePS(hPS);
 } // end of wxWindow::GetTextExtent
 
     ::WinReleasePS(hPS);
 } // end of wxWindow::GetTextExtent
 
+bool wxWindowOS2::IsMouseInWindow() const
+{
+    //
+    // Get the mouse position
+    POINTL                          vPt;
+
+    ::WinQueryPointerPos(HWND_DESKTOP, &vPt);
+
+    //
+    // Find the window which currently has the cursor and go up the window
+    // chain until we find this window - or exhaust it
+    //
+    HWND                            hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPt, TRUE);
+
+    while (hWnd && (hWnd != GetHwnd()))
+        hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
+
+    return hWnd != NULL;
+} // end of wxWindowOS2::IsMouseInWindow
+
 #if wxUSE_CARET && WXWIN_COMPATIBILITY
 // ---------------------------------------------------------------------------
 // Caret manipulation
 #if wxUSE_CARET && WXWIN_COMPATIBILITY
 // ---------------------------------------------------------------------------
 // Caret manipulation
@@ -1877,8 +1947,8 @@ static void wxYieldForCommandsOnly()
     //
     QMSG                            vMsg;
 
     //
     QMSG                            vMsg;
 
-    while (::WinPeekMsg(vHabmain, &vMsg, (HWND)0, WM_COMMAND,
-           WM_COMMAND,PM_REMOVE) && vMsg.msg != WM_QUIT)
+    while (::WinPeekMsg(vHabmain, &vMsg, (HWND)0, WM_COMMAND, WM_COMMAND, PM_REMOVE)
+           && vMsg.msg != WM_QUIT)
     {
         wxTheApp->DoMessage((WXMSG*)&vMsg);
     }
     {
         wxTheApp->DoMessage((WXMSG*)&vMsg);
     }
@@ -1892,9 +1962,10 @@ bool wxWindowOS2::DoPopupMenu(
 , int                               nY
 )
 {
 , int                               nY
 )
 {
-    HWND                            hWnd = GetHwnd();
-    HWND                            hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
+    HWND                            hWndOwner = GetHwnd();
+    HWND                            hWndParent = GetHwnd();
     HWND                            hMenu = GetHmenuOf(pMenu);
     HWND                            hMenu = GetHmenuOf(pMenu);
+    bool                            bIsWaiting = TRUE;
 
     pMenu->SetInvokingWindow(this);
     pMenu->UpdateUI();
 
     pMenu->SetInvokingWindow(this);
     pMenu->UpdateUI();
@@ -1905,21 +1976,25 @@ bool wxWindowOS2::DoPopupMenu(
     wxCurrentPopupMenu = pMenu;
 
     ::WinPopupMenu( hWndParent
     wxCurrentPopupMenu = pMenu;
 
     ::WinPopupMenu( hWndParent
-                   ,hWnd
+                   ,hWndOwner
                    ,hMenu
                    ,nX
                    ,nY
                    ,0L
                    ,hMenu
                    ,nX
                    ,nY
                    ,0L
-                   ,PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2 | PU_KEYBOARD
+                   ,PU_HCONSTRAIN | PU_VCONSTRAIN | PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2
                   );
                   );
-    // we need to do it righ now as otherwise the events are never going to be
-    // sent to wxCurrentPopupMenu from ;()
-    //
-    // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't
-    // help and we'd still need wxYieldForCommandsOnly() as the menu may be
-    // destroyed as soon as we return (it can be a local variable in the caller
-    // for example) and so we do need to process the event immediately
-    wxYieldForCommandsOnly();
+    while(bIsWaiting)
+    {
+        QMSG                        vMsg;
+
+        while (::WinPeekMsg(vHabmain, &vMsg, (HWND)0, WM_COMMAND, WM_COMMAND, PM_REMOVE)
+               && vMsg.msg != WM_QUIT)
+        {
+            wxTheApp->DoMessage((WXMSG*)&vMsg);
+        }
+        if (vMsg.msg == WM_DESTROY || vMsg.msg == WM_QUIT)
+            break;
+    }
     wxCurrentPopupMenu = NULL;
 
     pMenu->SetInvokingWindow(NULL);
     wxCurrentPopupMenu = NULL;
 
     pMenu->SetInvokingWindow(NULL);
@@ -2140,6 +2215,14 @@ bool wxWindowOS2::OS2TranslateMessage(
 #endif //wxUSE_ACCEL
 } // end of wxWindowOS2::OS2TranslateMessage
 
 #endif //wxUSE_ACCEL
 } // end of wxWindowOS2::OS2TranslateMessage
 
+bool wxWindowOS2::OS2ShouldPreProcessMessage(
+  WXMSG*                            pMsg
+)
+{
+    // preprocess all messages by default
+    return TRUE;
+} // end of wxWindowOS2::OS2ShouldPreProcessMessage
+
 // ---------------------------------------------------------------------------
 // message params unpackers
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // message params unpackers
 // ---------------------------------------------------------------------------
@@ -2326,6 +2409,32 @@ MRESULT wxWindowOS2::OS2WindowProc(
                                    );
             break;
 
                                    );
             break;
 
+        case WM_WINDOWPOSCHANGED:
+
+            //
+            // Dialogs under OS/2 do not get WM_SIZE events at all.
+            // Instead they get this, which can function much like WM_SIZE
+            // PSWP contains the new sizes and positioning, PSWP+1 the old
+            // We use this because ADJUSTWINDOWPOS comes BEFORE the new
+            // position is added and our auto layout does a WinQueryWindowRect
+            // to get the CURRENT client size.  That is the size used to position
+            // child controls, so we need to already be sized
+            // in order to get the child controls positoned properly.
+            //
+            if (IsKindOf(CLASSINFO(wxDialog)))
+            {
+                PSWP                pSwp = (PSWP)PVOIDFROMMP(wParam);
+                PSWP                pSwp2 = pSwp++;
+
+                if (!(pSwp->cx == pSwp2->cx &&
+                      pSwp->cy == pSwp2->cy))
+                    bProcessed = HandleSize( pSwp->cx
+                                            ,pSwp->cy
+                                            ,(WXUINT)lParam
+                                           );
+            }
+            break;
+
         case WM_ACTIVATE:
             {
                 WXWORD              wState;
         case WM_ACTIVATE:
             {
                 WXWORD              wState;
@@ -2651,12 +2760,16 @@ MRESULT wxWindowOS2::OS2WindowProc(
 #endif // __WXDEBUG__
         if (IsKindOf(CLASSINFO(wxFrame)))
             mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam);
 #endif // __WXDEBUG__
         if (IsKindOf(CLASSINFO(wxFrame)))
             mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam);
+        else if (IsKindOf(CLASSINFO(wxDialog)))
+            mResult = ::WinDefDlgProc( m_hWnd, uMsg, wParam, lParam);
         else
             mResult = OS2DefWindowProc(uMsg, wParam, lParam);
     }
     return mResult;
 } // end of wxWindowOS2::OS2WindowProc
 
         else
             mResult = OS2DefWindowProc(uMsg, wParam, lParam);
     }
     return mResult;
 } // end of wxWindowOS2::OS2WindowProc
 
+#ifndef __EMX__
+// clashes with wxDlgProc in toplevel.cpp?
 //
 // Dialog window proc
 //
 //
 // Dialog window proc
 //
@@ -2683,6 +2796,7 @@ MRESULT wxDlgProc(
         return (MRESULT)0;
     }
 } // end of wxDlgProc
         return (MRESULT)0;
     }
 } // end of wxDlgProc
+#endif
 
 wxWindow* wxFindWinFromHandle(
   WXHWND                            hWnd
 
 wxWindow* wxFindWinFromHandle(
   WXHWND                            hWnd
@@ -2741,183 +2855,180 @@ void wxWindowOS2::OS2DestroyWindow()
 {
 }
 
 {
 }
 
-void wxWindowOS2::OS2DetachWindowMenu()
+bool wxWindowOS2::OS2GetCreateWindowCoords(
+  const wxPoint&                    rPos
+, const wxSize&                     rSize
+, int&                              rnX
+, int&                              rnY
+, int&                              rnWidth
+, int&                              rnHeight
+) const
 {
 {
-#ifndef __WXUNIVERSAL__
-    if (m_hMenu)
-    {
-        HMENU                       hMenu = (HMENU)m_hMenu;
-
-        int                         nN = (int)::WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0);
-        int                         i;
-
-        for (i = 0; i < nN; i++)
-        {
-            wxChar                   zBuf[100];
-            int                      nChars = (int)::WinSendMsg( hMenu
-                                                                ,MM_QUERYITEMTEXT
-                                                                ,MPFROM2SHORT(i, nN)
-                                                                ,zBuf
-                                                               );
-            if (!nChars)
-            {
-                wxLogLastError(wxT("GetMenuString"));
-                continue;
-            }
+    bool                            bNonDefault = FALSE;
 
 
-            if (wxStrcmp(zBuf, wxT("&Window")) == 0)
-            {
-                ::WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
-                break;
-            }
-        }
+    if (rPos.x == -1)
+    {
+        //
+        // If set x to CW_USEDEFAULT, y parameter is ignored anyhow so we can
+        // just as well set it to CW_USEDEFAULT as well
+        rnX = rnY = CW_USEDEFAULT;
     }
     }
-#endif // __WXUNIVERSAL__
-} // end of wxWindowOS2::OS2DetachWindowMenu
+    else
+    {
+        rnX = rPos.x;
+        rnY = rPos.y == -1 ? CW_USEDEFAULT : rPos.y;
+        bNonDefault = TRUE;
+    }
+    if (rSize.x == -1)
+    {
+        //
+        // As abobe, h is not used at all in this case anyhow
+        //
+        rnWidth = rnHeight = CW_USEDEFAULT;
+    }
+    else
+    {
+        rnWidth  = rSize.x;
+        rnHeight = rSize.y == -1 ? CW_USEDEFAULT : rSize.y;
+        bNonDefault = TRUE;
+    }
+    return bNonDefault;
+} // end of wxWindowOS2::OS2GetCreateWindowCoords
 
 bool wxWindowOS2::OS2Create(
 
 bool wxWindowOS2::OS2Create(
-  WXHWND                            hParent
-, PSZ                               zClass
-, const wxChar*                     zTitle
+  PSZ                               zClass
+, const char*                       zTitle
 , WXDWORD                           dwStyle
 , WXDWORD                           dwStyle
-, long                              lX
-, long                              lY
-, long                              lWidth
-, long                              lHeight
-, WXHWND                            hOwner
-, WXHWND                            WXUNUSED(hZOrder)
-, unsigned long                     ulId
+, const wxPoint&                    rPos
+, const wxSize&                     rSize
 , void*                             pCtlData
 , void*                             pCtlData
-, void*                             pPresParams
 , WXDWORD                           dwExStyle
 , WXDWORD                           dwExStyle
+, bool                              bIsChild
 )
 {
     ERRORID                         vError;
     wxString                        sError;
 )
 {
     ERRORID                         vError;
     wxString                        sError;
-    long                            lX1      = 0L;
-    long                            lY1      = 0L;
-    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
-    // panel size the size of the parent window
-    //
-    lX1 = lX;
-    lY1 = lY;
-    if (lWidth > -1L)
-        lWidth1 = lWidth;
-    if (lHeight > -1L)
-        lHeight1 = lHeight;
-
-    wxWndHook = this;
+    int                             nX      = 0L;
+    int                             nY      = 0L;
+    int                             nWidth  = 0L;
+    int                             nHeight = 0L;
+    wxWindow*                       pParent = GetParent();
+    HWND                            hWnd = NULLHANDLE;
+    HWND                            hParent;
+    long                            lControlId = 0L;
+    wxWindowCreationHook            vHook(this);
+    wxString                        sClassName((wxChar*)zClass);
+
+    OS2GetCreateWindowCoords( rPos
+                             ,rSize
+                             ,nX
+                             ,nY
+                             ,nWidth
+                             ,nHeight
+                            );
 
 
-    //
-    // check to see if the new window is a standard control
-    //
-    if ((ULONG)zClass == (ULONG)WC_BUTTON ||
-        (ULONG)zClass == (ULONG)WC_COMBOBOX ||
-        (ULONG)zClass == (ULONG)WC_CONTAINER ||
-        (ULONG)zClass == (ULONG)WC_ENTRYFIELD ||
-        (ULONG)zClass == (ULONG)WC_FRAME ||
-        (ULONG)zClass == (ULONG)WC_LISTBOX ||
-        (ULONG)zClass == (ULONG)WC_MENU ||
-        (ULONG)zClass == (ULONG)WC_NOTEBOOK ||
-        (ULONG)zClass == (ULONG)WC_SCROLLBAR ||
-        (ULONG)zClass == (ULONG)WC_SPINBUTTON ||
-        (ULONG)zClass == (ULONG)WC_STATIC ||
-        (ULONG)zClass == (ULONG)WC_TITLEBAR ||
-        (ULONG)zClass == (ULONG)WC_VALUESET
-       )
-    {
-            nControlId = ulId;
-    }
+    if (GetWindowStyleFlag() & wxPOPUP_WINDOW)
+        hParent = HWND_DESKTOP;
     else
     {
     else
     {
-        // no standard controls
-        if(wxString (wxT("wxFrameClass")) == wxString(zClass) )
+        if ((bIsChild || HasFlag(wxFRAME_TOOL_WINDOW)) && pParent )
         {
         {
-            pszClass =  WC_FRAME;
-            nNeedsubclass = 1;
+            //
+            // This is either a normal child window or a top level window with
+            // wxFRAME_TOOL_WINDOW style (see below)
+            //
+            hParent = GetHwndOf(pParent);
         }
         else
         {
         }
         else
         {
-            nControlId = ulId;
-            if(nControlId < 0)
-                nControlId = FID_CLIENT;
+            //
+            // This is either a window for which no parent was specified (not
+            // much we can do then) or a frame without wxFRAME_TOOL_WINDOW
+            // style: we should use NULL parent HWND for it or it would be
+            // always on top of its parent which is not what we usually want
+            // (in fact, we only want it for frames with the special
+            // wxFRAME_TOOL_WINDOW as above)
+            //
+            hParent = NULL;
+        }
+    }
+    if (bIsChild)
+    {
+        lControlId = GetId();
+        if (GetWindowStyleFlag() & wxCLIP_SIBLINGS)
+        {
+            dwStyle |= WS_CLIPSIBLINGS;
         }
     }
         }
     }
-
-   HWND parent;
-   if ( GetWindowStyleFlag() & wxPOPUP_WINDOW )
-   {
-       // popup windows should have desktop as parent because they shouldn't
-       // be limited to the parents client area as child windows usually are
-       parent = HWND_DESKTOP;
-   }
-   else if ( hParent )
-   {
-       parent = hParent;
-   }
-   else
-   {
-       // top level window
-       parent = NULL;
-   }
-
     //
     //
-    // We will either have a registered class via string name or a standard PM Class via a long
+    // For each class "Foo" we have we also have "FooNR" ("no repaint") class
+    // which is the same but without CS_[HV]REDRAW class styles so using it
+    // ensures that the window is not fully repainted on each resize
     //
     //
-    m_hWnd = (WXHWND)::WinCreateWindow(parent, zClass,
-                                       (PSZ)zTitle ? zTitle : wxT(""),
-                                       dwStyle, lX1, lY1, lWidth, lHeight,
-                                       hOwner, HWND_TOP, (ULONG)nControlId,
-                                       pCtlData, pPresParams);
-
-    if (!m_hWnd)
+    if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE)
     {
     {
-        vError = ::WinGetLastError(vHabmain);
-        sError = wxPMErrorToStr(vError);
-        wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError);
-        return FALSE;
+        sClassName += wxT("NR");
     }
     }
-    m_dwExStyle = dwExStyle;
-    ::WinSetWindowULong(m_hWnd, QWL_USER, (ULONG) this);
-    wxWndHook = NULL;
 
 
-#ifdef __WXDEBUG__
-    wxNode*                         pNode = wxWinHandleList->Member(this);
-
-    if (pNode)
+    //
+    // If the window being created is a Frame's Statusbar we need to use
+    // the actual Frame's size, not its client
+    //
+    if (pParent)
     {
     {
-        HWND                        hWnd = (HWND)pNode->GetKeyInteger();
-
-        if (hWnd != (HWND)m_hWnd)
-
+        if ( pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
+             pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
+           )
         {
         {
-            wxLogError("A second HWND association is being added for the same window!");
+            if (IsKindOf(CLASSINFO(wxStatusBar)) &&
+                pParent->IsKindOf(CLASSINFO(wxFrame)))
+            {
+                RECTL               vRect;
+                wxFrame*            pFrame = wxDynamicCast(pParent, wxFrame);
+
+                ::WinQueryWindowRect((HWND)pFrame->GetFrame(), &vRect);
+                nY = vRect.yTop - (nY + nHeight);
+            }
+            else
+                nY = pParent->GetSize().y - (nY + nHeight);
         }
     }
         }
     }
-#endif
-    wxAssociateWinWithHandle((HWND)m_hWnd
-                             ,this
-                            );
-    //
-    // Now need to subclass window.
-    //
-    if(!nNeedsubclass)
+    else
     {
     {
-         wxAssociateWinWithHandle((HWND)m_hWnd,this);
+        RECTL                   vRect;
+
+        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+        nY = vRect.yTop - (nY + nHeight);
     }
     }
-    else
+    m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent
+                                      ,(PSZ)sClassName.c_str()
+                                      ,(PSZ)zTitle ? zTitle : ""
+                                      ,(ULONG)dwStyle
+                                      ,(LONG)0L
+                                      ,(LONG)0L
+                                      ,(LONG)0L
+                                      ,(LONG)0L
+                                      ,NULLHANDLE
+                                      ,HWND_TOP
+                                      ,(ULONG)lControlId
+                                      ,pCtlData
+                                      ,NULL
+                                     );
+    if (!m_hWnd)
     {
     {
-        SubclassWin(GetHWND());
+        vError = ::WinGetLastError(wxGetInstance());
+        sError = wxPMErrorToStr(vError);
+        return FALSE;
     }
     }
+    SubclassWin(m_hWnd);
+    SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+    SetSize( nX
+            ,nY
+            ,nWidth
+            ,nHeight
+           );
     return TRUE;
     return TRUE;
-} // end of wxWindowOS2::OS2Create
+} // end of WinGuiBase_Window::OS2Create
 
 // ===========================================================================
 // OS2 PM message handlers
 
 // ===========================================================================
 // OS2 PM message handlers
@@ -2990,6 +3101,13 @@ bool wxWindowOS2::HandleSetFocus(
   WXHWND                            WXUNUSED(hWnd)
 )
 {
   WXHWND                            WXUNUSED(hWnd)
 )
 {
+    //
+    // Notify the parent keeping track of focus for the kbd navigation
+    // purposes that we got it
+    //
+    wxChildFocusEvent               vEventFocus((wxWindow *)this);
+    (void)GetEventHandler()->ProcessEvent(vEventFocus);
+
 #if wxUSE_CARET
     //
     // Deal with caret
 #if wxUSE_CARET
     //
     // Deal with caret
@@ -3991,7 +4109,7 @@ int wxWindowOS2::GetOS2ParentHeight(
     // Case 1
     //
     if (pParent->IsKindOf(CLASSINFO(wxDialog)))
     // Case 1
     //
     if (pParent->IsKindOf(CLASSINFO(wxDialog)))
-        return(pParent->GetSize().y);
+        return(pParent->GetClientSize().y);
 
     //
     // Case 2 -- if we are one of the separately built standard Frame
 
     //
     // Case 2 -- if we are one of the separately built standard Frame
@@ -4045,6 +4163,18 @@ int wxWindowOS2::GetOS2ParentHeight(
     return(0L);
 } // end of wxWindowOS2::GetOS2ParentHeight
 
     return(0L);
 } // end of wxWindowOS2::GetOS2ParentHeight
 
+wxWindowCreationHook::wxWindowCreationHook(
+  wxWindow*                         pWinBeingCreated
+)
+{
+    gpWinBeingCreated = pWinBeingCreated;
+} // end of wxWindowCreationHook::wxWindowCreationHook
+
+wxWindowCreationHook::~wxWindowCreationHook()
+{
+    gpWinBeingCreated = NULL;
+} // end of wxWindowCreationHook::~wxWindowCreationHook
+
 // ===========================================================================
 // global functions
 // ===========================================================================
 // ===========================================================================
 // global functions
 // ===========================================================================