[gnumeric] Add optional markers to indicate that cell content has been truncated. [#662149]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Add optional markers to indicate that cell content has been truncated. [#662149]
- Date: Fri, 21 Oct 2011 08:23:02 +0000 (UTC)
commit afca41846a5ff1755481485dbc7bd9642c47de38
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Fri Oct 21 02:22:16 2011 -0600
Add optional markers to indicate that cell content has been truncated. [#662149]
2011-10-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/cell-draw.h (cell_draw): add argument
* src/cell-draw.c (cell_draw_extension_mark_bottom): new
(cell_draw_extension_mark_left): new
(cell_draw_extension_mark_right): new
(cell_draw_h_extension_markers): new
(cell_draw_v_extension_markers): new
(cell_draw): add argument and call the above
* src/item-grid.c (item_grid_draw_merged_range): adjust call to
cell_draw
(item_grid_draw_region): ditto
* src/preview-grid.c (preview_grid_draw_region): adjust call to
cell_draw
* src/workbook-view.h (_WorkbookView): add field
* src/workbook-view.c (wb_view_set_attribute): handle new
property
(wb_view_set_property): ditto
(wb_view_set_attribute): ditto
(workbook_view_class_init): install new property
(workbook_view_new): initialize new property
2011-10-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-workbook-attr.c (attr_dialog_init_cell_marker_page): handle
cell extension toggle
* workbook-attr.ui: add cell extension marker toggle
ChangeLog | 24 ++++++++-
NEWS | 2 +
src/cell-draw.c | 101 +++++++++++++++++++++++++++++++++++-
src/cell-draw.h | 3 +-
src/dialogs/ChangeLog | 6 ++
src/dialogs/dialog-workbook-attr.c | 7 ++-
src/dialogs/workbook-attr.ui | 26 ++++++++-
src/item-grid.c | 14 ++++--
src/preview-grid.c | 3 +-
src/workbook-view.c | 22 ++++++++
src/workbook-view.h | 1 +
11 files changed, 197 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c42f9b6..ec35c8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,28 @@
+2011-10-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/cell-draw.h (cell_draw): add argument
+ * src/cell-draw.c (cell_draw_extension_mark_bottom): new
+ (cell_draw_extension_mark_left): new
+ (cell_draw_extension_mark_right): new
+ (cell_draw_h_extension_markers): new
+ (cell_draw_v_extension_markers): new
+ (cell_draw): add argument and call the above
+ * src/item-grid.c (item_grid_draw_merged_range): adjust call to
+ cell_draw
+ (item_grid_draw_region): ditto
+ * src/preview-grid.c (preview_grid_draw_region): adjust call to
+ cell_draw
+ * src/workbook-view.h (_WorkbookView): add field
+ * src/workbook-view.c (wb_view_set_attribute): handle new
+ property
+ (wb_view_set_property): ditto
+ (wb_view_set_attribute): ditto
+ (workbook_view_class_init): install new property
+ (workbook_view_new): initialize new property
+
2011-10-20 Andreas J. Guelzow <aguelzow pyrshep ca>
- * src/cell-draw.c (cell_draw): fix rounding of h_center
+ * src/cell-draw.c (cell_draw): fix rounding of h_center
transformation
2011-10-20 Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/NEWS b/NEWS
index 284c267..9ea37e0 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,8 @@ Andreas:
* Fix hyperlink placement when inserting or adding hyperlink. [#662310]
* Fix spanning of long centered cell content. [#662331]
* Fix centering of spanned cell content. [#662361]
+ * Add optional markers to indicate that cell content has been
+ truncated. [#662149]
Jean:
* Make things build against gtk+-3.0.
diff --git a/src/cell-draw.c b/src/cell-draw.c
index 3de5e57..d9c6f64 100644
--- a/src/cell-draw.c
+++ b/src/cell-draw.c
@@ -291,6 +291,80 @@ cell_finish_layout (GnmCell *cell, GnmRenderedValue *rv,
}
+static void
+cell_draw_extension_mark_bottom (cairo_t *cr, int x1, int y1, int height, int h_center)
+{
+ cairo_set_source_rgba (cr, 1, 0, 0, 0.7);
+ cairo_new_path (cr);
+ cairo_move_to (cr, x1 + h_center, y1 + height);
+ cairo_rel_line_to (cr, -3, -3);
+ cairo_rel_line_to (cr, 6, 0);
+ cairo_close_path (cr);
+ cairo_fill (cr);
+}
+
+static void
+cell_draw_extension_mark_left (cairo_t *cr, int x1, int y1, int height)
+{
+ cairo_set_source_rgba (cr, 1, 0, 0, 0.7);
+ cairo_new_path (cr);
+ cairo_move_to (cr, x1, y1 + height/2);
+ cairo_rel_line_to (cr, 3, -3);
+ cairo_rel_line_to (cr, 0, 6);
+ cairo_close_path (cr);
+ cairo_fill (cr);
+}
+
+static void
+cell_draw_extension_mark_right (cairo_t *cr, int x1, int y1, int width, int height)
+{
+ cairo_set_source_rgba (cr, 1, 0, 0, 0.7);
+ cairo_new_path (cr);
+ cairo_move_to (cr, x1 + width, y1 + height/2);
+ cairo_rel_line_to (cr, -3, -3);
+ cairo_rel_line_to (cr, 0, 6);
+ cairo_close_path (cr);
+ cairo_fill (cr);
+
+}
+
+
+static void
+cell_draw_h_extension_markers (cairo_t *cr, GnmRenderedValue *rv,
+ int x1, int y1,
+ int width, int height)
+{
+ switch (rv->effective_halign) {
+ case HALIGN_GENERAL:
+ case HALIGN_LEFT:
+ cell_draw_extension_mark_right (cr, x1, y1, width, height);
+ break;
+ case HALIGN_RIGHT:
+ cell_draw_extension_mark_left (cr, x1, y1, height);
+ break;
+ case HALIGN_DISTRIBUTED:
+ case HALIGN_CENTER:
+ case HALIGN_CENTER_ACROSS_SELECTION:
+ cell_draw_extension_mark_right (cr, x1, y1, width, height);
+ cell_draw_extension_mark_left (cr, x1, y1, height);
+ break;
+ case HALIGN_FILL:
+ default:
+ break;
+ }
+}
+
+static void
+cell_draw_v_extension_markers (cairo_t *cr,
+ int x1, int y1,
+ int width, int height,
+ int h_center)
+{
+ if (h_center == -1)
+ h_center = width / 2;
+ cell_draw_extension_mark_bottom (cr, x1, y1, height, h_center);
+}
+
/**
* cell_draw:
* @cell : #GnmCell const
@@ -300,10 +374,12 @@ cell_finish_layout (GnmCell *cell, GnmRenderedValue *rv,
* @width : including margins and leading grid line
* @height : including margins and leading grid line
* @h_center :
+ * @show_extension_markers:
**/
void
cell_draw (GnmCell const *cell, cairo_t *cr,
- int x1, int y1, int width, int height, int h_center)
+ int x1, int y1, int width, int height, int h_center,
+ gboolean show_extension_markers)
{
GOColor fore_color;
gint x;
@@ -365,8 +441,31 @@ cell_draw (GnmCell const *cell, cairo_t *cr,
pango_layout_context_changed (rv->layout);
cairo_new_path (cr);
} else {
+ cairo_save (cr);
cairo_translate (cr, x1 + PANGO_PIXELS (x), y1 + PANGO_PIXELS (y));
pango_cairo_show_layout (cr, rv->layout);
+ cairo_restore (cr);
+
+ if (show_extension_markers &&
+ width < PANGO_PIXELS (rv->layout_natural_width)) {
+ cairo_save (cr);
+ cell_draw_h_extension_markers
+ (cr, rv,
+ x1 + 1 + GNM_COL_MARGIN,
+ y1 + 1 + GNM_ROW_MARGIN,
+ width, height);
+ cairo_restore (cr);
+ }
+
+ if (show_extension_markers &&
+ height < PANGO_PIXELS (rv->layout_natural_height)) {
+ cairo_save (cr);
+ cell_draw_v_extension_markers
+ (cr, x1 + 1 + GNM_COL_MARGIN,
+ y1 + 1 + GNM_ROW_MARGIN,
+ width, height, h_center);
+ cairo_restore (cr);
+ }
}
cairo_restore (cr);
}
diff --git a/src/cell-draw.h b/src/cell-draw.h
index 9c9c0ac..b0043a5 100644
--- a/src/cell-draw.h
+++ b/src/cell-draw.h
@@ -15,7 +15,8 @@ void cell_finish_layout (GnmCell *cell, GnmRenderedValue *rv,
gboolean inhibit_overflow);
void cell_draw (GnmCell const *cell, cairo_t* cr,
- int x, int y, int height, int width, int h_center);
+ int x, int y, int height, int width, int h_center,
+ gboolean show_extension_markers);
G_END_DECLS
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 80ec5b3..24364fe 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,9 @@
+2011-10-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-workbook-attr.c (attr_dialog_init_cell_marker_page): handle
+ cell extension toggle
+ * workbook-attr.ui: add cell extension marker toggle
+
2011-10-20 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-hyperlink.c (dhl_cb_ok): refocus original sheet, fixes #662310
diff --git a/src/dialogs/dialog-workbook-attr.c b/src/dialogs/dialog-workbook-attr.c
index 5f773a4..0d964fa 100644
--- a/src/dialogs/dialog-workbook-attr.c
+++ b/src/dialogs/dialog-workbook-attr.c
@@ -143,7 +143,12 @@ attr_dialog_init_cell_marker_page (AttrState *state)
{
attr_dialog_init_toggle
(state,
- "WorkbookView::show_function_cell_markers", "show_function_cell_markers");
+ "WorkbookView::show_function_cell_markers",
+ "show_function_cell_markers");
+ attr_dialog_init_toggle
+ (state,
+ "WorkbookView::show_extension_markers",
+ "show_extension_markers");
}
static void
diff --git a/src/dialogs/workbook-attr.ui b/src/dialogs/workbook-attr.ui
index f69ead9..0fa945d 100644
--- a/src/dialogs/workbook-attr.ui
+++ b/src/dialogs/workbook-attr.ui
@@ -71,8 +71,8 @@
<child>
<object class="GtkBox" id="vbox2">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="WorkbookView::show_notebook_tabs">
<property name="label" translatable="yes">Notebook _Tabs for Sheets</property>
@@ -212,8 +212,8 @@
<child>
<object class="GtkBox" id="vbox1">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="WorkbookView::do_auto_completion">
<property name="label" translatable="yes">A_uto Complete Text in Cells</property>
@@ -249,16 +249,18 @@
<child>
<object class="GtkBox" id="vbox-f-marker">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="WorkbookView::show_function_cell_markers">
<property name="label" translatable="yes">Show _Formula Cell Markers</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">This checkbox determines whether each cell containing a spreadsheet formula is marked with a green top left corner.</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
@@ -267,6 +269,24 @@
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="WorkbookView::show_extension_markers">
+ <property name="label" translatable="yes">Show _Extension Markers</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">This checkbox determines whether small red arrows indicate that the content has been truncated in that direction.</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">3</property>
diff --git a/src/item-grid.c b/src/item-grid.c
index 81c04bd..d30d98a 100644
--- a/src/item-grid.c
+++ b/src/item-grid.c
@@ -237,6 +237,7 @@ item_grid_draw_merged_range (cairo_t *cr, ItemGrid *ig,
SheetView const *sv = scg_view (ig->scg);
WorkbookView *wbv = sv_wbv (sv);
gboolean show_function_cell_markers = wbv->show_function_cell_markers;
+ gboolean show_extension_markers = wbv->show_extension_markers;
Sheet const *sheet = sv->sheet;
GnmCell const *cell = sheet_cell_get (sheet, range->start.col, range->start.row);
int const dir = sheet->text_is_rtl ? -1 : 1;
@@ -313,13 +314,15 @@ item_grid_draw_merged_range (cairo_t *cr, ItemGrid *ig,
draw_function_marker (cell, cr, l, t,
r - l, b - t, dir);
cell_draw (cell, cr,
- l, t, r - l, b - t, -1);
+ l, t, r - l, b - t, -1,
+ show_extension_markers);
} else {
if (show_function_cell_markers)
draw_function_marker (cell, cr, r, t,
l - r, b - t, dir);
cell_draw (cell, cr,
- r, t, l - r, b - t, -1);
+ r, t, l - r, b - t, -1,
+ show_extension_markers);
}
}
if (dir > 0)
@@ -393,6 +396,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;
+ gboolean show_extension_markers = wbv->show_extension_markers;
GtkStyleContext *ctxt = gtk_widget_get_style_context (GTK_WIDGET (canvas));
/* To ensure that far and near borders get drawn we pretend to draw +-2
@@ -689,7 +693,8 @@ plain_draw : /* a quick hack to deal with 142267 */
dir);
cell_draw (cell, cr,
x, y, ci->size_pixels,
- ri->size_pixels, -1);
+ ri->size_pixels, -1,
+ show_extension_markers);
}
/* Only draw spaning cells after all the backgrounds
* that we are going to draw have been drawn. No need
@@ -745,7 +750,8 @@ plain_draw : /* a quick hack to deal with 142267 */
ri->size_pixels, dir);
cell_draw (cell, cr,
real_x, y, tmp_width,
- ri->size_pixels, center_offset);
+ ri->size_pixels, center_offset,
+ show_extension_markers);
} else if (col != span->left)
sr.vertical [col] = NULL;
diff --git a/src/preview-grid.c b/src/preview-grid.c
index 57ea05b..ac2e45c 100644
--- a/src/preview-grid.c
+++ b/src/preview-grid.c
@@ -276,7 +276,8 @@ preview_grid_draw_region (GocItem const *item, cairo_t *cr,
if (!gnm_cell_is_empty (cell))
cell_draw (cell, cr,
- x, y, colwidths[col], row_height, -1);
+ x, y, colwidths[col], row_height,
+ -1, FALSE);
x += colwidths[col];
}
diff --git a/src/workbook-view.c b/src/workbook-view.c
index 5605095..44b7a01 100644
--- a/src/workbook-view.c
+++ b/src/workbook-view.c
@@ -81,6 +81,7 @@ enum {
PROP_SHOW_VERTICAL_SCROLLBAR,
PROP_SHOW_NOTEBOOK_TABS,
PROP_SHOW_FUNCTION_CELL_MARKERS,
+ PROP_SHOW_EXTENSION_MARKERS,
PROP_DO_AUTO_COMPLETION,
PROP_PROTECTED,
PROP_PREFERRED_WIDTH,
@@ -233,6 +234,8 @@ wb_view_set_attribute (WorkbookView *wbv, char const *name, char const *value)
g_object_set (obj, "show_notebook_tabs", res, NULL);
else if (!strcmp (tname , "show_function_cell_markers"))
g_object_set (obj, "show_function_cell_markers", res, NULL);
+ else if (!strcmp (tname , "show_extension_markers"))
+ g_object_set (obj, "show_extension_markers", res, NULL);
else if (!strcmp (tname , "do_auto_completion"))
g_object_set (obj, "do_auto_completion", res, NULL);
else if (!strcmp (tname , "is_protected"))
@@ -729,6 +732,11 @@ wb_view_set_property (GObject *object, guint property_id,
if (wbv->current_sheet)
sheet_redraw_all (wbv->current_sheet, FALSE);
break;
+ case PROP_SHOW_EXTENSION_MARKERS:
+ wbv->show_extension_markers = !!g_value_get_boolean (value);
+ if (wbv->current_sheet)
+ sheet_redraw_all (wbv->current_sheet, FALSE);
+ break;
case PROP_DO_AUTO_COMPLETION:
wbv->do_auto_completion = !!g_value_get_boolean (value);
break;
@@ -781,6 +789,9 @@ wb_view_get_property (GObject *object, guint property_id,
case PROP_SHOW_FUNCTION_CELL_MARKERS:
g_value_set_boolean (value, wbv->show_function_cell_markers);
break;
+ case PROP_SHOW_EXTENSION_MARKERS:
+ g_value_set_boolean (value, wbv->show_extension_markers);
+ break;
case PROP_DO_AUTO_COMPLETION:
g_value_set_boolean (value, wbv->do_auto_completion);
break;
@@ -958,6 +969,16 @@ workbook_view_class_init (GObjectClass *gobject_class)
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
+ PROP_SHOW_EXTENSION_MARKERS,
+ g_param_spec_boolean ("show-extension-markers",
+ _("Show extension markers"),
+ _("Mark each cell that fails to show "
+ "the complete content"),
+ FALSE,
+ GSF_PARAM_STATIC |
+ G_PARAM_READWRITE));
+ g_object_class_install_property
+ (gobject_class,
PROP_DO_AUTO_COMPLETION,
g_param_spec_boolean ("do-auto-completion",
_("Do auto completion"),
@@ -1017,6 +1038,7 @@ workbook_view_new (Workbook *wb)
wbv->show_vertical_scrollbar = TRUE;
wbv->show_notebook_tabs = TRUE;
wbv->show_function_cell_markers = FALSE;
+ wbv->show_extension_markers = FALSE;
wbv->do_auto_completion = gnm_conf_get_core_gui_editing_autocomplete ();
wbv->is_protected = FALSE;
diff --git a/src/workbook-view.h b/src/workbook-view.h
index 7fc14e0..c74b7f6 100644
--- a/src/workbook-view.h
+++ b/src/workbook-view.h
@@ -22,6 +22,7 @@ struct _WorkbookView {
gboolean show_vertical_scrollbar;
gboolean show_notebook_tabs;
gboolean show_function_cell_markers;
+ gboolean show_extension_markers;
gboolean do_auto_completion;
gboolean is_protected;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]