#include "wx/timer.h"
#include "wx/settings.h"
#include "wx/msgdlg.h"
+ #include "wx/scrolbar.h"
+ #include "wx/listbox.h"
+ #include "wx/scrolwin.h"
+ #include "wx/layout.h"
+ #include "wx/menuitem.h"
+ #include "wx/module.h"
#endif
-#include "wx/layout.h"
-#include "wx/listbox.h"
-#include "wx/scrolwin.h"
-#include "wx/scrolbar.h"
-#include "wx/module.h"
-#include "wx/menuitem.h"
#include "wx/fontutil.h"
#include "wx/univ/renderer.h"
}
// Destroy the window
- Window xwindow = (Window) m_mainWindow;
- wxDeleteWindowFromTable( xwindow );
- XDestroyWindow( wxGlobalDisplay(), xwindow );
- m_mainWindow = NULL;
+ if ( m_mainWindow )
+ {
+ Window xwindow = (Window) m_mainWindow;
+ wxDeleteWindowFromTable( xwindow );
+ XDestroyWindow( wxGlobalDisplay(), xwindow );
+ m_mainWindow = NULL;
+ }
}
// ---------------------------------------------------------------------------
int direction, ascent, descent2;
XCharStruct overall;
- int slen = string.Len();
+ int slen = string.length();
XTextExtents((XFontStruct*) pFontStruct, (char*) string.c_str(), slen,
&direction, &ascent, &descent2, &overall);
return wxFindWindowAtPoint(wxGetMousePosition());
}
-// Get the current mouse position.
-wxPoint wxGetMousePosition()
+void wxGetMouseState(int& rootX, int& rootY, unsigned& maskReturn)
{
#if wxUSE_NANOX
/* TODO */
- return wxPoint(0, 0);
+ rootX = rootY = 0;
+ maskReturn = 0;
#else
Display *display = wxGlobalDisplay();
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
Window rootReturn, childReturn;
- int rootX, rootY, winX, winY;
- unsigned int maskReturn;
+ int winX, winY;
XQueryPointer (display,
rootWindow,
&rootReturn,
&childReturn,
&rootX, &rootY, &winX, &winY, &maskReturn);
- return wxPoint(rootX, rootY);
#endif
}
+// Get the current mouse position.
+wxPoint wxGetMousePosition()
+{
+ int x, y;
+ unsigned mask;
+
+ wxGetMouseState(x, y, mask);
+ return wxPoint(x, y);
+}
+
+wxMouseState wxGetMouseState()
+{
+ wxMouseState ms;
+ int x, y;
+ unsigned mask;
+
+ wxGetMouseState(x, y, mask);
+
+ ms.SetX(x);
+ ms.SetY(y);
+
+ ms.SetLeftDown(mask & Button1Mask);
+ ms.SetMiddleDown(mask & Button2Mask);
+ ms.SetRightDown(mask & Button3Mask);
+
+ ms.SetControlDown(mask & ControlMask);
+ ms.SetShiftDown(mask & ShiftMask);
+ ms.SetAltDown(mask & Mod3Mask);
+ ms.SetMetaDown(mask & Mod1Mask);
+
+ return ms;
+}
+
// ----------------------------------------------------------------------------
// wxNoOptimize: switch off size optimization
class wxWinModule : public wxModule
{
public:
- bool OnInit();
- void OnExit();
+ wxWinModule()
+ {
+ // we must be cleaned up before the display is closed
+ AddDependency(wxClassInfo::FindClass(_T("wxX11DisplayModule")));
+ }
+
+ virtual bool OnInit();
+ virtual void OnExit();
private:
DECLARE_DYNAMIC_CLASS(wxWinModule)