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;
66 * @obj: a pointer to the #AccessibleText object on which to operate.
68 * Increment the reference count for an #AccessibleText object.
71 AccessibleText_ref (AccessibleText *obj)
73 cspi_object_ref (obj);
77 * AccessibleText_unref:
78 * @obj: a pointer to the #Accessible object on which to operate.
80 * Decrement the reference count for an #AccessibleText object.
83 AccessibleText_unref (AccessibleText *obj)
85 cspi_object_unref (obj);
89 * AccessibleText_getCharacterCount:
90 * @obj: a pointer to the #AccessibleText object to query.
92 * Get the character count of an #AccessibleText object.
94 * Returns: a long integer indicating the total number of
95 * characters in the #AccessibleText object.
98 AccessibleText_getCharacterCount (AccessibleText *obj)
102 cspi_return_val_if_fail (obj != NULL, -1);
104 retval = Accessibility_Text__get_characterCount (CSPI_OBJREF (obj), cspi_ev ());
106 cspi_return_val_if_ev ("getCharacterCount", -1);
112 * AccessibleText_getText:
113 * @obj: a pointer to the #AccessibleText object to query.
114 * @startOffset: a #long indicating the start of the desired text range.
115 * @endOffset: a #long indicating the first character past the desired range.
117 * Get a range of text from an #AccessibleText object. The number of bytes
118 * in the returned string may exceed endOffset-startOffset, since
119 * UTF-8 is a variable-width encoding.
121 * Returns: a text string containing characters from @startOffset
122 * to @endOffset-1, inclusive, encoded as UTF-8.
125 AccessibleText_getText (AccessibleText *obj,
126 long int startOffset,
131 cspi_return_val_if_fail (obj != NULL, NULL);
134 Accessibility_Text_getText (CSPI_OBJREF (obj),
139 cspi_return_val_if_ev ("getText", NULL);
145 * AccessibleText_getCaretOffset:
146 * @obj: a pointer to the #AccessibleText object to query.
148 * Get the current offset of the text caret in an #AccessibleText object.
150 * Returns: a long integer indicating the current position of the text caret.
153 AccessibleText_getCaretOffset (AccessibleText *obj)
157 cspi_return_val_if_fail (obj != NULL, -1);
160 Accessibility_Text__get_caretOffset (CSPI_OBJREF (obj), cspi_ev ());
162 cspi_return_val_if_ev ("getCaretOffset", -1);
168 * AccessibleText_getAttributes:
169 * @obj: a pointer to the #AccessibleText object to query.
170 * @offset: a long integer indicating the offset from which the attribute
172 * @startOffset: a #long indicating the start of the desired text range.
173 * @endOffset: a #long indicating the first character past the desired range.
175 * Get the attributes applied to a range of text from an #AccessibleText
176 * object, and the bounds of the range.
177 * The text attributes correspond to CSS attributes where possible,
178 * keys and values are delimited from one another via ":", and
179 * the delimiter between key/value pairs is ";". Thus
180 * "font-size:10;foreground-color:0,0,0" would be a valid
183 * Returns: a text string describing the attributes occurring within the
184 * attribute run containing @offset, encoded as UTF-8.
187 AccessibleText_getAttributes (AccessibleText *obj,
189 long int *startOffset,
192 CORBA_long retStartOffset, retEndOffset;
197 *startOffset = *endOffset = -1;
201 retval = Accessibility_Text_getAttributes (CSPI_OBJREF (obj),
207 if (!cspi_check_ev ("getAttributes"))
209 *startOffset = *endOffset = -1;
214 *startOffset = retStartOffset;
215 *endOffset = retEndOffset;
222 * AccessibleText_setCaretOffset:
223 * @obj: a pointer to the #AccessibleText object on which to operate.
224 * @newOffset: the offset to which the text caret is to be moved.
226 * Set the text caret position for an #AccessibleText object.
228 * Returns: #TRUE if successful, #FALSE otherwise.
231 AccessibleText_setCaretOffset (AccessibleText *obj,
236 cspi_return_val_if_fail (obj != NULL, FALSE);
239 Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj),
240 newOffset, cspi_ev ());
242 cspi_return_val_if_ev ("setCaretOffset", FALSE);
248 * AccessibleText_getTextBeforeOffset:
249 * @obj: a pointer to the #AccessibleText object on which to operate.
250 * @offset: a long integer indicating the offset from which the delimiter
252 * @type: an #AccessibleTextBoundaryType indicating whether the desired
253 * text string is a word, sentence, line, or attribute run.
254 * @startOffset: a pointer to a long integer which is assigned the
255 * starting offset of the returned string, relative to the
256 * original #AccessibleText.
257 * @endOffset: a pointer to a long integer which is assigned the
258 * ending offset of the returned string, relative to the original
261 * Get delimited text from an #AccessibleText object which precedes a given
264 * Returns: a UTF-8 string representing the delimited text, both of whose
265 * delimiting boundaries are before the current offset, or
266 * an empty string if no such text exists.
269 AccessibleText_getTextBeforeOffset (AccessibleText *obj,
271 AccessibleTextBoundaryType type,
272 long int *startOffset,
276 CORBA_long retStartOffset, retEndOffset;
280 *startOffset = *endOffset = -1;
284 retval = Accessibility_Text_getTextBeforeOffset (CSPI_OBJREF (obj),
286 get_accessible_text_boundary_type (type),
287 &retStartOffset, &retEndOffset,
289 if (!cspi_check_ev ("getTextBeforeOffset"))
291 *startOffset = *endOffset = -1;
296 *startOffset = retStartOffset;
297 *endOffset = retEndOffset;
303 * AccessibleText_getTextAtOffset:
304 * @obj: a pointer to the #AccessibleText object on which to operate.
305 * @offset: a long integer indicating the offset from which the delimiter
307 * @type: an #AccessibleTextBoundaryType indicating whether the desired
308 * text string is a word, sentence, line, or attribute run.
309 * @startOffset: a pointer to a long integer which is assigned the
310 * starting offset of the returned string, relative to the
311 * original #AccessibleText.
312 * @endOffset: a pointer to a long integer which is assigned the
313 * ending offset of the returned string, relative to the original
316 * Get delimited text from an #AccessibleText object which includes a given
319 * Returns: a UTF-8 string representing the delimited text, whose
320 * delimiting boundaries bracket the current offset, or
321 * an empty string if no such text exists.
324 AccessibleText_getTextAtOffset (AccessibleText *obj,
326 AccessibleTextBoundaryType type,
327 long int *startOffset, long int *endOffset)
329 CORBA_long corbaStartOffset;
330 CORBA_long corbaEndOffset;
335 *startOffset = *endOffset = -1;
339 retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj),
341 get_accessible_text_boundary_type (type),
346 if (!cspi_check_ev ("getTextAtOffset"))
348 *startOffset = *endOffset = -1;
353 *startOffset = corbaStartOffset;
354 *endOffset = corbaEndOffset;
360 * AccessibleText_getTextAfterOffset:
361 * @obj: a pointer to the #AccessibleText object on which to operate.
362 * @offset: a long integer indicating the offset from which the delimiter
364 * @type: an #AccessibleTextBoundaryType indicating whether the desired
365 * text string is a word, sentence, line, or attribute run.
366 * @startOffset: a pointer to a long integer which is assigned the
367 * starting offset of the returned string, relative to the
368 * original #AccessibleText.
369 * @endOffset: a pointer to a long integer which is assigned the
370 * ending offset of the returned string, relative to the original
373 * Get delimited text from an #AccessibleText object which follows a given
376 * Returns: a UTF-8 string representing the delimited text, both of whose
377 * delimiting boundaries are after or inclusive of the current
378 * offset, or an empty string if no such text exists.
381 AccessibleText_getTextAfterOffset (AccessibleText *obj,
383 AccessibleTextBoundaryType type,
384 long int *startOffset, long int *endOffset)
387 CORBA_long retStartOffset, retEndOffset;
391 *startOffset = *endOffset = -1;
395 retval = Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj),
397 get_accessible_text_boundary_type (type),
398 &retStartOffset, &retEndOffset,
401 if (!cspi_check_ev ("getTextAfterOffset"))
403 *startOffset = *endOffset = -1;
408 *startOffset = retStartOffset;
409 *endOffset = retEndOffset;
415 * AccessibleText_getCharacterAtOffset:
416 * @obj: a pointer to the #AccessibleText object on which to operate.
417 * @offset: a long integer indicating the text offset where the desired
418 * character is located.
420 * Get the character at a given offset for an #AccessibleText object.
422 * Returns: an #unsigned long integer which represents the
423 * UCS-4 unicode code point of the given character, or
424 * 0xFFFFFFFF if the character in question cannot be represented
425 * in the UCS-4 encoding.
428 AccessibleText_getCharacterAtOffset (AccessibleText *obj,
433 cspi_return_val_if_fail (obj != NULL, -1);
436 Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj),
440 cspi_return_val_if_ev ("getCharacterAtOffset", -1);
446 * AccessibleText_getCharacterExtents:
447 * @obj: a pointer to the #AccessibleText object on which to operate.
448 * @offset: an integer indicating the offset of the text character for
449 * whom boundary information is requested.
450 * @x: a pointer to a long integer into which the nominal x coordinate
451 * of the corresponding glyph will be returned.
452 * @y:a pointer to a long integer into which the nominal y coordinate
453 * of the corresponding glyph will be returned.
454 * @width:a pointer to a long integer into which the width
455 * of the corresponding glyph will be returned.
456 * @height: a pointer to a long integer into which the height
457 * of the corresponding glyph will be returned.
458 * @type: an #AccessibleCoordType indicating the coordinate system to use
459 * for the returned values.
461 * Get the bounding box containing the glyph representing
462 * the character at a particular text offset.
465 AccessibleText_getCharacterExtents (AccessibleText *obj,
471 AccessibleCoordType type)
473 CORBA_long retX, retY, retWidth, retHeight;
478 *width = *height = -1;
482 Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj),
490 if (!cspi_check_ev ("getCharacterExtents"))
493 *width = *height = -1;
505 * AccessibleText_getOffsetAtPoint:
506 * @obj: a pointer to the #AccessibleText object on which to operate.
507 * @x: the x coordinate of the point to be queried.
508 * @y: the y coordinate of the point to be queried.
509 * @type: an #AccessibleCoordType indicating the coordinate system in which
510 * the values should be returned.
512 * Get the bounding box for a glyph at a certain #AccessibleText offset.
514 * Returns: the offset (as a long integer) at the point (@x, @y)
515 * in the specified coordinate system.
519 AccessibleText_getOffsetAtPoint (AccessibleText *obj,
522 AccessibleCoordType type)
526 cspi_return_val_if_fail (obj != NULL, -1);
529 Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj),
534 cspi_return_val_if_ev ("getOffsetAtPoint", -1);
540 * AccessibleText_getNSelections:
541 * @obj: a pointer to the #AccessibleText object on which to operate.
543 * Get the number of active non-contiguous selections for an
544 * #AccessibleText object.
546 * Returns: a long integer indicating the current
547 * number of non-contiguous text selections active
548 * within an #AccessibleText object.
551 AccessibleText_getNSelections (AccessibleText *obj)
555 cspi_return_val_if_fail (obj != NULL, -1);
558 Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ());
560 cspi_return_val_if_ev ("getNSelections", -1);
566 * AccessibleText_getSelection:
567 * @obj: a pointer to the #AccessibleText object on which to operate.
568 * @selectionNum: an integer indicating which selection to query.
569 * @startOffset: a pointer to a long integer into which the start offset
570 * of the selection will be returned.
571 * @endOffset: a pointer to a long integer into which the start offset
572 * of the selection will be returned.
574 * Get the bounds of the @selectionNum-th active text selection for an
575 * #AccessibleText object.
578 AccessibleText_getSelection (AccessibleText *obj,
579 long int selectionNum,
580 long int *startOffset,
583 CORBA_long retStartOffset, retEndOffset;
587 *endOffset = *startOffset = -1;
591 Accessibility_Text_getSelection (CSPI_OBJREF (obj),
593 &retStartOffset, &retEndOffset,
596 if (!cspi_check_ev ("getSelection"))
598 *startOffset = *endOffset = -1;
602 *startOffset = retStartOffset;
603 *endOffset = retEndOffset;
608 * AccessibleText_addSelection:
609 * @obj: a pointer to the #AccessibleText object on which to operate.
610 * @startOffset: the starting offset of the desired new selection.
611 * @endOffset: the offset of the first character after the new selection.
613 * Select some text (add a text selection) in an #AccessibleText object.
615 * Returns: #TRUE if successful, #FALSE otherwise.
618 AccessibleText_addSelection (AccessibleText *obj,
619 long int startOffset, long int endOffset)
623 cspi_return_val_if_fail (obj != NULL, FALSE);
626 Accessibility_Text_addSelection (
627 CSPI_OBJREF (obj), startOffset,
628 endOffset, cspi_ev ());
630 cspi_return_val_if_ev ("addSelection", FALSE);
636 * AccessibleText_removeSelection:
637 * @obj: a pointer to the #AccessibleText object on which to operate.
638 * @selectionNum: an integer indicating which (possibly of several)
639 * text selection to remove.
641 * De-select a text selection.
643 * Returns: #TRUE if successful, #FALSE otherwise.
646 AccessibleText_removeSelection (AccessibleText *obj,
647 long int selectionNum)
651 cspi_return_val_if_fail (obj != NULL, FALSE);
654 Accessibility_Text_removeSelection (
655 CSPI_OBJREF (obj), selectionNum, cspi_ev ());
657 cspi_return_val_if_ev ("removeSelection", FALSE);
663 * AccessibleText_setSelection:
664 * @obj: a pointer to the #AccessibleText object on which to operate.
665 * @selectionNum: a zero-offset index indicating which text selection to modify.
666 * @startOffset: a long int, the new starting offset for the selection.
667 * @endOffset: a long int, the desired new offset of the first character
668 * after the selection.
670 * Change the bounds of an existing #AccessibleText text selection.
672 * Returns: #TRUE if successful, #FALSE otherwise.
675 AccessibleText_setSelection (AccessibleText *obj,
676 long int selectionNum,
677 long int startOffset,
682 cspi_return_val_if_fail (obj != NULL, FALSE);
684 retval = Accessibility_Text_setSelection (CSPI_OBJREF (obj),
687 endOffset, cspi_ev ());
689 cspi_return_val_if_ev ("setSelection", FALSE);