]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/utils.cpp
3 // Purpose: Various utilities
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - real functionality
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
34 #include "wx/apptrait.h"
35 #include "wx/dynload.h"
36 #include "wx/confbase.h"
39 #include <MemoryMgr.h>
43 // ============================================================================
45 // ============================================================================
47 // ----------------------------------------------------------------------------
48 // get host name and related
49 // ----------------------------------------------------------------------------
51 // Get hostname only (without domain name)
52 bool wxGetHostName(wxChar
*buf
, int maxSize
)
57 // get full hostname (with domain name if possible)
58 bool wxGetFullHostName(wxChar
*buf
, int maxSize
)
63 // Get user ID e.g. jacs
64 bool wxGetUserId(wxChar
*buf
, int maxSize
)
66 return wxGetUserName(buf
, maxSize
);
69 // Get user name e.g. Julian Smart
70 bool wxGetUserName(wxChar
*buf
, int maxSize
)
75 MemHandle handle
= MemHandleNew(maxSize
-1);
80 char *id
= (char *)MemHandleLock(handle
);
85 if( DlkGetSyncInfo(NULL
, NULL
, NULL
, id
, NULL
, NULL
) != errNone
)
91 wxStrncpy (buf
, wxConvertMB2WX(id
), maxSize
- 1);
99 const wxChar
* wxGetHomeDir(wxString
*pstr
)
104 wxChar
*wxGetUserHome(const wxString
& WXUNUSED(user
))
109 bool wxDirExists(const wxString
& dir
)
114 bool wxGetDiskSpace(const wxString
& path
, wxLongLong
*pTotal
, wxLongLong
*pFree
)
119 // ----------------------------------------------------------------------------
121 // ----------------------------------------------------------------------------
123 bool wxGetEnv(const wxString
& var
, wxString
*value
)
128 bool wxSetEnv(const wxString
& var
, const wxChar
*value
)
133 // ----------------------------------------------------------------------------
134 // process management
135 // ----------------------------------------------------------------------------
137 int wxKill(long pid
, wxSignal sig
, wxKillError
*krc
, int flags
)
142 // Execute a program in an Interactive Shell
143 bool wxShell(const wxString
& command
)
148 // Shutdown or reboot the PC
149 bool wxShutdown(wxShutdownFlags wFlags
)
154 wxPowerType
wxGetPowerType()
156 return wxPOWER_BATTERY
;
159 wxBatteryState
wxGetBatteryState()
162 return wxBATTERY_UNKNOWN_STATE
;
165 // ----------------------------------------------------------------------------
167 // ----------------------------------------------------------------------------
169 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
170 wxMemorySize
wxGetFreeMemory()
172 uint32_t freeTotal
= 0;
176 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
177 for ( uint16_t i
=0; i
<MemNumRAMHeaps(); i
++)
179 status_t err
= MemHeapFreeBytes(i
, &freeHeap
, &freeChunk
);
185 return (wxMemorySize
)freeTotal
;
188 unsigned long wxGetProcessId()
196 SndPlaySystemSound(sndWarning
);
199 wxString
wxGetOsDescription()
201 wxString strOS
= _T("PalmOS");
203 char *version
= SysGetOSVersionString();
206 wxString str
= wxString::FromAscii(version
);
210 strOS
<< _(" ") << str
;
217 wxToolkitInfo
& wxAppTraits::GetToolkitInfo()
219 static wxToolkitInfo info
;
220 info
.name
= _T("wxBase");
224 // ----------------------------------------------------------------------------
226 // ----------------------------------------------------------------------------
228 void wxMilliSleep(unsigned long milliseconds
)
232 void wxMicroSleep(unsigned long microseconds
)
236 void wxSleep(int nSecs
)
240 // ----------------------------------------------------------------------------
241 // font encoding <-> Win32 codepage conversion functions
242 // ----------------------------------------------------------------------------
244 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
249 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
250 // looks up the vlaues in the registry and the new one which is more
251 // politically correct and has more chances to work on other Windows versions
252 // as well but the old version is still needed for !wxUSE_FONTMAP case
255 #include "wx/fontmap.h"
257 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
262 extern long wxCharsetToCodepage(const wxChar
*name
)
267 #else // !wxUSE_FONTMAP
269 // this should work if Internet Exploiter is installed
270 extern long wxCharsetToCodepage(const wxChar
*name
)
275 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP