]>
git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
21d02155ad3c37a7a4e1b1c03dd86132adab858c
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
18 #include "wx/string.h"
21 #include "wx/apptrait.h"
23 #include "wx/process.h"
28 #include <sys/types.h>
33 #include "wx/unix/execute.h"
36 #include "wx/mgl/private.h"
38 //----------------------------------------------------------------------------
40 //----------------------------------------------------------------------------
49 // VS: this should be in utilsdos.cpp, but since there will hardly ever
50 // be a non-MGL MS-DOS port...
52 void wxSleep(int nSecs
)
54 wxUsleep(1000 * nSecs
);
57 void wxUsleep(unsigned long milliseconds
)
59 PM_sleep(milliseconds
);
63 bool wxGetEnv(const wxString
& var
, wxString
*value
)
65 // wxGetenv is defined as getenv()
66 wxChar
*p
= wxGetenv(var
);
76 bool wxSetEnv(const wxString
& variable
, const wxChar
*value
)
78 wxString s
= variable
;
80 s
<< _T('=') << value
;
83 const char *p
= s
.mb_str();
85 // the string will be free()d by libc
86 char *buf
= (char *)malloc(strlen(p
) + 1);
89 return putenv(buf
) == 0;
92 const wxChar
* wxGetHomeDir(wxString
*home
)
98 const wxChar
* wxGetUserHomeDir(wxString
*home
)
101 return home
->c_str();
105 const wxMB2WXbuf
wxGetUserHome(const wxString
&user
)
106 #else // just for binary compatibility -- there is no 'const' here
107 wxChar
*wxGetUserHome(const wxString
&user
)
113 void wxFatalError(const wxString
&msg
, const wxString
&title
)
116 wxFprintf( stderr
, wxT("%s "), WXSTRINGCAST(title
));
117 PM_fatalError(msg
.c_str());
120 bool wxGetUserId(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
122 wxFAIL_MSG( wxT("wxGetUserId not implemented under MS-DOS!") );
126 bool wxGetUserName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
128 wxFAIL_MSG( wxT("wxGetUserName not implemented under MS-DOS!") );
132 bool wxGetHostName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
134 wxFAIL_MSG( wxT("wxGetHostName not implemented under MS-DOS!") );
138 bool wxGetFullHostName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
140 wxFAIL_MSG( wxT("wxGetFullHostName not implemented under MS-DOS!") );
144 int wxKill(long WXUNUSED(pid
), wxSignal
WXUNUSED(sig
), wxKillError
*WXUNUSED(rc
))
146 wxFAIL_MSG( wxT("wxKill not implemented under MS-DOS!") );
150 long wxExecute(const wxString
& WXUNUSED(command
), int WXUNUSED(flags
), wxProcess
*WXUNUSED(process
))
152 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
156 long wxExecute(char **WXUNUSED(argv
), int WXUNUSED(flags
), wxProcess
*WXUNUSED(process
))
158 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
165 // ----------------------------------------------------------------------------
166 // display characterstics
167 // ----------------------------------------------------------------------------
169 void wxDisplaySize(int *width
, int *height
)
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;
176 void wxDisplaySizeMM(int *width
, int *height
)
178 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
181 MGL_getDotsPerInch(&xDPI
, &yDPI
);
184 *width
= (int)((g_displayDC
->sizex()+1) * 25.4 / xDPI
);
186 *height
= (int)((g_displayDC
->sizey()+1) * 25.4 / yDPI
);
189 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
193 wxDisplaySize(width
, height
);
194 // FIXME_MGL - windowed version needs different handling
197 bool wxColourDisplay()
199 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
201 return (wxDisplayDepth() > 1);
206 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
208 return g_displayDC
->getBitsPerPixel();
213 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
215 static wxToolkitInfo info
;
216 info
.shortName
= _T("mgluniv");
217 info
.name
= _T("wxMGL");
218 info
.versionMajor
= MGL_RELEASE_MAJOR
;
219 info
.versionMinor
= MGL_RELEASE_MINOR
;
221 #if defined(__UNIX__)
222 info
.os
= wxMGL_UNIX
;
223 #elif defined(__OS2__)
225 #elif defined(__WIN32__)
226 info
.os
= wxMGL_WIN32
;
227 #elif defined(__DOS__)
230 #error Platform not supported by wxMGL!
237 wxToolkitInfo
& wxConsoleAppTraits::GetToolkitInfo()
239 static wxToolkitInfo info
;
240 info
.shortName
= _T("mglbase");
241 info
.versionMajor
= MGL_RELEASE_MAJOR
;
242 info
.versionMinor
= MGL_RELEASE_MINOR
;
243 info
.name
= _T("wxBase");
245 #if defined(__UNIX__)
246 info
.os
= wxMGL_UNIX
;
247 #elif defined(__OS2__)
249 #elif defined(__WIN32__)
250 info
.os
= wxMGL_WIN32
;
251 #elif defined(__DOS__)
254 #error Platform not supported by wxMGL!
259 void wxGetMousePosition(int* x
, int* y
)
264 wxPoint
wxGetMousePosition()
267 wxGetMousePosition(&pt
.x
, &pt
.y
);
275 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
277 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
279 #if 0 // FIXME_MGL -do we need it at all?
280 int tag
= gdk_input_add(fd
,
282 GTK_EndProcessDetector
,
283 (gpointer
)proc_data
);