]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
added SetDoubleBuffered() (patch 1491093)
[wxWidgets.git] / src / mgl / utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mgl/utils.cpp
3 // Purpose:
4 // Author: Vaclav Slavik
5 // Id: $Id$
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #include "wx/utils.h"
18
19 #ifndef WX_PRECOMP
20 #include "wx/string.h"
21 #include "wx/intl.h"
22 #include "wx/log.h"
23 #endif
24
25 #include "wx/apptrait.h"
26 #include "wx/process.h"
27
28 #include <stdarg.h>
29 #include <string.h>
30 #include <sys/stat.h>
31 #include <sys/types.h>
32 #include <unistd.h>
33 #include <mgraph.hpp>
34
35 #ifdef __UNIX__
36 #include "wx/unix/execute.h"
37 #endif
38
39 #include "wx/mgl/private.h"
40
41 //----------------------------------------------------------------------------
42 // misc.
43 //----------------------------------------------------------------------------
44
45 void wxBell()
46 {
47 // FIXME_MGL
48 }
49
50 bool wxGetKeyState(wxKeyCode key)
51 {
52 wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
53 WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
54
55 // TODO
56
57 return false;
58 }
59
60 // ----------------------------------------------------------------------------
61 // display characterstics
62 // ----------------------------------------------------------------------------
63
64 void wxDisplaySize(int *width, int *height)
65 {
66 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
67 if (width) *width = g_displayDC->sizex()+1;
68 if (height) *height = g_displayDC->sizey()+1;
69 }
70
71 void wxDisplaySizeMM(int *width, int *height)
72 {
73 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
74
75 int xDPI, yDPI;
76 MGL_getDotsPerInch(&xDPI, &yDPI);
77
78 if ( width )
79 *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI);
80 if ( height )
81 *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI);
82 }
83
84 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
85 {
86 if ( x ) *x = 0;
87 if ( y ) *y = 0;
88 wxDisplaySize(width, height);
89 // FIXME_MGL - windowed version needs different handling
90 }
91
92 bool wxColourDisplay()
93 {
94 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
95
96 return (wxDisplayDepth() > 1);
97 }
98
99 int wxDisplayDepth()
100 {
101 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
102
103 return g_displayDC->getBitsPerPixel();
104 }
105
106 #if wxUSE_GUI
107
108 wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
109 {
110 static wxToolkitInfo info;
111 info.shortName = _T("mgluniv");
112 info.name = _T("wxMGL");
113 info.versionMajor = MGL_RELEASE_MAJOR;
114 info.versionMinor = MGL_RELEASE_MINOR;
115 info.os = wxGTK;
116 #if defined(__UNIX__)
117 info.os = wxMGL_UNIX;
118 #elif defined(__OS2__)
119 info.os = wxMGL_OS2;
120 #elif defined(__WIN32__)
121 info.os = wxMGL_WIN32;
122 #elif defined(__DOS__)
123 info.os = wxMGL_DOS;
124 #else
125 #error Platform not supported by wxMGL!
126 #endif
127 return info;
128 }
129
130 #endif
131
132 #if 0
133 wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
134 {
135 static wxToolkitInfo info;
136 info.shortName = _T("mglbase");
137 info.versionMajor = MGL_RELEASE_MAJOR;
138 info.versionMinor = MGL_RELEASE_MINOR;
139 info.name = _T("wxBase");
140 info.os = wxGTK;
141 #if defined(__UNIX__)
142 info.os = wxMGL_UNIX;
143 #elif defined(__OS2__)
144 info.os = wxMGL_OS2;
145 #elif defined(__WIN32__)
146 info.os = wxMGL_WIN32;
147 #elif defined(__DOS__)
148 info.os = wxMGL_DOS;
149 #else
150 #error Platform not supported by wxMGL!
151 #endif
152 return info;
153 }
154 #endif
155
156 void wxGetMousePosition(int* x, int* y)
157 {
158 MS_getPos(x, y);
159 }
160
161 wxPoint wxGetMousePosition()
162 {
163 wxPoint pt;
164 wxGetMousePosition(&pt.x, &pt.y);
165 return pt;
166 }
167
168
169
170 #ifdef __UNIX__
171
172 int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
173 {
174 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
175 return 0;
176 #if 0 // FIXME_MGL -do we need it at all?
177 int tag = gdk_input_add(fd,
178 GDK_INPUT_READ,
179 GTK_EndProcessDetector,
180 (gpointer)proc_data);
181
182 return tag;
183 #endif
184 }
185
186 #endif