[gnumeric] Make the row and column headers and selection match the theme better. [#639019]



commit 3793afb0bc82f0b241ead3ee9388fe78f71b7620
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Sat Jan 8 18:01:52 2011 -0700

    Make the row and column headers and selection match the theme better. [#639019]
    
    2011-01-08  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/item-edit.c (item_edit_draw): add NULL argument to call of
    	  gnumeric_background_set
    	* src/item-grid.c (item_grid_draw_merged_range): add theme argument
    	  to pass to gnumeric_background_set
    	(item_grid_draw_background): ditto
    	(item_grid_draw_region): pass theme to item_grid_draw_merged_range and
    	  item_grid_draw_background
    	* src/pattern.h (gnumeric_background_set): add theme argument
    	* src/pattern.c (gnumeric_background_set): add and use theme argument
    	(gnm_get_light): new
    	* src/preview-grid.c (preview_grid_draw_background): add NULL argument
    	  to call of gnumeric_background_set

 ChangeLog          |   15 +++++++++++++++
 NEWS               |    3 ++-
 src/item-edit.c    |    2 +-
 src/item-grid.c    |   15 +++++++++------
 src/pattern.c      |   23 ++++++++++++++++++++---
 src/pattern.h      |    3 ++-
 src/preview-grid.c |    2 +-
 7 files changed, 50 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 89c724b..aa056aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2011-01-08  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* src/item-edit.c (item_edit_draw): add NULL argument to call of
+	  gnumeric_background_set
+	* src/item-grid.c (item_grid_draw_merged_range): add theme argument
+	  to pass to gnumeric_background_set
+	(item_grid_draw_background): ditto
+	(item_grid_draw_region): pass theme to item_grid_draw_merged_range and
+	  item_grid_draw_background
+	* src/pattern.h (gnumeric_background_set): add theme argument
+	* src/pattern.c (gnumeric_background_set): add and use theme argument
+	(gnm_get_light): new
+	* src/preview-grid.c (preview_grid_draw_background): add NULL argument 
+	  to call of gnumeric_background_set
+
+2011-01-08  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* src/item-bar.c (ib_draw_cell): use selection colours
 	
 2011-01-07  Morten Welinder  <terra gnome org>
diff --git a/NEWS b/NEWS
index 7d4cb21..f79b56e 100644
--- a/NEWS
+++ b/NEWS
@@ -8,7 +8,8 @@ Andreas:
 	* Fix ODF import of sheets with far forward references. [#636968]
 	* Add EEK support to EURO and EUROCONVERT.
 	* Fix leaks in potentially failing analysis tools.
-	* Make the row and column headers math the theme better.
+	* Make the row and column headers and selection match the theme better.
+	  [#639019]
 
 Jean:
 	* Only disable the formula bar when a chart sheet is selected. [#636031]
diff --git a/src/item-edit.c b/src/item-edit.c
index a336e24..4d23c35 100644
--- a/src/item-edit.c
+++ b/src/item-edit.c
@@ -117,7 +117,7 @@ item_edit_draw (GocItem const *item, cairo_t *cr)
 	/* avoid a weak/strong cursor to extent outside the item,
 	 a better fix would be to have enough room for cursors */
 	cairo_clip_preserve (cr);
-	if (!gnumeric_background_set (ie->style, cr, FALSE))
+	if (!gnumeric_background_set (ie->style, cr, FALSE, NULL))
 		cairo_set_source_rgba (cr, 1., 1., 0.878431373, 1.);
 	cairo_fill (cr);
 
diff --git a/src/item-grid.c b/src/item-grid.c
index c35b2b6..d9528f8 100644
--- a/src/item-grid.c
+++ b/src/item-grid.c
@@ -231,7 +231,7 @@ static void
 item_grid_draw_merged_range (cairo_t *cr, ItemGrid *ig,
 			     int start_x, int start_y,
 			     GnmRange const *view, GnmRange const *range,
-			     gboolean draw_selection)
+			     gboolean draw_selection, GtkStyle *theme)
 {
 	int l, r, t, b, last;
 	SheetView const *sv = scg_view (ig->scg);
@@ -278,7 +278,7 @@ item_grid_draw_merged_range (cairo_t *cr, ItemGrid *ig,
 
 	/* Check for background THEN selection */
 	if (gnumeric_background_set (style, cr,
-		is_selected) || is_selected) {
+				     is_selected, theme) || is_selected) {
 		/* Remember X excludes the far pixels */
 		if (dir > 0)
 			cairo_rectangle (cr, l, t, r-l+1, b-t+1);
@@ -332,7 +332,7 @@ static void
 item_grid_draw_background (cairo_t *cr, ItemGrid *ig,
 			   GnmStyle const *style,
 			   int col, int row, int x, int y, int w, int h,
-			   gboolean draw_selection)
+			   gboolean draw_selection, GtkStyle *theme)
 {
 	SheetView const *sv = scg_view (ig->scg);
 	gboolean const is_selected = draw_selection &&
@@ -340,7 +340,7 @@ item_grid_draw_background (cairo_t *cr, ItemGrid *ig,
 		sv_is_pos_selected (sv, col, row);
 	gboolean const has_back =
 		gnumeric_background_set (style, cr,
-					    is_selected);
+					 is_selected, theme);
 
 #if DEBUG_SELECTION_PAINT
 	if (is_selected) {
@@ -393,6 +393,7 @@ item_grid_draw_region (GocItem const *item, cairo_t *cr, double x_0, double y_0,
 	SheetView const *sv = scg_view (ig->scg);
 	WorkbookView *wbv = sv_wbv (sv);
 	gboolean show_function_cell_markers = wbv->show_function_cell_markers;
+	GtkStyle *theme = gtk_widget_get_style (GTK_WIDGET (canvas));
 
 	/* To ensure that far and near borders get drawn we pretend to draw +-2
 	 * pixels around the target area which would include the surrounding
@@ -565,7 +566,9 @@ item_grid_draw_region (GocItem const *item, cairo_t *cr, double x_0, double y_0,
 
 					if (ci->visible)
 						item_grid_draw_merged_range (cr, ig,
-							start_x, y, &view, r, draw_selection);
+									     start_x, y, &view, r, 
+									     draw_selection,
+									     theme);
 				}
 			} else {
 				lag = &(ptr->next);
@@ -661,7 +664,7 @@ plain_draw : /* a quick hack to deal with 142267 */
 			item_grid_draw_background (cr, ig,
 				style, col, row, x, y,
 				ci->size_pixels, ri->size_pixels,
-				draw_selection);
+						   draw_selection, theme);
 
 
 			/* Is this part of a span?
diff --git a/src/pattern.c b/src/pattern.c
index fff2839..ca47a29 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -47,9 +47,16 @@ static GOPatternType patterns[] = {
  *                              of a cell.
  * return : TRUE if there is a background to paint.
  */
+
+static double 
+gnm_get_light (guint16 c)
+{
+	return ((1 + c/65535.)/2);
+}
+
 gboolean
 gnumeric_background_set (GnmStyle const *mstyle, cairo_t *cr,
-			    gboolean const is_selected)
+			 gboolean const is_selected, GtkStyle *theme)
 {
 	int pattern;
 
@@ -68,8 +75,18 @@ gnumeric_background_set (GnmStyle const *mstyle, cairo_t *cr,
 		cairo_set_source (cr, crpat);
 		cairo_pattern_destroy (crpat);
 		return TRUE;
-	} else if (is_selected)
-		cairo_set_source_rgb (cr, .901960784, .901960784, .980392157);
+	} else if (is_selected) {
+		if (theme == NULL)
+			cairo_set_source_rgb 
+				(cr, .901960784, .901960784, .980392157);
+		else {
+			GdkColor color = theme->light[GTK_STATE_SELECTED];
+			cairo_set_source_rgb
+				(cr, gnm_get_light (color.red), 
+				 gnm_get_light (color.green), 
+				 gnm_get_light (color.blue));
+		}
+	}
 	return FALSE;
 }
 
diff --git a/src/pattern.h b/src/pattern.h
index ced929a..f8b1af5 100644
--- a/src/pattern.h
+++ b/src/pattern.h
@@ -10,7 +10,8 @@ G_BEGIN_DECLS
 
 gboolean    gnumeric_background_set	(GnmStyle const *style,
 					 cairo_t *cr,
-					 gboolean const is_selected);
+					 gboolean const is_selected,
+					 GtkStyle *theme);
 gboolean    gnumeric_background_set_gtk	(GnmStyle const *style,
 					 cairo_t *context);
 
diff --git a/src/preview-grid.c b/src/preview-grid.c
index 00224a6..57ea05b 100644
--- a/src/preview-grid.c
+++ b/src/preview-grid.c
@@ -174,7 +174,7 @@ static void
 preview_grid_draw_background (cairo_t *cr, PreviewGrid const *pg, GnmStyle const *mstyle,
 			      int col, int row, int x, int y, int w, int h)
 {
-	if (gnumeric_background_set (mstyle, cr, FALSE)) {
+	if (gnumeric_background_set (mstyle, cr, FALSE, NULL)) {
 		cairo_rectangle (cr, x, y, w+1, h+1);
 		cairo_fill (cr);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]