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);
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;
+ 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)
{
(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);
(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);
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,
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,
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;
}
notebook->click_child = 0;
notebook->button = 0;
notebook->need_timer = 0;
+ notebook->child_has_focus = FALSE;
}
GtkWidget*
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)
{
}
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))
{
|| 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))
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
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
(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;
children = children->next;
num++;
}
+ if (!children && !GTK_WIDGET_HAS_FOCUS (widget))
+ gtk_widget_grab_focus (widget);
}
return FALSE;
}
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)
{
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));
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);
}
}
+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)
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);
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);
+ }
}
}
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:
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));
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);
}
if (showarrow) /* first_tab <- focus_tab */
{
- children = notebook->focus_tab->prev;
+ children = focus_tab->prev;
while (children)
{
if (notebook->first_tab == children)
}
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 */
{
notebook->first_tab = notebook->children;
children = NULL;
- gtk_notebook_calc_tabs (notebook, notebook->focus_tab->next,
+ gtk_notebook_calc_tabs (notebook, focus_tab->next,
&children, &tab_space, STEP_NEXT);
if (tab_space <= 0)
GtkNotebook *notebook;
GtkWidget *focus_child;
GtkNotebookPage *page = NULL;
- GtkNotebookPage *old_page;
+ GtkNotebookPage *old_page = NULL;
gint return_val;
g_return_val_if_fail (container != NULL, FALSE);
return FALSE;
}
- old_page = notebook->focus_tab->data;
- return_val = FALSE;
+ if (notebook->focus_tab)
+ old_page = notebook->focus_tab->data;
- if (!GTK_WIDGET_HAS_FOCUS (container) && !focus_child)
- {
- gtk_widget_grab_focus (GTK_WIDGET (container));
- return TRUE;
- }
+ return_val = FALSE;
- if (focus_child && focus_child == old_page->child)
+ if (focus_child && old_page && focus_child == old_page->child &&
+ notebook->child_has_focus)
{
if (GTK_WIDGET_VISIBLE (old_page->child))
{
case GTK_DIR_TAB_FORWARD:
case GTK_DIR_RIGHT:
case GTK_DIR_DOWN:
- if (!notebook->focus_tab->next)
- return FALSE;
+ if (!notebook->focus_tab)
+ notebook->focus_tab = notebook->children;
+ else
+ notebook->focus_tab = notebook->focus_tab->next;
+
+ if (!notebook->focus_tab)
+ {
+ gtk_notebook_focus_changed (notebook, old_page);
+ return FALSE;
+ }
- notebook->focus_tab = notebook->focus_tab->next;
page = notebook->focus_tab->data;
return_val = TRUE;
break;
case GTK_DIR_TAB_BACKWARD:
case GTK_DIR_LEFT:
case GTK_DIR_UP:
- if (!notebook->focus_tab->prev)
+ if (!notebook->focus_tab)
+ notebook->focus_tab = g_list_last (notebook->children);
+ else
+ notebook->focus_tab = notebook->focus_tab->prev;
+
+ if (!notebook->focus_tab)
+ {
+ gtk_notebook_focus_changed (notebook, old_page);
return FALSE;
+ }
- notebook->focus_tab = notebook->focus_tab->prev;
page = notebook->focus_tab->data;
return_val = TRUE;
break;
if (return_val)
{
+ if (!GTK_WIDGET_HAS_FOCUS (container) )
+ gtk_widget_grab_focus (GTK_WIDGET (container));
+
if (GTK_WIDGET_MAPPED (page->tab_label))
gtk_notebook_focus_changed (notebook, old_page);
else
gtk_notebook_switch_focus_tab (GtkNotebook *notebook,
GList *new_child)
{
- GtkNotebookPage *old_page;
+ GtkNotebookPage *old_page = NULL;
GtkNotebookPage *page;
g_return_if_fail (notebook != NULL);
if (notebook->focus_tab != new_child)
{
- old_page = notebook->focus_tab->data;
+ if (notebook->focus_tab)
+ old_page = notebook->focus_tab->data;
+
notebook->focus_tab = new_child;
page = notebook->focus_tab->data;
if (GTK_WIDGET_MAPPED (page->tab_label))
direction = GTK_DIR_RIGHT;
break;
case GDK_Tab:
+ case GDK_ISO_Left_Tab:
if (event->state & GDK_SHIFT_MASK)
direction = GTK_DIR_TAB_BACKWARD;
else