]>
git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
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 wxString s
= variable
;
79 s
<< _T('=') << value
;
82 const char *p
= s
.mb_str();
84 // the string will be free()d by libc
85 char *buf
= (char *)malloc(strlen(p
) + 1);
88 return putenv(buf
) == 0;
91 const wxChar
* wxGetHomeDir(wxString
*home
)
97 const wxChar
* wxGetUserHomeDir(wxString
*home
)
100 return home
->c_str();
104 const wxMB2WXbuf
wxGetUserHome(const wxString
&user
)
105 #else // just for binary compatibility -- there is no 'const' here
106 wxChar
*wxGetUserHome(const wxString
&user
)
112 void wxFatalError(const wxString
&msg
, const wxString
&title
)
115 wxFprintf( stderr
, wxT("%s "), WXSTRINGCAST(title
));
116 PM_fatalError(msg
.c_str());
119 bool wxGetUserId(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
121 wxFAIL_MSG( wxT("wxGetUserId not implemented under MS-DOS!") );
125 bool wxGetUserName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
127 wxFAIL_MSG( wxT("wxGetUserName not implemented under MS-DOS!") );
131 bool wxGetHostName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
133 wxFAIL_MSG( wxT("wxGetHostName not implemented under MS-DOS!") );
137 bool wxGetFullHostName(wxChar
*WXUNUSED(buf
), int WXUNUSED(sz
))
139 wxFAIL_MSG( wxT("wxGetFullHostName not implemented under MS-DOS!") );
143 int wxKill(long WXUNUSED(pid
), wxSignal
WXUNUSED(sig
), wxKillError
*WXUNUSED(rc
))
145 wxFAIL_MSG( wxT("wxKill not implemented under MS-DOS!") );
149 long wxExecute(const wxString
& WXUNUSED(command
), bool WXUNUSED(sync
), wxProcess
*WXUNUSED(process
))
151 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
155 long wxExecute(wxChar
**WXUNUSED(argv
), bool WXUNUSED(sync
), wxProcess
*WXUNUSED(process
))
157 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
164 // ----------------------------------------------------------------------------
165 // display characterstics
166 // ----------------------------------------------------------------------------
168 void wxDisplaySize(int *width
, int *height
)
170 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
171 if (width
) *width
= g_displayDC
->sizex()+1;
172 if (height
) *height
= g_displayDC
->sizey()+1;
175 void wxDisplaySizeMM(int *width
, int *height
)
177 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
179 *width
= (g_displayDC
->sizex()+1) * 25/72;
181 *height
= (g_displayDC
->sizey()+1) * 25/72;
182 // FIXME_MGL -- what about returning *real* monitor dimensions?
185 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
189 wxDisplaySize(width
, height
);
190 // FIXME_MGL - windowed version needs different handling
193 bool wxColourDisplay()
195 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
197 return (wxDisplayDepth() > 1);
202 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
204 return g_displayDC
->getBitsPerPixel();
207 int wxGetOsVersion(int *majorVsn
, int *minorVsn
)
210 *majorVsn
= MGL_RELEASE_MAJOR
;
212 *minorVsn
= MGL_RELEASE_MINOR
;
214 #if defined(__UNIX__)
216 #elif defined(__OS2__)
218 #elif defined(__WIN32__)
220 #elif defined(__DOS__)
223 #error Platform not supported by wxMGL!
228 void wxGetMousePosition(int* x
, int* y
)
233 wxPoint
wxGetMousePosition()
236 wxGetMousePosition(&pt
.x
, &pt
.y
);
244 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
246 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
248 #if 0 // FIXME_MGL -do we need it at all?
249 int tag
= gdk_input_add(fd
,
251 GTK_EndProcessDetector
,
252 (gpointer
)proc_data
);