diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-05-05 06:24:10 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-05-05 06:24:10 +0800 |
commit | edd558cdd87e6324f9564596adb66d1a291bf840 (patch) | |
tree | f2391a940d24c64b71764134444a605761d1b322 /widgets/table | |
parent | ea787be7184b4d0c5d093b3c560b8f1879839d73 (diff) | |
download | gsoc2013-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
Diffstat (limited to 'widgets/table')
-rw-r--r-- | widgets/table/e-cell-text.c | 35 |
1 files changed, 19 insertions, 16 deletions
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 */ |