aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-05-05 06:24:10 +0800
committerChris Lahey <clahey@src.gnome.org>2000-05-05 06:24:10 +0800
commitedd558cdd87e6324f9564596adb66d1a291bf840 (patch)
treef2391a940d24c64b71764134444a605761d1b322
parentea787be7184b4d0c5d093b3c560b8f1879839d73 (diff)
downloadgsoc2013-evolution-edd558cdd87e6324f9564596adb66d1a291bf840.tar.gz
gsoc2013-evolution-edd558cdd87e6324f9564596adb66d1a291bf840.tar.zst
gsoc2013-evolution-edd558cdd87e6324f9564596adb66d1a291bf840.zip
Sped up e_cell_text's get_height function.
2000-05-04 Christopher James Lahey <clahey@helixcode.com> * e-cell-text.c: Sped up e_cell_text's get_height function. svn path=/trunk/; revision=2803
-rw-r--r--widgets/e-table/ChangeLog4
-rw-r--r--widgets/e-table/e-cell-text.c35
-rw-r--r--widgets/table/e-cell-text.c35
3 files changed, 42 insertions, 32 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 9d367ae392..7ba3180f4b 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,5 +1,9 @@
2000-05-04 Christopher James Lahey <clahey@helixcode.com>
+ * e-cell-text.c: Sped up e_cell_text's get_height function.
+
+2000-05-04 Christopher James Lahey <clahey@helixcode.com>
+
* e-table-item.c, e-table-item.h: Added a height_cache idle loop
so that the height_cache will be validated in the idle loop.
diff --git a/widgets/e-table/e-cell-text.c b/widgets/e-table/e-cell-text.c
index 549e004825..0a7e66e0ab 100644
--- a/widgets/e-table/e-cell-text.c
+++ b/widgets/e-table/e-cell-text.c
@@ -186,6 +186,7 @@ static void _selection_received (GtkInvisible *invisible,
GtkSelectionData *selection_data,
guint time,
CellEdit *edit);
+static int number_of_lines (char *text);
static void split_into_lines (CurrentCell *cell);
static void unref_lines (CurrentCell *cell);
static void calc_line_widths (CurrentCell *cell);
@@ -950,17 +951,8 @@ static int
ect_height (ECellView *ecell_view, int model_col, int view_col, int row)
{
ECellTextView *text_view = (ECellTextView *) ecell_view;
- CurrentCell cell;
- int return_val;
- build_current_cell (&cell, text_view, model_col, view_col, row);
- split_into_lines (&cell);
-
- return_val = (text_view->font->ascent + text_view->font->descent) * cell.breaks->num_lines + TEXT_PAD;
-
- unref_lines (&cell);
-
- return return_val;
+ return (text_view->font->ascent + text_view->font->descent) * number_of_lines(e_table_model_value_at (ecell_view->e_table_model, model_col, row)) + TEXT_PAD;
}
/*
@@ -1736,6 +1728,21 @@ _get_tep (CellEdit *edit)
}
}
+static int
+number_of_lines (char *text)
+{
+ int num_lines = 0;
+ char *p;
+ if (!text)
+ return 0;
+ for (p = text; *p; p++)
+ if (*p == '\n')
+ num_lines++;
+
+ num_lines++;
+ return num_lines;
+}
+
/* Splits the text of the text item into lines */
static void
split_into_lines (CurrentCell *cell)
@@ -1765,12 +1772,8 @@ split_into_lines (CurrentCell *cell)
return;
/* First, count the number of lines */
-
- for (p = text; *p; p++)
- if (*p == '\n')
- linebreaks->num_lines++;
-
- linebreaks->num_lines++;
+
+ linebreaks->num_lines = number_of_lines(cell->text);
/* Allocate array of lines and calculate split positions */
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 549e004825..0a7e66e0ab 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -186,6 +186,7 @@ static void _selection_received (GtkInvisible *invisible,
GtkSelectionData *selection_data,
guint time,
CellEdit *edit);
+static int number_of_lines (char *text);
static void split_into_lines (CurrentCell *cell);
static void unref_lines (CurrentCell *cell);
static void calc_line_widths (CurrentCell *cell);
@@ -950,17 +951,8 @@ static int
ect_height (ECellView *ecell_view, int model_col, int view_col, int row)
{
ECellTextView *text_view = (ECellTextView *) ecell_view;
- CurrentCell cell;
- int return_val;
- build_current_cell (&cell, text_view, model_col, view_col, row);
- split_into_lines (&cell);
-
- return_val = (text_view->font->ascent + text_view->font->descent) * cell.breaks->num_lines + TEXT_PAD;
-
- unref_lines (&cell);
-
- return return_val;
+ return (text_view->font->ascent + text_view->font->descent) * number_of_lines(e_table_model_value_at (ecell_view->e_table_model, model_col, row)) + TEXT_PAD;
}
/*
@@ -1736,6 +1728,21 @@ _get_tep (CellEdit *edit)
}
}
+static int
+number_of_lines (char *text)
+{
+ int num_lines = 0;
+ char *p;
+ if (!text)
+ return 0;
+ for (p = text; *p; p++)
+ if (*p == '\n')
+ num_lines++;
+
+ num_lines++;
+ return num_lines;
+}
+
/* Splits the text of the text item into lines */
static void
split_into_lines (CurrentCell *cell)
@@ -1765,12 +1772,8 @@ split_into_lines (CurrentCell *cell)
return;
/* First, count the number of lines */
-
- for (p = text; *p; p++)
- if (*p == '\n')
- linebreaks->num_lines++;
-
- linebreaks->num_lines++;
+
+ linebreaks->num_lines = number_of_lines(cell->text);
/* Allocate array of lines and calculate split positions */