]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/utils.cpp
some wxArtProv docs
[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") );
39578f9c
VS
178
179 int xDPI, yDPI;
180 MGL_getDotsPerInch(&xDPI, &yDPI);
181
2343d81b 182 if ( width )
39578f9c 183 *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI);
2343d81b 184 if ( height )
39578f9c 185 *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI);
a4bbc9f7
VS
186}
187
7bdc1879 188void wxClientDisplayRect(int *x, int *y, int *width, int *height)
a4bbc9f7 189{
58061670
VS
190 if ( x ) *x = 0;
191 if ( y ) *y = 0;
7bdc1879 192 wxDisplaySize(width, height);
58061670 193 // FIXME_MGL - windowed version needs different handling
32b8ec41
VZ
194}
195
196bool wxColourDisplay()
197{
1f43b5c9 198 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
32b8ec41
VZ
199
200 return (wxDisplayDepth() > 1);
201}
202
203int wxDisplayDepth()
204{
1f43b5c9 205 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
32b8ec41
VZ
206
207 return g_displayDC->getBitsPerPixel();
208}
209
210int wxGetOsVersion(int *majorVsn, int *minorVsn)
211{
a246f95e
VS
212 if ( majorVsn )
213 *majorVsn = MGL_RELEASE_MAJOR;
214 if ( minorVsn )
215 *minorVsn = MGL_RELEASE_MINOR;
2343d81b
VS
216
217#if defined(__UNIX__)
a246f95e 218 return wxMGL_UNIX;
2343d81b 219#elif defined(__OS2__)
a246f95e 220 return wxMGL_OS2;
2343d81b 221#elif defined(__WIN32__)
a246f95e
VS
222 return wxMGL_WIN32;
223#elif defined(__DOS__)
224 return wxMGL_DOS;
225#else
226 #error Platform not supported by wxMGL!
32b8ec41
VZ
227#endif
228}
229
230
7bdc1879
VS
231void wxGetMousePosition(int* x, int* y)
232{
233 MS_getPos(x, y);
234}
235
236wxPoint wxGetMousePosition()
237{
238 wxPoint pt;
239 wxGetMousePosition(&pt.x, &pt.y);
240 return pt;
241}
242
243
244
32b8ec41
VZ
245#ifdef __UNIX__
246
247int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
248{
2343d81b
VS
249 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
250 return 0;
32b8ec41
VZ
251#if 0 // FIXME_MGL -do we need it at all?
252 int tag = gdk_input_add(fd,
253 GDK_INPUT_READ,
254 GTK_EndProcessDetector,
255 (gpointer)proc_data);
256
257 return tag;
258#endif
259}
260
261#endif