]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/utilsgui.cpp
!__WX_DC_BLIT_FIXED__ case
[wxWidgets.git] / src / os2 / utilsgui.cpp
index d5153224f1a735d3d8df478026b5804173476f38..dc2651beefbb0849e4da18f024c90a4a333e9fba 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        os2/utilsgui.cpp
+// Name:        src/os2/utilsgui.cpp
 // Purpose:     Various utility functions only available in GUI
 // Author:      David Webster
 // Modified by:
 // Purpose:     Various utility functions only available in GUI
 // Author:      David Webster
 // Modified by:
 #endif
 
 #ifndef WX_PRECOMP
 #endif
 
 #ifndef WX_PRECOMP
-    #include "wx/setup.h"
     #include "wx/utils.h"
     #include "wx/app.h"
     #include "wx/cursor.h"
     #include "wx/utils.h"
     #include "wx/app.h"
     #include "wx/cursor.h"
+    #include "wx/font.h"
+    #include "wx/timer.h"
 #endif //WX_PRECOMP
 
 #include "wx/apptrait.h"
 #endif //WX_PRECOMP
 
 #include "wx/apptrait.h"
-#include "wx/timer.h"
 
 #include "wx/os2/private.h"     // includes <windows.h>
 
 
 #include "wx/os2/private.h"     // includes <windows.h>
 
 // ----------------------------------------------------------------------------
 
 // Sleep for nSecs seconds. Attempt a Windows implementation using timers.
 // ----------------------------------------------------------------------------
 
 // Sleep for nSecs seconds. Attempt a Windows implementation using timers.
-static bool inTimer = FALSE;
+static bool inTimer = false;
 
 class wxSleepTimer: public wxTimer
 {
 public:
     inline void Notify()
     {
 
 class wxSleepTimer: public wxTimer
 {
 public:
     inline void Notify()
     {
-        inTimer = FALSE;
+        inTimer = false;
         Stop();
     }
 };
 
         Stop();
     }
 };
 
-static wxTimer*                     wxTheSleepTimer = NULL;
-
 // Reading and writing resources (eg WIN.INI, .Xdefaults)
 #if wxUSE_RESOURCES
 // Reading and writing resources (eg WIN.INI, .Xdefaults)
 #if wxUSE_RESOURCES
-bool wxWriteResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, const wxString&                   rValue
-, const wxString&                   rFile
-)
+bool wxWriteResource( const wxString& rSection,
+                      const wxString& rEntry,
+                      const wxString& rValue,
+                      const wxString& rFile )
 {
 {
-    HAB                             hab = 0;
-    HINI                            hIni = 0;
+    HAB  hab = 0;
+    HINI hIni = 0;
 
 
-    if (rFile != "")
+    if (!rFile.empty())
     {
         hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST rFile);
         if (hIni != 0L)
     {
         hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST rFile);
         if (hIni != 0L)
@@ -89,7 +85,7 @@ bool wxWriteResource(
                                         ,(PSZ)WXSTRINGCAST rEntry
                                         ,(PSZ)WXSTRINGCAST rValue
                                        ));
                                         ,(PSZ)WXSTRINGCAST rEntry
                                         ,(PSZ)WXSTRINGCAST rValue
                                        ));
-    return FALSE;
+    return false;
 }
 
 bool wxWriteResource(
 }
 
 bool wxWriteResource(
@@ -126,36 +122,28 @@ bool wxWriteResource(
                           );
 }
 
                           );
 }
 
-bool wxWriteResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, int                               lValue
-, const wxString&                   rFile
-)
+bool wxWriteResource( const wxString& rSection,
+                      const wxString& rEntry,
+                      int lValue,
+                      const wxString& rFile )
 {
 {
-    wxChar                          zBuf[50];
+    wxChar zBuf[50];
 
     wxSprintf(zBuf, "%d", lValue);
 
     wxSprintf(zBuf, "%d", lValue);
-    return wxWriteResource( rSection
-                           ,rEntry
-                           ,zBuf
-                           ,rFile
-                          );
+    return wxWriteResource( rSection, rEntry, zBuf, rFile );
 }
 
 }
 
-bool wxGetResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, wxChar**                          ppValue
-, const wxString&                   rFile
-)
+bool wxGetResource( const wxString& rSection,
+                    const wxString& rEntry,
+                    wxChar** ppValue,
+                    const wxString& rFile )
 {
 {
-    HAB                             hab = 0;
-    HINI                            hIni = 0;
-    wxChar                          zDefunkt[] = _T("$$default");
-    char                            zBuf[1000];
+    HAB    hab = 0;
+    HINI   hIni = 0;
+    wxChar zDefunkt[] = _T("$$default");
+    char   zBuf[1000];
 
 
-    if (rFile != "")
+    if (!rFile.empty())
     {
         hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST rFile);
         if (hIni != 0L)
     {
         hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST rFile);
         if (hIni != 0L)
@@ -168,13 +156,13 @@ bool wxGetResource(
                                               ,1000
                                              );
             if (zBuf == NULL)
                                               ,1000
                                              );
             if (zBuf == NULL)
-                return FALSE;
+                return false;
             if (n == 0L || wxStrcmp(zBuf, zDefunkt) == 0)
             if (n == 0L || wxStrcmp(zBuf, zDefunkt) == 0)
-                return FALSE;
+                return false;
             zBuf[n-1] = '\0';
         }
         else
             zBuf[n-1] = '\0';
         }
         else
-            return FALSE;
+            return false;
     }
     else
     {
     }
     else
     {
@@ -186,100 +174,70 @@ bool wxGetResource(
                                           ,1000
                                          );
         if (zBuf == NULL)
                                           ,1000
                                          );
         if (zBuf == NULL)
-            return FALSE;
+            return false;
         if (n == 0L || wxStrcmp(zBuf, zDefunkt) == 0)
         if (n == 0L || wxStrcmp(zBuf, zDefunkt) == 0)
-            return FALSE;
+            return false;
         zBuf[n-1] = '\0';
     }
     strcpy((char*)*ppValue, zBuf);
         zBuf[n-1] = '\0';
     }
     strcpy((char*)*ppValue, zBuf);
-    return TRUE;
+    return true;
 }
 
 }
 
-bool wxGetResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, float*                            pValue
-, const wxString&                   rFile
-)
+bool wxGetResource( const wxString& rSection,
+                    const wxString& rEntry,
+                    float* pValue,
+                    const wxString& rFile )
 {
 {
-    wxChar*                         zStr = NULL;
+    wxChar* zStr = NULL;
 
     zStr = new wxChar[1000];
 
     zStr = new wxChar[1000];
-    bool                            bSucc = wxGetResource( rSection
-                                                          ,rEntry
-                                                          ,(wxChar **)&zStr
-                                                          ,rFile
-                                                         );
+    bool bSucc = wxGetResource( rSection, rEntry, (wxChar **)&zStr, rFile );
 
     if (bSucc)
     {
         *pValue = (float)wxStrtod(zStr, NULL);
 
     if (bSucc)
     {
         *pValue = (float)wxStrtod(zStr, NULL);
-        delete[] zStr;
-        return TRUE;
-    }
-    else
-    {
-        delete[] zStr;
-        return FALSE;
     }
     }
+
+    delete[] zStr;
+    return bSucc;
 }
 
 }
 
-bool wxGetResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, long*                             pValue
-, const wxString&                   rFile
-)
+bool wxGetResource( const wxString& rSection,
+                    const wxString& rEntry,
+                    long* pValue,
+                    const wxString& rFile )
 {
 {
-    wxChar*                           zStr = NULL;
+    wxChar* zStr = NULL;
 
     zStr = new wxChar[1000];
 
     zStr = new wxChar[1000];
-    bool                              bSucc = wxGetResource( rSection
-                                                            ,rEntry
-                                                            ,(wxChar **)&zStr
-                                                            ,rFile
-                                                           );
+    bool bSucc = wxGetResource( rSection, rEntry, (wxChar **)&zStr, rFile );
 
     if (bSucc)
     {
         *pValue = wxStrtol(zStr, NULL, 10);
 
     if (bSucc)
     {
         *pValue = wxStrtol(zStr, NULL, 10);
-        delete[] zStr;
-        return TRUE;
-    }
-    else
-    {
-        delete[] zStr;
-        return FALSE;
     }
     }
+
+    delete[] zStr;
+    return bSucc;
 }
 
 }
 
-bool wxGetResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, int*                              pValue
-, const wxString&                   rFile
-)
+bool wxGetResource( const wxString& rSection,
+                    const wxString& rEntry,
+                    int* pValue,
+                    const wxString& rFile )
 {
 {
-    wxChar*                         zStr = NULL;
+    wxChar* zStr = NULL;
 
     zStr = new wxChar[1000];
 
     zStr = new wxChar[1000];
-    bool                            bSucc = wxGetResource( rSection
-                                                          ,rEntry
-                                                          ,(wxChar **)&zStr
-                                                          ,rFile
-                                                         );
+    bool bSucc = wxGetResource( rSection, rEntry, (wxChar **)&zStr, rFile );
 
     if (bSucc)
     {
         *pValue = (int)wxStrtol(zStr, NULL, 10);
 
     if (bSucc)
     {
         *pValue = (int)wxStrtol(zStr, NULL, 10);
-        delete[] zStr;
-        return TRUE;
-    }
-    else
-    {
-        delete[] zStr;
-        return FALSE;
     }
     }
+
+    delete[] zStr;
+    return bSucc;
 }
 #endif // wxUSE_RESOURCES
 
 }
 #endif // wxUSE_RESOURCES
 
@@ -292,9 +250,7 @@ HCURSOR gs_wxBusyCursorOld = 0;  // old cursor
 static int gs_wxBusyCursorCount = 0;
 
 // Set the cursor to the busy cursor for all windows
 static int gs_wxBusyCursorCount = 0;
 
 // Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(
-  wxCursor*                         pCursor
-)
+void wxBeginBusyCursor(const wxCursor* pCursor)
 {
     if ( gs_wxBusyCursorCount++ == 0 )
     {
 {
     if ( gs_wxBusyCursorCount++ == 0 )
     {
@@ -318,7 +274,7 @@ void wxEndBusyCursor()
     }
 }
 
     }
 }
 
-// TRUE if we're between the above two calls
+// true if we're between the above two calls
 bool wxIsBusy()
 {
     return (gs_wxBusyCursorCount > 0);
 bool wxIsBusy()
 {
     return (gs_wxBusyCursorCount > 0);
@@ -326,27 +282,24 @@ bool wxIsBusy()
 
 // Check whether this window wants to process messages, e.g. Stop button
 // in long calculations.
 
 // Check whether this window wants to process messages, e.g. Stop button
 // in long calculations.
-bool wxCheckForInterrupt(
-  wxWindow*                         pWnd
-)
+bool wxCheckForInterrupt( wxWindow* pWnd )
 {
     if(pWnd)
     {
 {
     if(pWnd)
     {
-        QMSG                        vMsg;
-        HAB                         hab = 0;
-        HWND                        hwndFilter = NULLHANDLE;
-        HWND                        hwndWin= (HWND) pWnd->GetHWND();
+        QMSG vMsg;
+        HAB  hab = 0;
+        HWND hwndFilter = NULLHANDLE;
 
         while(::WinPeekMsg(hab, &vMsg, hwndFilter, 0, 0, PM_REMOVE))
         {
             ::WinDispatchMsg(hab, &vMsg);
         }
 
         while(::WinPeekMsg(hab, &vMsg, hwndFilter, 0, 0, PM_REMOVE))
         {
             ::WinDispatchMsg(hab, &vMsg);
         }
-        return TRUE;//*** temporary?
+        return true;//*** temporary?
     }
     else
     {
         wxFAIL_MSG(_T("pWnd==NULL !!!"));
     }
     else
     {
         wxFAIL_MSG(_T("pWnd==NULL !!!"));
-        return FALSE;//*** temporary?
+        return false;//*** temporary?
     }
 }
 
     }
 }
 
@@ -368,7 +321,7 @@ void wxGetMousePosition(
     *pY = vPt.y;
 };
 
     *pY = vPt.y;
 };
 
-// Return TRUE if we have a colour display
+// Return true if we have a colour display
 bool wxColourDisplay()
 {
 #if 0
 bool wxColourDisplay()
 {
 #if 0
@@ -383,7 +336,7 @@ bool wxColourDisplay()
 #else
     // I don't see how the PM display could not be color. Besides, this
     // was leaking DCs and PSs!!!  MN
 #else
     // I don't see how the PM display could not be color. Besides, this
     // was leaking DCs and PSs!!!  MN
-    return TRUE;
+    return true;
 #endif
 }
 
 #endif
 }
 
@@ -431,8 +384,10 @@ void wxDisplaySize(
         ::DevCloseDC(hdcScreen);
         ::WinReleasePS(hpsScreen);
     }
         ::DevCloseDC(hdcScreen);
         ::WinReleasePS(hpsScreen);
     }
-    *pWidth = (int)lWidth;
-    *pHeight = (int)lHeight;
+    if (pWidth)
+        *pWidth = (int)lWidth;
+    if (pHeight)
+        *pHeight = (int)lHeight;
 }
 
 void wxDisplaySizeMM(
 }
 
 void wxDisplaySizeMM(
@@ -483,61 +438,42 @@ void wxGUIAppTraits::TerminateGui(unsigned long ulHab)
     ::WinTerminate(ulHab);
 }
 
     ::WinTerminate(ulHab);
 }
 
-wxToolkitInfo & wxGUIAppTraits::GetToolkitInfo()
+wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
 {
 {
-    static wxToolkitInfo           vInfo;
-    ULONG                           ulSysInfo[QSV_MAX] = {0};
-    APIRET                          ulrc;
-
-    vInfo.shortName = _T("PM");
-    vInfo.name = _T("wxOS2");
-#ifdef __WXUNIVERSAL__
-    vInfo.shortName << _T("univ");
-    vInfo.name << _T("/wxUniversal");
-#endif
-    ulrc = ::DosQuerySysInfo( 1L
-                             ,QSV_MAX
-                             ,(PVOID)ulSysInfo
-                             ,sizeof(ULONG) * QSV_MAX
-                            );
-    if (ulrc == 0L)
-    {
-        vInfo.versionMajor = ulSysInfo[QSV_VERSION_MAJOR] / 10;
-        vInfo.versionMinor = ulSysInfo[QSV_VERSION_MINOR];
-    }
-    vInfo.os = wxOS2_PM;
-    return vInfo;
+    // How to get version of PM ? I guess, just reusing the OS version is OK.
+    (void) wxGetOsVersion(verMaj, verMin);
+    return wxPORT_OS2;
 }
 
 }
 
+
 // ---------------------------------------------------------------------------
 // window information functions
 // ---------------------------------------------------------------------------
 
 // ---------------------------------------------------------------------------
 // window information functions
 // ---------------------------------------------------------------------------
 
-wxString WXDLLEXPORT wxGetWindowText(
-  WXHWND                            hWnd
-)
+wxString WXDLLEXPORT wxGetWindowText( WXHWND hWnd )
 {
 {
-    wxString                        vStr;
-    long                            lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1;
+    wxString vStr;
 
 
-    ::WinQueryWindowText((HWND)hWnd, lLen, vStr.GetWriteBuf((int)lLen));
-    vStr.UngetWriteBuf();
+    if ( hWnd )
+    {
+        long lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1;
+        ::WinQueryWindowText((HWND)hWnd, lLen, (PSZ)(wxChar*)wxStringBuffer(vStr, lLen));
+    }
 
     return vStr;
 }
 
 
     return vStr;
 }
 
-wxString WXDLLEXPORT wxGetWindowClass(
-  WXHWND                            hWnd
-)
+wxString WXDLLEXPORT wxGetWindowClass( WXHWND hWnd )
 {
 {
-    wxString                        vStr;
-    int                             nLen = 256; // some starting value
+    wxString vStr;
+    if ( hWnd )
+    {
+        int nLen = 256; // some starting value
 
     for ( ;; )
     {
 
     for ( ;; )
     {
-        int                         nCount = ::WinQueryClassName((HWND)hWnd, nLen, vStr.GetWriteBuf(nLen));
+        int                     nCount = ::WinQueryClassName((HWND)hWnd, nLen, (PSZ)(wxChar*)wxStringBuffer(vStr, nLen));
 
 
-        vStr.UngetWriteBuf();
         if (nCount == nLen )
         {
             // the class name might have been truncated, retry with larger
         if (nCount == nLen )
         {
             // the class name might have been truncated, retry with larger
@@ -548,6 +484,7 @@ wxString WXDLLEXPORT wxGetWindowClass(
         {
             break;
         }
         {
             break;
         }
+        }
     }
     return vStr;
 }
     }
     return vStr;
 }
@@ -938,7 +875,7 @@ wxBitmap wxDisableBitmap(
     int                             j;
 
     //
     int                             j;
 
     //
-    // Bitmap must be ina double-word alligned address so we may
+    // Bitmap must be in a double-word aligned address so we may
     // have some padding to worry about
     //
     if (nLineBoundary > 0)
     // have some padding to worry about
     //
     if (nLineBoundary > 0)