]>
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"
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
), int WXUNUSED(flags
), wxProcess
*WXUNUSED(process
))
151 wxFAIL_MSG( wxT("wxExecute not implemented under MS-DOS!") );
155 long wxExecute(char **WXUNUSED(argv
), int WXUNUSED(flags
), 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") );
180 MGL_getDotsPerInch(&xDPI
, &yDPI
);
183 *width
= (int)((g_displayDC
->sizex()+1) * 25.4 / xDPI
);
185 *height
= (int)((g_displayDC
->sizey()+1) * 25.4 / yDPI
);
188 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
192 wxDisplaySize(width
, height
);
193 // FIXME_MGL - windowed version needs different handling
196 bool wxColourDisplay()
198 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
200 return (wxDisplayDepth() > 1);
205 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
207 return g_displayDC
->getBitsPerPixel();
210 int wxGetOsVersion(int *majorVsn
, int *minorVsn
)
213 *majorVsn
= MGL_RELEASE_MAJOR
;
215 *minorVsn
= MGL_RELEASE_MINOR
;
217 #if defined(__UNIX__)
219 #elif defined(__OS2__)
221 #elif defined(__WIN32__)
223 #elif defined(__DOS__)
226 #error Platform not supported by wxMGL!
231 void wxGetMousePosition(int* x
, int* y
)
236 wxPoint
wxGetMousePosition()
239 wxGetMousePosition(&pt
.x
, &pt
.y
);
247 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
249 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
251 #if 0 // FIXME_MGL -do we need it at all?
252 int tag
= gdk_input_add(fd
,
254 GTK_EndProcessDetector
,
255 (gpointer
)proc_data
);