]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/utils.cpp
Also need to override Show
[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, wxConvertMB2WX(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 // ----------------------------------------------------------------------------
131 // process management
132 // ----------------------------------------------------------------------------
133
134 int wxKill(long pid, wxSignal sig, wxKillError *krc, int flags)
135 {
136 return 0;
137 }
138
139 // Execute a program in an Interactive Shell
140 bool wxShell(const wxString& command)
141 {
142 return false;
143 }
144
145 // Shutdown or reboot the PC
146 bool wxShutdown(wxShutdownFlags wFlags)
147 {
148 return false;
149 }
150
151 // ----------------------------------------------------------------------------
152 // power management
153 // ----------------------------------------------------------------------------
154
155 wxPowerType wxGetPowerType()
156 {
157 return wxPOWER_BATTERY;
158 }
159
160 wxBatteryState wxGetBatteryState()
161 {
162 // TODO
163 return wxBATTERY_UNKNOWN_STATE;
164 }
165
166 // ----------------------------------------------------------------------------
167 // misc
168 // ----------------------------------------------------------------------------
169
170 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
171 wxMemorySize wxGetFreeMemory()
172 {
173 uint32_t freeTotal = 0;
174 uint32_t freeHeap;
175 uint32_t freeChunk;
176
177 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
178 for ( uint16_t i=0; i<MemNumRAMHeaps(); i++)
179 {
180 status_t err = MemHeapFreeBytes(i, &freeHeap, &freeChunk);
181 if( err != errNone )
182 return -1;
183 freeTotal+=freeHeap;
184 }
185
186 return (wxMemorySize)freeTotal;
187 }
188
189 unsigned long wxGetProcessId()
190 {
191 return 0;
192 }
193
194 // Emit a beeeeeep
195 void wxBell()
196 {
197 SndPlaySystemSound(sndWarning);
198 }
199
200 wxString wxGetOsDescription()
201 {
202 wxString strOS = _T("PalmOS");
203
204 char *version = SysGetOSVersionString();
205 if(version)
206 {
207 wxString str = wxString::FromAscii(version);
208 MemPtrFree(version);
209 if(!str.empty())
210 {
211 strOS << _(" ") << str;
212 }
213 }
214
215 return strOS;
216 }
217
218 wxToolkitInfo& wxAppTraits::GetToolkitInfo()
219 {
220 static wxToolkitInfo info;
221 info.os = wxPALMOS;
222 info.name = _T("wxBase");
223 return info;
224 }
225
226 // ----------------------------------------------------------------------------
227 // sleep functions
228 // ----------------------------------------------------------------------------
229
230 void wxMilliSleep(unsigned long milliseconds)
231 {
232 }
233
234 void wxMicroSleep(unsigned long microseconds)
235 {
236 }
237
238 void wxSleep(int nSecs)
239 {
240 }
241
242 // ----------------------------------------------------------------------------
243 // font encoding <-> Win32 codepage conversion functions
244 // ----------------------------------------------------------------------------
245
246 extern WXDLLIMPEXP_BASE long wxEncodingToCharset(wxFontEncoding encoding)
247 {
248 return 0;
249 }
250
251 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
252 // looks up the vlaues in the registry and the new one which is more
253 // politically correct and has more chances to work on other Windows versions
254 // as well but the old version is still needed for !wxUSE_FONTMAP case
255 #if wxUSE_FONTMAP
256
257 #include "wx/fontmap.h"
258
259 extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding)
260 {
261 return 0;
262 }
263
264 extern long wxCharsetToCodepage(const wxChar *name)
265 {
266 return 0;
267 }
268
269 #else // !wxUSE_FONTMAP
270
271 // this should work if Internet Exploiter is installed
272 extern long wxCharsetToCodepage(const wxChar *name)
273 {
274 return 0;
275 }
276
277 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP