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 between @start_offset and @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.
156 atk_text_get_text_after_offset (AtkText *text,
158 AtkTextBoundary boundary_type)
162 g_return_val_if_fail (text != NULL, NULL);
163 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
165 iface = ATK_TEXT_GET_IFACE (text);
167 if (iface->get_text_after_offset)
168 return (*(iface->get_text_after_offset)) (text, offset, boundary_type);
174 *atk_text_get_text_at_offset
177 *@boundary_type: An #AtkTextBoundary
179 *Returns the text at @offset up to the specified @boundary_type.
182 atk_text_get_text_at_offset (AtkText *text,
184 AtkTextBoundary boundary_type)
188 g_return_val_if_fail (text != NULL, NULL);
189 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
191 iface = ATK_TEXT_GET_IFACE (text);
193 if (iface->get_text_at_offset)
194 return (*(iface->get_text_at_offset)) (text, offset, boundary_type);
200 *atk_text_get_text_before_offset
203 *@boundary_type: An #AtkTextBoundary
205 *Returns the text before @offset up to the specified @boundary_type.
208 atk_text_get_text_before_offset (AtkText *text,
210 AtkTextBoundary boundary_type)
214 g_return_val_if_fail (text != NULL, NULL);
215 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
217 iface = ATK_TEXT_GET_IFACE (text);
219 if (iface->get_text_before_offset)
220 return (*(iface->get_text_before_offset)) (text, offset, boundary_type);
226 *atk_text_get_caret_offset
229 *Returns the position of the caret (cursor).
232 atk_text_get_caret_offset (AtkText *text)
236 g_return_val_if_fail (text != NULL, -1);
237 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
239 iface = ATK_TEXT_GET_IFACE (text);
241 if (iface->get_caret_offset)
242 return (*(iface->get_caret_offset)) (text);
248 *atk_text_get_row_col_at_offset
254 *Given an @offset, the @row and @col arguments are filled appropriately.
257 atk_text_get_row_col_at_offset (AtkText *text,
264 g_return_if_fail (text != NULL);
265 g_return_if_fail (ATK_IS_TEXT (text));
267 iface = ATK_TEXT_GET_IFACE (text);
269 if (iface->get_row_col_at_offset)
270 (*(iface->get_row_col_at_offset)) (text, offset, row, col);
279 *atk_text_get_range_attributes
281 *@start_offset: start position
282 *@end_offset: end position
284 *Returns a #PangoAttrList with the text attributes between the
285 *@start_offset and the @end_offset.
288 atk_text_get_range_attributes (AtkText *text,
294 g_return_val_if_fail (text != NULL, NULL);
295 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
297 iface = ATK_TEXT_GET_IFACE (text);
299 if (iface->get_range_attributes)
300 return (*(iface->get_range_attributes)) (text, start_offset, end_offset);
306 *atk_text_get_character_extents
309 *@x: x-position of character
310 *@y: y-position of character
311 *@length: length of character
312 *@width: width of character
314 *Given an @offset, the @x, @y, @length, and @width values are filled
318 atk_text_get_character_extents (AtkText *text,
327 g_return_if_fail (text != NULL);
328 g_return_if_fail (ATK_IS_TEXT (text));
330 iface = ATK_TEXT_GET_IFACE (text);
332 if (iface->get_character_extents)
333 (*(iface->get_character_extents)) (text, offset, x, y, length, width);
344 *atk_text_get_character_count
347 *Returns the number of characters.
350 atk_text_get_character_count (AtkText *text)
354 g_return_val_if_fail (text != NULL, -1);
355 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
357 iface = ATK_TEXT_GET_IFACE (text);
359 if (iface->get_character_count)
360 return (*(iface->get_character_count)) (text);
366 *atk_text_get_offset_at_point
368 *@x: x-position of character
369 *@y: y-position of character
371 *Returns the offset to the character which is located at
372 *the specified @x and @y coordinates.
375 atk_text_get_offset_at_point (AtkText *text,
381 g_return_val_if_fail (text != NULL, -1);
382 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
384 iface = ATK_TEXT_GET_IFACE (text);
386 if (iface->get_offset_at_point)
387 return (*(iface->get_offset_at_point)) (text, x, y);
393 *atk_text_get_selected_text
396 *Returns the selected text.
399 atk_text_get_selected_text (AtkText *text)
403 g_return_val_if_fail (text != NULL, NULL);
404 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
406 iface = ATK_TEXT_GET_IFACE (text);
408 if (iface->get_selected_text)
409 return (*(iface->get_selected_text)) (text);
415 *atk_text_get_selection_bounds
417 *@start_offset: start position
418 *@end_offset: end position
420 *@start_offset and @end_offset are filled with the
421 *current selection bounds.
424 atk_text_get_selection_bounds (AtkText *text,
430 g_return_if_fail (text != NULL);
431 g_return_if_fail (ATK_IS_TEXT (text));
433 iface = ATK_TEXT_GET_IFACE (text);
435 if (iface->get_selection_bounds)
436 (*(iface->get_selection_bounds)) (text, start_offset, end_offset);
445 *atk_text_set_selection_bounds
447 *@start_offset: start position
448 *@end_offset: end position
450 *The selection bounds are set to the specified @start_offset
451 *and @end_offset values.
452 *Returns TRUE if success, FALSE otherwise.
455 atk_text_set_selection_bounds (AtkText *text,
461 g_return_val_if_fail (text != NULL, FALSE);
462 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
464 iface = ATK_TEXT_GET_IFACE (text);
466 if (iface->set_selection_bounds)
468 return (*(iface->set_selection_bounds)) (text, start_offset, end_offset);
477 *atk_text_set_caret_offset
481 *Sets the caret (cursor) position to the specified @offset.
482 *Returns TRUE if success, FALSE otherwise.
485 atk_text_set_caret_offset (AtkText *text,
490 g_return_val_if_fail (text != NULL, FALSE);
491 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
493 iface = ATK_TEXT_GET_IFACE (text);
495 if (iface->set_caret_offset)
497 return (*(iface->set_caret_offset)) (text, offset);