return index_ + trailing;
}
-/*
+/**
* clutter_text_position_to_coords:
* @self: a #ClutterText
* @position: position in characters
* Retrieves the coordinates of the given @position.
*
* Return value: %TRUE if the conversion was successful
+ *
+ * Since: 1.0
*/
-static gboolean
+gboolean
clutter_text_position_to_coords (ClutterText *self,
gint position,
gfloat *x,
gfloat *y,
gfloat *line_height)
{
- ClutterTextPrivate *priv = self->priv;
+ ClutterTextPrivate *priv;
PangoRectangle rect;
gint password_char_bytes = 1;
gint index_;
+ g_return_val_if_fail (CLUTTER_IS_TEXT (self), FALSE);
+
+ priv = self->priv;
+
+ if (position < -1 || position > priv->n_chars)
+ return FALSE;
+
if (priv->password_char != 0)
password_char_bytes = g_unichar_to_utf8 (priv->password_char, NULL);
if (line_height)
*line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.height);
- /* FIXME: should return false if coords were outside text */
return TRUE;
}
gboolean clutter_text_get_single_line_mode (ClutterText *self);
gboolean clutter_text_activate (ClutterText *self);
+gboolean clutter_text_position_to_coords (ClutterText *self,
+ gint position,
+ gfloat *x,
+ gfloat *y,
+ gfloat *line_height);
G_END_DECLS