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