From 2f2ca62347688c9f34fa5970c4b3c58d3cd6fc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 24 Jan 2014 23:54:53 +0000 Subject: [PATCH] [GB.GTK] * BUG: Controls inside TabStrip now are detected correctly and are not insensitive anymore. [GB.GTK3] * BUG: Controls inside TabStrip now are detected correctly and are not insensitive anymore. git-svn-id: svn://localhost/gambas/trunk@6100 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.gtk/src/gapplication.cpp | 3 ++- gb.gtk/src/gcontainer.cpp | 7 +++++++ gb.gtk/src/gcontrol.cpp | 21 ++++++++++++++------- gb.gtk/src/gcontrol.h | 2 +- gb.gtk/src/gmainwindow.cpp | 8 +++----- gb.gtk/src/gmainwindow.h | 2 +- gb.gtk/src/gtabstrip.cpp | 27 +++++++++++++-------------- 7 files changed, 41 insertions(+), 29 deletions(-) diff --git a/gb.gtk/src/gapplication.cpp b/gb.gtk/src/gapplication.cpp index e1d7a01e7..a53a9e370 100644 --- a/gb.gtk/src/gapplication.cpp +++ b/gb.gtk/src/gapplication.cpp @@ -112,7 +112,6 @@ static gControl *find_child(gControl *control, int rx, int ry, gControl *button_ gControl *child; int x, y; - //fprintf(stderr, "find_child: %s ", control->name()); if (gApplication::_control_grab) return gApplication::_control_grab; @@ -127,6 +126,8 @@ static gControl *find_child(gControl *control, int rx, int ry, gControl *button_ if (button_grab) return button_grab; + //fprintf(stderr, "find_child: %s\n", control->name()); + control = control->topLevel(); while (control->isContainer()) diff --git a/gb.gtk/src/gcontainer.cpp b/gb.gtk/src/gcontainer.cpp index ddd0aa449..3f885c991 100644 --- a/gb.gtk/src/gcontainer.cpp +++ b/gb.gtk/src/gcontainer.cpp @@ -515,6 +515,8 @@ gControl *gContainer::find(int x, int y) int i; gControl *ch; + //fprintf(stderr, "gContainer::find: %s (C %d %d %d %d) (S %d %d): %d %d\n", name(), clientX(), clientY(), clientWidth(), clientHeight(), scrollX(), scrollY(), x, y); + x -= clientX(); y -= clientY(); @@ -533,10 +535,15 @@ gControl *gContainer::find(int x, int y) for (i = childCount() - 1; i >= 0; i--) { ch = child(i); + //fprintf(stderr, "test: %s %d: %d %d %d %d / %d %d\n", ch->name(), ch->isVisible(), ch->x(), ch->y(), ch->width(), ch->height(), x, y); if (ch->isVisible() && x >= ch->left() && y >= ch->top() && x < (ch->left() + ch->width()) && y < (ch->top() + ch->height())) + { + //fprintf(stderr, "--> %s\n", ch->name()); return ch; + } } + //fprintf(stderr, "--> NULL\n"); return NULL; } diff --git a/gb.gtk/src/gcontrol.cpp b/gb.gtk/src/gcontrol.cpp index a3540c7b7..81823b7b3 100644 --- a/gb.gtk/src/gcontrol.cpp +++ b/gb.gtk/src/gcontrol.cpp @@ -415,16 +415,18 @@ POSITION AND SIZE ******************************************************************/ -void gControl::getScreenPos(int *x, int *y) +bool gControl::getScreenPos(int *x, int *y) { if (!gtk_widget_get_window(border)) { - *x = *y = 0; - return; + *x = *y = 0; // widget is not realized + return true; } gdk_window_get_origin(gtk_widget_get_window(border), x, y); + //fprintf(stderr, "getScreenPos: %s: %d %d: %d\n", name(), *x, *y, gtk_widget_get_has_window(border)); + #if GTK_CHECK_VERSION(2, 18, 0) if (!gtk_widget_get_has_window(border)) { @@ -434,6 +436,9 @@ void gControl::getScreenPos(int *x, int *y) *y += a.y; } #endif + + //fprintf(stderr, "getScreenPos: --> %d %d\n", *x, *y); + return false; } int gControl::screenX() @@ -1520,6 +1525,7 @@ PATCH_DECLARE(GTK_TYPE_TOGGLE_BUTTON) PATCH_DECLARE(GTK_TYPE_SCROLLED_WINDOW) PATCH_DECLARE(GTK_TYPE_CHECK_BUTTON) PATCH_DECLARE(GTK_TYPE_RADIO_BUTTON) +PATCH_DECLARE(GTK_TYPE_NOTEBOOK) int gt_get_preferred_width(GtkWidget *widget) { @@ -1579,6 +1585,7 @@ void gControl::realize(bool make_frame) else PATCH_CLASS(border, GTK_TYPE_SCROLLED_WINDOW) else PATCH_CLASS(border, GTK_TYPE_CHECK_BUTTON) else PATCH_CLASS(border, GTK_TYPE_RADIO_BUTTON) + else PATCH_CLASS(border, GTK_TYPE_NOTEBOOK) else fprintf(stderr, "gb.gtk3: warning: class %s was not patched\n", G_OBJECT_TYPE_NAME(border)); #endif @@ -1686,19 +1693,19 @@ int gControl::getFrameWidth() return p; } - if (_scroll) + /*if (_scroll) { if (gtk_scrolled_window_get_shadow_type(_scroll) == GTK_SHADOW_NONE) return 0; else - return 2; - } + return gApplication::getFrameWidth(); + }*/ switch (frame_border) { case BORDER_NONE: p = 0; break; case BORDER_PLAIN: p = 1; break; - default: p = 2; break; // TODO: Use style + default: p = gApplication::getFrameWidth(); break; } return p; } diff --git a/gb.gtk/src/gcontrol.h b/gb.gtk/src/gcontrol.h index b7d629d7b..090ee3d3c 100644 --- a/gb.gtk/src/gcontrol.h +++ b/gb.gtk/src/gcontrol.h @@ -72,7 +72,7 @@ public: gControl *previous(); int screenX(); int screenY(); - virtual void getScreenPos(int *x, int *y); + virtual bool getScreenPos(int *x, int *y); char *toolTip(); bool isVisible() const { return visible; } bool isReallyVisible(); diff --git a/gb.gtk/src/gmainwindow.cpp b/gb.gtk/src/gmainwindow.cpp index 054e58d02..17c5bae52 100644 --- a/gb.gtk/src/gmainwindow.cpp +++ b/gb.gtk/src/gmainwindow.cpp @@ -1441,12 +1441,10 @@ void gMainWindow::embedMenuBar(GtkWidget *border) } } -void gMainWindow::getScreenPos(int *x, int *y) +/*bool gMainWindow::getScreenPos(int *x, int *y) { - gContainer::getScreenPos(x, y); - //if (y && isMenuBarVisible()) - // *y += menuBarHeight(); -} + return gContainer::getScreenPos(x, y); +}*/ double gMainWindow::opacity() { diff --git a/gb.gtk/src/gmainwindow.h b/gb.gtk/src/gmainwindow.h index 82fde1fc4..2edee6198 100644 --- a/gb.gtk/src/gmainwindow.h +++ b/gb.gtk/src/gmainwindow.h @@ -88,7 +88,7 @@ public: virtual int containerX(); virtual int containerY(); - virtual void getScreenPos(int *x, int *y); + //virtual bool getScreenPos(int *x, int *y); bool spontaneous() { return !_not_spontaneous; } diff --git a/gb.gtk/src/gtabstrip.cpp b/gb.gtk/src/gtabstrip.cpp index c69207829..761023393 100644 --- a/gb.gtk/src/gtabstrip.cpp +++ b/gb.gtk/src/gtabstrip.cpp @@ -71,10 +71,19 @@ static void cb_size_allocate(GtkWidget *wid, GtkAllocation *alloc, gTabStrip *da { if (wid == data->getContainer() && (alloc->width != data->_client_w || alloc->height != data->_client_h)) { - data->_client_x = alloc->x; - data->_client_y = alloc->y; + int tx, ty, px, py; + + if (data->getScreenPos(&tx, &ty)) + return; + + gdk_window_get_origin(gtk_widget_get_window(wid), &px, &py); + //fprintf(stderr, "alloc: tab = %d %d page = %d %d alloc = %d %d\n", tx, ty, px, py, alloc->x, alloc->y); + + data->_client_x = px - tx + alloc->x; + data->_client_y = py - ty + alloc->y; data->_client_w = alloc->width; data->_client_h = alloc->height; + //fprintf(stderr, "alloc: %s: %d %d %d %d\n", data->name(), data->_client_x, data->_client_y, alloc->width, alloc->height); data->performArrange(); } } @@ -196,16 +205,6 @@ static void cb_scroll(GtkWidget *wid, GdkEvent *event, gTabStrip *data) if (dir == GDK_SCROLL_SMOOTH) return; - /* - { - gdouble dx = 0, dy = 0; - gdk_event_get_scroll_deltas((GdkEvent *)event, &dx, &dy); - if (fabs(dy) > fabs(dx)) - dir = (dy < 0) ? GDK_SCROLL_UP : GDK_SCROLL_DOWN; - else - dir = (dx < 0) ? GDK_SCROLL_LEFT : GDK_SCROLL_RIGHT; - }*/ - page = gtk_notebook_get_current_page(GTK_NOTEBOOK(data->widget)); switch (dir) @@ -533,10 +532,10 @@ gTabStrip::gTabStrip(gContainer *parent) : gContainer(parent) onClick = NULL; onClose = NULL; - border = gtk_event_box_new(); + //border = gtk_event_box_new(); //gtk_event_box_set_visible_window(GTK_EVENT_BOX(border), false); - widget = gtk_notebook_new(); + border = widget = gtk_notebook_new(); gtk_notebook_set_scrollable(GTK_NOTEBOOK(widget), TRUE); gtk_drag_dest_unset(widget);