]>
git.saurik.com Git - wxWidgets.git/blob - src/mgl/utils.cpp
   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" 
  27 #include "wx/evtloop.h" 
  32 #include <sys/types.h> 
  37 #include "wx/unix/execute.h" 
  40 #include "wx/mgl/private.h" 
  42 //---------------------------------------------------------------------------- 
  44 //---------------------------------------------------------------------------- 
  46 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) 
  47 wxMemorySize 
wxGetFreeMemory() 
  49     // TODO - probably should be extracted to 
  50     //        src/msdos/utilsdos.cpp and src/unix/utilsunx.cpp 
  51     //        to avoid code duplication 
  60 bool wxGetKeyState(wxKeyCode key
) 
  62     wxASSERT_MSG(key 
!= WXK_LBUTTON 
&& key 
!= WXK_RBUTTON 
&& key 
!= 
  63         WXK_MBUTTON
, wxT("can't use wxGetKeyState() for mouse buttons")); 
  70 // ---------------------------------------------------------------------------- 
  71 // display characterstics 
  72 // ---------------------------------------------------------------------------- 
  74 void wxDisplaySize(int *width
, int *height
) 
  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; 
  81 void wxDisplaySizeMM(int *width
, int *height
) 
  83     wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") ); 
  86     MGL_getDotsPerInch(&xDPI
, &yDPI
); 
  89         *width 
= (int)((g_displayDC
->sizex()+1) * 25.4 / xDPI
); 
  91         *height 
= (int)((g_displayDC
->sizey()+1) * 25.4 / yDPI
); 
  94 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
) 
  98     wxDisplaySize(width
, height
); 
  99     // FIXME_MGL - windowed version needs different handling 
 102 bool wxColourDisplay() 
 104     wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") ); 
 106     return (wxDisplayDepth() > 1); 
 111     wxASSERT_MSG( g_displayDC
, wxT("You must call wxApp::SetDisplayMode before using this function") ); 
 113     return g_displayDC
->getBitsPerPixel(); 
 116 wxPortId 
wxGUIAppTraits::GetToolkitVersion(int *verMaj
, int *verMin
) const 
 119         *verMaj 
= MGL_RELEASE_MAJOR
; 
 121         *verMin 
= MGL_RELEASE_MINOR
; 
 126 wxEventLoopBase
* wxGUIAppTraits::CreateEventLoop() 
 128     return new wxEventLoop
; 
 132 void wxGetMousePosition(int* x
, int* y
) 
 137 wxPoint 
wxGetMousePosition() 
 140     wxGetMousePosition(&pt
.x
, &pt
.y
); 
 144 wxMouseState 
wxGetMouseState() 
 149     wxGetMousePosition(&x
, &y
); 
 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
); 
 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
)); 
 170 int wxAddProcessCallback(wxEndProcessData 
*proc_data
, int fd
) 
 172     wxFAIL_MSG(wxT("wxAddProcessCallback not implemented in wxMGL!")); 
 174 #if 0 // FIXME_MGL -do we need it at all? 
 175     int tag 
= gdk_input_add(fd
, 
 177                             GTK_EndProcessDetector
, 
 178                             (gpointer
)proc_data
);