]>
git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
ec8ed4ff07c3a5a07c0302f58666318a5438f79c
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 wxMilliSleep(1000 * nSecs
);
57 void wxMilliSleep(unsigned long milliseconds
)
59 PM_sleep(milliseconds
);
62 void wxMicroSleep(unsigned long microseconds
)
64 wxMilliSleep(microseconds
/1000);
67 bool wxGetEnv(const wxString
& var
, wxString
*value
)
69 // wxGetenv is defined as getenv()
70 wxChar
*p
= wxGetenv(var
);
80 bool wxSetEnv(const wxString
& variable
, const wxChar
*value
)
82 wxString s
= variable
;
84 s
<< _T('=') << value
;
87 const char *p
= s
.mb_str();
89 // the string will be free()d by libc
90 char *buf
= (char *)malloc(strlen(p
) + 1);
93 return putenv(buf
) == 0;
96 const wxChar
* wxGetHomeDir(wxString
*home
)
102 const wxChar
* wxGetUserHomeDir(wxString
*home
)
105 return home
->c_str();
109 const wxMB2WXbuf
wxGetUserHome(const wxString
&user
)
110 #else // just for binary compatibility -- there is no 'const' here
111 wxChar
*wxGetUserHome(const wxString
&user
)
117 void wxFatalError(const wxString
&msg
, const wxString
&title
)
120 wxFprintf( stderr
, wxT("%s "), WXSTRINGCAST(title
));
121 PM_fatalError(msg
.c_str());
124 bool wxGetUserId(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
126 wxFAIL_MSG( wxT("wxGetUserId not implemented under MS-DOS!") );
130 bool wxGetUserName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
132 wxFAIL_MSG( wxT("wxGetUserName not implemented under MS-DOS!") );
136 bool wxGetHostName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
138 wxFAIL_MSG( wxT("wxGetHostName not implemented under MS-DOS!") );
142 bool wxGetFullHostName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
144 wxFAIL_MSG( wxT("wxGetFullHostName not implemented under MS-DOS!") );
148 int wxKill(long WXUNUSED(pid
), wxSignal
WXUNUSED(sig
), wxKillError
*WXUNUSED(rc
), int WXUNUSED(flags
))
150 wxFAIL_MSG( wxT("wxKill not implemented under MS-DOS!") );
154 long wxExecute(const wxString
& WXUNUSED(command
), int WXUNUSED(flags
), wxProcess
*WXUNUSED(process
))
156 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
160 long wxExecute(char **WXUNUSED(argv
), int WXUNUSED(flags
), wxProcess
*WXUNUSED(process
))
162 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
169 // ----------------------------------------------------------------------------
170 // display characterstics
171 // ----------------------------------------------------------------------------
173 void wxDisplaySize(int *width
, int *height
)
175 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
176 if (width
) *width
= g_displayDC
->sizex()+1;
177 if (height
) *height
= g_displayDC
->sizey()+1;
180 void wxDisplaySizeMM(int *width
, int *height
)
182 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
185 MGL_getDotsPerInch(&xDPI
, &yDPI
);
188 *width
= (int)((g_displayDC
->sizex()+1) * 25.4 / xDPI
);
190 *height
= (int)((g_displayDC
->sizey()+1) * 25.4 / yDPI
);
193 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
197 wxDisplaySize(width
, height
);
198 // FIXME_MGL - windowed version needs different handling
201 bool wxColourDisplay()
203 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
205 return (wxDisplayDepth() > 1);
210 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
212 return g_displayDC
->getBitsPerPixel();
217 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
219 static wxToolkitInfo info
;
220 info
.shortName
= _T("mgluniv");
221 info
.name
= _T("wxMGL");
222 info
.versionMajor
= MGL_RELEASE_MAJOR
;
223 info
.versionMinor
= MGL_RELEASE_MINOR
;
225 #if defined(__UNIX__)
226 info
.os
= wxMGL_UNIX
;
227 #elif defined(__OS2__)
229 #elif defined(__WIN32__)
230 info
.os
= wxMGL_WIN32
;
231 #elif defined(__DOS__)
234 #error Platform not supported by wxMGL!
241 wxToolkitInfo
& wxConsoleAppTraits::GetToolkitInfo()
243 static wxToolkitInfo info
;
244 info
.shortName
= _T("mglbase");
245 info
.versionMajor
= MGL_RELEASE_MAJOR
;
246 info
.versionMinor
= MGL_RELEASE_MINOR
;
247 info
.name
= _T("wxBase");
249 #if defined(__UNIX__)
250 info
.os
= wxMGL_UNIX
;
251 #elif defined(__OS2__)
253 #elif defined(__WIN32__)
254 info
.os
= wxMGL_WIN32
;
255 #elif defined(__DOS__)
258 #error Platform not supported by wxMGL!
263 void wxGetMousePosition(int* x
, int* y
)
268 wxPoint
wxGetMousePosition()
271 wxGetMousePosition(&pt
.x
, &pt
.y
);
279 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
281 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
283 #if 0 // FIXME_MGL -do we need it at all?
284 int tag
= gdk_input_add(fd
,
286 GTK_EndProcessDetector
,
287 (gpointer
)proc_data
);