]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/utils.cpp
define WM_CONTEXTMENU if the standard headers don't
[wxWidgets.git] / src / palmos / utils.cpp
CommitLineData
ffecfa5a 1/////////////////////////////////////////////////////////////////////////////
6929fe3a 2// Name: src/palmos/utils.cpp
ffecfa5a 3// Purpose: Various utilities
6929fe3a
WS
4// Author: William Osborne - minimal working wxPalmOS port
5// Modified by: Wlodzimierz ABX Skiba - real functionality
ffecfa5a 6// Created: 10/13/04
6929fe3a
WS
7// RCS-ID: $Id$
8// Copyright: (c) William Osborne, Wlodzimierz Skiba
ffecfa5a
JS
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#endif //WX_PRECOMP
33
34#include "wx/apptrait.h"
35#include "wx/dynload.h"
d1df2399 36#include "wx/confbase.h"
ffecfa5a
JS
37#include "wx/timer.h"
38
d1df2399
WS
39#include <MemoryMgr.h>
40#include <DLServer.h>
41#include <SoundMgr.h>
ffecfa5a
JS
42
43// ============================================================================
44// implementation
45// ============================================================================
46
47// ----------------------------------------------------------------------------
48// get host name and related
49// ----------------------------------------------------------------------------
50
51// Get hostname only (without domain name)
52bool wxGetHostName(wxChar *buf, int maxSize)
53{
54 return false;
55}
56
57// get full hostname (with domain name if possible)
58bool wxGetFullHostName(wxChar *buf, int maxSize)
59{
60 return false;
61}
62
63// Get user ID e.g. jacs
64bool wxGetUserId(wxChar *buf, int maxSize)
65{
d1df2399 66 return wxGetUserName(buf, maxSize);
ffecfa5a
JS
67}
68
69// Get user name e.g. Julian Smart
70bool wxGetUserName(wxChar *buf, int maxSize)
71{
d1df2399
WS
72 *buf = wxT('\0');
73
74 // buffer allocation
75 MemHandle handle = MemHandleNew(maxSize-1);
76 if( handle == NULL )
77 return false;
78
79 // lock the buffer
80 char *id = (char *)MemHandleLock(handle);
81 if( id == NULL )
82 return false;
83
84 // get user's name
85 if( DlkGetSyncInfo(NULL, NULL, NULL, id, NULL, NULL) != errNone )
86 {
87 MemPtrUnlock(id);
88 return false;
89 }
90
91 wxStrncpy (buf, wxConvertMB2WX(id), maxSize - 1);
92
9d8aca48 93 // free the buffer
d1df2399
WS
94 MemPtrUnlock(id);
95
96 return true;
ffecfa5a
JS
97}
98
99const wxChar* wxGetHomeDir(wxString *pstr)
100{
101 return NULL;
102}
103
104wxChar *wxGetUserHome(const wxString& WXUNUSED(user))
105{
106 return NULL;
107}
108
ffecfa5a
JS
109bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
110{
111 return false;
112}
113
114// ----------------------------------------------------------------------------
115// env vars
116// ----------------------------------------------------------------------------
117
118bool wxGetEnv(const wxString& var, wxString *value)
119{
120 return false;
121}
122
123bool wxSetEnv(const wxString& var, const wxChar *value)
124{
125 return false;
126}
127
128// ----------------------------------------------------------------------------
129// process management
130// ----------------------------------------------------------------------------
131
e0f6b731 132int wxKill(long pid, wxSignal sig, wxKillError *krc, int flags)
ffecfa5a
JS
133{
134 return 0;
135}
136
137// Execute a program in an Interactive Shell
138bool wxShell(const wxString& command)
139{
140 return false;
141}
142
143// Shutdown or reboot the PC
144bool wxShutdown(wxShutdownFlags wFlags)
145{
146 return false;
147}
148
8ea92b4d
WS
149wxPowerType wxGetPowerType()
150{
151 return wxPOWER_BATTERY;
152}
153
154wxBatteryState wxGetBatteryState()
155{
156 // TODO
157 return wxBATTERY_UNKNOWN_STATE;
158}
159
ffecfa5a
JS
160// ----------------------------------------------------------------------------
161// misc
162// ----------------------------------------------------------------------------
163
164// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
9d8aca48 165wxMemorySize wxGetFreeMemory()
ffecfa5a 166{
d1df2399
WS
167 uint32_t freeTotal = 0;
168 uint32_t freeHeap;
169 uint32_t freeChunk;
170
171 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
172 for ( uint16_t i=0; i<MemNumRAMHeaps(); i++)
173 {
174 status_t err = MemHeapFreeBytes(i, &freeHeap, &freeChunk);
175 if( err != errNone )
176 return -1;
177 freeTotal+=freeHeap;
178 }
179
9d8aca48 180 return (wxMemorySize)freeTotal;
ffecfa5a
JS
181}
182
183unsigned long wxGetProcessId()
184{
185 return 0;
186}
187
188// Emit a beeeeeep
189void wxBell()
190{
d1df2399 191 SndPlaySystemSound(sndWarning);
ffecfa5a
JS
192}
193
194wxString wxGetOsDescription()
195{
cc2c11e2 196 wxString strOS = _T("PalmOS");
ffecfa5a 197
cc2c11e2
WS
198 char *version = SysGetOSVersionString();
199 if(version)
200 {
201 wxString str = wxString::FromAscii(version);
6929fe3a 202 MemPtrFree(version);
cc2c11e2
WS
203 if(!str.empty())
204 {
205 strOS << _(" ") << str;
206 }
207 }
208
209 return strOS;
ffecfa5a
JS
210}
211
212wxToolkitInfo& wxAppTraits::GetToolkitInfo()
213{
214 static wxToolkitInfo info;
215 info.name = _T("wxBase");
216 return info;
217}
218
219// ----------------------------------------------------------------------------
220// sleep functions
221// ----------------------------------------------------------------------------
222
223void wxMilliSleep(unsigned long milliseconds)
224{
225}
226
227void wxMicroSleep(unsigned long microseconds)
228{
229}
230
231void wxSleep(int nSecs)
232{
233}
234
235// ----------------------------------------------------------------------------
236// font encoding <-> Win32 codepage conversion functions
237// ----------------------------------------------------------------------------
238
239extern WXDLLIMPEXP_BASE long wxEncodingToCharset(wxFontEncoding encoding)
240{
241 return 0;
242}
243
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
248#if wxUSE_FONTMAP
249
250#include "wx/fontmap.h"
251
252extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding)
253{
254 return 0;
255}
256
257extern long wxCharsetToCodepage(const wxChar *name)
258{
259 return 0;
260}
261
262#else // !wxUSE_FONTMAP
263
ffecfa5a
JS
264// this should work if Internet Exploiter is installed
265extern long wxCharsetToCodepage(const wxChar *name)
266{
267 return 0;
268}
269
270#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
271