Commit 6b61461a authored by Lars Hamann's avatar Lars Hamann

adapted clist pixmap clipping

        * gtk/gtkctree.c (draw_row): adapted clist pixmap clipping

        * gtk/gtknotebook.h (struct _GtkNotebookClass):
        * gtk/gtknotebook.c (gtk_real_notebook_switch_page):
        added missing argument (according to Joseph Coleman's bug report)

        * gtk/gtknotebook.c (gtk_notebook_set_focus_child): new class
        function to fix notebook focus handling
parent 344572dc
Wed Jun 10 22:23:27 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (draw_row): adapted clist pixmap clipping
* gtk/gtknotebook.h (struct _GtkNotebookClass):
* gtk/gtknotebook.c (gtk_real_notebook_switch_page):
added missing argument (according to Joseph Coleman's bug report)
* gtk/gtknotebook.c (gtk_notebook_set_focus_child): new class
function to fix notebook focus handling
Wed Jun 10 12:57:03 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdkcc.c glib/ghash.c glib/glib.h glib/gstring.c
......
Wed Jun 10 22:23:27 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (draw_row): adapted clist pixmap clipping
* gtk/gtknotebook.h (struct _GtkNotebookClass):
* gtk/gtknotebook.c (gtk_real_notebook_switch_page):
added missing argument (according to Joseph Coleman's bug report)
* gtk/gtknotebook.c (gtk_notebook_set_focus_child): new class
function to fix notebook focus handling
Wed Jun 10 12:57:03 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdkcc.c glib/ghash.c glib/glib.h glib/gstring.c
......
Wed Jun 10 22:23:27 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (draw_row): adapted clist pixmap clipping
* gtk/gtknotebook.h (struct _GtkNotebookClass):
* gtk/gtknotebook.c (gtk_real_notebook_switch_page):
added missing argument (according to Joseph Coleman's bug report)
* gtk/gtknotebook.c (gtk_notebook_set_focus_child): new class
function to fix notebook focus handling
Wed Jun 10 12:57:03 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdkcc.c glib/ghash.c glib/glib.h glib/gstring.c
......
Wed Jun 10 22:23:27 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (draw_row): adapted clist pixmap clipping
* gtk/gtknotebook.h (struct _GtkNotebookClass):
* gtk/gtknotebook.c (gtk_real_notebook_switch_page):
added missing argument (according to Joseph Coleman's bug report)
* gtk/gtknotebook.c (gtk_notebook_set_focus_child): new class
function to fix notebook focus handling
Wed Jun 10 12:57:03 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdkcc.c glib/ghash.c glib/glib.h glib/gstring.c
......
Wed Jun 10 22:23:27 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (draw_row): adapted clist pixmap clipping
* gtk/gtknotebook.h (struct _GtkNotebookClass):
* gtk/gtknotebook.c (gtk_real_notebook_switch_page):
added missing argument (according to Joseph Coleman's bug report)
* gtk/gtknotebook.c (gtk_notebook_set_focus_child): new class
function to fix notebook focus handling
Wed Jun 10 12:57:03 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdkcc.c glib/ghash.c glib/glib.h glib/gstring.c
......
Wed Jun 10 22:23:27 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (draw_row): adapted clist pixmap clipping
* gtk/gtknotebook.h (struct _GtkNotebookClass):
* gtk/gtknotebook.c (gtk_real_notebook_switch_page):
added missing argument (according to Joseph Coleman's bug report)
* gtk/gtknotebook.c (gtk_notebook_set_focus_child): new class
function to fix notebook focus handling
Wed Jun 10 12:57:03 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdkcc.c glib/ghash.c glib/glib.h glib/gstring.c
......
Wed Jun 10 22:23:27 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (draw_row): adapted clist pixmap clipping
* gtk/gtknotebook.h (struct _GtkNotebookClass):
* gtk/gtknotebook.c (gtk_real_notebook_switch_page):
added missing argument (according to Joseph Coleman's bug report)
* gtk/gtknotebook.c (gtk_notebook_set_focus_child): new class
function to fix notebook focus handling
Wed Jun 10 12:57:03 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdkcc.c glib/ghash.c glib/glib.h glib/gstring.c
......
......@@ -970,6 +970,7 @@ draw_row (GtkCList *clist,
gint i, offset = 0, width, height, pixmap_width = 0, string_width = 0;
gint xsrc, ysrc, xdest = 0, ydest;
gboolean need_redraw = TRUE;
gboolean draw_pixmap = FALSE;
g_return_if_fail (clist != NULL);
......@@ -1418,29 +1419,10 @@ draw_row (GtkCList *clist,
if (pixmap_width && xdest + pixmap_width >= rect->x &&
xdest <= rect->x + rect->width)
{
if (GTK_CELL_PIXTEXT (clist_row->cell[i])->mask)
{
gdk_gc_set_clip_mask
(fg_gc, GTK_CELL_PIXTEXT (clist_row->cell[i])->mask);
gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
}
gdk_draw_pixmap (clist->clist_window, fg_gc,
GTK_CELL_PIXTEXT
(clist_row->cell[i])->pixmap, xsrc, ysrc,
xdest, ydest, pixmap_width, height);
if (xdest + pixmap_width >
clip_rectangle.x + clip_rectangle.width)
gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
rect->x + rect->width, ydest + 1,
xdest + pixmap_width -
(rect->x + rect->width), height - 1);
}
draw_pixmap = TRUE;
xdest += (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
pixmap_width);
break;
case GTK_JUSTIFY_RIGHT:
offset_x = 0;
......@@ -1566,29 +1548,62 @@ draw_row (GtkCList *clist,
+ clist_row->cell[i].horizontal);
if (pixmap_width && xdest + pixmap_width >= rect->x &&
xdest <= rect->x + rect->width && xdest >= clip_rectangle.x)
xdest <= rect->x + rect->width)
draw_pixmap = TRUE;
break;
default :
break;
}
if (draw_pixmap)
{
if (GTK_CELL_PIXTEXT (clist_row->cell[i])->mask)
{
gdk_gc_set_clip_mask
(fg_gc, GTK_CELL_PIXTEXT (clist_row->cell[i])->mask);
gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
gdk_draw_pixmap (clist->clist_window, fg_gc,
GTK_CELL_PIXTEXT
(clist_row->cell[i])->pixmap,
xsrc, ysrc, xdest, ydest,
pixmap_width, height);
}
xdest -= (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
string_width);
break;
default :
break;
if (xdest < clip_rectangle.x)
{
xsrc = clip_rectangle.x - xdest;
pixmap_width -= xsrc;
xdest = clip_rectangle.x;
}
if (xdest + pixmap_width >
clip_rectangle.x + clip_rectangle.width)
pixmap_width =
(clip_rectangle.x + clip_rectangle.width) - xdest;
if (ydest < clip_rectangle.y)
{
ysrc = clip_rectangle.y - ydest;
height -= ysrc;
ydest = clip_rectangle.y;
}
if (ydest + height > clip_rectangle.y + clip_rectangle.height)
height = (clip_rectangle.y + clip_rectangle.height) - ydest;
gdk_draw_pixmap (clist->clist_window, fg_gc,
GTK_CELL_PIXTEXT
(clist_row->cell[i])->pixmap,
xsrc, ysrc, xdest, ydest,
pixmap_width, height);
}
if (string_width)
{
gint delta;
if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
xdest -= (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
string_width);
else
xdest += (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
pixmap_width);
delta = CELL_SPACING - (rect->y - clip_rectangle.y);
if (delta > 0)
{
......@@ -1641,6 +1656,29 @@ draw_row (GtkCList *clist,
(clist_row->cell[i])->mask);
gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
}
if (xdest < clip_rectangle.x)
{
xsrc = clip_rectangle.x - xdest;
pixmap_width -= xsrc;
xdest = clip_rectangle.x;
}
if (xdest + pixmap_width >
clip_rectangle.x + clip_rectangle.width)
pixmap_width = (clip_rectangle.x + clip_rectangle.width) -
xdest;
if (ydest < clip_rectangle.y)
{
ysrc = clip_rectangle.y - ydest;
height -= ysrc;
ydest = clip_rectangle.y;
}
if (ydest + height > clip_rectangle.y + clip_rectangle.height)
height = (clip_rectangle.y + clip_rectangle.height) - ydest;
gdk_draw_pixmap (clist->clist_window, fg_gc,
GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,
xsrc, ysrc, xdest, ydest, pixmap_width, height);
......@@ -1666,7 +1704,29 @@ draw_row (GtkCList *clist,
(clist_row->cell[i])->mask);
gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
}
if (xdest < clip_rectangle.x)
{
xsrc = clip_rectangle.x - xdest;
pixmap_width -= xsrc;
xdest = clip_rectangle.x;
}
if (xdest + pixmap_width >
clip_rectangle.x + clip_rectangle.width)
pixmap_width = (clip_rectangle.x + clip_rectangle.width)
- xdest;
if (ydest < clip_rectangle.y)
{
ysrc = clip_rectangle.y - ydest;
height -= ysrc;
ydest = clip_rectangle.y;
}
if (ydest + height > clip_rectangle.y + clip_rectangle.height)
height = (clip_rectangle.y + clip_rectangle.height) - ydest;
gdk_draw_pixmap (clist->clist_window, fg_gc,
GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
xsrc, ysrc, xdest, ydest, pixmap_width, height);
......
......@@ -94,6 +94,8 @@ static void gtk_notebook_switch_page (GtkNotebook *notebook,
static void gtk_notebook_draw_tab (GtkNotebook *notebook,
GtkNotebookPage *page,
GdkRectangle *area);
static void gtk_notebook_set_focus_child (GtkContainer *container,
GtkWidget *child);
static gint gtk_notebook_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static gint gtk_notebook_focus_out (GtkWidget *widget,
......@@ -121,7 +123,8 @@ static void gtk_notebook_expose_tabs (GtkNotebook *notebook);
static void gtk_notebook_switch_focus_tab (GtkNotebook *notebook,
GList *new_child);
static void gtk_real_notebook_switch_page (GtkNotebook *notebook,
GtkNotebookPage *page);
GtkNotebookPage *page,
gint page_num);
static void gtk_notebook_marshal_signal (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
......@@ -215,6 +218,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
container_class->remove = gtk_notebook_remove;
container_class->foreach = gtk_notebook_foreach;
container_class->focus = gtk_notebook_focus;
container_class->set_focus_child = gtk_notebook_set_focus_child;
class->switch_page = gtk_real_notebook_switch_page;
}
......@@ -240,6 +244,7 @@ gtk_notebook_init (GtkNotebook *notebook)
notebook->click_child = 0;
notebook->button = 0;
notebook->need_timer = 0;
notebook->child_has_focus = FALSE;
}
GtkWidget*
......@@ -384,9 +389,6 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
if (!notebook->first_tab)
notebook->first_tab = notebook->children;
if (!notebook->focus_tab)
notebook->focus_tab = notebook->children;
gtk_widget_set_parent (child, GTK_WIDGET (notebook));
if (tab_label)
{
......@@ -395,7 +397,10 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
}
if (!notebook->cur_page)
gtk_notebook_switch_page (notebook, page, 0);
{
gtk_notebook_switch_page (notebook, page, 0);
notebook->focus_tab = NULL;
}
if (GTK_WIDGET_VISIBLE (notebook))
{
......@@ -1479,9 +1484,6 @@ gtk_notebook_button_press (GtkWidget *widget,
|| notebook->button)
return FALSE;
if (!GTK_WIDGET_HAS_FOCUS (widget) && !(GTK_CONTAINER (widget)->focus_child))
gtk_widget_grab_focus (widget);
if (event->window == notebook->panel)
{
if (!GTK_WIDGET_HAS_FOCUS (widget))
......@@ -1495,7 +1497,9 @@ gtk_notebook_button_press (GtkWidget *widget,
notebook->click_child = GTK_ARROW_LEFT;
if (event->button == 1)
{
gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_LEFT);
if (!notebook->focus_tab || notebook->focus_tab->prev)
gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_LEFT);
if (!notebook->timer)
{
notebook->timer = gtk_timeout_add
......@@ -1515,7 +1519,8 @@ gtk_notebook_button_press (GtkWidget *widget,
notebook->click_child = GTK_ARROW_RIGHT;
if (event->button == 1)
{
gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_RIGHT);
if (!notebook->focus_tab || notebook->focus_tab->next)
gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_RIGHT);
if (!notebook->timer)
{
notebook->timer = gtk_timeout_add
......@@ -1554,14 +1559,13 @@ gtk_notebook_button_press (GtkWidget *widget,
(event->x <= (page->allocation.x + page->allocation.width)) &&
(event->y <= (page->allocation.y + page->allocation.height)))
{
gtk_container_set_focus_child (GTK_CONTAINER (notebook), NULL);
if (page == notebook->cur_page &&
notebook->focus_tab != children &&
if (page == notebook->cur_page && notebook->focus_tab &&
notebook->focus_tab != children &&
GTK_WIDGET_HAS_FOCUS (notebook))
{
GtkNotebookPage *old_page;
notebook->child_has_focus = FALSE;
old_page = (GtkNotebookPage *)
(notebook->focus_tab->data);
notebook->focus_tab = children;
......@@ -1578,6 +1582,8 @@ gtk_notebook_button_press (GtkWidget *widget,
children = children->next;
num++;
}
if (!children && !GTK_WIDGET_HAS_FOCUS (widget))
gtk_widget_grab_focus (widget);
}
return FALSE;
}
......@@ -1734,9 +1740,15 @@ gtk_notebook_timer (GtkNotebook *notebook)
if (notebook->timer)
{
if (notebook->click_child == GTK_ARROW_LEFT)
gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_LEFT);
{
if (!notebook->focus_tab || notebook->focus_tab->prev)
gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_LEFT);
}
else if (notebook->click_child == GTK_ARROW_RIGHT)
gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_RIGHT);
{
if (!notebook->focus_tab || notebook->focus_tab->next)
gtk_container_focus (GTK_CONTAINER (notebook), GTK_DIR_RIGHT);
}
if (notebook->need_timer)
{
......@@ -1803,7 +1815,8 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook, guint arrow)
static void
gtk_real_notebook_switch_page (GtkNotebook *notebook,
GtkNotebookPage *page)
GtkNotebookPage *page,
gint page_num)
{
g_return_if_fail (notebook != NULL);
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
......@@ -1817,7 +1830,8 @@ gtk_real_notebook_switch_page (GtkNotebook *notebook,
notebook->cur_page = page;
if (notebook->focus_tab->data != (gpointer) notebook->cur_page)
if (!notebook->focus_tab ||
notebook->focus_tab->data != (gpointer) notebook->cur_page)
notebook->focus_tab =
g_list_find (notebook->children, notebook->cur_page);
......@@ -2072,6 +2086,40 @@ gtk_notebook_draw_tab (GtkNotebook *notebook,
}
}
static void
gtk_notebook_set_focus_child (GtkContainer *container,
GtkWidget *child)
{
GtkNotebook *notebook;
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_NOTEBOOK (container));
if (child)
{
g_return_if_fail (GTK_IS_WIDGET (child));
notebook = GTK_NOTEBOOK (container);
notebook->child_has_focus = TRUE;
if (!notebook->focus_tab)
{
GList *children;
GtkNotebookPage *page;
children = notebook->children;
while (children)
{
page = children->data;
if (page->child == child || page->tab_label == child)
notebook->focus_tab = children;
children = children->next;
}
}
}
parent_class->set_focus_child (container, child);
}
static gint
gtk_notebook_focus_in (GtkWidget *widget,
GdkEventFocus *event)
......@@ -2080,14 +2128,7 @@ gtk_notebook_focus_in (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (GTK_CONTAINER (widget)->focus_child)
{
if (gtk_notebook_page_select (GTK_NOTEBOOK (widget)))
return FALSE;
else
gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
}
GTK_NOTEBOOK (widget)->child_has_focus = FALSE;
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
gtk_widget_draw_focus (widget);
......@@ -2149,43 +2190,48 @@ gtk_notebook_focus_changed (GtkNotebook *notebook, GtkNotebookPage *old_page)
g_return_if_fail (notebook != NULL);
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
g_return_if_fail (old_page != NULL);
widget = GTK_WIDGET (notebook);
if (GTK_WIDGET_DRAWABLE (widget) && notebook->show_tabs &&
notebook->focus_tab)
if (GTK_WIDGET_DRAWABLE (widget) && notebook->show_tabs)
{
GtkNotebookPage *page;
GdkGC *gc;
page = notebook->focus_tab->data;
if (GTK_WIDGET_HAS_FOCUS (widget))
gc = widget->style->black_gc;
else if (page == notebook->cur_page)
gc = widget->style->bg_gc[GTK_STATE_NORMAL];
else
gc = widget->style->bg_gc[GTK_STATE_ACTIVE];
if (notebook->focus_tab)
{
GtkNotebookPage *page;
gdk_draw_rectangle (widget->window,
gc, FALSE,
page->tab_label->allocation.x - 1,
page->tab_label->allocation.y - 1,
page->tab_label->allocation.width + 1,
page->tab_label->allocation.height + 1);
page = notebook->focus_tab->data;
if (old_page == notebook->cur_page)
gc = widget->style->bg_gc[GTK_STATE_NORMAL];
else
gc = widget->style->bg_gc[GTK_STATE_ACTIVE];
if (GTK_WIDGET_HAS_FOCUS (widget))
gc = widget->style->black_gc;
else if (page == notebook->cur_page)
gc = widget->style->bg_gc[GTK_STATE_NORMAL];
else
gc = widget->style->bg_gc[GTK_STATE_ACTIVE];
gdk_draw_rectangle (widget->window,
gc, FALSE,
page->tab_label->allocation.x - 1,
page->tab_label->allocation.y - 1,
page->tab_label->allocation.width + 1,
page->tab_label->allocation.height + 1);
}
gdk_draw_rectangle (widget->window,
gc, FALSE,
old_page->tab_label->allocation.x - 1,
old_page->tab_label->allocation.y - 1,
old_page->tab_label->allocation.width + 1,
old_page->tab_label->allocation.height + 1);
if (old_page)
{
if (old_page == notebook->cur_page)
gc = widget->style->bg_gc[GTK_STATE_NORMAL];
else
gc = widget->style->bg_gc[GTK_STATE_ACTIVE];
gdk_draw_rectangle (widget->window,
gc, FALSE,
old_page->tab_label->allocation.x - 1,
old_page->tab_label->allocation.y - 1,
old_page->tab_label->allocation.width + 1,
old_page->tab_label->allocation.height + 1);
}
}
}
......@@ -2295,7 +2341,17 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
if (notebook->scrollable)
{
GList *focus_tab;
children = notebook->children;
if (notebook->focus_tab)
focus_tab = notebook->focus_tab;
else if (notebook->first_tab)
focus_tab = notebook->first_tab;
else
focus_tab = notebook->children;
switch (notebook->tab_pos)
{
case GTK_POS_TOP:
......@@ -2309,7 +2365,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
if (tab_space > allocation->width - 2 * container->border_width - TAB_OVERLAP)
{
showarrow = TRUE;
page = notebook->focus_tab->data;
page = focus_tab->data;
tab_space = (allocation->width - TAB_OVERLAP - page->requisition.width -
2 * (container->border_width + ARROW_SPACING + ARROW_SIZE));
......@@ -2334,7 +2390,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
if (tab_space > (allocation->height - 2 * container->border_width - TAB_OVERLAP))
{
showarrow = TRUE;
page = notebook->focus_tab->data;
page = focus_tab->data;
tab_space = (allocation->height -
ARROW_SIZE - ARROW_SPACING - TAB_OVERLAP -
2 * container->border_width - page->requisition.height);
......@@ -2353,7 +2409,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
}
if (showarrow) /* first_tab <- focus_tab */
{
children = notebook->focus_tab->prev;
children = focus_tab->prev;
while (children)
{
if (notebook->first_tab == children)
......@@ -2362,17 +2418,17 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
}
if (!children)
notebook->first_tab = notebook->focus_tab;
notebook->first_tab = focus_tab;
else
gtk_notebook_calc_tabs (notebook, notebook->focus_tab->prev,
gtk_notebook_calc_tabs (notebook, focus_tab->prev,
&(notebook->first_tab), &tab_space,
STEP_PREV);
if (tab_space <= 0)
{
notebook->first_tab = notebook->first_tab->next;
if (!notebook->first_tab)
notebook->first_tab = notebook->focus_tab;
last_child = notebook->focus_tab->next;
notebook->first_tab = focus_tab;
last_child = focus_tab->next;
}
else /* focus_tab -> end */
{
......@@ -2380,7 +2436,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook,
notebook->first_tab = notebook->children;