]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/utils.cpp
02d4de03246a0a320bfc8b0cd4e3bdfd7375ee6c
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: palmos/utils.cpp
3 // Purpose: Various utilities
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
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 // ----------------------------------------------------------------------------
156 // ----------------------------------------------------------------------------
158 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
159 wxMemorySize
wxGetFreeMemory()
161 uint32_t freeTotal
= 0;
165 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
166 for ( uint16_t i
=0; i
<MemNumRAMHeaps(); i
++)
168 status_t err
= MemHeapFreeBytes(i
, &freeHeap
, &freeChunk
);
174 return (wxMemorySize
)freeTotal
;
177 unsigned long wxGetProcessId()
185 SndPlaySystemSound(sndWarning
);
188 wxString
wxGetOsDescription()
190 wxString strOS
= _T("PalmOS");
192 char *version
= SysGetOSVersionString();
195 wxString str
= wxString::FromAscii(version
);
198 strOS
<< _(" ") << str
;
205 wxToolkitInfo
& wxAppTraits::GetToolkitInfo()
207 static wxToolkitInfo info
;
208 info
.name
= _T("wxBase");
212 // ----------------------------------------------------------------------------
214 // ----------------------------------------------------------------------------
216 void wxMilliSleep(unsigned long milliseconds
)
220 void wxMicroSleep(unsigned long microseconds
)
224 void wxSleep(int nSecs
)
228 // ----------------------------------------------------------------------------
229 // font encoding <-> Win32 codepage conversion functions
230 // ----------------------------------------------------------------------------
232 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
237 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
238 // looks up the vlaues in the registry and the new one which is more
239 // politically correct and has more chances to work on other Windows versions
240 // as well but the old version is still needed for !wxUSE_FONTMAP case
243 #include "wx/fontmap.h"
245 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
250 extern long wxCharsetToCodepage(const wxChar
*name
)
255 #else // !wxUSE_FONTMAP
257 // this should work if Internet Exploiter is installed
258 extern long wxCharsetToCodepage(const wxChar
*name
)
263 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP