From dd544117b957dee3161b6f07d7801c8fa8c1d61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 2 Oct 2010 22:28:53 +0000 Subject: [PATCH] [GB.GTK] * BUG: MouseMove event should be correctly raised in all case now. git-svn-id: svn://localhost/gambas/trunk@3248 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.gtk/src/CWidget.cpp | 37 +++++++++++++++++++++++++++++-------- gb.gtk/src/gapplication.cpp | 5 +++++ gb.gtk/src/gcontrol.cpp | 7 +++++-- gb.gtk/src/gcontrol.h | 1 + 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/gb.gtk/src/CWidget.cpp b/gb.gtk/src/CWidget.cpp index 69c4f1957..de2e55d6d 100644 --- a/gb.gtk/src/CWidget.cpp +++ b/gb.gtk/src/CWidget.cpp @@ -136,6 +136,26 @@ void gb_plug_raise_error(gControl *sender) // GB.Unref(POINTER(&_object)); // } +static bool gb_can_raise(gControl *sender, int type) +{ + CWIDGET *ob = GetObject(sender); + if (!ob) return false; + + switch (type) + { + case gEvent_MousePress: type = EVENT_MouseDown; break; + case gEvent_MouseRelease: type = EVENT_MouseUp; break; + case gEvent_MouseMove: type = EVENT_MouseMove; break; + case gEvent_MouseDrag: type = EVENT_MouseDrag; break; + case gEvent_MouseWheel: type =EVENT_MouseWheel; break; + case gEvent_MouseMenu: type = EVENT_Menu; break; + case gEvent_MouseDblClick: type = EVENT_DblClick; break; + default: return true; + } + + return GB.CanRaise(ob, type); +} + bool gb_raise_MouseEvent(gControl *sender, int type) { CWIDGET *ob = GetObject(sender); @@ -332,14 +352,15 @@ void InitControl(gControl *control, CWIDGET *widget) control->setName(name); - control->onFinish=DeleteControl; - control->onMouseEvent=gb_raise_MouseEvent; - control->onKeyEvent=gb_raise_KeyEvent; - control->onFocusEvent=gb_raise_FocusEvent; - control->onDrag=gb_raise_Drag; - control->onDragMove=gb_raise_DragMove; - control->onDrop=gb_raise_Drop; - control->onEnterLeave=gb_raise_EnterLeave; + control->onFinish = DeleteControl; + control->onMouseEvent = gb_raise_MouseEvent; + control->onKeyEvent = gb_raise_KeyEvent; + control->onFocusEvent = gb_raise_FocusEvent; + control->onDrag = gb_raise_Drag; + control->onDragMove = gb_raise_DragMove; + control->onDrop = gb_raise_Drop; + control->onEnterLeave = gb_raise_EnterLeave; + control->canRaise = gb_can_raise; if (control->isContainer()) { diff --git a/gb.gtk/src/gapplication.cpp b/gb.gtk/src/gapplication.cpp index 9c3559505..a304ccbe5 100644 --- a/gb.gtk/src/gapplication.cpp +++ b/gb.gtk/src/gapplication.cpp @@ -314,7 +314,11 @@ static void gambas_handle_event(GdkEvent *event) if (grab) { if (widget != grab && !gtk_widget_is_ancestor(widget, grab)) + { widget = grab; + if (event->type == GDK_MOTION_NOTIFY) + fprintf(stderr, "GDK_MOTION_NOTIFY: -> %p\n", widget); + } } real = true; @@ -416,6 +420,7 @@ static void gambas_handle_event(GdkEvent *event) if (win->isPopup() && (x < 0 || y < 0 || x >= win->width() || y >= win->height())) win->close(); } + break; case GDK_2BUTTON_PRESS: diff --git a/gb.gtk/src/gcontrol.cpp b/gb.gtk/src/gcontrol.cpp index 64ddf0668..ddd9ab18a 100644 --- a/gb.gtk/src/gcontrol.cpp +++ b/gb.gtk/src/gcontrol.cpp @@ -1269,13 +1269,13 @@ void gControl::realize(bool make_frame) // g_signal_connect(G_OBJECT(widget), "size-allocate", G_CALLBACK(cb_size_allocate), (gpointer)this); gtk_widget_add_events(widget, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK - | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); if (widget != border && GTK_IS_EVENT_BOX(border) && !gtk_event_box_get_visible_window(GTK_EVENT_BOX(border))) { gtk_widget_add_events(border, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK - | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); } @@ -1671,6 +1671,8 @@ int gControl::minimumHeight() void gControl::setTracking(bool v) { + _tracking = v; + /* GtkWidget *wid; if (GTK_IS_EVENT_BOX(border)) @@ -1699,6 +1701,7 @@ void gControl::setTracking(bool v) gtk_widget_realize(wid); } } + */ } bool gControl::grab(bool showIt) diff --git a/gb.gtk/src/gcontrol.h b/gb.gtk/src/gcontrol.h index 24df4e057..d36330a84 100644 --- a/gb.gtk/src/gcontrol.h +++ b/gb.gtk/src/gcontrol.h @@ -151,6 +151,7 @@ public: void emit(void *signal, char *arg) { emit(signal, (intptr_t)arg); } // "Signals" + bool (*canRaise)(gControl *sender, int type); void (*onFinish)(gControl *sender); // Special void (*onFocusEvent)(gControl *sender, int type); bool (*onKeyEvent)(gControl *sender, int type);