]>
Commit | Line | Data |
---|---|---|
32b8ec41 | 1 | ///////////////////////////////////////////////////////////////////////////// |
df91131c | 2 | // Name: src/mgl/utils.cpp |
32b8ec41 VZ |
3 | // Purpose: |
4 | // Author: Vaclav Slavik | |
5 | // Id: $Id$ | |
c41c20a5 | 6 | // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 7 | // Licence: wxWindows licence |
32b8ec41 VZ |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
a246f95e VS |
10 | // For compilers that support precompilation, includes "wx.h". |
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #ifdef __BORLANDC__ | |
14 | #pragma hdrstop | |
15 | #endif | |
16 | ||
32b8ec41 | 17 | #include "wx/utils.h" |
df91131c WS |
18 | |
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/string.h" | |
88a7a4e1 | 21 | #include "wx/intl.h" |
e4db172a | 22 | #include "wx/log.h" |
df91131c | 23 | #endif |
32b8ec41 | 24 | |
cd478a95 | 25 | #include "wx/apptrait.h" |
32b8ec41 VZ |
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 | ||
a4bbc9f7 VS |
39 | #include "wx/mgl/private.h" |
40 | ||
32b8ec41 VZ |
41 | //---------------------------------------------------------------------------- |
42 | // misc. | |
43 | //---------------------------------------------------------------------------- | |
44 | ||
45 | void wxBell() | |
46 | { | |
47 | // FIXME_MGL | |
48 | } | |
49 | ||
33903958 WS |
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 | ||
32b8ec41 VZ |
60 | // ---------------------------------------------------------------------------- |
61 | // display characterstics | |
62 | // ---------------------------------------------------------------------------- | |
63 | ||
a4bbc9f7 | 64 | void wxDisplaySize(int *width, int *height) |
32b8ec41 | 65 | { |
9210a48a | 66 | wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") ); |
b8c0528d VS |
67 | if (width) *width = g_displayDC->sizex()+1; |
68 | if (height) *height = g_displayDC->sizey()+1; | |
32b8ec41 VZ |
69 | } |
70 | ||
7bdc1879 | 71 | void wxDisplaySizeMM(int *width, int *height) |
32b8ec41 | 72 | { |
1f43b5c9 | 73 | wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") ); |
39578f9c VS |
74 | |
75 | int xDPI, yDPI; | |
99f0cdf2 WS |
76 | MGL_getDotsPerInch(&xDPI, &yDPI); |
77 | ||
78 | if ( width ) | |
39578f9c | 79 | *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI); |
99f0cdf2 | 80 | if ( height ) |
39578f9c | 81 | *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI); |
a4bbc9f7 VS |
82 | } |
83 | ||
7bdc1879 | 84 | void wxClientDisplayRect(int *x, int *y, int *width, int *height) |
a4bbc9f7 | 85 | { |
58061670 VS |
86 | if ( x ) *x = 0; |
87 | if ( y ) *y = 0; | |
7bdc1879 | 88 | wxDisplaySize(width, height); |
58061670 | 89 | // FIXME_MGL - windowed version needs different handling |
32b8ec41 VZ |
90 | } |
91 | ||
92 | bool wxColourDisplay() | |
93 | { | |
1f43b5c9 | 94 | wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") ); |
99f0cdf2 | 95 | |
32b8ec41 VZ |
96 | return (wxDisplayDepth() > 1); |
97 | } | |
98 | ||
99 | int wxDisplayDepth() | |
100 | { | |
1f43b5c9 | 101 | wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") ); |
32b8ec41 VZ |
102 | |
103 | return g_displayDC->getBitsPerPixel(); | |
104 | } | |
105 | ||
1c53456f VS |
106 | #if wxUSE_GUI |
107 | ||
752464f9 | 108 | wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() |
32b8ec41 | 109 | { |
752464f9 VS |
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; | |
2343d81b | 116 | #if defined(__UNIX__) |
752464f9 | 117 | info.os = wxMGL_UNIX; |
2343d81b | 118 | #elif defined(__OS2__) |
752464f9 | 119 | info.os = wxMGL_OS2; |
2343d81b | 120 | #elif defined(__WIN32__) |
752464f9 | 121 | info.os = wxMGL_WIN32; |
a246f95e | 122 | #elif defined(__DOS__) |
752464f9 | 123 | info.os = wxMGL_DOS; |
a246f95e VS |
124 | #else |
125 | #error Platform not supported by wxMGL! | |
32b8ec41 | 126 | #endif |
752464f9 | 127 | return info; |
32b8ec41 VZ |
128 | } |
129 | ||
1c53456f VS |
130 | #endif |
131 | ||
83d8eb47 | 132 | #if 0 |
1c53456f VS |
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 | } | |
83d8eb47 | 154 | #endif |
32b8ec41 | 155 | |
7bdc1879 VS |
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 | ||
b2e17848 WS |
168 | wxMouseState wxGetMouseState() |
169 | { | |
170 | wxMouseState ms; | |
06414d99 MW |
171 | int x, y; |
172 | ||
173 | wxGetMousePosition(&x, &y); | |
174 | ||
175 | ms.SetX(x); | |
176 | ms.SetY(y); | |
177 | ||
178 | extern unsigned long g_buttonState; | |
179 | ms.SetLeftDown(g_buttonState & EVT_LEFTBUT); | |
180 | ms.SetMiddleDown(g_buttonState & EVT_MIDDLEBUT); | |
181 | ms.SetRightDown(g_buttonState & EVT_RIGHTBUT); | |
182 | ||
183 | ms.SetControlDown(EVT_isKeyDown(KB_leftCtrl) || EVT_isKeyDown(KB_rightCtrl)); | |
184 | ms.SetShiftDown(EVT_isKeyDown(KB_leftShift) || EVT_isKeyDown(KB_rightShift)); | |
185 | ms.SetAltDown(EVT_isKeyDown(KB_leftAlt)); | |
186 | ms.SetMetaDown(EVT_isKeyDown(KB_rightAlt)); | |
187 | ||
b2e17848 WS |
188 | return ms; |
189 | } | |
7bdc1879 VS |
190 | |
191 | ||
32b8ec41 VZ |
192 | #ifdef __UNIX__ |
193 | ||
194 | int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) | |
195 | { | |
2343d81b VS |
196 | wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!")); |
197 | return 0; | |
32b8ec41 VZ |
198 | #if 0 // FIXME_MGL -do we need it at all? |
199 | int tag = gdk_input_add(fd, | |
200 | GDK_INPUT_READ, | |
201 | GTK_EndProcessDetector, | |
202 | (gpointer)proc_data); | |
203 | ||
204 | return tag; | |
205 | #endif | |
206 | } | |
207 | ||
208 | #endif |