]> 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 1dda24c9c9dc4e3080498e527f6fffbaa31935d7..c30bdb8ba473a66866005eda2ff68c537520797c 100644 (file)
@@ -583,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
@@ -1051,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()
@@ -2002,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);
     }
@@ -2017,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();
@@ -2030,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);
@@ -2265,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
 // ---------------------------------------------------------------------------
@@ -2466,11 +2424,14 @@ MRESULT wxWindowOS2::OS2WindowProc(
             if (IsKindOf(CLASSINFO(wxDialog)))
             {
                 PSWP                pSwp = (PSWP)PVOIDFROMMP(wParam);
             if (IsKindOf(CLASSINFO(wxDialog)))
             {
                 PSWP                pSwp = (PSWP)PVOIDFROMMP(wParam);
+                PSWP                pSwp2 = pSwp++;
 
 
-                bProcessed = HandleSize( pSwp->cx
-                                        ,pSwp->cy
-                                        ,(WXUINT)lParam
-                                       );
+                if (!(pSwp->cx == pSwp2->cx &&
+                      pSwp->cy == pSwp2->cy))
+                    bProcessed = HandleSize( pSwp->cx
+                                            ,pSwp->cy
+                                            ,(WXUINT)lParam
+                                           );
             }
             break;
 
             }
             break;
 
@@ -3015,17 +2976,22 @@ bool wxWindowOS2::OS2Create(
     //
     if (pParent)
     {
     //
     if (pParent)
     {
-        if (IsKindOf(CLASSINFO(wxStatusBar)) &&
-            pParent->IsKindOf(CLASSINFO(wxFrame)))
+        if ( pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
+             pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
+           )
         {
         {
-            RECTL                   vRect;
-            wxFrame*                pFrame = wxDynamicCast(pParent, wxFrame);
+            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);
+                ::WinQueryWindowRect((HWND)pFrame->GetFrame(), &vRect);
+                nY = vRect.yTop - (nY + nHeight);
+            }
+            else
+                nY = pParent->GetSize().y - (nY + nHeight);
         }
         }
-        else
-            nY = pParent->GetSize().y - (nY + nHeight);
     }
     else
     {
     }
     else
     {
@@ -3135,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