2007-01-16 Behdad Esfahbod <behdad@gnome.org>
+ Bug 363510 – Ability to query whether a PangoLayout is effectively
+ ellipsized (as opposed to the set_ellpisize()/get_ellipsize() methods
+ which only set a request, or return the set request respectively)
+ Patch from Milosz Derezynski
+
+ * pango/pango-layout.h:
+ * pango/ellipsize.c (_pango_layout_line_ellipsize):
+ * pango/pango-layout-private.h:
+ * pango/pango-layout.c (pango_layout_init), (pango_layout_copy),
+ (pango_layout_is_ellipsized), (pango_layout_clear_lines),
+ (pango_layout_line_postprocess):
+ New public function:
+
+ pango_layout_is_ellipsized()
+
+ * pango/pango.def:
+ * docs/tmpl/layout.sgml:
+ * docs/pango-sections.txt:
+ Update.
+
+2007-01-16 Behdad Esfahbod <behdad@gnome.org>
+
* pango/pango-renderer.c (pango_renderer_draw_layout_line): Fix
background rendering being off in presence of rise attributes.
PANGO_TYPE_WRAP_MODE
pango_layout_set_ellipsize
pango_layout_get_ellipsize
+pango_layout_is_ellipsized
PangoEllipsizeMode
PANGO_TYPE_ELLIPSIZE_MODE
pango_layout_set_indent
@Returns:
+<!-- ##### FUNCTION pango_layout_is_ellipsized ##### -->
+<para>
+
+</para>
+
+@layout:
+@Returns:
+
+
<!-- ##### ENUM PangoEllipsizeMode ##### -->
<para>
*
* Given a #PangoLayoutLine with the runs still in logical order, ellipsize
* it according the layout's policy to fit within the set width of the layout.
+ *
+ * Return value: whether the line had to be ellipsized
**/
-void
+gboolean
_pango_layout_line_ellipsize (PangoLayoutLine *line,
PangoAttrList *attrs)
{
EllipsizeState state;
int goal_width;
+ gboolean is_ellipsized = FALSE;
if (line->layout->ellipsize == PANGO_ELLIPSIZE_NONE ||
line->layout->width < 0)
- return;
+ goto ret;
init_state (&state, line, attrs);
g_slist_free (line->runs);
line->runs = get_run_list (&state);
+ is_ellipsized = TRUE;
out:
free_state (&state);
+ ret:
+ return is_ellipsized;
}
guint wrap : 2; /* PangoWrapMode */
guint ellipsize : 2; /* PangoEllipsizeMode */
+ guint is_ellipsized : 1; /* Whether the layout has any ellipsized lines */
/* some caching */
guint logical_rect_cached : 1;
G_END_DECLS
-void _pango_layout_line_ellipsize (PangoLayoutLine *line,
+gboolean _pango_layout_line_ellipsize (PangoLayoutLine *line,
PangoAttrList *attrs);
PangoLayoutLine* _pango_layout_iter_get_line_readonly (PangoLayoutIter *iter);
layout->wrap = PANGO_WRAP_WORD;
layout->ellipsize = PANGO_ELLIPSIZE_NONE;
+ layout->is_ellipsized = FALSE;
}
static void
layout->wrap = src->wrap;
layout->ellipsize = src->ellipsize;
- /* log_attrs, lines fields are updated by check_lines */
+ /* is_ellipsized, log_attrs, lines fields are updated by check_lines */
return layout;
}
}
/**
+ * pango_layout_is_ellipsized:
+ * @layout: a #PangoLayout
+ *
+ * Queries whether the layout had to ellipsize any paragraphs.
+ *
+ * This can only return %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
+ * ellipsized.
+ *
+ * Return value: %TRUE if any paragraphs had to be ellipsized, %FALSE
+ * otherwise.
+ *
+ * Since: 1.16
+ */
+gboolean
+pango_layout_is_ellipsized (PangoLayout *layout)
+{
+ g_return_if_fail (layout != NULL);
+
+ pango_layout_check_lines (layout);
+
+ return layout->is_ellipsized;
+}
+
+/**
* pango_layout_set_text:
* @layout: a #PangoLayout
* @text: a valid UTF-8 string
static void
pango_layout_clear_lines (PangoLayout *layout)
{
+ layout->is_ellipsized = FALSE;
+
if (layout->lines)
{
GSList *tmp_list = layout->lines;
/* Ellipsize the line if necessary
*/
- _pango_layout_line_ellipsize (line, state->attrs);
+ if (_pango_layout_line_ellipsize (line, state->attrs))
+ line->layout->is_ellipsized = TRUE;
/* Now convert logical to visual order
*/
void pango_layout_set_ellipsize (PangoLayout *layout,
PangoEllipsizeMode ellipsize);
PangoEllipsizeMode pango_layout_get_ellipsize (PangoLayout *layout);
+gboolean pango_layout_is_ellipsized (PangoLayout *layout);
void pango_layout_context_changed (PangoLayout *layout);
pango_layout_get_wrap
pango_layout_index_to_line_x
pango_layout_index_to_pos
+ pango_layout_is_ellipsized
pango_layout_iter_at_last_line
pango_layout_iter_free
pango_layout_iter_get_baseline