2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #include <cspi/spi-private.h>
26 static Accessibility_TEXT_BOUNDARY_TYPE
27 get_accessible_text_boundary_type (AccessibleTextBoundaryType type)
31 case SPI_TEXT_BOUNDARY_CHAR:
32 return Accessibility_TEXT_BOUNDARY_CHAR;
34 case SPI_TEXT_BOUNDARY_CURSOR_POS:
36 return Accessibility_TEXT_BOUNDARY_CHAR;
38 case SPI_TEXT_BOUNDARY_WORD_START:
39 return Accessibility_TEXT_BOUNDARY_WORD_START;
41 case SPI_TEXT_BOUNDARY_WORD_END:
42 return Accessibility_TEXT_BOUNDARY_WORD_END;
44 case SPI_TEXT_BOUNDARY_SENTENCE_START:
45 return Accessibility_TEXT_BOUNDARY_SENTENCE_START;
47 case SPI_TEXT_BOUNDARY_SENTENCE_END:
48 return Accessibility_TEXT_BOUNDARY_SENTENCE_END;
50 case SPI_TEXT_BOUNDARY_LINE_START:
51 return Accessibility_TEXT_BOUNDARY_LINE_START;
53 case SPI_TEXT_BOUNDARY_LINE_END:
54 return Accessibility_TEXT_BOUNDARY_LINE_END;
56 case SPI_TEXT_BOUNDARY_ATTRIBUTE_RANGE:
58 return Accessibility_TEXT_BOUNDARY_CHAR;
62 return Accessibility_TEXT_BOUNDARY_CHAR;
68 * @obj: a pointer to the #AccessibleText object on which to operate.
70 * Increment the reference count for an #AccessibleText object.
73 AccessibleText_ref (AccessibleText *obj)
75 cspi_object_ref (obj);
79 * AccessibleText_unref:
80 * @obj: a pointer to the #Accessible object on which to operate.
82 * Decrement the reference count for an #AccessibleText object.
85 AccessibleText_unref (AccessibleText *obj)
87 cspi_object_unref (obj);
91 * AccessibleText_getCharacterCount:
92 * @obj: a pointer to the #AccessibleText object to query.
94 * Get the character count of an #AccessibleText object.
96 * Returns: a long integer indicating the total number of
97 * characters in the #AccessibleText object.
100 AccessibleText_getCharacterCount (AccessibleText *obj)
104 cspi_return_val_if_fail (obj != NULL, -1);
106 retval = Accessibility_Text__get_characterCount (CSPI_OBJREF (obj), cspi_ev ());
108 cspi_return_val_if_ev ("getCharacterCount", -1);
114 * AccessibleText_getText:
115 * @obj: a pointer to the #AccessibleText object to query.
116 * @startOffset: a #long indicating the start of the desired text range.
117 * @endOffset: a #long indicating the first character past the desired range.
119 * Get a range of text from an #AccessibleText object. The number of bytes
120 * in the returned string may exceed endOffset-startOffset, since
121 * UTF-8 is a variable-width encoding.
123 * Returns: a text string containing characters from @startOffset
124 * to @endOffset-1, inclusive, encoded as UTF-8.
127 AccessibleText_getText (AccessibleText *obj,
128 long int startOffset,
133 cspi_return_val_if_fail (obj != NULL, NULL);
136 Accessibility_Text_getText (CSPI_OBJREF (obj),
141 cspi_return_val_if_ev ("getText", NULL);
147 * AccessibleText_getCaretOffset:
148 * @obj: a pointer to the #AccessibleText object to query.
150 * Get the current offset of the text caret in an #AccessibleText object.
152 * Returns: a long integer indicating the current position of the text caret.
155 AccessibleText_getCaretOffset (AccessibleText *obj)
159 cspi_return_val_if_fail (obj != NULL, -1);
162 Accessibility_Text__get_caretOffset (CSPI_OBJREF (obj), cspi_ev ());
164 cspi_return_val_if_ev ("getCaretOffset", -1);
170 * AccessibleText_getAttributes:
171 * @obj: a pointer to the #AccessibleText object to query.
172 * @offset: a long integer indicating the offset from which the attribute
174 * @startOffset: a #long indicating the start of the desired text range.
175 * @endOffset: a #long indicating the first character past the desired range.
177 * Get the attributes applied to a range of text from an #AccessibleText
178 * object, and the bounds of the range.
179 * The text attributes correspond to CSS attributes where possible,
180 * keys and values are delimited from one another via ":", and
181 * the delimiter between key/value pairs is ";". Thus
182 * "font-size:10;foreground-color:0,0,0" would be a valid
185 * Returns: a text string describing the attributes occurring within the
186 * attribute run containing @offset, encoded as UTF-8.
189 AccessibleText_getAttributes (AccessibleText *obj,
191 long int *startOffset,
194 CORBA_long retStartOffset, retEndOffset;
199 *startOffset = *endOffset = -1;
203 retval = Accessibility_Text_getAttributes (CSPI_OBJREF (obj),
209 if (!cspi_check_ev ("getAttributes"))
211 *startOffset = *endOffset = -1;
216 *startOffset = retStartOffset;
217 *endOffset = retEndOffset;
224 * AccessibleText_setCaretOffset:
225 * @obj: a pointer to the #AccessibleText object on which to operate.
226 * @newOffset: the offset to which the text caret is to be moved.
228 * Set the text caret position for an #AccessibleText object.
230 * Returns: #TRUE if successful, #FALSE otherwise.
233 AccessibleText_setCaretOffset (AccessibleText *obj,
238 cspi_return_val_if_fail (obj != NULL, FALSE);
241 Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj),
242 newOffset, cspi_ev ());
244 cspi_return_val_if_ev ("setCaretOffset", FALSE);
250 * AccessibleText_getTextBeforeOffset:
251 * @obj: a pointer to the #AccessibleText object on which to operate.
252 * @offset: a long integer indicating the offset from which the delimiter
254 * @type: an #AccessibleTextBoundaryType indicating whether the desired
255 * text string is a word, sentence, line, or attribute run.
256 * @startOffset: a pointer to a long integer which is assigned the
257 * starting offset of the returned string, relative to the
258 * original #AccessibleText.
259 * @endOffset: a pointer to a long integer which is assigned the
260 * ending offset of the returned string, relative to the original
263 * Get delimited text from an #AccessibleText object which precedes a given
266 * Returns: a UTF-8 string representing the delimited text, both of whose
267 * delimiting boundaries are before the current offset, or
268 * an empty string if no such text exists.
271 AccessibleText_getTextBeforeOffset (AccessibleText *obj,
273 AccessibleTextBoundaryType type,
274 long int *startOffset,
278 CORBA_long retStartOffset, retEndOffset;
282 *startOffset = *endOffset = -1;
286 retval = Accessibility_Text_getTextBeforeOffset (CSPI_OBJREF (obj),
288 get_accessible_text_boundary_type (type),
289 &retStartOffset, &retEndOffset,
291 if (!cspi_check_ev ("getTextBeforeOffset"))
293 *startOffset = *endOffset = -1;
298 *startOffset = retStartOffset;
299 *endOffset = retEndOffset;
305 * AccessibleText_getTextAtOffset:
306 * @obj: a pointer to the #AccessibleText object on which to operate.
307 * @offset: a long integer indicating the offset from which the delimiter
309 * @type: an #AccessibleTextBoundaryType indicating whether the desired
310 * text string is a word, sentence, line, or attribute run.
311 * @startOffset: a pointer to a long integer which is assigned the
312 * starting offset of the returned string, relative to the
313 * original #AccessibleText.
314 * @endOffset: a pointer to a long integer which is assigned the
315 * ending offset of the returned string, relative to the original
318 * Get delimited text from an #AccessibleText object which includes a given
321 * Returns: a UTF-8 string representing the delimited text, whose
322 * delimiting boundaries bracket the current offset, or
323 * an empty string if no such text exists.
326 AccessibleText_getTextAtOffset (AccessibleText *obj,
328 AccessibleTextBoundaryType type,
329 long int *startOffset, long int *endOffset)
331 CORBA_long corbaStartOffset;
332 CORBA_long corbaEndOffset;
337 *startOffset = *endOffset = -1;
341 retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj),
343 get_accessible_text_boundary_type (type),
348 if (!cspi_check_ev ("getTextAtOffset"))
350 *startOffset = *endOffset = -1;
355 *startOffset = corbaStartOffset;
356 *endOffset = corbaEndOffset;
362 * AccessibleText_getTextAfterOffset:
363 * @obj: a pointer to the #AccessibleText object on which to operate.
364 * @offset: a long integer indicating the offset from which the delimiter
366 * @type: an #AccessibleTextBoundaryType indicating whether the desired
367 * text string is a word, sentence, line, or attribute run.
368 * @startOffset: a pointer to a long integer which is assigned the
369 * starting offset of the returned string, relative to the
370 * original #AccessibleText.
371 * @endOffset: a pointer to a long integer which is assigned the
372 * ending offset of the returned string, relative to the original
375 * Get delimited text from an #AccessibleText object which follows a given
378 * Returns: a UTF-8 string representing the delimited text, both of whose
379 * delimiting boundaries are after or inclusive of the current
380 * offset, or an empty string if no such text exists.
383 AccessibleText_getTextAfterOffset (AccessibleText *obj,
385 AccessibleTextBoundaryType type,
386 long int *startOffset, long int *endOffset)
389 CORBA_long retStartOffset, retEndOffset;
393 *startOffset = *endOffset = -1;
397 retval = Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj),
399 get_accessible_text_boundary_type (type),
400 &retStartOffset, &retEndOffset,
403 if (!cspi_check_ev ("getTextAfterOffset"))
405 *startOffset = *endOffset = -1;
410 *startOffset = retStartOffset;
411 *endOffset = retEndOffset;
417 * AccessibleText_getCharacterAtOffset:
418 * @obj: a pointer to the #AccessibleText object on which to operate.
419 * @offset: a long integer indicating the text offset where the desired
420 * character is located.
422 * Get the character at a given offset for an #AccessibleText object.
424 * Returns: an #unsigned long integer which represents the
425 * UCS-4 unicode code point of the given character, or
426 * 0xFFFFFFFF if the character in question cannot be represented
427 * in the UCS-4 encoding.
430 AccessibleText_getCharacterAtOffset (AccessibleText *obj,
435 cspi_return_val_if_fail (obj != NULL, -1);
438 Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj),
442 cspi_return_val_if_ev ("getCharacterAtOffset", -1);
448 * AccessibleText_getCharacterExtents:
449 * @obj: a pointer to the #AccessibleText object on which to operate.
450 * @offset: an integer indicating the offset of the text character for
451 * whom boundary information is requested.
452 * @x: a pointer to a long integer into which the nominal x coordinate
453 * of the corresponding glyph will be returned.
454 * @y:a pointer to a long integer into which the nominal y coordinate
455 * of the corresponding glyph will be returned.
456 * @width:a pointer to a long integer into which the width
457 * of the corresponding glyph will be returned.
458 * @height: a pointer to a long integer into which the height
459 * of the corresponding glyph will be returned.
460 * @type: an #AccessibleCoordType indicating the coordinate system to use
461 * for the returned values.
463 * Get the bounding box containing the glyph representing
464 * the character at a particular text offset.
467 AccessibleText_getCharacterExtents (AccessibleText *obj,
473 AccessibleCoordType type)
475 CORBA_long retX, retY, retWidth, retHeight;
480 *width = *height = -1;
484 Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj),
492 if (!cspi_check_ev ("getCharacterExtents"))
495 *width = *height = -1;
507 * AccessibleText_getOffsetAtPoint:
508 * @obj: a pointer to the #AccessibleText object on which to operate.
509 * @x: the x coordinate of the point to be queried.
510 * @y: the y coordinate of the point to be queried.
511 * @type: an #AccessibleCoordType indicating the coordinate system in which
512 * the values should be returned.
514 * Get the bounding box for a glyph at a certain #AccessibleText offset.
516 * Returns: the offset (as a long integer) at the point (@x, @y)
517 * in the specified coordinate system.
521 AccessibleText_getOffsetAtPoint (AccessibleText *obj,
524 AccessibleCoordType type)
528 cspi_return_val_if_fail (obj != NULL, -1);
531 Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj),
536 cspi_return_val_if_ev ("getOffsetAtPoint", -1);
542 * AccessibleText_getNSelections:
543 * @obj: a pointer to the #AccessibleText object on which to operate.
545 * Get the number of active non-contiguous selections for an
546 * #AccessibleText object.
548 * Returns: a long integer indicating the current
549 * number of non-contiguous text selections active
550 * within an #AccessibleText object.
553 AccessibleText_getNSelections (AccessibleText *obj)
557 cspi_return_val_if_fail (obj != NULL, -1);
560 Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ());
562 cspi_return_val_if_ev ("getNSelections", -1);
568 * AccessibleText_getSelection:
569 * @obj: a pointer to the #AccessibleText object on which to operate.
570 * @selectionNum: an integer indicating which selection to query.
571 * @startOffset: a pointer to a long integer into which the start offset
572 * of the selection will be returned.
573 * @endOffset: a pointer to a long integer into which the start offset
574 * of the selection will be returned.
576 * Get the bounds of the @selectionNum-th active text selection for an
577 * #AccessibleText object.
580 AccessibleText_getSelection (AccessibleText *obj,
581 long int selectionNum,
582 long int *startOffset,
585 CORBA_long retStartOffset, retEndOffset;
589 *endOffset = *startOffset = -1;
593 Accessibility_Text_getSelection (CSPI_OBJREF (obj),
595 &retStartOffset, &retEndOffset,
598 if (!cspi_check_ev ("getSelection"))
600 *startOffset = *endOffset = -1;
604 *startOffset = retStartOffset;
605 *endOffset = retEndOffset;
610 * AccessibleText_addSelection:
611 * @obj: a pointer to the #AccessibleText object on which to operate.
612 * @startOffset: the starting offset of the desired new selection.
613 * @endOffset: the offset of the first character after the new selection.
615 * Select some text (add a text selection) in an #AccessibleText object.
617 * Returns: #TRUE if successful, #FALSE otherwise.
620 AccessibleText_addSelection (AccessibleText *obj,
621 long int startOffset, long int endOffset)
625 cspi_return_val_if_fail (obj != NULL, FALSE);
628 Accessibility_Text_addSelection (
629 CSPI_OBJREF (obj), startOffset,
630 endOffset, cspi_ev ());
632 cspi_return_val_if_ev ("addSelection", FALSE);
638 * AccessibleText_removeSelection:
639 * @obj: a pointer to the #AccessibleText object on which to operate.
640 * @selectionNum: an integer indicating which (possibly of several)
641 * text selection to remove.
643 * De-select a text selection.
645 * Returns: #TRUE if successful, #FALSE otherwise.
648 AccessibleText_removeSelection (AccessibleText *obj,
649 long int selectionNum)
653 cspi_return_val_if_fail (obj != NULL, FALSE);
656 Accessibility_Text_removeSelection (
657 CSPI_OBJREF (obj), selectionNum, cspi_ev ());
659 cspi_return_val_if_ev ("removeSelection", FALSE);
665 * AccessibleText_setSelection:
666 * @obj: a pointer to the #AccessibleText object on which to operate.
667 * @selectionNum: a zero-offset index indicating which text selection to modify.
668 * @startOffset: a long int, the new starting offset for the selection.
669 * @endOffset: a long int, the desired new offset of the first character
670 * after the selection.
672 * Change the bounds of an existing #AccessibleText text selection.
674 * Returns: #TRUE if successful, #FALSE otherwise.
677 AccessibleText_setSelection (AccessibleText *obj,
678 long int selectionNum,
679 long int startOffset,
684 cspi_return_val_if_fail (obj != NULL, FALSE);
686 retval = Accessibility_Text_setSelection (CSPI_OBJREF (obj),
689 endOffset, cspi_ev ());
691 cspi_return_val_if_ev ("setSelection", FALSE);