]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/utils.cpp
Include wx/stopwatch.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / msw / utils.cpp
index 977ae5d5c39f29e5baeea2c28bf3a710c2b2be8b..7409cd6c8fb5aabf3488bf39ce8421f6784c1142 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        msw/utils.cpp
+// Name:        src/msw/utils.cpp
 // Purpose:     Various utilities
 // Author:      Julian Smart
 // Modified by:
 // Purpose:     Various utilities
 // Author:      Julian Smart
 // Modified by:
     #include "wx/app.h"
     #include "wx/intl.h"
     #include "wx/log.h"
     #include "wx/app.h"
     #include "wx/intl.h"
     #include "wx/log.h"
+    #include "wx/timer.h"
 #endif  //WX_PRECOMP
 
 #endif  //WX_PRECOMP
 
+#include "wx/msw/registry.h"
 #include "wx/apptrait.h"
 #include "wx/dynlib.h"
 #include "wx/dynload.h"
 #include "wx/apptrait.h"
 #include "wx/dynlib.h"
 #include "wx/dynload.h"
@@ -54,8 +56,6 @@
     #include <winsock.h>
 #endif
 
     #include <winsock.h>
 #endif
 
-#include "wx/timer.h"
-
 #if !defined(__GNUWIN32__) && !defined(__SALFORDC__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
     #include <direct.h>
 
 #if !defined(__GNUWIN32__) && !defined(__SALFORDC__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
     #include <direct.h>
 
 // ----------------------------------------------------------------------------
 
 // In the WIN.INI file
 // ----------------------------------------------------------------------------
 
 // In the WIN.INI file
+#if (!defined(USE_NET_API) && !defined(__WXWINCE__)) || defined(__WXMICROWIN__)
 static const wxChar WX_SECTION[] = wxT("wxWindows");
 static const wxChar WX_SECTION[] = wxT("wxWindows");
+#endif
+
+#if (!defined(USE_NET_API) && !defined(__WXWINCE__))
 static const wxChar eUSERNAME[]  = wxT("UserName");
 static const wxChar eUSERNAME[]  = wxT("UserName");
+#endif
 
 // ============================================================================
 // implementation
 
 // ============================================================================
 // implementation
@@ -262,8 +267,8 @@ bool wxGetUserId(wxChar *WXUNUSED_IN_WINCE(buf),
 
     // Can't assume we have NIS (PC-NFS) or some other ID daemon
     // So we ...
 
     // Can't assume we have NIS (PC-NFS) or some other ID daemon
     // So we ...
-    if (  (user = wxGetenv(wxT("USER"))) == NULL &&
-            (user = wxGetenv(wxT("LOGNAME"))) == NULL )
+    if ( (user = wxGetenv(wxT("USER"))) == NULL &&
+         (user = wxGetenv(wxT("LOGNAME"))) == NULL )
     {
         // Use wxWidgets configuration data (comming soon)
         GetProfileString(WX_SECTION, eUSERID, default_id, buf, maxSize - 1);
     {
         // Use wxWidgets configuration data (comming soon)
         GetProfileString(WX_SECTION, eUSERID, default_id, buf, maxSize - 1);
@@ -278,12 +283,21 @@ bool wxGetUserId(wxChar *WXUNUSED_IN_WINCE(buf),
 }
 
 // Get user name e.g. Julian Smart
 }
 
 // Get user name e.g. Julian Smart
-bool wxGetUserName(wxChar *WXUNUSED_IN_WINCE(buf),
-                   int WXUNUSED_IN_WINCE(maxSize))
+bool wxGetUserName(wxChar *buf, int maxSize)
 {
 {
+    wxCHECK_MSG( buf && ( maxSize > 0 ), false,
+                    _T("empty buffer in wxGetUserName") );
 #if defined(__WXWINCE__)
 #if defined(__WXWINCE__)
-    // TODO-CE
-    return false;
+    wxLogNull noLog;
+    wxRegKey key(wxRegKey::HKCU, wxT("ControlPanel\\Owner"));
+    if(!key.Open(wxRegKey::Read))
+        return false;
+    wxString name;
+    if(!key.QueryValue(wxT("Owner"),name))
+        return false;
+    wxStrncpy(buf, name.c_str(), maxSize-1);
+    buf[maxSize-1] = _T('\0');
+    return true;
 #elif defined(USE_NET_API)
     CHAR szUserName[256];
     if ( !wxGetUserId(szUserName, WXSIZEOF(szUserName)) )
 #elif defined(USE_NET_API)
     CHAR szUserName[256];
     if ( !wxGetUserId(szUserName, WXSIZEOF(szUserName)) )
@@ -465,8 +479,8 @@ wxChar *wxGetUserHome(const wxString& WXUNUSED(user))
 }
 
 bool wxGetDiskSpace(const wxString& WXUNUSED_IN_WINCE(path),
 }
 
 bool wxGetDiskSpace(const wxString& WXUNUSED_IN_WINCE(path),
-                    wxLongLong *WXUNUSED_IN_WINCE(pTotal),
-                    wxLongLong *WXUNUSED_IN_WINCE(pFree))
+                    wxDiskspaceSize_t *WXUNUSED_IN_WINCE(pTotal),
+                    wxDiskspaceSize_t *WXUNUSED_IN_WINCE(pFree))
 {
 #ifdef __WXWINCE__
     // TODO-CE
 {
 #ifdef __WXWINCE__
     // TODO-CE
@@ -521,12 +535,20 @@ bool wxGetDiskSpace(const wxString& WXUNUSED_IN_WINCE(path),
 #endif
         if ( pTotal )
         {
 #endif
         if ( pTotal )
         {
-            *pTotal = wxLongLong(UL(bytesTotal).HighPart, UL(bytesTotal).LowPart);
+#if wxUSE_LONGLONG
+            *pTotal = wxDiskspaceSize_t(UL(bytesTotal).HighPart, UL(bytesTotal).LowPart);
+#else
+            *pTotal = wxDiskspaceSize_t(UL(bytesTotal).LowPart);
+#endif
         }
 
         if ( pFree )
         {
         }
 
         if ( pFree )
         {
+#if wxUSE_LONGLONG
             *pFree = wxLongLong(UL(bytesFree).HighPart, UL(bytesFree).LowPart);
             *pFree = wxLongLong(UL(bytesFree).HighPart, UL(bytesFree).LowPart);
+#else
+            *pFree = wxDiskspaceSize_t(UL(bytesFree).LowPart);
+#endif
         }
     }
     else
         }
     }
     else
@@ -554,7 +576,7 @@ bool wxGetDiskSpace(const wxString& WXUNUSED_IN_WINCE(path),
             return false;
         }
 
             return false;
         }
 
-        wxLongLong lBytesPerCluster = lSectorsPerCluster;
+        wxDiskspaceSize_t lBytesPerCluster = (wxDiskspaceSize_t) lSectorsPerCluster;
         lBytesPerCluster *= lBytesPerSector;
 
         if ( pTotal )
         lBytesPerCluster *= lBytesPerSector;
 
         if ( pTotal )
@@ -825,6 +847,8 @@ static void InitToolHelp32()
     lpfProcess32First = NULL;
     lpfProcess32Next = NULL;
 
     lpfProcess32First = NULL;
     lpfProcess32Next = NULL;
 
+#if wxUSE_DYNLIB_CLASS
+
     wxDynamicLibrary dllKernel(_T("kernel32.dll"), wxDL_VERBATIM);
 
     // Get procedure addresses.
     wxDynamicLibrary dllKernel(_T("kernel32.dll"), wxDL_VERBATIM);
 
     // Get procedure addresses.
@@ -841,6 +865,8 @@ static void InitToolHelp32()
 
     lpfProcess32Next =
         (Process32_t)dllKernel.RawGetSymbol(_T("Process32Next"));
 
     lpfProcess32Next =
         (Process32_t)dllKernel.RawGetSymbol(_T("Process32Next"));
+
+#endif // wxUSE_DYNLIB_CLASS
 }
 
 // By John Skiff
 }
 
 // By John Skiff
@@ -977,18 +1003,6 @@ bool wxShutdown(wxShutdownFlags WXUNUSED_IN_WINCE(wFlags))
 #endif // Win32/16
 }
 
 #endif // Win32/16
 }
 
-wxPowerType wxGetPowerType()
-{
-    // TODO
-    return wxPOWER_UNKNOWN;
-}
-
-wxBatteryState wxGetBatteryState()
-{
-    // TODO
-    return wxBATTERY_UNKNOWN_STATE;
-}
-
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------
@@ -1055,6 +1069,13 @@ wxString wxGetOsDescription()
     {
         switch ( info.dwPlatformId )
         {
     {
         switch ( info.dwPlatformId )
         {
+#ifdef VER_PLATFORM_WIN32_CE
+            case VER_PLATFORM_WIN32_CE:
+                str.Printf(_("Windows CE (%d.%d)"),
+                           info.dwMajorVersion,
+                           info.dwMinorVersion);
+                break;
+#endif
             case VER_PLATFORM_WIN32s:
                 str = _("Win32s on Windows 3.1");
                 break;
             case VER_PLATFORM_WIN32s:
                 str = _("Win32s on Windows 3.1");
                 break;
@@ -1118,7 +1139,7 @@ wxString wxGetOsDescription()
                             break;
                     }
                 }
                             break;
                     }
                 }
-                if ( wxIsEmpty(str) )
+                if ( str.empty() )
                 {
                     str.Printf(_("Windows NT %lu.%lu (build %lu"),
                            info.dwMajorVersion,
                 {
                     str.Printf(_("Windows NT %lu.%lu (build %lu"),
                            info.dwMajorVersion,
@@ -1540,4 +1561,3 @@ wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc)
 
     return hwnd;
 }
 
     return hwnd;
 }
-