]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/utils.cpp
Recognize the numpad cursor keys too
[wxWidgets.git] / src / mgl / utils.cpp
CommitLineData
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
45void wxBell()
46{
47 // FIXME_MGL
48}
49
33903958
WS
50bool 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 64void 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 71void 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 84void 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
92bool 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
99int 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
8bb6b2c0 106wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
32b8ec41 107{
8bb6b2c0
VZ
108 if ( verMaj )
109 *verMaj = MGL_RELEASE_MAJOR;
110 if ( verMin )
111 *verMin = MGL_RELEASE_MINOR;
1c53456f 112
8bb6b2c0 113 return wxPORT_MGL;
1c53456f 114}
32b8ec41 115
7bdc1879
VS
116void wxGetMousePosition(int* x, int* y)
117{
118 MS_getPos(x, y);
119}
120
121wxPoint wxGetMousePosition()
122{
123 wxPoint pt;
124 wxGetMousePosition(&pt.x, &pt.y);
125 return pt;
126}
127
b2e17848
WS
128wxMouseState wxGetMouseState()
129{
130 wxMouseState ms;
06414d99
MW
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
b2e17848
WS
148 return ms;
149}
7bdc1879
VS
150
151
32b8ec41
VZ
152#ifdef __UNIX__
153
154int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
155{
2343d81b
VS
156 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
157 return 0;
32b8ec41
VZ
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