wxPlatformInfo (patch 1532064)
[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 wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
107 {
108 if ( verMaj )
109 *verMaj = MGL_RELEASE_MAJOR;
110 if ( verMin )
111 *verMin = MGL_RELEASE_MINOR;
112
113 return wxPORT_MGL;
114 }
115
116 void wxGetMousePosition(int* x, int* y)
117 {
118 MS_getPos(x, y);
119 }
120
121 wxPoint wxGetMousePosition()
122 {
123 wxPoint pt;
124 wxGetMousePosition(&pt.x, &pt.y);
125 return pt;
126 }
127
128 wxMouseState wxGetMouseState()
129 {
130 wxMouseState ms;
131 int x, y;
132
133 wxGetMousePosition(&x, &y);
134
135 ms.SetX(x);
136 ms.SetY(y);
137
138 extern unsigned long g_buttonState;
139 ms.SetLeftDown(g_buttonState & EVT_LEFTBUT);
140 ms.SetMiddleDown(g_buttonState & EVT_MIDDLEBUT);
141 ms.SetRightDown(g_buttonState & EVT_RIGHTBUT);
142
143 ms.SetControlDown(EVT_isKeyDown(KB_leftCtrl) || EVT_isKeyDown(KB_rightCtrl));
144 ms.SetShiftDown(EVT_isKeyDown(KB_leftShift) || EVT_isKeyDown(KB_rightShift));
145 ms.SetAltDown(EVT_isKeyDown(KB_leftAlt));
146 ms.SetMetaDown(EVT_isKeyDown(KB_rightAlt));
147
148 return ms;
149 }
150
151
152 #ifdef __UNIX__
153
154 int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
155 {
156 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
157 return 0;
158 #if 0 // FIXME_MGL -do we need it at all?
159 int tag = gdk_input_add(fd,
160 GDK_INPUT_READ,
161 GTK_EndProcessDetector,
162 (gpointer)proc_data);
163
164 return tag;
165 #endif
166 }
167
168 #endif