[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
This commit is contained in:
parent
8bfa98f865
commit
2f2ca62347
7 changed files with 41 additions and 29 deletions
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue