]>
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>
44 // ============================================================================
46 // ============================================================================
48 // ----------------------------------------------------------------------------
49 // get host name and related
50 // ----------------------------------------------------------------------------
52 // Get hostname only (without domain name)
53 bool wxGetHostName(wxChar
*buf
, int maxSize
)
58 // get full hostname (with domain name if possible)
59 bool wxGetFullHostName(wxChar
*buf
, int maxSize
)
64 // Get user ID e.g. jacs
65 bool wxGetUserId(wxChar
*buf
, int maxSize
)
67 return wxGetUserName(buf
, maxSize
);
70 // Get user name e.g. Julian Smart
71 bool wxGetUserName(wxChar
*buf
, int maxSize
)
76 MemHandle handle
= MemHandleNew(maxSize
-1);
81 char *id
= (char *)MemHandleLock(handle
);
86 if( DlkGetSyncInfo(NULL
, NULL
, NULL
, id
, NULL
, NULL
) != errNone
)
92 wxStrncpy (buf
, wxConvertMB2WX(id
), maxSize
- 1);
100 const wxChar
* wxGetHomeDir(wxString
*pstr
)
105 wxChar
*wxGetUserHome(const wxString
& WXUNUSED(user
))
110 bool wxGetDiskSpace(const wxString
& path
, wxDiskspaceSize_t
*pTotal
, wxDiskspaceSize_t
*pFree
)
115 // ----------------------------------------------------------------------------
117 // ----------------------------------------------------------------------------
119 bool wxGetEnv(const wxString
& var
, wxString
*value
)
124 bool wxSetEnv(const wxString
& var
, const wxChar
*value
)
129 // ----------------------------------------------------------------------------
130 // process management
131 // ----------------------------------------------------------------------------
133 int wxKill(long pid
, wxSignal sig
, wxKillError
*krc
, int flags
)
138 // Execute a program in an Interactive Shell
139 bool wxShell(const wxString
& command
)
144 // Shutdown or reboot the PC
145 bool wxShutdown(wxShutdownFlags wFlags
)
150 wxPowerType
wxGetPowerType()
152 return wxPOWER_BATTERY
;
155 wxBatteryState
wxGetBatteryState()
158 return wxBATTERY_UNKNOWN_STATE
;
161 // ----------------------------------------------------------------------------
163 // ----------------------------------------------------------------------------
165 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
166 wxMemorySize
wxGetFreeMemory()
168 uint32_t freeTotal
= 0;
172 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
173 for ( uint16_t i
=0; i
<MemNumRAMHeaps(); i
++)
175 status_t err
= MemHeapFreeBytes(i
, &freeHeap
, &freeChunk
);
181 return (wxMemorySize
)freeTotal
;
184 unsigned long wxGetProcessId()
192 SndPlaySystemSound(sndWarning
);
195 wxString
wxGetOsDescription()
197 wxString strOS
= _T("PalmOS");
199 char *version
= SysGetOSVersionString();
202 wxString str
= wxString::FromAscii(version
);
206 strOS
<< _(" ") << str
;
213 wxToolkitInfo
& wxAppTraits::GetToolkitInfo()
215 static wxToolkitInfo info
;
217 info
.name
= _T("wxBase");
221 // ----------------------------------------------------------------------------
223 // ----------------------------------------------------------------------------
225 void wxMilliSleep(unsigned long milliseconds
)
229 void wxMicroSleep(unsigned long microseconds
)
233 void wxSleep(int nSecs
)
237 // ----------------------------------------------------------------------------
238 // font encoding <-> Win32 codepage conversion functions
239 // ----------------------------------------------------------------------------
241 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
246 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
247 // looks up the vlaues in the registry and the new one which is more
248 // politically correct and has more chances to work on other Windows versions
249 // as well but the old version is still needed for !wxUSE_FONTMAP case
252 #include "wx/fontmap.h"
254 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
259 extern long wxCharsetToCodepage(const wxChar
*name
)
264 #else // !wxUSE_FONTMAP
266 // this should work if Internet Exploiter is installed
267 extern long wxCharsetToCodepage(const wxChar
*name
)
272 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP