]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
b62f4b02ec986073988b3efe54c13ebaa6dd1199
[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 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
46 wxMemorySize wxGetFreeMemory()
47 {
48 // TODO - probably should be extracted to
49 // src/msdos/utilsdos.cpp and src/unix/utilsunx.cpp
50 // to avoid code duplication
51 return -1;
52 }
53
54 void wxBell()
55 {
56 // FIXME_MGL
57 }
58
59 bool wxGetKeyState(wxKeyCode key)
60 {
61 wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
62 WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
63
64 // TODO
65
66 return false;
67 }
68
69 // ----------------------------------------------------------------------------
70 // display characterstics
71 // ----------------------------------------------------------------------------
72
73 void wxDisplaySize(int *width, int *height)
74 {
75 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
76 if (width) *width = g_displayDC->sizex()+1;
77 if (height) *height = g_displayDC->sizey()+1;
78 }
79
80 void wxDisplaySizeMM(int *width, int *height)
81 {
82 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
83
84 int xDPI, yDPI;
85 MGL_getDotsPerInch(&xDPI, &yDPI);
86
87 if ( width )
88 *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI);
89 if ( height )
90 *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI);
91 }
92
93 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
94 {
95 if ( x ) *x = 0;
96 if ( y ) *y = 0;
97 wxDisplaySize(width, height);
98 // FIXME_MGL - windowed version needs different handling
99 }
100
101 bool wxColourDisplay()
102 {
103 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
104
105 return (wxDisplayDepth() > 1);
106 }
107
108 int wxDisplayDepth()
109 {
110 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
111
112 return g_displayDC->getBitsPerPixel();
113 }
114
115 wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
116 {
117 if ( verMaj )
118 *verMaj = MGL_RELEASE_MAJOR;
119 if ( verMin )
120 *verMin = MGL_RELEASE_MINOR;
121
122 return wxPORT_MGL;
123 }
124
125 void wxGetMousePosition(int* x, int* y)
126 {
127 MS_getPos(x, y);
128 }
129
130 wxPoint wxGetMousePosition()
131 {
132 wxPoint pt;
133 wxGetMousePosition(&pt.x, &pt.y);
134 return pt;
135 }
136
137 wxMouseState wxGetMouseState()
138 {
139 wxMouseState ms;
140 int x, y;
141
142 wxGetMousePosition(&x, &y);
143
144 ms.SetX(x);
145 ms.SetY(y);
146
147 extern unsigned long g_buttonState;
148 ms.SetLeftDown(g_buttonState & EVT_LEFTBUT);
149 ms.SetMiddleDown(g_buttonState & EVT_MIDDLEBUT);
150 ms.SetRightDown(g_buttonState & EVT_RIGHTBUT);
151
152 ms.SetControlDown(EVT_isKeyDown(KB_leftCtrl) || EVT_isKeyDown(KB_rightCtrl));
153 ms.SetShiftDown(EVT_isKeyDown(KB_leftShift) || EVT_isKeyDown(KB_rightShift));
154 ms.SetAltDown(EVT_isKeyDown(KB_leftAlt));
155 ms.SetMetaDown(EVT_isKeyDown(KB_rightAlt));
156
157 return ms;
158 }
159
160
161 #ifdef __UNIX__
162
163 int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
164 {
165 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
166 return 0;
167 #if 0 // FIXME_MGL -do we need it at all?
168 int tag = gdk_input_add(fd,
169 GDK_INPUT_READ,
170 GTK_EndProcessDetector,
171 (gpointer)proc_data);
172
173 return tag;
174 #endif
175 }
176
177 #endif