aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2002-09-11 01:24:50 +0800
committerJP Rosevear <jpr@src.gnome.org>2002-09-11 01:24:50 +0800
commitf533402ce6a9dfda06bffeaf07dc406f6403d677 (patch)
treeee76fb9a452ddf5e19f6b32845948a1b65e3bb13 /widgets
parentc70fc69cd574bbe3e9b3449f1b434b983c2dde66 (diff)
downloadgsoc2013-evolution-f533402ce6a9dfda06bffeaf07dc406f6403d677.tar.gz
gsoc2013-evolution-f533402ce6a9dfda06bffeaf07dc406f6403d677.tar.zst
gsoc2013-evolution-f533402ce6a9dfda06bffeaf07dc406f6403d677.zip
take a clip_height and use it to set the maximum number of lines if
2002-09-10 JP Rosevear <jpr@ximian.com> * gal/e-text/e-text.c (line_splitter): take a clip_height and use it to set the maximum number of lines if necessary (split_into_lines): pass clip_height arg svn path=/trunk/; revision=18032
Diffstat (limited to 'widgets')
-rw-r--r--widgets/text/e-text.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 836c7ffa2a..6275235c11 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -687,8 +687,8 @@ typedef void (*LineSplitterFn) (int line_num, const char *start, int length, gpo
static gint
line_splitter (ETextModel *model, EFont *font, EFontStyle style,
const char *break_characters,
- gboolean wrap_lines, double clip_width, gint max_lines,
- LineSplitterFn split_cb, gpointer user_data)
+ gboolean wrap_lines, double clip_width, double clip_height,
+ gint max_lines, LineSplitterFn split_cb, gpointer user_data)
{
const char *curr;
const char *text;
@@ -700,7 +700,9 @@ line_splitter (ETextModel *model, EFont *font, EFontStyle style,
if (max_lines < 1)
max_lines = G_MAXINT;
-
+ if (clip_height != -1)
+ max_lines = CLAMP (max_lines, 1, clip_height / e_font_height (font));
+
text = e_text_model_get_text (model);
linestart = NULL;
last_breakpoint = text;
@@ -723,9 +725,13 @@ line_splitter (ETextModel *model, EFont *font, EFontStyle style,
if (clip_width < text_width_with_objects (model, font, style, linestart, curr - linestart)
&& last_breakpoint > linestart) {
-
- if (split_cb)
+
+ /* Don't use break point if we are on the last usable line */
+ if (split_cb && line_count < max_lines - 1)
split_cb (line_count, linestart, last_breakpoint - linestart, user_data);
+ else if (split_cb)
+ split_cb (line_count, linestart, strlen (linestart), user_data);
+
++line_count;
linestart = NULL;
curr = last_breakpoint;
@@ -739,17 +745,6 @@ line_splitter (ETextModel *model, EFont *font, EFontStyle style,
/* Handle any leftover text. */
if (linestart) {
-
- if (clip_width < text_width_with_objects (model, font, style, linestart, strlen (linestart))
- && last_breakpoint > linestart) {
-
- if (split_cb)
- split_cb (line_count, linestart, last_breakpoint - linestart, user_data);
-
- ++line_count;
- linestart = g_utf8_next_char (last_breakpoint);
- }
-
if (split_cb)
split_cb (line_count, linestart, strlen (linestart), user_data);
++line_count;
@@ -796,16 +791,16 @@ split_into_lines (EText *text)
/* First, count the number of lines */
text->num_lines = line_splitter (text->model, text->font, text->style,
text->break_characters,
- text->line_wrap, text->clip_width, -1,
- NULL, NULL);
+ text->line_wrap, text->clip_width, text->clip_height,
+ -1, NULL, NULL);
/* Allocate our array of lines */
text->lines = g_new0 (struct line, text->num_lines);
text->num_lines = line_splitter (text->model, text->font, text->style,
text->break_characters,
- text->line_wrap, text->clip_width, text->num_lines,
- line_split_cb, text);
+ text->line_wrap, text->clip_width, text->clip_height,
+ text->num_lines, line_split_cb, text);
}
/* Convenience function to set the text's GC's foreground color */