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;
71 * Note that text_changed signal supports details "insert", "delete",
75 atk_text_signals[TEXT_CHANGED] =
76 g_signal_newc ("text_changed",
78 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
79 G_STRUCT_OFFSET (AtkTextIface, text_changed),
81 g_cclosure_marshal_VOID__VOID,
85 atk_text_signals[CARET_MOVED] =
86 g_signal_newc ("text_caret_moved",
89 G_STRUCT_OFFSET (AtkTextIface, caret_changed),
91 g_cclosure_marshal_VOID__INT,
100 * @start_offset: start position
101 * @end_offset: end position
103 * Returns: the text from @start_offset up to, but not including @end_offset.
106 atk_text_get_text (AtkText *text,
112 g_return_val_if_fail (text != NULL, NULL);
113 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
115 iface = ATK_TEXT_GET_IFACE (text);
118 return (*(iface->get_text)) (text, start_offset, end_offset);
124 * atk_text_get_character_at_offset
128 * Returns: the character at @offset.
131 atk_text_get_character_at_offset (AtkText *text,
136 g_return_val_if_fail (text != NULL, (gunichar) 0);
137 g_return_val_if_fail (ATK_IS_TEXT (text), (gunichar) 0);
139 iface = ATK_TEXT_GET_IFACE (text);
141 if (iface->get_character_at_offset)
142 return (*(iface->get_character_at_offset)) (text, offset);
148 * atk_text_get_text_after_offset
151 * @boundary_type: An #AtkTextBoundary
153 * Returns: the text after @offset up to the specified @boundary_type.
154 * If the boundary type is ATK_TEXT_BOUNDARY_WORD_START or
155 * ATK_TEXT_BOUNDARY_WORD_END part of a word may be returned.
156 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the start point
157 * will be the offset and will continue to the start of the next sentence.
158 * The first word may not be a complete word. Similarly for
159 * ATK_TEXT_BOUNDARY_SENTENCE_END, ATK_TEXT_BOUNDARY_LINE_START and
160 * ATK_TEXT_BOUNDARY_LINE_END
163 atk_text_get_text_after_offset (AtkText *text,
165 AtkTextBoundary boundary_type)
169 g_return_val_if_fail (text != NULL, NULL);
170 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
172 iface = ATK_TEXT_GET_IFACE (text);
174 if (iface->get_text_after_offset)
175 return (*(iface->get_text_after_offset)) (text, offset, boundary_type);
181 * atk_text_get_text_at_offset
184 * @boundary_type: An #AtkTextBoundary
186 * Returns: the text at @offset up to the specified @boundary_type.
187 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START or
188 * ATK_TEXT_BOUNDARY_WORD_END a complete word is returned;
189 * if the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START or
190 * ATK_TEXT_BOUNDARY_SENTENCE_END a complete sentence
191 * is returned; if the boundary type is ATK_TEXT_BOUNDARY_LINE_START or
192 * ATK_TEXT_BOUNDARY_LINE_END a complete line is returned.
195 atk_text_get_text_at_offset (AtkText *text,
197 AtkTextBoundary boundary_type)
201 g_return_val_if_fail (text != NULL, NULL);
202 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
204 iface = ATK_TEXT_GET_IFACE (text);
206 if (iface->get_text_at_offset)
207 return (*(iface->get_text_at_offset)) (text, offset, boundary_type);
213 * atk_text_get_text_before_offset
216 * @boundary_type: An #AtkTextBoundary
218 * Returns: the text before @offset starting from the specified @boundary_type.
219 * If the boundary type is ATK_TEXT_BOUNDARY_WORD_START or
220 * ATK_TEXT_BOUNDARY_WORD_END part of a word may be returned.
221 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the start point
222 * will be at the start of the sentence, and will continue to the offset.
223 * The last word may not be a complete word. Similarly for
224 * ATK_TEXT_BOUNDARY_SENTENCE_END, ATK_TEXT_BOUNDARY_LINE_START and
225 * ATK_TEXT_BOUNDARY_LINE_END
228 atk_text_get_text_before_offset (AtkText *text,
230 AtkTextBoundary boundary_type)
234 g_return_val_if_fail (text != NULL, NULL);
235 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
237 iface = ATK_TEXT_GET_IFACE (text);
239 if (iface->get_text_before_offset)
240 return (*(iface->get_text_before_offset)) (text, offset, boundary_type);
246 * atk_text_get_caret_offset
249 * Returns: the position of the caret (cursor).
252 atk_text_get_caret_offset (AtkText *text)
256 g_return_val_if_fail (text != NULL, -1);
257 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
259 iface = ATK_TEXT_GET_IFACE (text);
261 if (iface->get_caret_offset)
262 return (*(iface->get_caret_offset)) (text);
268 * atk_text_get_row_col_at_offset
272 * @col: column number
274 * Given an @offset, the @row and @col arguments are filled appropriately.
277 atk_text_get_row_col_at_offset (AtkText *text,
284 g_return_if_fail (text != NULL);
285 g_return_if_fail (ATK_IS_TEXT (text));
287 iface = ATK_TEXT_GET_IFACE (text);
289 if (iface->get_row_col_at_offset)
290 (*(iface->get_row_col_at_offset)) (text, offset, row, col);
299 * atk_text_get_range_attributes
301 * @start_offset: start position
302 * @end_offset: end position
304 * Returns a #PangoAttrList with the text attributes between the
305 * @start_offset and the @end_offset.
308 atk_text_get_range_attributes (AtkText *text,
314 g_return_val_if_fail (text != NULL, NULL);
315 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
317 iface = ATK_TEXT_GET_IFACE (text);
319 if (iface->get_range_attributes)
320 return (*(iface->get_range_attributes)) (text, start_offset, end_offset);
326 * atk_text_get_character_extents
329 * @x: x-position of character
330 * @y: y-position of character
331 * @length: length of character
332 * @width: width of character
334 * Given an @offset, the @x, @y, @length, and @width values are filled
338 atk_text_get_character_extents (AtkText *text,
347 g_return_if_fail (text != NULL);
348 g_return_if_fail (ATK_IS_TEXT (text));
350 iface = ATK_TEXT_GET_IFACE (text);
352 if (iface->get_character_extents)
353 (*(iface->get_character_extents)) (text, offset, x, y, length, width);
364 * atk_text_get_character_count
367 * Returns: the number of characters.
370 atk_text_get_character_count (AtkText *text)
374 g_return_val_if_fail (text != NULL, -1);
375 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
377 iface = ATK_TEXT_GET_IFACE (text);
379 if (iface->get_character_count)
380 return (*(iface->get_character_count)) (text);
386 * atk_text_get_offset_at_point
388 * @x: x-position of character
389 * @y: y-position of character
391 * Returns: the offset to the character which is located at
392 * the specified @x and @y coordinates.
395 atk_text_get_offset_at_point (AtkText *text,
401 g_return_val_if_fail (text != NULL, -1);
402 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
404 iface = ATK_TEXT_GET_IFACE (text);
406 if (iface->get_offset_at_point)
407 return (*(iface->get_offset_at_point)) (text, x, y);
413 * atk_text_get_selected_text
416 * Returns: the selected text.
419 atk_text_get_selected_text (AtkText *text)
423 g_return_val_if_fail (text != NULL, NULL);
424 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
426 iface = ATK_TEXT_GET_IFACE (text);
428 if (iface->get_selected_text)
429 return (*(iface->get_selected_text)) (text);
435 * atk_text_get_selection_bounds
437 * @start_offset: start position
438 * @end_offset: end position
440 * @start_offset and @end_offset are filled with the
441 * current selection bounds.
444 atk_text_get_selection_bounds (AtkText *text,
450 g_return_if_fail (text != NULL);
451 g_return_if_fail (ATK_IS_TEXT (text));
453 iface = ATK_TEXT_GET_IFACE (text);
455 if (iface->get_selection_bounds)
456 (*(iface->get_selection_bounds)) (text, start_offset, end_offset);
465 * atk_text_set_selection_bounds
467 * @start_offset: start position
468 * @end_offset: end position
470 * The selection bounds are set to the specified @start_offset
471 * and @end_offset values.
473 * Returns: %TRUE if success, %FALSE otherwise.
476 atk_text_set_selection_bounds (AtkText *text,
482 g_return_val_if_fail (text != NULL, FALSE);
483 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
485 iface = ATK_TEXT_GET_IFACE (text);
487 if (iface->set_selection_bounds)
489 return (*(iface->set_selection_bounds)) (text, start_offset, end_offset);
498 * atk_text_set_caret_offset
502 * Sets the caret (cursor) position to the specified @offset.
504 * Returns: %TRUE if success, %FALSE otherwise.
507 atk_text_set_caret_offset (AtkText *text,
512 g_return_val_if_fail (text != NULL, FALSE);
513 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
515 iface = ATK_TEXT_GET_IFACE (text);
517 if (iface->set_caret_offset)
519 return (*(iface->set_caret_offset)) (text, offset);