diff options
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | docs/pango-sections.txt | 1 | ||||
-rw-r--r-- | docs/tmpl/layout.sgml | 9 | ||||
-rw-r--r-- | pango/pango-layout-private.h | 1 | ||||
-rw-r--r-- | pango/pango-layout.c | 46 | ||||
-rw-r--r-- | pango/pango-layout.h | 3 | ||||
-rw-r--r-- | pango/pango.def | 1 |
7 files changed, 74 insertions, 6 deletions
@@ -1,5 +1,24 @@ 2007-01-16 Behdad Esfahbod <behdad@gnome.org> + Part of Bug 326693 – PangoLayouts should be query-able about their + effective properties (width / wrapped / ellipsized / etc) + + * pango/pango-layout-private.h: + * pango/pango-layout.c (pango_layout_init), (pango_layout_copy), + (pango_layout_is_wrapped), (pango_layout_clear_lines), + (process_line): + * pango/pango-layout.h: + New public function: + + pango_layout_is_wrapped() + + * pango/pango.def: + * docs/tmpl/layout.sgml: + * docs/pango-sections.txt: + Update. + +2007-01-16 Behdad Esfahbod <behdad@gnome.org> + Bug 397327 – pango-layout.c: 'pango_layout_is_ellipsized' must return a value diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt index be100e0c..541dadce 100644 --- a/docs/pango-sections.txt +++ b/docs/pango-sections.txt @@ -444,6 +444,7 @@ pango_layout_set_width pango_layout_get_width pango_layout_set_wrap pango_layout_get_wrap +pango_layout_is_wrapped PangoWrapMode PANGO_TYPE_WRAP_MODE pango_layout_set_ellipsize diff --git a/docs/tmpl/layout.sgml b/docs/tmpl/layout.sgml index 6fb3fb80..32b89c03 100644 --- a/docs/tmpl/layout.sgml +++ b/docs/tmpl/layout.sgml @@ -210,6 +210,15 @@ has no user-visible fields. @Returns: +<!-- ##### FUNCTION pango_layout_is_wrapped ##### --> +<para> + +</para> + +@layout: +@Returns: + + <!-- ##### ENUM PangoWrapMode ##### --> <para> A #PangoWrapMode describes how to wrap the lines of a #PangoLayout to the desired width. diff --git a/pango/pango-layout-private.h b/pango/pango-layout-private.h index 56370c1a..c3def007 100644 --- a/pango/pango-layout-private.h +++ b/pango/pango-layout-private.h @@ -51,6 +51,7 @@ struct _PangoLayout guint auto_dir : 1; guint wrap : 2; /* PangoWrapMode */ + guint is_wrapped : 1; /* Whether the layout has any wrapped lines */ guint ellipsize : 2; /* PangoEllipsizeMode */ guint is_ellipsized : 1; /* Whether the layout has any ellipsized lines */ diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 9ece852c..c95e9e20 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -199,6 +199,7 @@ pango_layout_init (PangoLayout *layout) layout->tab_width = -1; layout->wrap = PANGO_WRAP_WORD; + layout->is_wrapped = FALSE; layout->ellipsize = PANGO_ELLIPSIZE_NONE; layout->is_ellipsized = FALSE; } @@ -307,7 +308,8 @@ pango_layout_copy (PangoLayout *src) layout->wrap = src->wrap; layout->ellipsize = src->ellipsize; - /* is_ellipsized, log_attrs, lines fields are updated by check_lines */ + /* is_wrapped, is_ellipsized, log_attrs, lines + * fields are updated by check_lines */ return layout; } @@ -393,6 +395,9 @@ pango_layout_set_wrap (PangoLayout *layout, * @layout: a #PangoLayout * * Gets the wrap mode for the layout. + * + * Use pango_layout_is_wrapped() to query whether any paragraphs + * were actually wrapped. * * Return value: active wrap mode. **/ @@ -405,6 +410,32 @@ pango_layout_get_wrap (PangoLayout *layout) } /** + * pango_layout_is_wrapped: + * @layout: a #PangoLayout + * + * Queries whether the layout had to wrap any paragraphs. + * + * This returns %TRUE if a positive width is set on @layout, + * ellipsization mode of @layout is set to %PANGO_ELLIPSIZE_NONE, + * and there are paragraphs exceeding the layout width that have + * to be wrapped. + * + * Return value: %TRUE if any paragraphs had to be wrapped, %FALSE + * otherwise. + * + * Since: 1.16 + */ +gboolean +pango_layout_is_wrapped (PangoLayout *layout) +{ + g_return_val_if_fail (layout != NULL, FALSE); + + pango_layout_check_lines (layout); + + return layout->is_wrapped; +} + +/** * pango_layout_set_indent * @layout: a #PangoLayout. * @indent: the amount by which to indent. @@ -835,6 +866,9 @@ pango_layout_set_ellipsize (PangoLayout *layout, * * Return value: the current ellipsization mode for @layout. * + * Use pango_layout_is_ellipsized() to query whether any paragraphs + * were actually ellipsized. + * * Since: 1.6 **/ PangoEllipsizeMode @@ -851,9 +885,9 @@ pango_layout_get_ellipsize (PangoLayout *layout) * * Queries whether the layout had to ellipsize any paragraphs. * - * This can only return %TRUE if the ellipsization mode for @layout + * This returns %TRUE if the ellipsization mode for @layout * is not %PANGO_ELLIPSIZE_NONE, a positive width is set on @layout, - * and there were paragraphs exceeding that width that had to be + * and there are paragraphs exceeding that width that have to be * ellipsized. * * Return value: %TRUE if any paragraphs had to be ellipsized, %FALSE @@ -2483,8 +2517,6 @@ pango_layout_get_pixel_size (PangoLayout *layout, static void pango_layout_clear_lines (PangoLayout *layout) { - layout->is_ellipsized = FALSE; - if (layout->lines) { GSList *tmp_list = layout->lines; @@ -2508,6 +2540,8 @@ pango_layout_clear_lines (PangoLayout *layout) } layout->logical_rect_cached = FALSE; layout->ink_rect_cached = FALSE; + layout->is_ellipsized = FALSE; + layout->is_wrapped = FALSE; } static void @@ -3274,6 +3308,7 @@ process_line (PangoLayout *layout, case BREAK_SOME_FIT: state->start_offset += old_num_chars - item->num_chars; + layout->is_wrapped = TRUE; goto done; case BREAK_NONE_FIT: @@ -3293,6 +3328,7 @@ process_line (PangoLayout *layout, state->start_offset += old_num_chars - item->num_chars; + layout->is_wrapped = TRUE; goto done; case BREAK_LINE_SEPARATOR: diff --git a/pango/pango-layout.h b/pango/pango-layout.h index 5a73c537..ff592407 100644 --- a/pango/pango-layout.h +++ b/pango/pango-layout.h @@ -125,6 +125,7 @@ int pango_layout_get_width (PangoLayout *la void pango_layout_set_wrap (PangoLayout *layout, PangoWrapMode wrap); PangoWrapMode pango_layout_get_wrap (PangoLayout *layout); +gboolean pango_layout_is_wrapped (PangoLayout *layout); void pango_layout_set_indent (PangoLayout *layout, int indent); int pango_layout_get_indent (PangoLayout *layout); @@ -153,7 +154,7 @@ gboolean pango_layout_get_single_paragraph_mode (PangoLayout void pango_layout_set_ellipsize (PangoLayout *layout, PangoEllipsizeMode ellipsize); PangoEllipsizeMode pango_layout_get_ellipsize (PangoLayout *layout); -gboolean pango_layout_is_ellipsized (PangoLayout *layout); +gboolean pango_layout_is_ellipsized (PangoLayout *layout); void pango_layout_context_changed (PangoLayout *layout); diff --git a/pango/pango.def b/pango/pango.def index 3ea0951e..e0380441 100644 --- a/pango/pango.def +++ b/pango/pango.def @@ -239,6 +239,7 @@ EXPORTS pango_layout_index_to_line_x pango_layout_index_to_pos pango_layout_is_ellipsized + pango_layout_is_wrapped pango_layout_iter_at_last_line pango_layout_iter_free pango_layout_iter_get_baseline |