]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
detection of aqua layout scheme added
[wxWidgets.git] / src / mgl / utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: utils.cpp
3 // Purpose:
4 // Author: Vaclav Slavik
5 // Id: $Id$
6 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #include "wx/utils.h"
18 #include "wx/string.h"
19
20 #include "wx/intl.h"
21 #include "wx/log.h"
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
35 #include "wx/mgl/private.h"
36
37 //----------------------------------------------------------------------------
38 // misc.
39 //----------------------------------------------------------------------------
40
41 void wxBell()
42 {
43 // FIXME_MGL
44 }
45
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
51 void wxSleep(int nSecs)
52 {
53 wxUsleep(1000 * nSecs);
54 }
55
56 void wxUsleep(unsigned long milliseconds)
57 {
58 PM_sleep(milliseconds);
59 }
60
61
62 bool 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
75 bool wxSetEnv(const wxString& variable, const wxChar *value)
76 {
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;
89 }
90
91 const wxChar* wxGetHomeDir(wxString *home)
92 {
93 *home = wxT(".");
94 return home->c_str();
95 }
96
97 const wxChar* wxGetUserHomeDir(wxString *home)
98 {
99 *home = wxT(".");
100 return home->c_str();
101 }
102
103 #if wxUSE_UNICODE
104 const wxMB2WXbuf wxGetUserHome(const wxString &user)
105 #else // just for binary compatibility -- there is no 'const' here
106 wxChar *wxGetUserHome(const wxString &user)
107 #endif
108 {
109 return wxT(".");
110 }
111
112 void 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
119 bool wxGetUserId(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
120 {
121 wxFAIL_MSG( wxT("wxGetUserId not implemented under MS-DOS!") );
122 return FALSE;
123 }
124
125 bool wxGetUserName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
126 {
127 wxFAIL_MSG( wxT("wxGetUserName not implemented under MS-DOS!") );
128 return FALSE;
129 }
130
131 bool wxGetHostName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
132 {
133 wxFAIL_MSG( wxT("wxGetHostName not implemented under MS-DOS!") );
134 return FALSE;
135 }
136
137 bool wxGetFullHostName(wxChar *WXUNUSED(buf), int WXUNUSED(sz))
138 {
139 wxFAIL_MSG( wxT("wxGetFullHostName not implemented under MS-DOS!") );
140 return FALSE;
141 }
142
143 int 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
149 long 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
155 long 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
164 // ----------------------------------------------------------------------------
165 // display characterstics
166 // ----------------------------------------------------------------------------
167
168 void wxDisplaySize(int *width, int *height)
169 {
170 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
171 if (width) *width = g_displayDC->sizex()+1;
172 if (height) *height = g_displayDC->sizey()+1;
173 }
174
175 void wxDisplaySizeMM(int *width, int *height)
176 {
177 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
178 if ( width )
179 *width = (g_displayDC->sizex()+1) * 25/72;
180 if ( height )
181 *height = (g_displayDC->sizey()+1) * 25/72;
182 // FIXME_MGL -- what about returning *real* monitor dimensions?
183 }
184
185 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
186 {
187 if ( x ) *x = 0;
188 if ( y ) *y = 0;
189 wxDisplaySize(width, height);
190 // FIXME_MGL - windowed version needs different handling
191 }
192
193 bool wxColourDisplay()
194 {
195 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
196
197 return (wxDisplayDepth() > 1);
198 }
199
200 int wxDisplayDepth()
201 {
202 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
203
204 return g_displayDC->getBitsPerPixel();
205 }
206
207 int wxGetOsVersion(int *majorVsn, int *minorVsn)
208 {
209 if ( majorVsn )
210 *majorVsn = MGL_RELEASE_MAJOR;
211 if ( minorVsn )
212 *minorVsn = MGL_RELEASE_MINOR;
213
214 #if defined(__UNIX__)
215 return wxMGL_UNIX;
216 #elif defined(__OS2__)
217 return wxMGL_OS2;
218 #elif defined(__WIN32__)
219 return wxMGL_WIN32;
220 #elif defined(__DOS__)
221 return wxMGL_DOS;
222 #else
223 #error Platform not supported by wxMGL!
224 #endif
225 }
226
227
228 void wxGetMousePosition(int* x, int* y)
229 {
230 MS_getPos(x, y);
231 }
232
233 wxPoint wxGetMousePosition()
234 {
235 wxPoint pt;
236 wxGetMousePosition(&pt.x, &pt.y);
237 return pt;
238 }
239
240
241
242 #ifdef __UNIX__
243
244 int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
245 {
246 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
247 return 0;
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