aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/table/e-cell-text.c29
-rw-r--r--widgets/table/e-cell-tree.c31
-rw-r--r--widgets/table/e-cell.c37
-rw-r--r--widgets/table/e-cell.h240
4 files changed, 211 insertions, 126 deletions
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 63a78a5a98..1fc6b1ef50 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -1209,6 +1209,34 @@ ect_max_width (ECellView *ecell_view,
return max_width;
}
+static int
+ect_max_width_by_row (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row)
+{
+ /* New ECellText */
+ ECellTextView *text_view = (ECellTextView *) ecell_view;
+ CurrentCell cell;
+ struct line *line;
+ int width;
+
+ if (row >= e_table_model_row_count (ecell_view->e_table_model))
+ return 0;
+
+ build_current_cell (&cell, text_view, model_col, view_col, row);
+ split_into_lines (&cell);
+ calc_line_widths (&cell);
+
+ line = (struct line *)cell.breaks->lines;
+ width = e_font_utf8_text_width (text_view->font, cell.style,
+ line->text, line->length);
+ unref_lines (&cell);
+ unbuild_current_cell (&cell);
+
+ return width;
+}
+
static gint
tooltip_event (GtkWidget *window,
GdkEvent *event,
@@ -1505,6 +1533,7 @@ e_cell_text_class_init (GtkObjectClass *object_class)
ecc->print = ect_print;
ecc->print_height = ect_print_height;
ecc->max_width = ect_max_width;
+ ecc->max_width_by_row = ect_max_width_by_row;
ecc->show_tooltip = ect_show_tooltip;
ecc->get_bg_color = ect_get_bg_color;
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index bc9fa0d782..f581dab0fa 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -94,6 +94,9 @@ visible_depth_of_node (ETableModel *model, int row)
- (e_tree_table_adapter_root_node_is_visible (adapter) ? 0 : 1));
}
+/* If this is changed to not include the width of the expansion pixmap
+ if the path is not expandable, then max_width needs to change as
+ well. */
static gint
offset_of_node (ETableModel *table_model, int row)
{
@@ -425,27 +428,29 @@ ect_max_width (ECellView *ecell_view, int model_col, int view_col)
int number_of_rows;
int max_width = 0;
int width = 0;
- int subcell_max_width;
+ int subcell_max_width = 0;
+ gboolean per_row = e_cell_max_width_by_row_implemented (tree_view->subcell_view);
number_of_rows = e_table_model_row_count (ecell_view->e_table_model);
- subcell_max_width = e_cell_max_width (tree_view->subcell_view, model_col, view_col);
+ if (!per_row)
+ subcell_max_width = e_cell_max_width (tree_view->subcell_view, model_col, view_col);
for (row = 0; row < number_of_rows; row++) {
ETreeModel *tree_model = e_cell_tree_get_tree_model(ecell_view->e_table_model, row);
- ETreeTableAdapter *tree_table_adapter = e_cell_tree_get_tree_table_adapter(ecell_view->e_table_model, row);
ETreePath node;
GdkPixbuf *node_image;
int node_image_width = 0, node_image_height = 0;
int offset, subcell_offset;
+#if 0
gboolean expanded, expandable;
+ ETreeTableAdapter *tree_table_adapter = e_cell_tree_get_tree_table_adapter(ecell_view->e_table_model, row);
+#endif
node = e_cell_tree_get_node (ecell_view->e_table_model, row);
offset = offset_of_node (ecell_view->e_table_model, row);
- expandable = e_tree_model_node_is_expandable (tree_model, node);
- expanded = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node);
subcell_offset = offset;
node_image = e_tree_model_icon_at (tree_model, node);
@@ -455,7 +460,20 @@ ect_max_width (ECellView *ecell_view, int model_col, int view_col)
node_image_height = gdk_pixbuf_get_height (node_image);
}
- width = subcell_max_width + subcell_offset + node_image_width;
+ width = subcell_offset + node_image_width;
+
+ if (per_row)
+ width += e_cell_max_width_by_row (tree_view->subcell_view, model_col, view_col, row);
+ else
+ width += subcell_max_width;
+
+#if 0
+ expandable = e_tree_model_node_is_expandable (tree_model, node);
+ expanded = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node);
+
+ /* This is unnecessary since this is already handled
+ by the offset_of_node function. If that changes,
+ this will have to change too. */
if (expandable) {
GdkPixbuf *image;
@@ -466,6 +484,7 @@ ect_max_width (ECellView *ecell_view, int model_col, int view_col)
width += gdk_pixbuf_get_width(image);
}
+#endif
max_width = MAX (max_width, width);
}
diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c
index 3045081cc4..beb86489f0 100644
--- a/widgets/table/e-cell.c
+++ b/widgets/table/e-cell.c
@@ -150,6 +150,7 @@ e_cell_class_init (GtkObjectClass *object_class)
ecc->print = NULL;
ecc->print_height = NULL;
ecc->max_width = NULL;
+ ecc->max_width_by_row = NULL;
ecc->show_tooltip = ec_show_tooltip;
}
@@ -434,6 +435,42 @@ e_cell_max_width (ECellView *ecell_view, int model_col, int view_col)
return ECVIEW_EC_CLASS(ecell_view)->max_width
(ecell_view, model_col, view_col);
}
+
+/**
+ * e_cell_max_width_by_row:
+ * @ecell_view: the ECellView that we are curious about
+ * @model_col: the column in the model
+ * @view_col: the column in the view.
+ * @row: The row in the model.
+ *
+ * Returns: the maximum width for the ECellview at @model_col which
+ * is being rendered as @view_col for the data in @row.
+ */
+int
+e_cell_max_width_by_row (ECellView *ecell_view, int model_col, int view_col, int row)
+{
+ if (ECVIEW_EC_CLASS(ecell_view)->max_width_by_row)
+ return ECVIEW_EC_CLASS(ecell_view)->max_width_by_row
+ (ecell_view, model_col, view_col, row);
+ else
+ return e_cell_max_width (ecell_view, model_col, view_col);
+}
+
+/**
+ * e_cell_max_width_by_row_implemented:
+ * @ecell_view: the ECellView that we are curious about
+ * @model_col: the column in the model
+ * @view_col: the column in the view.
+ * @row: The row in the model.
+ *
+ * Returns: the maximum width for the ECellview at @model_col which
+ * is being rendered as @view_col for the data in @row.
+ */
+gboolean
+e_cell_max_width_by_row_implemented (ECellView *ecell_view)
+{
+ return (ECVIEW_EC_CLASS(ecell_view)->max_width_by_row != NULL);
+}
void
e_cell_show_tooltip (ECellView *ecell_view, int model_col, int view_col,
diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h
index daa33449fc..f872d0c81f 100644
--- a/widgets/table/e-cell.h
+++ b/widgets/table/e-cell.h
@@ -81,132 +81,132 @@ typedef struct {
typedef struct {
GtkObjectClass parent_class;
- ECellView *(*new_view) (ECell *ecell, ETableModel *table_model, void *e_table_item_view);
- void (*kill_view) (ECellView *ecell_view);
-
- void (*realize) (ECellView *ecell_view);
- void (*unrealize) (ECellView *ecell_view);
-
- void (*draw) (ECellView *ecell_view, GdkDrawable *drawable,
- int model_col, int view_col, int row,
- ECellFlags flags, int x1, int y1, int x2, int y2);
- gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions);
- void (*focus) (ECellView *ecell_view, int model_col, int view_col,
- int row, int x1, int y1, int x2, int y2);
- void (*unfocus) (ECellView *ecell_view);
- int (*height) (ECellView *ecell_view, int model_col, int view_col, int row);
-
- void *(*enter_edit) (ECellView *ecell_view, int model_col, int view_col, int row);
- void (*leave_edit) (ECellView *ecell_view, int model_col, int view_col, int row, void *context);
- void *(*save_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *context);
- void (*load_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *context, void *save_state);
- void (*free_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *save_state);
- void (*print) (ECellView *ecell_view, GnomePrintContext *context,
- int model_col, int view_col, int row,
- gdouble width, gdouble height);
- gdouble (*print_height) (ECellView *ecell_view, GnomePrintContext *context,
- int model_col, int view_col, int row, gdouble width);
- int (*max_width) (ECellView *ecell_view, int model_col, int view_col);
- void (*show_tooltip) (ECellView *ecell_view, int model_col, int view_col, int row, int col_width, ETableTooltip *tooltip);
- gchar *(*get_bg_color) (ECellView *ecell_view, int row);
+ ECellView *(*new_view) (ECell *ecell, ETableModel *table_model, void *e_table_item_view);
+ void (*kill_view) (ECellView *ecell_view);
+
+ void (*realize) (ECellView *ecell_view);
+ void (*unrealize) (ECellView *ecell_view);
+
+ void (*draw) (ECellView *ecell_view, GdkDrawable *drawable,
+ int model_col, int view_col, int row,
+ ECellFlags flags, int x1, int y1, int x2, int y2);
+ gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row, ECellFlags flags, ECellActions *actions);
+ void (*focus) (ECellView *ecell_view, int model_col, int view_col,
+ int row, int x1, int y1, int x2, int y2);
+ void (*unfocus) (ECellView *ecell_view);
+ int (*height) (ECellView *ecell_view, int model_col, int view_col, int row);
+
+ void *(*enter_edit) (ECellView *ecell_view, int model_col, int view_col, int row);
+ void (*leave_edit) (ECellView *ecell_view, int model_col, int view_col, int row, void *context);
+ void *(*save_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *context);
+ void (*load_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *context, void *save_state);
+ void (*free_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *save_state);
+ void (*print) (ECellView *ecell_view, GnomePrintContext *context,
+ int model_col, int view_col, int row,
+ gdouble width, gdouble height);
+ gdouble (*print_height) (ECellView *ecell_view, GnomePrintContext *context,
+ int model_col, int view_col, int row, gdouble width);
+ int (*max_width) (ECellView *ecell_view, int model_col, int view_col);
+ int (*max_width_by_row) (ECellView *ecell_view, int model_col, int view_col, int row);
+ void (*show_tooltip) (ECellView *ecell_view, int model_col, int view_col, int row, int col_width, ETableTooltip *tooltip);
+ gchar *(*get_bg_color) (ECellView *ecell_view, int row);
} ECellClass;
-
-GtkType e_cell_get_type (void);
+GtkType e_cell_get_type (void);
/* View creation methods. */
-ECellView *e_cell_new_view (ECell *ecell,
- ETableModel *table_model,
- void *e_table_item_view);
-void e_cell_kill_view (ECellView *ecell_view);
+ECellView *e_cell_new_view (ECell *ecell,
+ ETableModel *table_model,
+ void *e_table_item_view);
+void e_cell_kill_view (ECellView *ecell_view);
/* Cell View methods. */
-gint e_cell_event (ECellView *ecell_view,
- GdkEvent *event,
- int model_col,
- int view_col,
- int row,
- ECellFlags flags,
- ECellActions *actions);
-void e_cell_realize (ECellView *ecell_view);
-void e_cell_unrealize (ECellView *ecell_view);
-void e_cell_draw (ECellView *ecell_view,
- GdkDrawable *drawable,
- int model_col,
- int view_col,
- int row,
- ECellFlags flags,
- int x1,
- int y1,
- int x2,
- int y2);
-void e_cell_print (ECellView *ecell_view,
- GnomePrintContext *context,
- int model_col,
- int view_col,
- int row,
- double width,
- double height);
-gdouble e_cell_print_height (ECellView *ecell_view,
- GnomePrintContext *context,
- int model_col,
- int view_col,
- int row,
- gdouble width);
-int e_cell_max_width (ECellView *ecell_view,
- int model_col,
- int view_col);
-void e_cell_show_tooltip (ECellView *ecell_view,
- int model_col,
- int view_col,
- int row,
- int col_width,
- ETableTooltip *tooltip);
-gchar *e_cell_get_bg_color (ECellView *ecell_view,
- int row);
-
-void e_cell_focus (ECellView *ecell_view,
- int model_col,
- int view_col,
- int row,
- int x1,
- int y1,
- int x2,
- int y2);
-void e_cell_unfocus (ECellView *ecell_view);
-int e_cell_height (ECellView *ecell_view,
- int model_col,
- int view_col,
- int row);
-
-void *e_cell_enter_edit (ECellView *ecell_view,
- int model_col,
- int view_col,
- int row);
-void e_cell_leave_edit (ECellView *ecell_view,
- int model_col,
- int view_col,
- int row,
- void *edit_context);
-
-void *e_cell_save_state (ECellView *ecell_view,
- int model_col,
- int view_col,
- int row,
- void *edit_context);
-
-void e_cell_load_state (ECellView *ecell_view,
- int model_col,
- int view_col,
- int row,
- void *edit_context,
- void *state);
-
-void e_cell_free_state (ECellView *ecell_view,
- int model_col,
- int view_col,
- int row,
- void *state);
+gint e_cell_event (ECellView *ecell_view,
+ GdkEvent *event,
+ int model_col,
+ int view_col,
+ int row,
+ ECellFlags flags,
+ ECellActions *actions);
+void e_cell_realize (ECellView *ecell_view);
+void e_cell_unrealize (ECellView *ecell_view);
+void e_cell_draw (ECellView *ecell_view,
+ GdkDrawable *drawable,
+ int model_col,
+ int view_col,
+ int row,
+ ECellFlags flags,
+ int x1,
+ int y1,
+ int x2,
+ int y2);
+void e_cell_print (ECellView *ecell_view,
+ GnomePrintContext *context,
+ int model_col,
+ int view_col,
+ int row,
+ double width,
+ double height);
+gdouble e_cell_print_height (ECellView *ecell_view,
+ GnomePrintContext *context,
+ int model_col,
+ int view_col,
+ int row,
+ gdouble width);
+int e_cell_max_width (ECellView *ecell_view,
+ int model_col,
+ int view_col);
+int e_cell_max_width_by_row (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row);
+gboolean e_cell_max_width_by_row_implemented (ECellView *ecell_view);
+void e_cell_show_tooltip (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row,
+ int col_width,
+ ETableTooltip *tooltip);
+gchar *e_cell_get_bg_color (ECellView *ecell_view,
+ int row);
+void e_cell_focus (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row,
+ int x1,
+ int y1,
+ int x2,
+ int y2);
+void e_cell_unfocus (ECellView *ecell_view);
+int e_cell_height (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row);
+void *e_cell_enter_edit (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row);
+void e_cell_leave_edit (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row,
+ void *edit_context);
+void *e_cell_save_state (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row,
+ void *edit_context);
+void e_cell_load_state (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row,
+ void *edit_context,
+ void *state);
+void e_cell_free_state (ECellView *ecell_view,
+ int model_col,
+ int view_col,
+ int row,
+ void *state);
END_GNOME_DECLS