1 /* ATK - The Accessibility Toolkit for GTK+
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
28 struct _AtkTextIfaceClass
33 typedef struct _AtkTextIfaceClass AtkTextIfaceClass;
35 static void atk_text_base_init (gpointer *g_class);
37 static guint atk_text_signals[LAST_SIGNAL] = { 0 };
42 static GType type = 0;
46 static const GTypeInfo tinfo =
48 sizeof (AtkTextIface),
49 (GBaseInitFunc) atk_text_base_init,
50 (GBaseFinalizeFunc) NULL,
51 (GClassInitFunc) NULL /* atk_text_interface_init */ ,
52 (GClassFinalizeFunc) NULL,
56 type = g_type_register_static (G_TYPE_INTERFACE, "AtkText", &tinfo, 0);
63 atk_text_base_init (gpointer *g_class)
65 static gboolean initialized = FALSE;
70 * Note that text_changed signal supports details "insert", "delete",
74 atk_text_signals[TEXT_CHANGED] =
75 g_signal_newc ("text_changed",
77 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
78 G_STRUCT_OFFSET (AtkTextIface, text_changed),
79 (GSignalAccumulator) NULL, NULL,
80 g_cclosure_marshal_VOID__VOID,
84 atk_text_signals[CARET_MOVED] =
85 g_signal_newc ("text_caret_moved",
88 G_STRUCT_OFFSET (AtkTextIface, caret_changed),
89 (GSignalAccumulator) NULL, NULL,
90 g_cclosure_marshal_VOID__INT,
101 * @start_offset: start position
102 * @end_offset: end position
104 * Gets the specified text.
106 * Returns: the text from @start_offset up to, but not including @end_offset.
109 atk_text_get_text (AtkText *text,
115 g_return_val_if_fail (text != NULL, NULL);
116 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
118 iface = ATK_TEXT_GET_IFACE (text);
121 return (*(iface->get_text)) (text, start_offset, end_offset);
127 * atk_text_get_character_at_offset
131 * Gets the specified text.
133 * Returns: the character at @offset.
136 atk_text_get_character_at_offset (AtkText *text,
141 g_return_val_if_fail (text != NULL, (gunichar) 0);
142 g_return_val_if_fail (ATK_IS_TEXT (text), (gunichar) 0);
144 iface = ATK_TEXT_GET_IFACE (text);
146 if (iface->get_character_at_offset)
147 return (*(iface->get_character_at_offset)) (text, offset);
153 * atk_text_get_text_after_offset
156 * @boundary_type: An #AtkTextBoundary
158 * Gets the specified text.
159 * If the boundary type is ATK_TEXT_BOUNDARY_WORD_START or
160 * ATK_TEXT_BOUNDARY_WORD_END part of a word may be returned.
161 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the start point
162 * will be the offset and will continue to the start of the next sentence.
163 * The first word may not be a complete word. Similarly for
164 * ATK_TEXT_BOUNDARY_SENTENCE_END, ATK_TEXT_BOUNDARY_LINE_START and
165 * ATK_TEXT_BOUNDARY_LINE_END
167 * Returns: the text after @offset up to the specified @boundary_type.
170 atk_text_get_text_after_offset (AtkText *text,
172 AtkTextBoundary boundary_type)
176 g_return_val_if_fail (text != NULL, NULL);
177 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
179 iface = ATK_TEXT_GET_IFACE (text);
181 if (iface->get_text_after_offset)
182 return (*(iface->get_text_after_offset)) (text, offset, boundary_type);
188 * atk_text_get_text_at_offset
191 * @boundary_type: An #AtkTextBoundary
193 * Gets the specified text.
194 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START or
195 * ATK_TEXT_BOUNDARY_WORD_END a complete word is returned;
196 * if the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START or
197 * ATK_TEXT_BOUNDARY_SENTENCE_END a complete sentence
198 * is returned; if the boundary type is ATK_TEXT_BOUNDARY_LINE_START or
199 * ATK_TEXT_BOUNDARY_LINE_END a complete line is returned.
201 * Returns: the text at @offset up to the specified @boundary_type.
204 atk_text_get_text_at_offset (AtkText *text,
206 AtkTextBoundary boundary_type)
210 g_return_val_if_fail (text != NULL, NULL);
211 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
213 iface = ATK_TEXT_GET_IFACE (text);
215 if (iface->get_text_at_offset)
216 return (*(iface->get_text_at_offset)) (text, offset, boundary_type);
222 * atk_text_get_text_before_offset
225 * @boundary_type: An #AtkTextBoundary
227 * Gets the specified text.
228 * If the boundary type is ATK_TEXT_BOUNDARY_WORD_START or
229 * ATK_TEXT_BOUNDARY_WORD_END part of a word may be returned.
230 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the start point
231 * will be at the start of the sentence, and will continue to the offset.
232 * The last word may not be a complete word. Similarly for
233 * ATK_TEXT_BOUNDARY_SENTENCE_END, ATK_TEXT_BOUNDARY_LINE_START and
234 * ATK_TEXT_BOUNDARY_LINE_END
236 * Returns: the text before @offset starting from the specified @boundary_type.
239 atk_text_get_text_before_offset (AtkText *text,
241 AtkTextBoundary boundary_type)
245 g_return_val_if_fail (text != NULL, NULL);
246 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
248 iface = ATK_TEXT_GET_IFACE (text);
250 if (iface->get_text_before_offset)
251 return (*(iface->get_text_before_offset)) (text, offset, boundary_type);
257 * atk_text_get_caret_offset
260 * Gets the offset position of the caret (cursor).
262 * Returns: the offset position of the caret (cursor).
265 atk_text_get_caret_offset (AtkText *text)
269 g_return_val_if_fail (text != NULL, -1);
270 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
272 iface = ATK_TEXT_GET_IFACE (text);
274 if (iface->get_caret_offset)
275 return (*(iface->get_caret_offset)) (text);
281 * atk_text_get_row_col_at_offset
285 * @col: column number
287 * Given an @offset, the @row and @col arguments are filled appropriately.
290 atk_text_get_row_col_at_offset (AtkText *text,
297 g_return_if_fail (text != NULL);
298 g_return_if_fail (ATK_IS_TEXT (text));
300 iface = ATK_TEXT_GET_IFACE (text);
302 if (iface->get_row_col_at_offset)
303 (*(iface->get_row_col_at_offset)) (text, offset, row, col);
312 * atk_text_get_range_attributes
314 * @start_offset: start position
315 * @end_offset: end position
317 * Gets attributes over the specified range.
319 * Returns: a #PangoAttrList with the text attributes between the
320 * @start_offset and the @end_offset.
323 atk_text_get_range_attributes (AtkText *text,
329 g_return_val_if_fail (text != NULL, NULL);
330 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
332 iface = ATK_TEXT_GET_IFACE (text);
334 if (iface->get_range_attributes)
335 return (*(iface->get_range_attributes)) (text, start_offset, end_offset);
341 * atk_text_get_character_extents
344 * @x: x-position of character
345 * @y: y-position of character
346 * @length: length of character
347 * @width: width of character
349 * Given an @offset, the @x, @y, @length, and @width values are filled
353 atk_text_get_character_extents (AtkText *text,
362 g_return_if_fail (text != NULL);
363 g_return_if_fail (ATK_IS_TEXT (text));
365 iface = ATK_TEXT_GET_IFACE (text);
367 if (iface->get_character_extents)
368 (*(iface->get_character_extents)) (text, offset, x, y, length, width);
379 * atk_text_get_character_count
382 * Gets the character count.
384 * Returns: the number of characters.
387 atk_text_get_character_count (AtkText *text)
391 g_return_val_if_fail (text != NULL, -1);
392 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
394 iface = ATK_TEXT_GET_IFACE (text);
396 if (iface->get_character_count)
397 return (*(iface->get_character_count)) (text);
403 * atk_text_get_offset_at_point
405 * @x: screen x-position of character
406 * @y: screen y-position of character
408 * Gets the x,y screen coordinates of the specified character.
410 * Returns: the offset to the character which is located at
411 * the specified @x and @y coordinates.
414 atk_text_get_offset_at_point (AtkText *text,
420 g_return_val_if_fail (text != NULL, -1);
421 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
423 iface = ATK_TEXT_GET_IFACE (text);
425 if (iface->get_offset_at_point)
426 return (*(iface->get_offset_at_point)) (text, x, y);
432 * atk_text_get_selected_text
435 * Gets the selected text.
437 * Returns: the selected text.
440 atk_text_get_selected_text (AtkText *text)
444 g_return_val_if_fail (text != NULL, NULL);
445 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
447 iface = ATK_TEXT_GET_IFACE (text);
449 if (iface->get_selected_text)
450 return (*(iface->get_selected_text)) (text);
456 * atk_text_get_selection_bounds
458 * @start_offset: start position
459 * @end_offset: end position
461 * @start_offset and @end_offset are filled with the
462 * current selection bounds.
465 atk_text_get_selection_bounds (AtkText *text,
471 g_return_if_fail (text != NULL);
472 g_return_if_fail (ATK_IS_TEXT (text));
474 iface = ATK_TEXT_GET_IFACE (text);
476 if (iface->get_selection_bounds)
477 (*(iface->get_selection_bounds)) (text, start_offset, end_offset);
486 * atk_text_set_selection_bounds
488 * @start_offset: start position
489 * @end_offset: end position
491 * The selection bounds are set to the specified @start_offset
492 * and @end_offset values.
494 * Returns: %TRUE if success, %FALSE otherwise.
497 atk_text_set_selection_bounds (AtkText *text,
503 g_return_val_if_fail (text != NULL, FALSE);
504 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
506 iface = ATK_TEXT_GET_IFACE (text);
508 if (iface->set_selection_bounds)
510 return (*(iface->set_selection_bounds)) (text, start_offset, end_offset);
519 * atk_text_set_caret_offset
523 * Sets the caret (cursor) position to the specified @offset.
525 * Returns: %TRUE if success, %FALSE otherwise.
528 atk_text_set_caret_offset (AtkText *text,
533 g_return_val_if_fail (text != NULL, FALSE);
534 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
536 iface = ATK_TEXT_GET_IFACE (text);
538 if (iface->set_caret_offset)
540 return (*(iface->set_caret_offset)) (text, offset);