]>
git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
7c138f7e4352468a71e0967c590f6429e1dbadc8
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2001 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"
22 #include "wx/process.h"
27 #include <sys/types.h>
32 #include "wx/unix/execute.h"
35 #include "wx/mgl/private.h"
37 //----------------------------------------------------------------------------
39 //----------------------------------------------------------------------------
48 // VS: this should be in utilsdos.cpp, but since there will hardly ever
49 // be a non-MGL MS-DOS port...
51 void wxSleep(int nSecs
)
53 wxUsleep(1000 * nSecs
);
56 void wxUsleep(unsigned long milliseconds
)
58 PM_sleep(milliseconds
);
62 bool wxGetEnv(const wxString
& var
, wxString
*value
)
64 // wxGetenv is defined as getenv()
65 wxChar
*p
= wxGetenv(var
);
75 bool wxSetEnv(const wxString
& variable
, const wxChar
*value
)
77 #ifdef __WATCOMC__ // has putenv()
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;
90 #else // no way to set an env var
91 #error "Don't know how to implement wxSetEnv on this platform!"
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
))
150 wxFAIL_MSG( wxT("wxKill not implemented under MS-DOS!") );
154 long wxExecute(const wxString
& WXUNUSED(command
), bool WXUNUSED(sync
), wxProcess
*WXUNUSED(process
))
156 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
160 long wxExecute(wxChar
**WXUNUSED(argv
), bool WXUNUSED(sync
), 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") );
184 *width
= (g_displayDC
->sizex()+1) * 25/72;
186 *height
= (g_displayDC
->sizey()+1) * 25/72;
187 // FIXME_MGL -- what about returning *real* monitor dimensions?
190 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
194 wxDisplaySize(width
, height
);
195 // FIXME_MGL - windowed version needs different handling
198 bool wxColourDisplay()
200 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
202 return (wxDisplayDepth() > 1);
207 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
209 return g_displayDC
->getBitsPerPixel();
212 int wxGetOsVersion(int *majorVsn
, int *minorVsn
)
215 *majorVsn
= MGL_RELEASE_MAJOR
;
217 *minorVsn
= MGL_RELEASE_MINOR
;
219 #if defined(__UNIX__)
221 #elif defined(__OS2__)
223 #elif defined(__WIN32__)
225 #elif defined(__DOS__)
228 #error Platform not supported by wxMGL!
233 void wxGetMousePosition(int* x
, int* y
)
238 wxPoint
wxGetMousePosition()
241 wxGetMousePosition(&pt
.x
, &pt
.y
);
249 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
251 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
253 #if 0 // FIXME_MGL -do we need it at all?
254 int tag
= gdk_input_add(fd
,
256 GTK_EndProcessDetector
,
257 (gpointer
)proc_data
);