]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/utils.cpp
Fixed a confusion between window and client size that could lead to
[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
d5eb0854
WS
45// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
46wxMemorySize 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
32b8ec41
VZ
54void wxBell()
55{
56 // FIXME_MGL
57}
58
33903958
WS
59bool 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
32b8ec41
VZ
69// ----------------------------------------------------------------------------
70// display characterstics
71// ----------------------------------------------------------------------------
72
a4bbc9f7 73void wxDisplaySize(int *width, int *height)
32b8ec41 74{
9210a48a 75 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
b8c0528d
VS
76 if (width) *width = g_displayDC->sizex()+1;
77 if (height) *height = g_displayDC->sizey()+1;
32b8ec41
VZ
78}
79
7bdc1879 80void wxDisplaySizeMM(int *width, int *height)
32b8ec41 81{
1f43b5c9 82 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
39578f9c
VS
83
84 int xDPI, yDPI;
99f0cdf2
WS
85 MGL_getDotsPerInch(&xDPI, &yDPI);
86
87 if ( width )
39578f9c 88 *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI);
99f0cdf2 89 if ( height )
39578f9c 90 *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI);
a4bbc9f7
VS
91}
92
7bdc1879 93void wxClientDisplayRect(int *x, int *y, int *width, int *height)
a4bbc9f7 94{
58061670
VS
95 if ( x ) *x = 0;
96 if ( y ) *y = 0;
7bdc1879 97 wxDisplaySize(width, height);
58061670 98 // FIXME_MGL - windowed version needs different handling
32b8ec41
VZ
99}
100
101bool wxColourDisplay()
102{
1f43b5c9 103 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
99f0cdf2 104
32b8ec41
VZ
105 return (wxDisplayDepth() > 1);
106}
107
108int wxDisplayDepth()
109{
1f43b5c9 110 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
32b8ec41
VZ
111
112 return g_displayDC->getBitsPerPixel();
113}
114
8bb6b2c0 115wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
32b8ec41 116{
8bb6b2c0
VZ
117 if ( verMaj )
118 *verMaj = MGL_RELEASE_MAJOR;
119 if ( verMin )
120 *verMin = MGL_RELEASE_MINOR;
1c53456f 121
8bb6b2c0 122 return wxPORT_MGL;
1c53456f 123}
32b8ec41 124
7bdc1879
VS
125void wxGetMousePosition(int* x, int* y)
126{
127 MS_getPos(x, y);
128}
129
130wxPoint wxGetMousePosition()
131{
132 wxPoint pt;
133 wxGetMousePosition(&pt.x, &pt.y);
134 return pt;
135}
136
b2e17848
WS
137wxMouseState wxGetMouseState()
138{
139 wxMouseState ms;
06414d99
MW
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
b2e17848
WS
157 return ms;
158}
7bdc1879
VS
159
160
32b8ec41
VZ
161#ifdef __UNIX__
162
163int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
164{
2343d81b
VS
165 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
166 return 0;
32b8ec41
VZ
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