]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/utils.cpp
update button style to include BS_MULTILINE when a multiline label is set
[wxWidgets.git] / 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
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #include "wx/utils.h"
29 #include "wx/app.h"
30 #include "wx/intl.h"
31 #include "wx/log.h"
32 #include "wx/timer.h"
33 #endif //WX_PRECOMP
34
35 #include "wx/apptrait.h"
36 #include "wx/dynload.h"
37 #include "wx/confbase.h"
38 #include "wx/power.h"
39
40 #include <MemoryMgr.h>
41 #include <DLServer.h>
42 #include <SoundMgr.h>
43 #include <SysUtils.h>
44
45 // ============================================================================
46 // implementation
47 // ============================================================================
48
49 // ----------------------------------------------------------------------------
50 // get host name and related
51 // ----------------------------------------------------------------------------
52
53 // Get hostname only (without domain name)
54 bool wxGetHostName(wxChar *buf, int maxSize)
55 {
56 return false;
57 }
58
59 // get full hostname (with domain name if possible)
60 bool wxGetFullHostName(wxChar *buf, int maxSize)
61 {
62 return false;
63 }
64
65 // Get user ID e.g. jacs
66 bool wxGetUserId(wxChar *buf, int maxSize)
67 {
68 return wxGetUserName(buf, maxSize);
69 }
70
71 // Get user name e.g. Julian Smart
72 bool wxGetUserName(wxChar *buf, int maxSize)
73 {
74 *buf = wxT('\0');
75
76 // buffer allocation
77 MemHandle handle = MemHandleNew(maxSize-1);
78 if( handle == NULL )
79 return false;
80
81 // lock the buffer
82 char *id = (char *)MemHandleLock(handle);
83 if( id == NULL )
84 return false;
85
86 // get user's name
87 if( DlkGetSyncInfo(NULL, NULL, NULL, id, NULL, NULL) != errNone )
88 {
89 MemPtrUnlock(id);
90 return false;
91 }
92
93 wxStrncpy (buf, wxSafeConvertMB2WX(id), maxSize - 1);
94
95 // free the buffer
96 MemPtrUnlock(id);
97
98 return true;
99 }
100
101 const wxChar* wxGetHomeDir(wxString *pstr)
102 {
103 return NULL;
104 }
105
106 wxChar *wxGetUserHome(const wxString& WXUNUSED(user))
107 {
108 return NULL;
109 }
110
111 bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree)
112 {
113 return false;
114 }
115
116 // ----------------------------------------------------------------------------
117 // env vars
118 // ----------------------------------------------------------------------------
119
120 bool wxGetEnv(const wxString& var, wxString *value)
121 {
122 return false;
123 }
124
125 bool wxSetEnv(const wxString& var, const wxChar *value)
126 {
127 return false;
128 }
129
130 bool wxUnsetEnv(const wxString& var)
131 {
132 return false;
133 }
134
135 // ----------------------------------------------------------------------------
136 // process management
137 // ----------------------------------------------------------------------------
138
139 int wxKill(long pid, wxSignal sig, wxKillError *krc, int flags)
140 {
141 return 0;
142 }
143
144 // Execute a program in an Interactive Shell
145 bool wxShell(const wxString& command)
146 {
147 return false;
148 }
149
150 // Shutdown or reboot the PC
151 bool wxShutdown(wxShutdownFlags wFlags)
152 {
153 return false;
154 }
155
156 // ----------------------------------------------------------------------------
157 // power management
158 // ----------------------------------------------------------------------------
159
160 wxPowerType wxGetPowerType()
161 {
162 return wxPOWER_BATTERY;
163 }
164
165 wxBatteryState wxGetBatteryState()
166 {
167 // TODO
168 return wxBATTERY_UNKNOWN_STATE;
169 }
170
171 // ----------------------------------------------------------------------------
172 // misc
173 // ----------------------------------------------------------------------------
174
175 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
176 wxMemorySize wxGetFreeMemory()
177 {
178 uint32_t freeTotal = 0;
179 uint32_t freeHeap;
180 uint32_t freeChunk;
181
182 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
183 for ( uint16_t i=0; i<MemNumRAMHeaps(); i++)
184 {
185 status_t err = MemHeapFreeBytes(i, &freeHeap, &freeChunk);
186 if( err != errNone )
187 return -1;
188 freeTotal+=freeHeap;
189 }
190
191 return (wxMemorySize)freeTotal;
192 }
193
194 unsigned long wxGetProcessId()
195 {
196 return 0;
197 }
198
199 // Emit a beeeeeep
200 void wxBell()
201 {
202 SndPlaySystemSound(sndWarning);
203 }
204
205 bool wxIsPlatform64Bit()
206 {
207 return false;
208 }
209
210 wxString wxGetOsDescription()
211 {
212 wxString strOS = _T("PalmOS");
213
214 char *version = SysGetOSVersionString();
215 if(version)
216 {
217 wxString str = wxString::FromAscii(version);
218 MemPtrFree(version);
219 if(!str.empty())
220 {
221 strOS << _(" ") << str;
222 }
223 }
224
225 return strOS;
226 }
227
228 wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
229 {
230 // TODO
231
232 return wxOS_UNKNOWN;
233 }
234
235 // ----------------------------------------------------------------------------
236 // sleep functions
237 // ----------------------------------------------------------------------------
238
239 void wxMilliSleep(unsigned long milliseconds)
240 {
241 }
242
243 void wxMicroSleep(unsigned long microseconds)
244 {
245 }
246
247 void wxSleep(int nSecs)
248 {
249 }
250
251 // ----------------------------------------------------------------------------
252 // font encoding <-> Win32 codepage conversion functions
253 // ----------------------------------------------------------------------------
254
255 extern WXDLLIMPEXP_BASE long wxEncodingToCharset(wxFontEncoding encoding)
256 {
257 return 0;
258 }
259
260 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
261 // looks up the vlaues in the registry and the new one which is more
262 // politically correct and has more chances to work on other Windows versions
263 // as well but the old version is still needed for !wxUSE_FONTMAP case
264 #if wxUSE_FONTMAP
265
266 #include "wx/fontmap.h"
267
268 extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding)
269 {
270 return 0;
271 }
272
273 extern long wxCharsetToCodepage(const wxChar *name)
274 {
275 return 0;
276 }
277
278 #else // !wxUSE_FONTMAP
279
280 // this should work if Internet Exploiter is installed
281 extern long wxCharsetToCodepage(const wxChar *name)
282 {
283 return 0;
284 }
285
286 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP