]>
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 wxGetDiskSpace(const wxString
& path
, wxLongLong
*pTotal
, wxLongLong
*pFree
)
114 // ----------------------------------------------------------------------------
116 // ----------------------------------------------------------------------------
118 bool wxGetEnv(const wxString
& var
, wxString
*value
)
123 bool wxSetEnv(const wxString
& var
, const wxChar
*value
)
128 // ----------------------------------------------------------------------------
129 // process management
130 // ----------------------------------------------------------------------------
132 int wxKill(long pid
, wxSignal sig
, wxKillError
*krc
, int flags
)
137 // Execute a program in an Interactive Shell
138 bool wxShell(const wxString
& command
)
143 // Shutdown or reboot the PC
144 bool wxShutdown(wxShutdownFlags wFlags
)
149 wxPowerType
wxGetPowerType()
151 return wxPOWER_BATTERY
;
154 wxBatteryState
wxGetBatteryState()
157 return wxBATTERY_UNKNOWN_STATE
;
160 // ----------------------------------------------------------------------------
162 // ----------------------------------------------------------------------------
164 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
165 wxMemorySize
wxGetFreeMemory()
167 uint32_t freeTotal
= 0;
171 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
172 for ( uint16_t i
=0; i
<MemNumRAMHeaps(); i
++)
174 status_t err
= MemHeapFreeBytes(i
, &freeHeap
, &freeChunk
);
180 return (wxMemorySize
)freeTotal
;
183 unsigned long wxGetProcessId()
191 SndPlaySystemSound(sndWarning
);
194 wxString
wxGetOsDescription()
196 wxString strOS
= _T("PalmOS");
198 char *version
= SysGetOSVersionString();
201 wxString str
= wxString::FromAscii(version
);
205 strOS
<< _(" ") << str
;
212 wxToolkitInfo
& wxAppTraits::GetToolkitInfo()
214 static wxToolkitInfo info
;
215 info
.name
= _T("wxBase");
219 // ----------------------------------------------------------------------------
221 // ----------------------------------------------------------------------------
223 void wxMilliSleep(unsigned long milliseconds
)
227 void wxMicroSleep(unsigned long microseconds
)
231 void wxSleep(int nSecs
)
235 // ----------------------------------------------------------------------------
236 // font encoding <-> Win32 codepage conversion functions
237 // ----------------------------------------------------------------------------
239 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
244 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
245 // looks up the vlaues in the registry and the new one which is more
246 // politically correct and has more chances to work on other Windows versions
247 // as well but the old version is still needed for !wxUSE_FONTMAP case
250 #include "wx/fontmap.h"
252 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
257 extern long wxCharsetToCodepage(const wxChar
*name
)
262 #else // !wxUSE_FONTMAP
264 // this should work if Internet Exploiter is installed
265 extern long wxCharsetToCodepage(const wxChar
*name
)
270 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP