]> git.saurik.com Git - wxWidgets.git/commitdiff
OS/2 bug fixes and new mod file
authorDavid Webster <Dave.Webster@bhmi.com>
Tue, 22 Jan 2002 23:19:28 +0000 (23:19 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Tue, 22 Jan 2002 23:19:28 +0000 (23:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13755 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/os2/app.cpp
src/os2/font.cpp
src/os2/fontutil.cpp
src/os2/frame.cpp
src/os2/textctrl.cpp
src/os2/toplevel.cpp
src/os2/window.cpp
src/os2/wx23.def

index 5d137de3d3ce21849e89993f46ff799a4ed1abf0..a2608efbf2306965f1e9b0883b2186d648239f6e 100644 (file)
@@ -253,22 +253,6 @@ bool wxApp::Initialize(
   #endif //wxUSE_CONSOLEDEBUG
 #endif
 
-    //
-    // OS2 has to have an anchorblock
-    //
-    vHab = WinInitialize(0);
-
-    if (!vHab)
-        return FALSE;
-    else
-        vHabmain = vHab;
-
-    // Some people may wish to use this, but
-    // probably it shouldn't be here by default.
-#ifdef __WXDEBUG__
-    //    wxRedirectIOToConsole();
-#endif
-
     wxBuffer = new wxChar[1500]; // FIXME; why?
 
     wxClassInfo::InitializeClasses();
@@ -289,7 +273,22 @@ bool wxApp::Initialize(
 
     wxBitmap::InitStandardHandlers();
 
-    RegisterWindowClasses(vHab);
+    //
+    // OS2 has to have an anchorblock
+    //
+    vHab = WinInitialize(0);
+
+    if (!vHab)
+        return FALSE;
+    else
+        vHabmain = vHab;
+
+    // Some people may wish to use this, but
+    // probably it shouldn't be here by default.
+#ifdef __WXDEBUG__
+    //    wxRedirectIOToConsole();
+#endif
+
     wxWinHandleList = new wxList(wxKEY_INTEGER);
 
     // This is to foil optimizations in Visual C++ that throw out dummy.obj.
@@ -304,6 +303,7 @@ bool wxApp::Initialize(
     wxModule::RegisterModules();
     if (!wxModule::InitializeModules())
         return FALSE;
+    RegisterWindowClasses(vHab);
     return TRUE;
 } // end of wxApp::Initialize
 
@@ -413,7 +413,7 @@ bool wxApp::RegisterWindowClasses(
     if (!::WinRegisterClass( vHab
                             ,wxCanvasClassName
                             ,wxWndProc
-                            ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT | CS_CLIPCHILDREN
+                            ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT
                             ,sizeof(ULONG)
                            ))
     {
@@ -901,6 +901,16 @@ bool wxApp::ProcessMessage(
     if (pMsg->msg == WM_TIMER)
         wxTimerProc(NULL, 0, (int)pMsg->mp1, 0);
 
+    //
+    // Allow the window to prevent certain messages from being
+    // translated/processed (this is currently used by wxTextCtrl to always
+    // grab Ctrl-C/V/X, even if they are also accelerators in some parent)
+    //
+    if (pWndThis && !pWndThis->OS2ShouldPreProcessMessage(pWxmsg))
+    {
+        return FALSE;
+    }
+
     //
     // For some composite controls (like a combobox), wndThis might be NULL
     // because the subcontrol is not a wxWindow, but only the control itself
index 623f7fd44490735f9a90b9a7b63ef1d8c0b4df81..c6a9b75646c44d935a464fe89cd11cbc66f8e704 100644 (file)
@@ -368,7 +368,7 @@ bool wxFontRefData::Alloc(
     {
         wxFillLogFont( &m_vNativeFontInfo.fa
                       ,&m_vNativeFontInfo.fn
-                      ,m_hPS
+                      ,&m_hPS
                       ,&flId
                       ,sFaceName
                       ,pFont
@@ -425,6 +425,8 @@ bool wxFontRefData::Alloc(
         m_nFamily = wxSCRIPT;
     else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Courier New") == 0)
         m_nFamily = wxMODERN;
+    else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Courier") == 0)
+        m_nFamily = wxMODERN;
     else
         m_nFamily = wxSWISS;
 
index 052537053e77cc9dc8daf6d883a580e3c80d250b..31bbcaac3d2a7eed998ebbe9c48ef7fab8e1a915 100644 (file)
@@ -261,7 +261,7 @@ bool wxTestFontEncoding(
 void wxFillLogFont(
   LOGFONT*                          pFattrs  // OS2 GPI FATTRS
 , PFACENAMEDESC                     pFaceName
-, HPS                               hPS
+, HPS*                              phPS
 , long*                             pflId
 , wxString&                         sFaceName
 , wxFont*                           pFont
@@ -269,7 +269,7 @@ void wxFillLogFont(
 {
     LONG                            lNumFonts = 0L;       // For system font count
     ERRORID                         vError;               // For logging API errors
-    LONG                            lTemp;
+    LONG                            lTemp = 0L;
     bool                            bInternalPS = FALSE;  // if we have to create one
     PFONTMETRICS                    pFM = NULL;
 
@@ -277,22 +277,30 @@ void wxFillLogFont(
     // Initial house cleaning to free data buffers and ensure we have a
     // functional PS to work with
     //
-    if (!hPS)
+    if (!*phPS)
     {
-        hPS = ::WinGetPS(HWND_DESKTOP);
+        *phPS = ::WinGetPS(HWND_DESKTOP);
         bInternalPS = TRUE;
     }
 
     //
     // Determine the number of fonts.
     //
-    lNumFonts = ::GpiQueryFonts( hPS
-                                ,QF_PUBLIC
-                                ,NULL
-                                ,&lTemp
-                                ,(LONG) sizeof(FONTMETRICS)
-                                ,NULL
-                               );
+    if((lNumFonts = ::GpiQueryFonts( *phPS
+                                    ,QF_PUBLIC
+                                    ,NULL
+                                    ,&lTemp
+                                    ,(LONG) sizeof(FONTMETRICS)
+                                    ,NULL
+                                   )) < 0L)
+    {
+        ERRORID                     vError;
+        wxString                    sError;
+
+        vError = ::WinGetLastError(wxGetInstance());
+        sError = wxPMErrorToStr(vError);
+        return;
+    }
 
     //
     // Allocate space for the font metrics.
@@ -303,7 +311,7 @@ void wxFillLogFont(
     // Retrieve the font metrics.
     //
     lTemp = lNumFonts;
-    lTemp = ::GpiQueryFonts( hPS
+    lTemp = ::GpiQueryFonts( *phPS
                             ,QF_PUBLIC
                             ,NULL
                             ,&lTemp
@@ -355,7 +363,7 @@ void wxFillLogFont(
     // We should now have the correct FATTRS set with the selected
     // font, so now we need to generate an ID
     //
-    long                            lNumLids = ::GpiQueryNumberSetIds(hPS);
+    long                            lNumLids = ::GpiQueryNumberSetIds(*phPS);
     long                            lGpiError;
 
     if(lNumLids )
@@ -364,7 +372,7 @@ void wxFillLogFont(
         STR8                        azNames[255];
         long                        alIds[255];
 
-        if(!::GpiQuerySetIds( hPS
+        if(!::GpiQuerySetIds( *phPS
                              ,lNumLids
                              ,alTypes
                              ,azNames
@@ -372,7 +380,7 @@ void wxFillLogFont(
                             ))
         {
             if (bInternalPS)
-                ::WinReleasePS(hPS);
+                ::WinReleasePS(*phPS);
             return;
         }
 
@@ -382,16 +390,17 @@ void wxFillLogFont(
         if(*pflId > 254)  // wow, no id available!
         {
             if (bInternalPS)
-               ::WinReleasePS(hPS);
+               ::WinReleasePS(*phPS);
            return;
         }
     }
-
+    else
+        *pflId = 1L;
     //
     // Release and delete the current font
     //
-    ::GpiSetCharSet(hPS, LCID_DEFAULT);/* release the font before deleting */
-    ::GpiDeleteSetId(hPS, 1L);         /* delete the logical font          */
+    ::GpiSetCharSet(*phPS, LCID_DEFAULT);/* release the font before deleting */
+    ::GpiDeleteSetId(*phPS, 1L);         /* delete the logical font          */
 
     //
     // Now build a facestring
@@ -400,7 +409,7 @@ void wxFillLogFont(
 
     strcpy(zFacename, pFattrs->szFacename);
 
-    if(::GpiQueryFaceString( hPS
+    if(::GpiQueryFaceString( *phPS
                             ,zFacename
                             ,pFaceName
                             ,FACESIZE
index d6087502a303b0021eb97e7530d04b250670adaf..0f687f7f86c709c23c25c02b1175a69726edddd8 100644 (file)
@@ -248,6 +248,26 @@ wxStatusBar* wxFrame::OnCreateStatusBar(
     if( !pStatusBar )
         return NULL;
 
+    wxClientDC                      vDC(pStatusBar);
+    int                             nY;
+
+    //
+    // Set the height according to the font and the border size
+    //
+    vDC.SetFont(pStatusBar->GetFont()); // Screws up the menues for some reason
+    vDC.GetTextExtent( "X"
+                      ,NULL
+                      ,&nY
+                     );
+
+    int                             nHeight = ((11 * nY) / 10 + 2 * pStatusBar->GetBorderY());
+
+    pStatusBar->SetSize( -1
+                        ,-1
+                        ,-1
+                        ,nHeight
+                       );
+
     ::WinSetParent( pStatusBar->GetHWND()
                    ,m_hFrame
                    ,FALSE
index 69f0914f4b5fb685130a2ab8502cd71ba5b36a1d..4070a296890d54c460df26f2433ff1d3257623aa 100644 (file)
@@ -965,6 +965,13 @@ WXHBRUSH wxTextCtrl::OnCtlColor(
     return (WXHBRUSH)pBackgroundBrush->GetResourceHandle();
 } // end of wxTextCtrl::OnCtlColor
 
+bool wxTextCtrl::OS2ShouldPreProcessMessage(
+  WXMSG*                            pMsg
+)
+{
+    return wxControl::OS2ShouldPreProcessMessage(pMsg);
+} // end of wxTextCtrl::OS2ShouldPreProcessMessage
+
 void wxTextCtrl::OnChar(
   wxKeyEvent&                       rEvent
 )
index 0362889309e826db4558c0fb7567bbe4424cede6..abbd5c5c21ea2d034b6abd6db3e2d84daeca9ab9 100644 (file)
@@ -351,7 +351,7 @@ bool wxTopLevelWindowOS2::CreateFrame(
     wxAssociateWinWithHandle(m_hWnd, this);
     wxAssociateWinWithHandle(m_hFrame, this);
 
-    m_backgroundColour.Set(wxString("GREY"));
+    m_backgroundColour.Set(wxString("DARK GREY"));
 
     LONG                            lColor = (LONG)m_backgroundColour.GetPixel();
 
@@ -403,6 +403,14 @@ bool wxTopLevelWindowOS2::CreateFrame(
         wxLogError("Error sizing frame. Error: %s\n", sError);
         return FALSE;
     }
+    lStyle =  ::WinQueryWindowULong( m_hWnd
+                                    ,QWL_STYLE
+                                   );
+    lStyle |= WS_CLIPCHILDREN;
+    ::WinSetWindowULong( m_hWnd
+                        ,QWL_STYLE
+                        ,lStyle
+                       );
     return TRUE;
 } // end of wxTopLevelWindowOS2::CreateFrame
 
@@ -584,7 +592,7 @@ void wxTopLevelWindowOS2::DoShowWindow(
   int                               nShowCmd
 )
 {
-    ::WinShowWindow(m_hFrame, (BOOL)nShowCmd);
+    ::WinShowWindow(m_hFrame, (BOOL)(nShowCmd & SWP_SHOW));
     m_bIconized = nShowCmd == SWP_MINIMIZE;
 } // end of wxTopLevelWindowOS2::DoShowWindow
 
@@ -600,12 +608,12 @@ bool wxTopLevelWindowOS2::Show(
     {
         if (m_bMaximizeOnShow)
         {
-            nShowCmd = SWP_SHOW;
+            nShowCmd = SWP_MAXIMIZE;
             m_bMaximizeOnShow = FALSE;
         }
         else
         {
-            nShowCmd = SWP_HIDE;
+            nShowCmd = SWP_SHOW;
         }
     }
     else // hide
index 9bc6c64ae5f942fdaf42ab4d55a466542a30107a..30ac8d5c44d2c53d01cb50af67730f0eb454386d 100644 (file)
@@ -2265,6 +2265,14 @@ bool 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
 // ---------------------------------------------------------------------------
@@ -3138,6 +3146,13 @@ bool wxWindowOS2::HandleSetFocus(
   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
index c35afce4db25652d8b83429cbdd9921863164698..871fd0b3b71a51635bec1620488015f3dd862486 100644 (file)
@@ -12321,8 +12321,8 @@ EXPORTS
       wxGetNativeFontEncoding__F14wxFontEncodingP20wxNativeEncodingInfo
       ;wxOS2SelectMatchingFontByName(_FATTRS*,_FACENAMEDESC*,_FONTMETRICS*,int,const wxFont*)
       wxOS2SelectMatchingFontByName__FP7_FATTRSP13_FACENAMEDESCP12_FONTMETRICSiPC6wxFont
-      ;wxFillLogFont(_FATTRS*,_FACENAMEDESC*,unsigned long,long*,wxString&,wxFont*)
-      wxFillLogFont__FP7_FATTRSP13_FACENAMEDESCUlPlR8wxStringP6wxFont
+      ;wxFillLogFont(_FATTRS*,_FACENAMEDESC*,unsigned long*,long*,wxString&,wxFont*)
+      wxFillLogFont__FP7_FATTRSP13_FACENAMEDESCPUlPlR8wxStringP6wxFont
       ;wxGpiStrcmp(char*,char*)
       wxGpiStrcmp__FPcT1
       ;wxNativeEncodingInfo::FromString(const wxString&)
@@ -14019,6 +14019,8 @@ EXPORTS
       Cut__10wxTextCtrlFv
       ;wxTextCtrl::SetInsertionPointEnd()
       SetInsertionPointEnd__10wxTextCtrlFv
+      ;wxTextCtrl::OS2ShouldPreProcessMessage(void**)
+      OS2ShouldPreProcessMessage__10wxTextCtrlFPPv
       ;wxTextCtrl::DiscardEdits()
       DiscardEdits__10wxTextCtrlFv
       ;wxTextCtrl::CanUndo() const
@@ -14650,6 +14652,8 @@ EXPORTS
       OS2WindowProc__8wxWindowFUiPvT2
       ;wxWindow::OS2TranslateMessage(void**)
       OS2TranslateMessage__8wxWindowFPPv
+      ;wxWindow::OS2ShouldPreProcessMessage(void**)
+      OS2ShouldPreProcessMessage__8wxWindowFPPv
       ;wxWindow::OS2DefWindowProc(unsigned int,void*,void*)
       OS2DefWindowProc__8wxWindowFUiPvT2
       ;wxWindow::HandleMinimize()