]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mgl/utils.cpp
Fixed bug [ 754596 ] wxUSE_CONSTRAINTS 0 breaks AutoLayout() with sizers
[wxWidgets.git] / src / mgl / utils.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: utils.cpp
3// Purpose:
4// Author: Vaclav Slavik
5// Id: $Id$
6// Copyright: (c) 2001-2002 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/apptrait.h"
22#include "wx/log.h"
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
36#include "wx/mgl/private.h"
37
38//----------------------------------------------------------------------------
39// misc.
40//----------------------------------------------------------------------------
41
42void wxBell()
43{
44 // FIXME_MGL
45}
46
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{
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;
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
150long wxExecute(const wxString& WXUNUSED(command), int WXUNUSED(flags), wxProcess *WXUNUSED(process))
151{
152 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
153 return 0;
154}
155
156long wxExecute(char **WXUNUSED(argv), int WXUNUSED(flags), wxProcess *WXUNUSED(process))
157{
158 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
159 return 0;
160}
161
162
163#endif
164
165// ----------------------------------------------------------------------------
166// display characterstics
167// ----------------------------------------------------------------------------
168
169void wxDisplaySize(int *width, int *height)
170{
171 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
172 if (width) *width = g_displayDC->sizex()+1;
173 if (height) *height = g_displayDC->sizey()+1;
174}
175
176void wxDisplaySizeMM(int *width, int *height)
177{
178 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
179
180 int xDPI, yDPI;
181 MGL_getDotsPerInch(&xDPI, &yDPI);
182
183 if ( width )
184 *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI);
185 if ( height )
186 *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI);
187}
188
189void wxClientDisplayRect(int *x, int *y, int *width, int *height)
190{
191 if ( x ) *x = 0;
192 if ( y ) *y = 0;
193 wxDisplaySize(width, height);
194 // FIXME_MGL - windowed version needs different handling
195}
196
197bool wxColourDisplay()
198{
199 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
200
201 return (wxDisplayDepth() > 1);
202}
203
204int wxDisplayDepth()
205{
206 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
207
208 return g_displayDC->getBitsPerPixel();
209}
210
211wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
212{
213 static wxToolkitInfo info;
214 info.shortName = _T("mgluniv");
215 info.name = _T("wxMGL");
216 info.versionMajor = MGL_RELEASE_MAJOR;
217 info.versionMinor = MGL_RELEASE_MINOR;
218 info.os = wxGTK;
219#if defined(__UNIX__)
220 info.os = wxMGL_UNIX;
221#elif defined(__OS2__)
222 info.os = wxMGL_OS2;
223#elif defined(__WIN32__)
224 info.os = wxMGL_WIN32;
225#elif defined(__DOS__)
226 info.os = wxMGL_DOS;
227#else
228 #error Platform not supported by wxMGL!
229#endif
230 return info;
231}
232
233
234void wxGetMousePosition(int* x, int* y)
235{
236 MS_getPos(x, y);
237}
238
239wxPoint wxGetMousePosition()
240{
241 wxPoint pt;
242 wxGetMousePosition(&pt.x, &pt.y);
243 return pt;
244}
245
246
247
248#ifdef __UNIX__
249
250int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
251{
252 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
253 return 0;
254#if 0 // FIXME_MGL -do we need it at all?
255 int tag = gdk_input_add(fd,
256 GDK_INPUT_READ,
257 GTK_EndProcessDetector,
258 (gpointer)proc_data);
259
260 return tag;
261#endif
262}
263
264#endif