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