{ GTK_CMCTREE_POS_AFTER, "GTK_CMCTREE_POS_AFTER", "after" },
{ 0, NULL, NULL }
};
-#if GLIB_CHECK_VERSION(2,10,0)
etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreePos"), values);
-#else
- etype = g_enum_register_static ("GtkCMCTreePos", values);
-#endif
}
return etype;
}
{ GTK_CMCTREE_LINES_NONE, "GTK_CMCTREE_LINES_NONE", "none" },
{ 0, NULL, NULL }
};
-#if GLIB_CHECK_VERSION(2,10,0)
etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreeLineStyle"), values);
-#else
- etype = g_enum_register_static ("GtkCMCTreeLineStyle", values);
-#endif
}
return etype;
}
{ GTK_CMCTREE_EXPANDER_TRIANGLE, "GTK_CMCTREE_EXPANDER_TRIANGLE", "triangle" },
{ 0, NULL, NULL }
};
-#if GLIB_CHECK_VERSION(2,10,0)
etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreeExpanderStyle"), values);
-#else
- etype = g_enum_register_static ("GtkCMCTreeExpanderStyle", values);
-#endif
}
return etype;
}
{ GTK_CMCTREE_EXPANSION_TOGGLE_RECURSIVE, "GTK_CMCTREE_EXPANSION_TOGGLE_RECURSIVE", "toggle-recursive" },
{ 0, NULL, NULL }
};
-#if GLIB_CHECK_VERSION(2,10,0)
- etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreeExpansionType"), values);
-#else
- etype = g_enum_register_static ("GtkCMCTreeExpansionType", values);
-#endif
+ etype = g_enum_register_static (g_intern_static_string ("GtkCMCTreeExpansionType"), values);
}
return etype;
}
sizeof (GtkCMCTree),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_cmctree_init,
+
+ (const GTypeValueTable *) NULL /* value table */
};
ctree_type = g_type_register_static (GTK_TYPE_CMCLIST, "GtkCMCTree", &ctree_info, (GTypeFlags)0);
gint x)
{
GtkCMCList *clist;
- GdkPoint points[3];
gint justification_factor;
gint y;
return x + justification_factor * (PM_SIZE + 3);
}
+ /* pixel offsets +/- 1 or +/- justification_factor here and there ..
+ * to fill correctly, somewhat ... what do I do wrong?
+ */
+ gdk_cairo_set_source_color(cr, >k_widget_get_style(GTK_WIDGET(ctree))->text[GTK_STATE_NORMAL]);
if (ctree_row->expanded)
{
- points[0].x = x;
- points[0].y = y + (PM_SIZE + 2) / 6;
- points[1].x = points[0].x + justification_factor * (PM_SIZE + 2);
- points[1].y = points[0].y;
- points[2].x = (points[0].x +
- justification_factor * (PM_SIZE + 2) / 2);
- points[2].y = y + 2 * (PM_SIZE + 2) / 3;
+ gint tmp3 = PM_SIZE / 2;
+ gint tmp6 = PM_SIZE / 6;
+ cairo_move_to(cr, x + justification_factor * (tmp3 + tmp6) + (PM_SIZE / 2), y + 1);
+ cairo_rel_line_to(cr, 0, tmp3 + tmp6 + 1);
+ cairo_rel_line_to(cr, -justification_factor * (tmp3 + tmp6) - justification_factor, -1);
}
else
{
- points[0].x = x + justification_factor * ((PM_SIZE + 2) / 6 + 2);
- points[0].y = y - 1;
- points[1].x = points[0].x;
- points[1].y = points[0].y + (PM_SIZE + 2);
- points[2].x = (points[0].x +
- justification_factor * (2 * (PM_SIZE + 2) / 3 - 1));
- points[2].y = points[0].y + (PM_SIZE + 2) / 2;
+ gint tmp3 = PM_SIZE / 2;
+ gint tmp6 = PM_SIZE / 6;
+ cairo_move_to(cr, x + tmp6 - justification_factor + (PM_SIZE / 2), y + tmp6 - 1);
+ cairo_rel_line_to(cr, justification_factor * tmp3, tmp3);
+ cairo_rel_line_to(cr, -justification_factor * tmp3, tmp3);
}
-
-
- cairo_new_path(cr);
- cairo_set_source_rgb(cr, 255, 255, 255);
- cairo_set_line_width(cr, 1);
- cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
- cairo_move_to(cr, points[0].x, points[0].y);
- cairo_line_to(cr, points[1].x, points[1].y);
- cairo_line_to(cr, points[2].x, points[2].y);
- cairo_close_path(cr);
cairo_fill(cr);
-
- cairo_new_path(cr);
- gdk_cairo_set_source_color(cr, >k_widget_get_style(ctree)->fg[GTK_STATE_NORMAL]);
- cairo_set_line_width(cr, 1);
- cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
- cairo_move_to(cr, points[0].x, points[0].y);
- cairo_line_to(cr, points[1].x, points[1].y);
- cairo_line_to(cr, points[2].x, points[2].y);
- cairo_close_path(cr);
- cairo_stroke(cr);
- cairo_set_antialias(cr, CAIRO_ANTIALIAS_DEFAULT);
x += justification_factor * (PM_SIZE + 3);
GtkWidget *widget;
GtkStyle *style;
GtkCMCTree *ctree;
- GdkRectangle *rect;
GdkRectangle *crect;
GdkRectangle row_rectangle;
GdkRectangle cell_rectangle;
GdkRectangle clip_rectangle;
GdkRectangle intersect_rectangle;
gint last_column;
- gint column_left = 0;
- gint column_right = 0;
gint offset = 0;
gint state;
gint i;
cm_return_if_fail (clist != NULL);
widget = GTK_WIDGET (clist);
- style = gtk_widget_get_style (widget);
+
+ /* if the function is passed the pointer to the row instead of null,
+ * it avoids this expensive lookup */
+ if (!clist_row)
+ clist_row = (g_list_nth (clist->row_list, row))->data;
+
+ style = clist_row->style ? clist_row->style : gtk_widget_get_style (widget);
if (greybg.pixel == 0 &&
greybg.red == 0 &&
ctree = GTK_CMCTREE (clist);
- /* if the function is passed the pointer to the row instead of null,
- * it avoids this expensive lookup */
- if (!clist_row)
- clist_row = (g_list_nth (clist->row_list, row))->data;
-
/* rectangle of the entire row */
row_rectangle.x = 0;
row_rectangle.y = ROW_TOP_YPIXEL (clist, row);
state = clist_row->state;
cr = gdk_cairo_create(clist->clist_window);
- fgcolor = &style->fg[clist_row->state];
+
+ if (clist_row->fg_set && state != GTK_STATE_SELECTED)
+ fgcolor = &clist_row->foreground;
+ else
+ fgcolor = &style->text[clist_row->state];
/* draw the cell borders */
if (area)
{
- rect = &intersect_rectangle;
crect = &intersect_rectangle;
if (gdk_rectangle_intersect (area, &cell_rectangle, crect)) {
gdk_cairo_rectangle(cr, &cell_rectangle);
gdk_cairo_set_source_color(cr, &style->base[GTK_STATE_NORMAL]);
cairo_fill(cr);
+ cairo_rectangle(cr, cell_rectangle.x, cell_rectangle.y + row_rectangle.height + 1,cell_rectangle.width,cell_rectangle.height);
+ cairo_fill(cr);
}
}
else
{
- rect = &clip_rectangle;
crect = &cell_rectangle;
gdk_cairo_rectangle(cr, &cell_rectangle);
gdk_cairo_set_source_color(cr, &style->base[GTK_STATE_NORMAL]);
cairo_fill(cr);
+ cairo_rectangle(cr, cell_rectangle.x, cell_rectangle.y + row_rectangle.height + 1,cell_rectangle.width,cell_rectangle.height);
+ cairo_fill(cr);
}
/* the last row has to clear its bottom cell spacing too */
else
gdk_cairo_set_source_color(cr, &style->base[state]);
cairo_fill(cr);
-
layout = create_cell_layout (clist, clist_row, i);
if (layout)
{
cairo_move_to(cr, offset, row_rectangle.y + row_center_offset + clist_row->cell[i].vertical);
gdk_cairo_set_source_color(cr, fgcolor);
pango_cairo_show_layout(cr, layout);
-
g_object_unref (G_OBJECT (layout));
}
}
/* draw focus rectangle */
if (clist->focus_row == row &&
- gtk_widget_get_can_focus (widget) && gtk_widget_has_focus (widget))
+ gtk_widget_get_can_focus (widget) && gtk_widget_has_focus (widget)
+ && state == GTK_STATE_SELECTED)
{
if (!area || gdk_rectangle_intersect (area, &row_rectangle,
&intersect_rectangle))
{
cairo_set_line_width(cr, 1.0);
cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
- gdk_cairo_set_source_color(cr, &style->fg[GTK_STATE_NORMAL]);
- cairo_rectangle(cr, row_rectangle.x, row_rectangle.y,
- row_rectangle.width + 1,
- row_rectangle.height);
+ gdk_cairo_set_source_color(cr, &style->text[GTK_STATE_NORMAL]);
+ cairo_move_to (cr, row_rectangle.x, row_rectangle.y + 0.5);
+ cairo_line_to (cr, row_rectangle.x + row_rectangle.width, row_rectangle.y + 0.5);
+ cairo_move_to (cr, row_rectangle.x, row_rectangle.y + row_rectangle.height - 0.5);
+ cairo_line_to (cr, row_rectangle.x + row_rectangle.width, row_rectangle.y + row_rectangle.height - 0.5);
cairo_stroke(cr);
}
}
switch (arg_id)
{
case ARG_N_COLUMNS: /* construct-only arg, only set at construction time */
-#if !GLIB_CHECK_VERSION(2,10,0)
- cm_return_if_fail (clist->row_mem_chunk == NULL);
-#endif
clist->columns = MAX (1, g_value_get_uint (value));
-#if !GLIB_CHECK_VERSION(2,10,0)
- clist->row_mem_chunk = g_mem_chunk_new ("ctree row mem chunk",
- sizeof (GtkCMCTreeRow),
- sizeof (GtkCMCTreeRow)
- * CLIST_OPTIMUM_SIZE,
- G_ALLOC_AND_FREE);
- clist->cell_mem_chunk = g_mem_chunk_new ("ctree cell mem chunk",
- sizeof (GtkCMCell) * clist->columns,
- sizeof (GtkCMCell) * clist->columns
- * CLIST_OPTIMUM_SIZE,
- G_ALLOC_AND_FREE);
-#endif
ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
break;
case ARG_TREE_COLUMN: /* construct-only arg, only set at construction time */
ctree->tree_column = g_value_get_uint (value);
-#if !GLIB_CHECK_VERSION(2,10,0)
- if (clist->row_mem_chunk)
-#endif
ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
break;
case ARG_INDENT:
GtkCMCList *clist;
GtkCMCTreeNode *node;
GtkCMCTreeNode *child;
- GtkStyle *style;
gint i;
cm_return_if_fail (GTK_IS_CMCTREE (widget));
gtk_cmctree_pre_recursive (ctree, child, ctree_attach_styles, NULL);
node = GTK_CMCTREE_NODE_NEXT (node);
}
-
- style = gtk_widget_get_style(widget);
}
static void
return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
}
-static gint
-gtk_cmctree_get_offset(GtkCMCTree *ctree,
- GtkCMCTreeRow *ctree_row,
- gint column,
- GdkRectangle *clip_rectangle)
-{
- gint justify_right = (GTK_CMCLIST (ctree)->column[column].justification == GTK_JUSTIFY_RIGHT);
-
- if (justify_right)
- return (clip_rectangle->x + clip_rectangle->width - 1 -
- ctree->tree_indent * (ctree_row->level - 1));
-
- return clip_rectangle->x + ctree->tree_indent * (ctree_row->level - 1);
-}
-
static GtkCMCTreeNode *
gtk_cmctree_last_visible (GtkCMCTree *ctree,
GtkCMCTreeNode *node)
list_end->next = work->next;
if (work->next)
- list = work->next->prev = list_end;
+ work->next->prev = list_end;
work->next = (GList *)node;
list = (GList *)node;
list->prev = work;
int i;
clist = GTK_CMCLIST (ctree);
-#if GLIB_CHECK_VERSION(2,10,0)
ctree_row = g_slice_new (GtkCMCTreeRow);
ctree_row->row.cell = g_slice_alloc (sizeof (GtkCMCell) * clist->columns);
-#else
- ctree_row = g_chunk_new (GtkCMCTreeRow, (GMemChunk *)clist->row_mem_chunk);
- ctree_row->row.cell = g_chunk_new (GtkCMCell, (GMemChunk *)clist->cell_mem_chunk);
-#endif
for (i = 0; i < clist->columns; i++)
{
dnotify (ddata);
}
-#if GLIB_CHECK_VERSION(2,10,0)
g_slice_free1 (sizeof (GtkCMCell) * clist->columns, ctree_row->row.cell);
g_slice_free (GtkCMCTreeRow, ctree_row);
-#else
- g_mem_chunk_free ((GMemChunk *)clist->cell_mem_chunk, ctree_row->row.cell);
- g_mem_chunk_free ((GMemChunk *)clist->row_mem_chunk, ctree_row);
-#endif
}
static void
GtkCMCList *clist;
gint xl;
gint yu;
-
+ gint hotspot_size;
+
cm_return_val_if_fail (GTK_IS_CMCTREE (ctree), FALSE);
cm_return_val_if_fail (node != NULL, FALSE);
tree_row = GTK_CMCTREE_ROW (node);
- yu = (ROW_TOP_YPIXEL (clist, row) + (clist->row_height - PM_SIZE) / 2 -
+ hotspot_size = clist->row_height-2;
+ if (hotspot_size > clist->column[ctree->tree_column].area.width - 2)
+ hotspot_size = clist->column[ctree->tree_column].area.width - 2;
+
+ yu = (ROW_TOP_YPIXEL (clist, row) + (clist->row_height - hotspot_size) / 2 -
(clist->row_height - 1) % 2);
if (clist->column[ctree->tree_column].justification == GTK_JUSTIFY_RIGHT)
xl = (clist->column[ctree->tree_column].area.x +
clist->column[ctree->tree_column].area.width - 1 + clist->hoffset -
- (tree_row->level - 1) * ctree->tree_indent - PM_SIZE);
+ (tree_row->level - 1) * ctree->tree_indent - hotspot_size);
else
xl = (clist->column[ctree->tree_column].area.x + clist->hoffset +
(tree_row->level - 1) * ctree->tree_indent);
- return (x >= xl && x <= xl + PM_SIZE && y >= yu && y <= yu + PM_SIZE);
+ return (x >= xl && x <= xl + hotspot_size && y >= yu && y <= yu + hotspot_size);
}
/***********************************************************
GdkDragContext *context)
{
GtkCMCList *clist;
- GtkCMCTree *ctree;
gboolean use_icons;
cm_return_if_fail (GTK_IS_CMCTREE (widget));
cm_return_if_fail (context != NULL);
clist = GTK_CMCLIST (widget);
- ctree = GTK_CMCTREE (widget);
use_icons = GTK_CMCLIST_USE_DRAG_ICONS (clist);
GTK_CMCLIST_UNSET_FLAG (clist, CMCLIST_USE_DRAG_ICONS);
if (use_icons)
{
- GtkCMCTreeNode *node;
-
GTK_CMCLIST_SET_FLAG (clist, CMCLIST_USE_DRAG_ICONS);
- node = GTK_CMCTREE_NODE (g_list_nth (clist->row_list,
- clist->click_cell.row));
gtk_drag_set_icon_default (context);
}
}