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 ATK_TEXT_GET_IFACE(g_class)->text_changed = 0;
71 ATK_TEXT_GET_IFACE(g_class)->caret_changed = 0;
75 * Note that text_changed signal supports details "insert", "delete",
79 atk_text_signals[TEXT_CHANGED] =
80 g_signal_newc ("text_changed",
82 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
83 G_STRUCT_OFFSET (AtkTextIface, text_changed),
84 (GSignalAccumulator) NULL, NULL,
85 g_cclosure_marshal_VOID__VOID,
89 atk_text_signals[CARET_MOVED] =
90 g_signal_newc ("text_caret_moved",
93 G_STRUCT_OFFSET (AtkTextIface, caret_changed),
94 (GSignalAccumulator) NULL, NULL,
95 g_cclosure_marshal_VOID__INT,
106 * @start_offset: start position
107 * @end_offset: end position
109 * Returns: the text from @start_offset up to, but not including @end_offset.
112 atk_text_get_text (AtkText *text,
118 g_return_val_if_fail (text != NULL, NULL);
119 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
121 iface = ATK_TEXT_GET_IFACE (text);
124 return (*(iface->get_text)) (text, start_offset, end_offset);
130 * atk_text_get_character_at_offset
134 * Returns: the character at @offset.
137 atk_text_get_character_at_offset (AtkText *text,
142 g_return_val_if_fail (text != NULL, (gunichar) 0);
143 g_return_val_if_fail (ATK_IS_TEXT (text), (gunichar) 0);
145 iface = ATK_TEXT_GET_IFACE (text);
147 if (iface->get_character_at_offset)
148 return (*(iface->get_character_at_offset)) (text, offset);
154 * atk_text_get_text_after_offset
157 * @boundary_type: An #AtkTextBoundary
159 * Returns: the text after @offset up to the specified @boundary_type.
160 * If the boundary type is ATK_TEXT_BOUNDARY_WORD_START or
161 * ATK_TEXT_BOUNDARY_WORD_END part of a word may be returned.
162 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the start point
163 * will be the offset and will continue to the start of the next sentence.
164 * The first word may not be a complete word. Similarly for
165 * ATK_TEXT_BOUNDARY_SENTENCE_END, ATK_TEXT_BOUNDARY_LINE_START and
166 * ATK_TEXT_BOUNDARY_LINE_END
169 atk_text_get_text_after_offset (AtkText *text,
171 AtkTextBoundary boundary_type)
175 g_return_val_if_fail (text != NULL, NULL);
176 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
178 iface = ATK_TEXT_GET_IFACE (text);
180 if (iface->get_text_after_offset)
181 return (*(iface->get_text_after_offset)) (text, offset, boundary_type);
187 * atk_text_get_text_at_offset
190 * @boundary_type: An #AtkTextBoundary
192 * Returns: the text at @offset up to the specified @boundary_type.
193 * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START or
194 * ATK_TEXT_BOUNDARY_WORD_END a complete word is returned;
195 * if the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START or
196 * ATK_TEXT_BOUNDARY_SENTENCE_END a complete sentence
197 * is returned; if the boundary type is ATK_TEXT_BOUNDARY_LINE_START or
198 * ATK_TEXT_BOUNDARY_LINE_END a complete line is returned.
201 atk_text_get_text_at_offset (AtkText *text,
203 AtkTextBoundary boundary_type)
207 g_return_val_if_fail (text != NULL, NULL);
208 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
210 iface = ATK_TEXT_GET_IFACE (text);
212 if (iface->get_text_at_offset)
213 return (*(iface->get_text_at_offset)) (text, offset, boundary_type);
219 * atk_text_get_text_before_offset
222 * @boundary_type: An #AtkTextBoundary
224 * Returns: the text before @offset starting from the specified @boundary_type.
225 * If the boundary type is ATK_TEXT_BOUNDARY_WORD_START or
226 * ATK_TEXT_BOUNDARY_WORD_END part of a word may be returned.
227 * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the start point
228 * will be at the start of the sentence, and will continue to the offset.
229 * The last word may not be a complete word. Similarly for
230 * ATK_TEXT_BOUNDARY_SENTENCE_END, ATK_TEXT_BOUNDARY_LINE_START and
231 * ATK_TEXT_BOUNDARY_LINE_END
234 atk_text_get_text_before_offset (AtkText *text,
236 AtkTextBoundary boundary_type)
240 g_return_val_if_fail (text != NULL, NULL);
241 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
243 iface = ATK_TEXT_GET_IFACE (text);
245 if (iface->get_text_before_offset)
246 return (*(iface->get_text_before_offset)) (text, offset, boundary_type);
252 * atk_text_get_caret_offset
255 * Returns: the position of the caret (cursor).
258 atk_text_get_caret_offset (AtkText *text)
262 g_return_val_if_fail (text != NULL, -1);
263 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
265 iface = ATK_TEXT_GET_IFACE (text);
267 if (iface->get_caret_offset)
268 return (*(iface->get_caret_offset)) (text);
274 * atk_text_get_row_col_at_offset
278 * @col: column number
280 * Given an @offset, the @row and @col arguments are filled appropriately.
283 atk_text_get_row_col_at_offset (AtkText *text,
290 g_return_if_fail (text != NULL);
291 g_return_if_fail (ATK_IS_TEXT (text));
293 iface = ATK_TEXT_GET_IFACE (text);
295 if (iface->get_row_col_at_offset)
296 (*(iface->get_row_col_at_offset)) (text, offset, row, col);
305 * atk_text_get_range_attributes
307 * @start_offset: start position
308 * @end_offset: end position
310 * Returns a #PangoAttrList with the text attributes between the
311 * @start_offset and the @end_offset.
314 atk_text_get_range_attributes (AtkText *text,
320 g_return_val_if_fail (text != NULL, NULL);
321 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
323 iface = ATK_TEXT_GET_IFACE (text);
325 if (iface->get_range_attributes)
326 return (*(iface->get_range_attributes)) (text, start_offset, end_offset);
332 * atk_text_get_character_extents
335 * @x: x-position of character
336 * @y: y-position of character
337 * @length: length of character
338 * @width: width of character
340 * Given an @offset, the @x, @y, @length, and @width values are filled
344 atk_text_get_character_extents (AtkText *text,
353 g_return_if_fail (text != NULL);
354 g_return_if_fail (ATK_IS_TEXT (text));
356 iface = ATK_TEXT_GET_IFACE (text);
358 if (iface->get_character_extents)
359 (*(iface->get_character_extents)) (text, offset, x, y, length, width);
370 * atk_text_get_character_count
373 * Returns: the number of characters.
376 atk_text_get_character_count (AtkText *text)
380 g_return_val_if_fail (text != NULL, -1);
381 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
383 iface = ATK_TEXT_GET_IFACE (text);
385 if (iface->get_character_count)
386 return (*(iface->get_character_count)) (text);
392 * atk_text_get_offset_at_point
394 * @x: x-position of character
395 * @y: y-position of character
397 * Returns: the offset to the character which is located at
398 * the specified @x and @y coordinates.
401 atk_text_get_offset_at_point (AtkText *text,
407 g_return_val_if_fail (text != NULL, -1);
408 g_return_val_if_fail (ATK_IS_TEXT (text), -1);
410 iface = ATK_TEXT_GET_IFACE (text);
412 if (iface->get_offset_at_point)
413 return (*(iface->get_offset_at_point)) (text, x, y);
419 * atk_text_get_selected_text
422 * Returns: the selected text.
425 atk_text_get_selected_text (AtkText *text)
429 g_return_val_if_fail (text != NULL, NULL);
430 g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
432 iface = ATK_TEXT_GET_IFACE (text);
434 if (iface->get_selected_text)
435 return (*(iface->get_selected_text)) (text);
441 * atk_text_get_selection_bounds
443 * @start_offset: start position
444 * @end_offset: end position
446 * @start_offset and @end_offset are filled with the
447 * current selection bounds.
450 atk_text_get_selection_bounds (AtkText *text,
456 g_return_if_fail (text != NULL);
457 g_return_if_fail (ATK_IS_TEXT (text));
459 iface = ATK_TEXT_GET_IFACE (text);
461 if (iface->get_selection_bounds)
462 (*(iface->get_selection_bounds)) (text, start_offset, end_offset);
471 * atk_text_set_selection_bounds
473 * @start_offset: start position
474 * @end_offset: end position
476 * The selection bounds are set to the specified @start_offset
477 * and @end_offset values.
479 * Returns: %TRUE if success, %FALSE otherwise.
482 atk_text_set_selection_bounds (AtkText *text,
488 g_return_val_if_fail (text != NULL, FALSE);
489 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
491 iface = ATK_TEXT_GET_IFACE (text);
493 if (iface->set_selection_bounds)
495 return (*(iface->set_selection_bounds)) (text, start_offset, end_offset);
504 * atk_text_set_caret_offset
508 * Sets the caret (cursor) position to the specified @offset.
510 * Returns: %TRUE if success, %FALSE otherwise.
513 atk_text_set_caret_offset (AtkText *text,
518 g_return_val_if_fail (text != NULL, FALSE);
519 g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
521 iface = ATK_TEXT_GET_IFACE (text);
523 if (iface->set_caret_offset)
525 return (*(iface->set_caret_offset)) (text, offset);