]>
git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
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();
211 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
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
;
219 #if defined(__UNIX__)
220 info
.os
= wxMGL_UNIX
;
221 #elif defined(__OS2__)
223 #elif defined(__WIN32__)
224 info
.os
= wxMGL_WIN32
;
225 #elif defined(__DOS__)
228 #error Platform not supported by wxMGL!
234 void wxGetMousePosition(int* x
, int* y
)
239 wxPoint
wxGetMousePosition()
242 wxGetMousePosition(&pt
.x
, &pt
.y
);
250 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
252 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
254 #if 0 // FIXME_MGL -do we need it at all?
255 int tag
= gdk_input_add(fd
,
257 GTK_EndProcessDetector
,
258 (gpointer
)proc_data
);