]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/utils.cpp
assigning line marker to itself shouldn't invalidate it, add self-assignment check
[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 26#include "wx/process.h"
b46b1d59 27#include "wx/evtloop.h"
32b8ec41
VZ
28
29#include <stdarg.h>
30#include <string.h>
31#include <sys/stat.h>
32#include <sys/types.h>
33#include <unistd.h>
34#include <mgraph.hpp>
35
36#ifdef __UNIX__
37#include "wx/unix/execute.h"
38#endif
39
a4bbc9f7
VS
40#include "wx/mgl/private.h"
41
32b8ec41
VZ
42//----------------------------------------------------------------------------
43// misc.
44//----------------------------------------------------------------------------
45
d5eb0854
WS
46// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
47wxMemorySize wxGetFreeMemory()
48{
49 // TODO - probably should be extracted to
50 // src/msdos/utilsdos.cpp and src/unix/utilsunx.cpp
51 // to avoid code duplication
52 return -1;
53}
54
32b8ec41
VZ
55void wxBell()
56{
57 // FIXME_MGL
58}
59
33903958
WS
60bool wxGetKeyState(wxKeyCode key)
61{
62 wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
63 WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
64
65 // TODO
66
67 return false;
68}
69
32b8ec41
VZ
70// ----------------------------------------------------------------------------
71// display characterstics
72// ----------------------------------------------------------------------------
73
a4bbc9f7 74void wxDisplaySize(int *width, int *height)
32b8ec41 75{
9210a48a 76 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
b8c0528d
VS
77 if (width) *width = g_displayDC->sizex()+1;
78 if (height) *height = g_displayDC->sizey()+1;
32b8ec41
VZ
79}
80
7bdc1879 81void wxDisplaySizeMM(int *width, int *height)
32b8ec41 82{
1f43b5c9 83 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
39578f9c
VS
84
85 int xDPI, yDPI;
99f0cdf2
WS
86 MGL_getDotsPerInch(&xDPI, &yDPI);
87
88 if ( width )
39578f9c 89 *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI);
99f0cdf2 90 if ( height )
39578f9c 91 *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI);
a4bbc9f7
VS
92}
93
7bdc1879 94void wxClientDisplayRect(int *x, int *y, int *width, int *height)
a4bbc9f7 95{
58061670
VS
96 if ( x ) *x = 0;
97 if ( y ) *y = 0;
7bdc1879 98 wxDisplaySize(width, height);
58061670 99 // FIXME_MGL - windowed version needs different handling
32b8ec41
VZ
100}
101
102bool wxColourDisplay()
103{
1f43b5c9 104 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
99f0cdf2 105
32b8ec41
VZ
106 return (wxDisplayDepth() > 1);
107}
108
109int wxDisplayDepth()
110{
1f43b5c9 111 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
32b8ec41
VZ
112
113 return g_displayDC->getBitsPerPixel();
114}
115
8bb6b2c0 116wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
32b8ec41 117{
8bb6b2c0
VZ
118 if ( verMaj )
119 *verMaj = MGL_RELEASE_MAJOR;
120 if ( verMin )
121 *verMin = MGL_RELEASE_MINOR;
1c53456f 122
8bb6b2c0 123 return wxPORT_MGL;
1c53456f 124}
32b8ec41 125
2ddff00c 126wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
b46b1d59
VZ
127{
128 return new wxEventLoop;
129}
130
131
7bdc1879
VS
132void wxGetMousePosition(int* x, int* y)
133{
134 MS_getPos(x, y);
135}
136
137wxPoint wxGetMousePosition()
138{
139 wxPoint pt;
140 wxGetMousePosition(&pt.x, &pt.y);
141 return pt;
142}
143
b2e17848
WS
144wxMouseState wxGetMouseState()
145{
146 wxMouseState ms;
06414d99
MW
147 int x, y;
148
149 wxGetMousePosition(&x, &y);
150
151 ms.SetX(x);
152 ms.SetY(y);
153
154 extern unsigned long g_buttonState;
155 ms.SetLeftDown(g_buttonState & EVT_LEFTBUT);
156 ms.SetMiddleDown(g_buttonState & EVT_MIDDLEBUT);
157 ms.SetRightDown(g_buttonState & EVT_RIGHTBUT);
158
159 ms.SetControlDown(EVT_isKeyDown(KB_leftCtrl) || EVT_isKeyDown(KB_rightCtrl));
160 ms.SetShiftDown(EVT_isKeyDown(KB_leftShift) || EVT_isKeyDown(KB_rightShift));
161 ms.SetAltDown(EVT_isKeyDown(KB_leftAlt));
162 ms.SetMetaDown(EVT_isKeyDown(KB_rightAlt));
163
b2e17848
WS
164 return ms;
165}
7bdc1879 166