aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-04-16 10:12:44 +0800
committerChris Lahey <clahey@src.gnome.org>2001-04-16 10:12:44 +0800
commitbf3357b91ec240f3d325df8d9e9ffea98c796ea8 (patch)
tree60084f4a63df1dfa3ec6dcac88c3c7be91c3ff56
parent17bc3ae168964c0d60aa3ab38c2d2db50f01b4fa (diff)
downloadgsoc2013-evolution-bf3357b91ec240f3d325df8d9e9ffea98c796ea8.tar
gsoc2013-evolution-bf3357b91ec240f3d325df8d9e9ffea98c796ea8.tar.gz
gsoc2013-evolution-bf3357b91ec240f3d325df8d9e9ffea98c796ea8.tar.bz2
gsoc2013-evolution-bf3357b91ec240f3d325df8d9e9ffea98c796ea8.tar.lz
gsoc2013-evolution-bf3357b91ec240f3d325df8d9e9ffea98c796ea8.tar.xz
gsoc2013-evolution-bf3357b91ec240f3d325df8d9e9ffea98c796ea8.tar.zst
gsoc2013-evolution-bf3357b91ec240f3d325df8d9e9ffea98c796ea8.zip
Set the background color to the specified tooltip->background. Set the
2001-04-15 Christopher James Lahey <clahey@ximian.com> * e-cell-text.c (ect_show_tooltip): Set the background color to the specified tooltip->background. Set the foreground color to the specified tooltip->foreground. * e-table-item.c (eti_get_cell_background_color, eti_get_cell_foreground_color): Added these functions. (eti_draw, _do_tooltip): Use these new functions. * e-table-tooltip.h: Added foreground and background colors to this structure. * e-tree.c, e-tree.h (e_tree_get_tooltip): Added this function. svn path=/trunk/; revision=9338
-rw-r--r--widgets/table/e-cell-text.c3
-rw-r--r--widgets/table/e-table-item.c123
-rw-r--r--widgets/table/e-table-tooltip.h2
-rw-r--r--widgets/table/e-tree.c6
-rw-r--r--widgets/table/e-tree.h1
5 files changed, 112 insertions, 23 deletions
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 1ad50921e3..5136c4e8fc 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -1218,7 +1218,7 @@ ect_show_tooltip (ECellView *ecell_view,
"y1", (double) 0.0,
"x2", (double) max_width + 4,
"y2", (double) text_height,
- "fill_color", "light gray",
+ "fill_color_gdk", tooltip->background,
NULL);
tooltip_text = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)),
@@ -1227,6 +1227,7 @@ ect_show_tooltip (ECellView *ecell_view,
/* "font_gdk", text_view->font, */
"bold", (gboolean) ect->bold_column >= 0 && e_table_model_value_at(ecell_view->e_table_model, ect->bold_column, row),
"strikeout", (gboolean) ect->strikeout_column >= 0 && e_table_model_value_at(ecell_view->e_table_model, ect->strikeout_column, row),
+ "fill_color_gdk", tooltip->foreground,
"text", cell.text,
"editable", FALSE,
"clip_width", max_width,
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 85fab6bd64..438c1050a4 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -141,7 +141,7 @@ view_to_model_col(ETableItem *eti, int col)
return ecol ? ecol->col_idx : -1;
}
-static gboolean
+inline static gboolean
eti_editing (ETableItem *eti)
{
if (eti->editing_col == -1)
@@ -150,6 +150,60 @@ eti_editing (ETableItem *eti)
return TRUE;
}
+inline static GdkColor *
+eti_get_cell_background_color (ETableItem *eti, int row, int col, gboolean selected, gboolean *allocated)
+{
+ GtkWidget *canvas = GTK_WIDGET(GNOME_CANVAS_ITEM(eti)->canvas);
+ GdkColor *background;
+
+ if (allocated)
+ *allocated = FALSE;
+
+ if (selected){
+ if (GTK_WIDGET_HAS_FOCUS(canvas))
+ background = &canvas->style->bg [GTK_STATE_SELECTED];
+ else
+ background = &canvas->style->bg [GTK_STATE_ACTIVE];
+ } else {
+ background = &canvas->style->base [GTK_STATE_NORMAL];
+ }
+
+#ifdef ALTERNATE_COLORS
+ if (row % 2) {
+
+ } else {
+ if (allocated)
+ *allocated = TRUE;
+ background = gdk_color_copy (background);
+ e_hsv_tweak (background, 0.0f, 0.0f, -0.05f);
+ gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (canvas)), background);
+ }
+#endif
+
+ return background;
+}
+
+inline static GdkColor *
+eti_get_cell_foreground_color (ETableItem *eti, int row, int col, gboolean selected, gboolean *allocated)
+{
+ GtkWidget *canvas = GTK_WIDGET(GNOME_CANVAS_ITEM(eti)->canvas);
+ GdkColor *foreground;
+
+ if (allocated)
+ *allocated = FALSE;
+
+ if (selected){
+ if (GTK_WIDGET_HAS_FOCUS (canvas))
+ foreground = &canvas->style->text [GTK_STATE_SELECTED];
+ else
+ foreground = &canvas->style->text [GTK_STATE_ACTIVE];
+ } else {
+ foreground = &canvas->style->text [GTK_STATE_NORMAL];
+ }
+
+ return foreground;
+}
+
/*
* During realization, we have to invoke the per-ecell realize routine
* (On our current setup, we have one e-cell per column.
@@ -965,6 +1019,10 @@ eti_destroy (GtkObject *object)
eti->height_cache_idle_count = 0;
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(eti)->canvas));
+ if (eti->tooltip->background)
+ gdk_color_free (eti->tooltip->background);
+ if (eti->tooltip->foreground)
+ gdk_color_free (eti->tooltip->foreground);
if (eti->tooltip->timer) {
gtk_timeout_remove (eti->tooltip->timer);
eti->tooltip->timer = 0;
@@ -1111,6 +1169,8 @@ eti_init (GnomeCanvasItem *item)
eti->tooltip = g_new0 (ETableTooltip, 1);
eti->tooltip->timer = 0;
eti->tooltip->eti = GNOME_CANVAS_ITEM (eti);
+ eti->tooltip->background = NULL;
+ eti->tooltip->foreground = NULL;
eti->grabbed_col = -1;
eti->grabbed_row = -1;
@@ -1315,7 +1375,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
ECellView *ecell_view = eti->cell_views [col];
gboolean col_selected = selected;
ECellFlags flags;
- gboolean free_background = FALSE;
+ gboolean free_background;
GdkColor *background;
switch (eti->cursor_mode) {
@@ -1329,25 +1389,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
break;
}
- if (col_selected){
- if (GTK_WIDGET_HAS_FOCUS(canvas))
- background = &canvas->style->bg [GTK_STATE_SELECTED];
- else
- background = &canvas->style->bg [GTK_STATE_ACTIVE];
- } else {
- background = &canvas->style->base [GTK_STATE_NORMAL];
- }
-
-#ifdef ALTERNATE_COLORS
- if (row % 2) {
-
- } else {
- free_background = TRUE;
- background = gdk_color_copy (background);
- e_hsv_tweak (background, 0.0f, 0.0f, -0.05f);
- gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (canvas)), background);
- }
-#endif
+ background = eti_get_cell_background_color (eti, row, col, col_selected, &free_background);
gdk_gc_set_foreground (eti->fill_gc, background);
gdk_draw_rectangle (drawable, eti->fill_gc, TRUE,
@@ -1547,6 +1589,10 @@ _do_tooltip (ETableItem *eti)
int x = 0, y = 0;
int i;
int height_extra = eti->horizontal_draw_grid ? 1 : 0;
+ gboolean free_color;
+ ETableCol *ecol;
+ gboolean selected;
+ int cursor_row, cursor_col;
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(eti)->canvas));
@@ -1564,6 +1610,39 @@ _do_tooltip (ETableItem *eti)
eti->tooltip->y = y;
eti->tooltip->row_height = ETI_ROW_HEIGHT (eti, i);
+ selected = e_selection_model_is_row_selected(E_SELECTION_MODEL (eti->selection), view_to_model_row(eti,eti->tooltip->row));
+
+ if (eti->tooltip->foreground)
+ gdk_color_free (eti->tooltip->foreground);
+ if (eti->tooltip->background)
+ gdk_color_free (eti->tooltip->background);
+
+ switch (eti->cursor_mode) {
+ case E_CURSOR_SIMPLE:
+ case E_CURSOR_SPREADSHEET:
+ ecol = e_table_header_get_column (eti->header, eti->tooltip->col);
+
+ gtk_object_get(GTK_OBJECT(eti->selection),
+ "cursor_row", &cursor_row,
+ "cursor_col", &cursor_col,
+ NULL);
+
+ if (cursor_col == ecol->col_idx && cursor_row == view_to_model_row(eti, eti->tooltip->row))
+ selected = !selected;
+ break;
+ case E_CURSOR_LINE:
+ /* Nothing */
+ break;
+ }
+
+ eti->tooltip->background = eti_get_cell_background_color (eti, eti->tooltip->row, eti->tooltip->col, selected, &free_color);
+ if (!free_color)
+ eti->tooltip->background = gdk_color_copy(eti->tooltip->background);
+
+ eti->tooltip->foreground = eti_get_cell_foreground_color (eti, eti->tooltip->row, eti->tooltip->col, selected, &free_color);
+ if (!free_color)
+ eti->tooltip->foreground = gdk_color_copy(eti->tooltip->foreground);
+
e_cell_show_tooltip (ecell_view,
view_to_model_col (eti, eti->tooltip->col),
eti->tooltip->col,
@@ -1650,7 +1729,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
"cursor_row", &cursor_row,
"cursor_col", &cursor_col,
NULL);
-
+
if (cursor_row == view_to_model_row(eti, row) && cursor_col == view_to_model_col(eti, col)){
if ((!eti_editing(eti)) && e_table_model_is_cell_editable(eti->table_model, col, row)) {
diff --git a/widgets/table/e-table-tooltip.h b/widgets/table/e-table-tooltip.h
index 617a0e3b55..259d6398db 100644
--- a/widgets/table/e-table-tooltip.h
+++ b/widgets/table/e-table-tooltip.h
@@ -12,6 +12,8 @@ typedef struct {
int row_height;
int x, y;
int cx, cy;
+ GdkColor *foreground;
+ GdkColor *background;
GnomeCanvasItem *eti;
} ETableTooltip;
diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c
index 4a81390783..358d7a22b1 100644
--- a/widgets/table/e-tree.c
+++ b/widgets/table/e-tree.c
@@ -1391,6 +1391,12 @@ e_tree_row_count (ETree *et)
return e_table_model_row_count (E_TABLE_MODEL(et->priv->etta));
}
+GtkWidget *
+e_tree_get_tooltip (ETree *et)
+{
+ return E_CANVAS(et->priv->table_canvas)->tooltip_window;
+}
+
struct _ETreeDragSourceSite
{
GdkModifierType start_button_mask;
diff --git a/widgets/table/e-tree.h b/widgets/table/e-tree.h
index 6c4066a047..5559908e97 100644
--- a/widgets/table/e-tree.h
+++ b/widgets/table/e-tree.h
@@ -248,6 +248,7 @@ void e_tree_save_expanded_state (ETree *et, char *filename);
void e_tree_load_expanded_state (ETree *et, char *filename);
int e_tree_row_count (ETree *et);
+GtkWidget *e_tree_get_tooltip (ETree *et);
END_GNOME_DECLS