]>
git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
b62f4b02ec986073988b3efe54c13ebaa6dd1199
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mgl/utils.cpp
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
20 #include "wx/string.h"
25 #include "wx/apptrait.h"
26 #include "wx/process.h"
31 #include <sys/types.h>
36 #include "wx/unix/execute.h"
39 #include "wx/mgl/private.h"
41 //----------------------------------------------------------------------------
43 //----------------------------------------------------------------------------
45 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
46 wxMemorySize
wxGetFreeMemory()
48 // TODO - probably should be extracted to
49 // src/msdos/utilsdos.cpp and src/unix/utilsunx.cpp
50 // to avoid code duplication
59 bool wxGetKeyState(wxKeyCode key
)
61 wxASSERT_MSG(key
!= WXK_LBUTTON
&& key
!= WXK_RBUTTON
&& key
!=
62 WXK_MBUTTON
, wxT("can't use wxGetKeyState() for mouse buttons"));
69 // ----------------------------------------------------------------------------
70 // display characterstics
71 // ----------------------------------------------------------------------------
73 void wxDisplaySize(int *width
, int *height
)
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;
80 void wxDisplaySizeMM(int *width
, int *height
)
82 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
85 MGL_getDotsPerInch(&xDPI
, &yDPI
);
88 *width
= (int)((g_displayDC
->sizex()+1) * 25.4 / xDPI
);
90 *height
= (int)((g_displayDC
->sizey()+1) * 25.4 / yDPI
);
93 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
97 wxDisplaySize(width
, height
);
98 // FIXME_MGL - windowed version needs different handling
101 bool wxColourDisplay()
103 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
105 return (wxDisplayDepth() > 1);
110 wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") );
112 return g_displayDC
->getBitsPerPixel();
115 wxPortId
wxGUIAppTraits::GetToolkitVersion(int *verMaj
, int *verMin
) const
118 *verMaj
= MGL_RELEASE_MAJOR
;
120 *verMin
= MGL_RELEASE_MINOR
;
125 void wxGetMousePosition(int* x
, int* y
)
130 wxPoint
wxGetMousePosition()
133 wxGetMousePosition(&pt
.x
, &pt
.y
);
137 wxMouseState
wxGetMouseState()
142 wxGetMousePosition(&x
, &y
);
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
);
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
));
163 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
165 wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!"));
167 #if 0 // FIXME_MGL -do we need it at all?
168 int tag
= gdk_input_add(fd
,
170 GTK_EndProcessDetector
,
171 (gpointer
)proc_data
);