From 0388831b8c7945a6afa328b321e52240df5fc394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 17 Aug 2012 15:53:52 +0000 Subject: [PATCH] [DEVELOPMENT ENVIRONMENT] * BUG: Fix a possible crash in form editor arrangement icons managemnt. [GB.GTK] * NEW: DrawingArea.UseTablet has been renamed as DrawingArea.Tablet. * NEW: Pointer.ScreenX and Pointer.ScreenY are two new properties that replace Pointer.X and Pointer.Y. Pointer.X and Pointer.Y are yet there, but now they return the pointer position relative to the control receiving the event. * BUG: Try to activate all XInput devices when the DrawingArea.Tablet property is set. [GB.QT4] * NEW: DrawingArea.UseTablet has been renamed as DrawingArea.Tablet. * NEW: Pointer.ScreenX and Pointer.ScreenY are two new properties that replace Pointer.X and Pointer.Y. Pointer.X and Pointer.Y are yet there, but now they return the pointer position relative to the control receiving the event. git-svn-id: svn://localhost/gambas/trunk@5051 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- TODO | 1 - app/src/gambas3/.src/Family/CFamily.class | 3 ++ gb.gtk/src/CDrawingArea.cpp | 4 +-- gb.gtk/src/CMouse.cpp | 20 +++++++++-- gb.gtk/src/gdrawingarea.cpp | 3 ++ gb.gtk/src/gmouse.cpp | 44 +++++++++++++++++++++++ gb.gtk/src/gmouse.h | 6 ++++ gb.qt4/share/gb.form.properties.h | 2 +- gb.qt4/src/CDrawingArea.cpp | 4 +-- gb.qt4/src/CMouse.cpp | 18 +++++++++- 10 files changed, 96 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index 2ea9ea044..2b2c02af1 100644 --- a/TODO +++ b/TODO @@ -33,7 +33,6 @@ DEBUGGER DEVELOPMENT ENVIRONMENT -- Bookmarks in editor. - Manage Object properties in IDE. - Make a visual control clipboard. - Generates an index control->component to suggest components for missing controls. diff --git a/app/src/gambas3/.src/Family/CFamily.class b/app/src/gambas3/.src/Family/CFamily.class index 819e1384c..13b888471 100644 --- a/app/src/gambas3/.src/Family/CFamily.class +++ b/app/src/gambas3/.src/Family/CFamily.class @@ -316,6 +316,9 @@ End Public Sub Timer_Timer() CheckIcons + +Finally + $bTrigger = False End diff --git a/gb.gtk/src/CDrawingArea.cpp b/gb.gtk/src/CDrawingArea.cpp index 21f52ae7c..d18a11983 100644 --- a/gb.gtk/src/CDrawingArea.cpp +++ b/gb.gtk/src/CDrawingArea.cpp @@ -162,7 +162,7 @@ BEGIN_METHOD(DrawingArea_Refresh, GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_I END_METHOD -BEGIN_PROPERTY(DrawingArea_UseTablet) +BEGIN_PROPERTY(DrawingArea_Tablet) if (READ_PROPERTY) GB.ReturnBoolean(WIDGET->useTablet()); @@ -191,7 +191,7 @@ GB_DESC CDrawingAreaDesc[] = GB_PROPERTY("Painted", "b", CDRAWINGAREA_painted), GB_PROPERTY("NoBackground", "b", DrawingArea_NoBackground), - GB_PROPERTY("UseTablet", "b", DrawingArea_UseTablet), + GB_PROPERTY("Tablet", "b", DrawingArea_Tablet), GB_METHOD("Clear", 0, CDRAWINGAREA_clear, NULL), GB_METHOD("Refresh", NULL, DrawingArea_Refresh, "[(X)i(Y)i(Width)i(Height)i]"), diff --git a/gb.gtk/src/CMouse.cpp b/gb.gtk/src/CMouse.cpp index 1733fc25e..7fd10418c 100644 --- a/gb.gtk/src/CMouse.cpp +++ b/gb.gtk/src/CMouse.cpp @@ -231,17 +231,31 @@ END_METHOD //------------------------------------------------------------------------- +BEGIN_PROPERTY(Pointer_ScreenX) + + CHECK_VALID(); + GB.ReturnFloat(gMouse::getPointerScreenX()); + +END_PROPERTY + +BEGIN_PROPERTY(Pointer_ScreenY) + + CHECK_VALID(); + GB.ReturnFloat(gMouse::getPointerScreenY()); + +END_PROPERTY + BEGIN_PROPERTY(Pointer_X) CHECK_VALID(); - GB.ReturnFloat(gMouse::getAxis(GDK_AXIS_X)); + GB.ReturnFloat(gMouse::getPointerX()); END_PROPERTY BEGIN_PROPERTY(Pointer_Y) CHECK_VALID(); - GB.ReturnFloat(gMouse::getAxis(GDK_AXIS_Y)); + GB.ReturnFloat(gMouse::getPointerY()); END_PROPERTY @@ -370,6 +384,8 @@ GB_DESC CPointerDesc[] = GB_STATIC_PROPERTY_READ("Type", "i", Pointer_Type), GB_STATIC_PROPERTY_READ("X", "f", Pointer_X), GB_STATIC_PROPERTY_READ("Y", "f", Pointer_Y), + GB_STATIC_PROPERTY_READ("ScreenX", "f", Pointer_ScreenX), + GB_STATIC_PROPERTY_READ("ScreenY", "f", Pointer_ScreenY), GB_STATIC_PROPERTY_READ("XTilt", "f", Pointer_XTilt), GB_STATIC_PROPERTY_READ("YTitt", "f", Pointer_YTilt), GB_STATIC_PROPERTY_READ("Pressure", "f", Pointer_Pressure), diff --git a/gb.gtk/src/gdrawingarea.cpp b/gb.gtk/src/gdrawingarea.cpp index 23056ca31..604b6f3a8 100644 --- a/gb.gtk/src/gdrawingarea.cpp +++ b/gb.gtk/src/gdrawingarea.cpp @@ -23,6 +23,7 @@ #include "widgets.h" #include "gdraw.h" +#include "gmouse.h" #include "gdrawingarea.h" /**************************************************************************************** @@ -370,6 +371,8 @@ void gDrawingArea::setRealBackground(gColor color) void gDrawingArea::updateUseTablet() { + if (_use_tablet) + gMouse::initDevices(); gtk_widget_set_extension_events(widget, _use_tablet ? GDK_EXTENSION_EVENTS_ALL : GDK_EXTENSION_EVENTS_NONE); } diff --git a/gb.gtk/src/gmouse.cpp b/gb.gtk/src/gmouse.cpp index 27b0fd514..c455b7de3 100644 --- a/gb.gtk/src/gmouse.cpp +++ b/gb.gtk/src/gmouse.cpp @@ -242,3 +242,47 @@ int gMouse::getType() default: return POINTER_MOUSE; } } + +void gMouse::initDevices() +{ + static bool done = false; + + GList *devices; + GdkDevice *device; + + if (done) + return; + + devices = gdk_devices_list(); + + while (devices) + { + device = (GdkDevice *)devices->data; + fprintf(stderr, "%s\n", gdk_device_get_name(device)); + gdk_device_set_mode(device, GDK_MODE_SCREEN); + devices = devices->next; + } + + done = true; +} + +double gMouse::getPointerX() +{ + return ((GdkEventMotion *)_event)->x; +} + +double gMouse::getPointerY() +{ + return ((GdkEventMotion *)_event)->y; +} + +double gMouse::getPointerScreenX() +{ + return getAxis(GDK_AXIS_X); +} + +double gMouse::getPointerScreenY() +{ + return getAxis(GDK_AXIS_Y); +} + diff --git a/gb.gtk/src/gmouse.h b/gb.gtk/src/gmouse.h index 659c9a690..68d07ef01 100644 --- a/gb.gtk/src/gmouse.h +++ b/gb.gtk/src/gmouse.h @@ -51,6 +51,12 @@ public: static double getAxis(GdkAxisUse axis); static int getType(); + static double getPointerX(); + static double getPointerY(); + static double getPointerScreenX(); + static double getPointerScreenY(); + + static void initDevices(); //"Methods" static void move(int x, int y); diff --git a/gb.qt4/share/gb.form.properties.h b/gb.qt4/share/gb.form.properties.h index 36ac59737..90d70300f 100644 --- a/gb.qt4/share/gb.form.properties.h +++ b/gb.qt4/share/gb.form.properties.h @@ -42,7 +42,7 @@ #define CCOLUMNVIEW_PROPERTIES "*,Mode{Select.*}=Single,Sorted,Editable,Header=True,Resizable=False,AutoResize=True,Border=True,ScrollBar{Scroll.*}=Both" #define CCOMBOBOX_PROPERTIES "*,Action,ReadOnly,List,Text,Password,MaxLength,Sorted" #define CDIAL_PROPERTIES "*,MinValue=0,MaxValue=100,Step=1,PageStep=10,Wrap,Mark=True" -#define CDRAWINGAREA_PROPERTIES "*," CARRANGEMENT_PROPERTIES ",Border{Border.*},Cached,Painted,Focus,NoBackground,UseTablet" +#define CDRAWINGAREA_PROPERTIES "*," CARRANGEMENT_PROPERTIES ",Border{Border.*},Cached,Painted,Focus,NoBackground,Tablet" #define CEDITOR_PROPERTIES "*,Font{Font:Fixed},Border=True,ScrollBar{Scroll.*}=Both,Highlight{Highlight.None;Custom;Gambas;HTML;CSS;WebPage;Diff;JavaScript;SQL}=None,ReadOnly=False,TabSize{Range:1;16}=2" #define CFRAME_PROPERTIES "*,Text" #define CGRIDVIEW_PROPERTIES "*,Mode{Select.None;Single;Multiple}=None,Grid=True,Header{GridView.None;Vertical;Horizontal;Both}=None,Scrollbar{Scroll.*}=Both,Border=True,AutoResize=True,Resizable=True" diff --git a/gb.qt4/src/CDrawingArea.cpp b/gb.qt4/src/CDrawingArea.cpp index fdc8a30ae..173901b99 100644 --- a/gb.qt4/src/CDrawingArea.cpp +++ b/gb.qt4/src/CDrawingArea.cpp @@ -639,7 +639,7 @@ BEGIN_METHOD(DrawingArea_Refresh, GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_I END_METHOD -BEGIN_PROPERTY(DrawingArea_UseTablet) +BEGIN_PROPERTY(DrawingArea_Tablet) if (READ_PROPERTY) GB.ReturnBoolean(THIS->widget.flag.use_tablet); @@ -671,7 +671,7 @@ GB_DESC CDrawingAreaDesc[] = GB_PROPERTY("Focus", "b", CDRAWINGAREA_focus), GB_PROPERTY("Enabled", "b", CDRAWINGAREA_enabled), GB_PROPERTY("Painted", "b", CDRAWINGAREA_painted), - GB_PROPERTY("UseTablet", "b", DrawingArea_UseTablet), + GB_PROPERTY("Tablet", "b", DrawingArea_Tablet), GB_METHOD("Clear", NULL, CDRAWINGAREA_clear, NULL), GB_METHOD("Refresh", NULL, DrawingArea_Refresh, "[(X)i(Y)i(Width)i(Height)i]"), diff --git a/gb.qt4/src/CMouse.cpp b/gb.qt4/src/CMouse.cpp index d1feae3a1..99ca65362 100644 --- a/gb.qt4/src/CMouse.cpp +++ b/gb.qt4/src/CMouse.cpp @@ -336,12 +336,26 @@ END_METHOD BEGIN_PROPERTY(Pointer_X) CHECK_VALID(); - GB.ReturnFloat(CMOUSE_info.tx); + GB.ReturnFloat((double)CMOUSE_info.x + (CMOUSE_info.tx - (int)CMOUSE_info.tx)); END_PROPERTY BEGIN_PROPERTY(Pointer_Y) + CHECK_VALID(); + GB.ReturnFloat((double)CMOUSE_info.y + (CMOUSE_info.ty - (int)CMOUSE_info.ty)); + +END_PROPERTY + +BEGIN_PROPERTY(Pointer_ScreenX) + + CHECK_VALID(); + GB.ReturnFloat(CMOUSE_info.tx); + +END_PROPERTY + +BEGIN_PROPERTY(Pointer_ScreenY) + CHECK_VALID(); GB.ReturnFloat(CMOUSE_info.ty); @@ -474,6 +488,8 @@ GB_DESC CPointerDesc[] = GB_STATIC_PROPERTY_READ("Type", "i", Pointer_Type), GB_STATIC_PROPERTY_READ("X", "f", Pointer_X), GB_STATIC_PROPERTY_READ("Y", "f", Pointer_Y), + GB_STATIC_PROPERTY_READ("ScreenX", "f", Pointer_ScreenX), + GB_STATIC_PROPERTY_READ("ScreenY", "f", Pointer_ScreenY), GB_STATIC_PROPERTY_READ("XTilt", "f", Pointer_XTilt), GB_STATIC_PROPERTY_READ("YTitt", "f", Pointer_YTilt), GB_STATIC_PROPERTY_READ("Pressure", "f", Pointer_Pressure),