]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mgl/utils.cpp
wxXmlNode::GetAttribute's pointer argument must not be NULL, check for it
[wxWidgets.git] / src / mgl / utils.cpp
... / ...
CommitLineData
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#include "wx/evtloop.h"
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
40#include "wx/mgl/private.h"
41
42//----------------------------------------------------------------------------
43// misc.
44//----------------------------------------------------------------------------
45
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
55void wxBell()
56{
57 // FIXME_MGL
58}
59
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
70// ----------------------------------------------------------------------------
71// display characterstics
72// ----------------------------------------------------------------------------
73
74void wxDisplaySize(int *width, int *height)
75{
76 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
77 if (width) *width = g_displayDC->sizex()+1;
78 if (height) *height = g_displayDC->sizey()+1;
79}
80
81void wxDisplaySizeMM(int *width, int *height)
82{
83 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
84
85 int xDPI, yDPI;
86 MGL_getDotsPerInch(&xDPI, &yDPI);
87
88 if ( width )
89 *width = (int)((g_displayDC->sizex()+1) * 25.4 / xDPI);
90 if ( height )
91 *height = (int)((g_displayDC->sizey()+1) * 25.4 / yDPI);
92}
93
94void wxClientDisplayRect(int *x, int *y, int *width, int *height)
95{
96 if ( x ) *x = 0;
97 if ( y ) *y = 0;
98 wxDisplaySize(width, height);
99 // FIXME_MGL - windowed version needs different handling
100}
101
102bool wxColourDisplay()
103{
104 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
105
106 return (wxDisplayDepth() > 1);
107}
108
109int wxDisplayDepth()
110{
111 wxASSERT_MSG( g_displayDC, wxT("You must call wxApp::SetDisplayMode before using this function") );
112
113 return g_displayDC->getBitsPerPixel();
114}
115
116wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
117{
118 if ( verMaj )
119 *verMaj = MGL_RELEASE_MAJOR;
120 if ( verMin )
121 *verMin = MGL_RELEASE_MINOR;
122
123 return wxPORT_MGL;
124}
125
126wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
127{
128 return new wxEventLoop;
129}
130
131
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
144wxMouseState wxGetMouseState()
145{
146 wxMouseState ms;
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
164 return ms;
165}
166
167
168#ifdef __UNIX__
169
170int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
171{
172 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
173 return 0;
174#if 0 // FIXME_MGL -do we need it at all?
175 int tag = gdk_input_add(fd,
176 GDK_INPUT_READ,
177 GTK_EndProcessDetector,
178 (gpointer)proc_data);
179
180 return tag;
181#endif
182}
183
184#endif