]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/utils.cpp
allow to change the event propagation level (modified patch 743086)
[wxWidgets.git] / src / mgl / utils.cpp
CommitLineData
32b8ec41
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: utils.cpp
3// Purpose:
4// Author: Vaclav Slavik
5// Id: $Id$
c41c20a5 6// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
32b8ec41
VZ
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
a246f95e
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
32b8ec41
VZ
17#include "wx/utils.h"
18#include "wx/string.h"
19
20#include "wx/intl.h"
cd478a95 21#include "wx/apptrait.h"
32b8ec41 22#include "wx/log.h"
32b8ec41
VZ
23#include "wx/process.h"
24
25#include <stdarg.h>
26#include <string.h>
27#include <sys/stat.h>
28#include <sys/types.h>
29#include <unistd.h>
30#include <mgraph.hpp>
31
32#ifdef __UNIX__
33#include "wx/unix/execute.h"
34#endif
35
a4bbc9f7
VS
36#include "wx/mgl/private.h"
37
32b8ec41
VZ
38//----------------------------------------------------------------------------
39// misc.
40//----------------------------------------------------------------------------
41
42void wxBell()
43{
44 // FIXME_MGL
45}
46
9210a48a
VS
47
48#ifdef __DOS__
49// VS: this should be in utilsdos.cpp, but since there will hardly ever
50// be a non-MGL MS-DOS port...
51
52void wxSleep(int nSecs)
53{
54 wxUsleep(1000 * nSecs);
55}
56
57void wxUsleep(unsigned long milliseconds)
58{
59 PM_sleep(milliseconds);
60}
61
62
63bool wxGetEnv(const wxString& var, wxString *value)
64{
65 // wxGetenv is defined as getenv()
66 wxChar *p = wxGetenv(var);
67 if ( !p )
68 return FALSE;
69
70 if ( value )
71 *value = p;
72
73 return TRUE;
74}
75
76bool wxSetEnv(const wxString& variable, const wxChar *value)
77{
9210a48a
VS
78 wxString s = variable;
79 if ( value )
80 s << _T('=') << value;
81
82 // transform to ANSI
83 const char *p = s.mb_str();
84
85 // the string will be free()d by libc
86 char *buf = (char *)malloc(strlen(p) + 1);
87 strcpy(buf, p);
88
89 return putenv(buf) == 0;
9210a48a
VS
90}
91
92const wxChar* wxGetHomeDir(wxString *home)
93{
94 *home = wxT(".");
95 return home->c_str();
96}
97
98const wxChar* wxGetUserHomeDir(wxString *home)
99{
100 *home = wxT(".");
101 return home->c_str();
102}
103
104#if wxUSE_UNICODE
105const wxMB2WXbuf wxGetUserHome(const wxString &user)
106#else // just for binary compatibility -- there is no 'const' here
107wxChar *wxGetUserHome(const wxString &user)
108#endif
109{
110 return wxT(".");
111}
112
113void wxFatalError(const wxString &msg, const wxString &title)
114{
115 if (!title.IsNull())
116 wxFprintf( stderr, wxT("%s "), WXSTRINGCAST(title));
117 PM_fatalError(msg.c_str());
118}
119
120bool wxGetUserId(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
121{
122 wxFAIL_MSG( wxT("wxGetUserId not implemented under MS-DOS!") );
123 return FALSE;
124}
125
126bool wxGetUserName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
127{
128 wxFAIL_MSG( wxT("wxGetUserName not implemented under MS-DOS!") );
129 return FALSE;
130}
131
132bool wxGetHostName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
133{
134 wxFAIL_MSG( wxT("wxGetHostName not implemented under MS-DOS!") );
135 return FALSE;
136}
137
138bool wxGetFullHostName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
139{
140 wxFAIL_MSG( wxT("wxGetFullHostName not implemented under MS-DOS!") );
141 return FALSE;
142}
143
144int wxKill(long WXUNUSED(pid), wxSignal WXUNUSED(sig), wxKillError *WXUNUSED(rc))
145{
146 wxFAIL_MSG( wxT("wxKill not implemented under MS-DOS!") );
147 return 0;
148}
149
0280ab6e 150long wxExecute(const wxString& WXUNUSED(command), int WXUNUSED(flags), wxProcess *WXUNUSED(process))
9210a48a
VS
151{
152 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
153 return 0;
154}
155
0280ab6e 156long wxExecute(char **WXUNUSED(argv), int WXUNUSED(flags), wxProcess *WXUNUSED(process))
9210a48a
VS
157{
158 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
159 return 0;
160}
161
162
163#endif
164
32b8ec41
VZ
165// ----------------------------------------------------------------------------
166// display characterstics
167// ----------------------------------------------------------------------------
168
a4bbc9f7 169void wxDisplaySize(int *width, int *height)
32b8ec41 170{
9210a48a 171 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
b8c0528d
VS
172 if (width) *width = g_displayDC->sizex()+1;
173 if (height) *height = g_displayDC->sizey()+1;
32b8ec41
VZ
174}
175
7bdc1879 176void wxDisplaySizeMM(int *width, int *height)
32b8ec41 177{
1f43b5c9 178 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
39578f9c
VS
179
180 int xDPI, yDPI;
181 MGL_getDotsPerInch(&xDPI, &yDPI);
182
2343d81b 183 if ( width )
39578f9c 184 *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI);
2343d81b 185 if ( height )
39578f9c 186 *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI);
a4bbc9f7
VS
187}
188
7bdc1879 189void wxClientDisplayRect(int *x, int *y, int *width, int *height)
a4bbc9f7 190{
58061670
VS
191 if ( x ) *x = 0;
192 if ( y ) *y = 0;
7bdc1879 193 wxDisplaySize(width, height);
58061670 194 // FIXME_MGL - windowed version needs different handling
32b8ec41
VZ
195}
196
197bool wxColourDisplay()
198{
1f43b5c9 199 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
32b8ec41
VZ
200
201 return (wxDisplayDepth() > 1);
202}
203
204int wxDisplayDepth()
205{
1f43b5c9 206 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
32b8ec41
VZ
207
208 return g_displayDC->getBitsPerPixel();
209}
210
cd478a95 211int wxGUIAppTraits::GetOSVersion(int *majorVsn, int *minorVsn)
32b8ec41 212{
a246f95e
VS
213 if ( majorVsn )
214 *majorVsn = MGL_RELEASE_MAJOR;
215 if ( minorVsn )
216 *minorVsn = MGL_RELEASE_MINOR;
2343d81b
VS
217
218#if defined(__UNIX__)
a246f95e 219 return wxMGL_UNIX;
2343d81b 220#elif defined(__OS2__)
a246f95e 221 return wxMGL_OS2;
2343d81b 222#elif defined(__WIN32__)
a246f95e
VS
223 return wxMGL_WIN32;
224#elif defined(__DOS__)
225 return wxMGL_DOS;
226#else
227 #error Platform not supported by wxMGL!
32b8ec41
VZ
228#endif
229}
230
231
7bdc1879
VS
232void wxGetMousePosition(int* x, int* y)
233{
234 MS_getPos(x, y);
235}
236
237wxPoint wxGetMousePosition()
238{
239 wxPoint pt;
240 wxGetMousePosition(&pt.x, &pt.y);
241 return pt;
242}
243
244
245
32b8ec41
VZ
246#ifdef __UNIX__
247
248int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
249{
2343d81b
VS
250 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
251 return 0;
32b8ec41
VZ
252#if 0 // FIXME_MGL -do we need it at all?
253 int tag = gdk_input_add(fd,
254 GDK_INPUT_READ,
255 GTK_EndProcessDetector,
256 (gpointer)proc_data);
257
258 return tag;
259#endif
260}
261
262#endif