]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/utils.cpp
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()
195 wxToolkitInfo
& wxAppTraits::GetToolkitInfo()
197 static wxToolkitInfo info
;
198 info
.name
= _T("wxBase");
202 // ----------------------------------------------------------------------------
204 // ----------------------------------------------------------------------------
206 void wxMilliSleep(unsigned long milliseconds
)
210 void wxMicroSleep(unsigned long microseconds
)
214 void wxSleep(int nSecs
)
218 // ----------------------------------------------------------------------------
219 // font encoding <-> Win32 codepage conversion functions
220 // ----------------------------------------------------------------------------
222 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
227 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
228 // looks up the vlaues in the registry and the new one which is more
229 // politically correct and has more chances to work on other Windows versions
230 // as well but the old version is still needed for !wxUSE_FONTMAP case
233 #include "wx/fontmap.h"
235 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
240 extern long wxCharsetToCodepage(const wxChar
*name
)
245 #else // !wxUSE_FONTMAP
247 // this should work if Internet Exploiter is installed
248 extern long wxCharsetToCodepage(const wxChar
*name
)
253 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP