]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/utilsgui.cpp
no need to iterate over all special icon names after a match was found, there won...
[wxWidgets.git] / src / os2 / utilsgui.cpp
index e64fc12f9b26533d63c0983e7f5617c17e942d52..79b584d217c3ec4ca63810751e61c21f1c419553 100644 (file)
     #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/timer.h"
+#include "wx/evtloop.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();
     }
 };
 
-// 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
-)
-{
-    HAB                             hab = 0;
-    HINI                            hIni = 0;
-
-    if (!rFile.empty())
-    {
-        hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST rFile);
-        if (hIni != 0L)
-        {
-            return (::PrfWriteProfileString( hIni
-                                            ,(PSZ)WXSTRINGCAST rSection
-                                            ,(PSZ)WXSTRINGCAST rEntry
-                                            ,(PSZ)WXSTRINGCAST rValue
-                                           ));
-        }
-    }
-    else
-        return (::PrfWriteProfileString( HINI_PROFILE
-                                        ,(PSZ)WXSTRINGCAST rSection
-                                        ,(PSZ)WXSTRINGCAST rEntry
-                                        ,(PSZ)WXSTRINGCAST rValue
-                                       ));
-    return FALSE;
-}
-
-bool wxWriteResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, float                             fValue
-, const wxString&                   rFile
-)
-{
-    wxChar                          zBuf[50];
-
-    wxSprintf(zBuf, "%.4f", fValue);
-    return wxWriteResource( rSection
-                           ,rEntry
-                           ,zBuf
-                           ,rFile
-                          );
-}
-
-bool wxWriteResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, long                              lValue
-, const wxString&                   rFile
-)
-{
-    wxChar                          zBuf[50];
-
-    wxSprintf(zBuf, "%ld", lValue);
-    return wxWriteResource( rSection
-                           ,rEntry
-                           ,zBuf
-                           ,rFile
-                          );
-}
-
-bool wxWriteResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, int                               lValue
-, const wxString&                   rFile
-)
-{
-    wxChar                          zBuf[50];
-
-    wxSprintf(zBuf, "%d", lValue);
-    return wxWriteResource( rSection
-                           ,rEntry
-                           ,zBuf
-                           ,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];
-
-    if (!rFile.empty())
-    {
-        hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST rFile);
-        if (hIni != 0L)
-        {
-            ULONG n = ::PrfQueryProfileString( hIni
-                                              ,(PSZ)WXSTRINGCAST rSection
-                                              ,(PSZ)WXSTRINGCAST rEntry
-                                              ,(PSZ)zDefunkt
-                                              ,(PVOID)zBuf
-                                              ,1000
-                                             );
-            if (zBuf == NULL)
-                return FALSE;
-            if (n == 0L || wxStrcmp(zBuf, zDefunkt) == 0)
-                return FALSE;
-            zBuf[n-1] = '\0';
-        }
-        else
-            return FALSE;
-    }
-    else
-    {
-        ULONG n = ::PrfQueryProfileString( HINI_PROFILE
-                                          ,(PSZ)WXSTRINGCAST rSection
-                                          ,(PSZ)WXSTRINGCAST rEntry
-                                          ,(PSZ)zDefunkt
-                                          ,(PVOID)zBuf
-                                          ,1000
-                                         );
-        if (zBuf == NULL)
-            return FALSE;
-        if (n == 0L || wxStrcmp(zBuf, zDefunkt) == 0)
-            return FALSE;
-        zBuf[n-1] = '\0';
-    }
-    strcpy((char*)*ppValue, zBuf);
-    return TRUE;
-}
-
-bool wxGetResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, float*                            pValue
-, const wxString&                   rFile
-)
-{
-    wxChar*                         zStr = NULL;
-
-    zStr = new wxChar[1000];
-    bool                            bSucc = wxGetResource( rSection
-                                                          ,rEntry
-                                                          ,(wxChar **)&zStr
-                                                          ,rFile
-                                                         );
-
-    if (bSucc)
-    {
-        *pValue = (float)wxStrtod(zStr, NULL);
-        delete[] zStr;
-        return TRUE;
-    }
-    else
-    {
-        delete[] zStr;
-        return FALSE;
-    }
-}
-
-bool wxGetResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, long*                             pValue
-, const wxString&                   rFile
-)
-{
-    wxChar*                           zStr = NULL;
-
-    zStr = new wxChar[1000];
-    bool                              bSucc = wxGetResource( rSection
-                                                            ,rEntry
-                                                            ,(wxChar **)&zStr
-                                                            ,rFile
-                                                           );
-
-    if (bSucc)
-    {
-        *pValue = wxStrtol(zStr, NULL, 10);
-        delete[] zStr;
-        return TRUE;
-    }
-    else
-    {
-        delete[] zStr;
-        return FALSE;
-    }
-}
-
-bool wxGetResource(
-  const wxString&                   rSection
-, const wxString&                   rEntry
-, int*                              pValue
-, const wxString&                   rFile
-)
-{
-    wxChar*                         zStr = NULL;
-
-    zStr = new wxChar[1000];
-    bool                            bSucc = wxGetResource( rSection
-                                                          ,rEntry
-                                                          ,(wxChar **)&zStr
-                                                          ,rFile
-                                                         );
-
-    if (bSucc)
-    {
-        *pValue = (int)wxStrtol(zStr, NULL, 10);
-        delete[] zStr;
-        return TRUE;
-    }
-    else
-    {
-        delete[] zStr;
-        return FALSE;
-    }
-}
-#endif // wxUSE_RESOURCES
-
 // ---------------------------------------------------------------------------
 // helper functions for showing a "busy" cursor
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // helper functions for showing a "busy" cursor
 // ---------------------------------------------------------------------------
@@ -313,7 +92,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);
@@ -321,26 +100,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;
+        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?
     }
 }
 
     }
 }
 
@@ -362,7 +139,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
@@ -377,7 +154,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
 }
 
@@ -479,30 +256,21 @@ 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;
+}
+
+wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
+{
+    return new wxOS2TimerImpl(timer);
+}
+
+wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
+{
+    return new wxEventLoop;
 }
 
 // ---------------------------------------------------------------------------
 }
 
 // ---------------------------------------------------------------------------