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_interface_init (AtkTextIfaceClass *klass);
37 static gpointer parent_class = NULL;
39 static guint atk_text_signals[LAST_SIGNAL] = { 0, 0, 0};
44 static GType type = 0;
48 static const GTypeInfo tinfo =
50 sizeof (AtkTextIface),
52 (GBaseFinalizeFunc) NULL,
53 (GClassInitFunc) atk_text_interface_init,
54 (GClassFinalizeFunc) NULL,
58 type = g_type_register_static (G_TYPE_INTERFACE, "AtkText", &tinfo, 0);
65 * Additional GObject properties exported by AtkText:
66 * "accessible_text" (accessible text has changed)
67 * "accessible_caret" (accessible text cursor position changed:
72 atk_text_interface_init (AtkTextIfaceClass *klass)
74 parent_class = g_type_class_ref (G_TYPE_OBJECT);
77 * Note that text_changed signal supports details "insert", "delete",
81 atk_text_signals[TEXT_CHANGED] =
82 g_signal_newc ("text_changed",
83 G_TYPE_FROM_CLASS (klass),
84 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
85 G_STRUCT_OFFSET (AtkTextIface, text_changed),
87 g_cclosure_marshal_VOID__VOID,
91 atk_text_signals[CARET_MOVED] =
92 g_signal_newc ("text_caret_moved",
93 G_TYPE_FROM_CLASS (klass),
95 G_STRUCT_OFFSET (AtkTextIface, caret_changed),
97 g_cclosure_marshal_VOID__INT,
103 atk_text_get_text (AtkText *text,
109 g_return_val_if_fail (text != NULL, NULL);
110 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
112 iface = ATK_TEXT_GET_IFACE (text);
115 return (*(iface->get_text)) (text, start_offset, end_offset);
121 atk_text_get_character_at_offset (AtkText *text,
126 g_return_val_if_fail (text != NULL, (gunichar) 0);
127 g_return_val_if_fail (ATK_IS_TEXT (text), (gunichar) 0);
129 iface = ATK_TEXT_GET_IFACE (text);
131 if (iface->get_character_at_offset)
132 return (*(iface->get_character_at_offset)) (text, offset);
138 atk_text_get_text_after_offset (AtkText *text,
140 AtkTextBoundary boundary_type)
144 g_return_val_if_fail (text != NULL, NULL);
145 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
147 iface = ATK_TEXT_GET_IFACE (text);
149 if (iface->get_text_after_offset)
150 return (*(iface->get_text_after_offset)) (text, offset, boundary_type);
156 atk_text_get_text_at_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_at_offset)
168 return (*(iface->get_text_at_offset)) (text, offset, boundary_type);
174 atk_text_get_text_before_offset (AtkText *text,
176 AtkTextBoundary boundary_type)
180 g_return_val_if_fail (text != NULL, NULL);
181 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
183 iface = ATK_TEXT_GET_IFACE (text);
185 if (iface->get_text_before_offset)
186 return (*(iface->get_text_before_offset)) (text, offset, boundary_type);
192 atk_text_get_caret_offset (AtkText *text)
196 g_return_val_if_fail (text != NULL, -1);
197 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
199 iface = ATK_TEXT_GET_IFACE (text);
201 if (iface->get_caret_offset)
202 return (*(iface->get_caret_offset)) (text);
208 atk_text_get_row_col_at_offset (AtkText *text,
215 g_return_if_fail (text != NULL);
216 g_return_if_fail (ATK_IS_TEXT (text));
218 iface = ATK_TEXT_GET_IFACE (text);
220 if (iface->get_row_col_at_offset)
221 (*(iface->get_row_col_at_offset)) (text, offset, row, col);
230 atk_text_get_range_attributes (AtkText *text,
236 g_return_val_if_fail (text != NULL, NULL);
237 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
239 iface = ATK_TEXT_GET_IFACE (text);
241 if (iface->get_range_attributes)
242 return (*(iface->get_range_attributes)) (text, start_offset, end_offset);
248 atk_text_get_character_extents (AtkText *text,
257 g_return_if_fail (text != NULL);
258 g_return_if_fail (ATK_IS_TEXT (text));
260 iface = ATK_TEXT_GET_IFACE (text);
262 if (iface->get_character_extents)
263 (*(iface->get_character_extents)) (text, offset, x, y, length, width);
274 atk_text_get_character_count (AtkText *text)
278 g_return_val_if_fail (text != NULL, -1);
279 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
281 iface = ATK_TEXT_GET_IFACE (text);
283 if (iface->get_character_count)
284 return (*(iface->get_character_count)) (text);
290 atk_text_get_offset_at_point (AtkText *text,
296 g_return_val_if_fail (text != NULL, -1);
297 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
299 iface = ATK_TEXT_GET_IFACE (text);
301 if (iface->get_offset_at_point)
302 return (*(iface->get_offset_at_point)) (text, x, y);
308 atk_text_get_selected_text (AtkText *text)
312 g_return_val_if_fail (text != NULL, NULL);
313 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
315 iface = ATK_TEXT_GET_IFACE (text);
317 if (iface->get_selected_text)
318 return (*(iface->get_selected_text)) (text);
324 atk_text_get_selection_bounds (AtkText *text,
330 g_return_if_fail (text != NULL);
331 g_return_if_fail (ATK_IS_TEXT (text));
333 iface = ATK_TEXT_GET_IFACE (text);
335 if (iface->get_selection_bounds)
336 (*(iface->get_selection_bounds)) (text, start_offset, end_offset);
345 atk_text_set_selection_bounds (AtkText *text,
351 g_return_val_if_fail (text != NULL, FALSE);
352 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
354 iface = ATK_TEXT_GET_IFACE (text);
356 if (iface->set_selection_bounds)
358 return (*(iface->set_selection_bounds)) (text, start_offset, end_offset);
367 atk_text_set_caret_offset (AtkText *text,
372 g_return_val_if_fail (text != NULL, FALSE);
373 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
375 iface = ATK_TEXT_GET_IFACE (text);
377 if (iface->set_caret_offset)
379 return (*(iface->set_caret_offset)) (text, offset);