2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #include <cspi/spi-private.h>
25 static Accessibility_TEXT_BOUNDARY_TYPE
26 get_accessible_text_boundary_type (AccessibleTextBoundaryType type)
30 case SPI_TEXT_BOUNDARY_CHAR:
31 return Accessibility_TEXT_BOUNDARY_CHAR;
33 case SPI_TEXT_BOUNDARY_CURSOR_POS:
35 return Accessibility_TEXT_BOUNDARY_CHAR;
37 case SPI_TEXT_BOUNDARY_WORD_START:
38 return Accessibility_TEXT_BOUNDARY_WORD_START;
40 case SPI_TEXT_BOUNDARY_WORD_END:
41 return Accessibility_TEXT_BOUNDARY_WORD_END;
43 case SPI_TEXT_BOUNDARY_SENTENCE_START:
44 return Accessibility_TEXT_BOUNDARY_SENTENCE_START;
46 case SPI_TEXT_BOUNDARY_SENTENCE_END:
47 return Accessibility_TEXT_BOUNDARY_SENTENCE_END;
49 case SPI_TEXT_BOUNDARY_LINE_START:
50 return Accessibility_TEXT_BOUNDARY_LINE_START;
52 case SPI_TEXT_BOUNDARY_LINE_END:
53 return Accessibility_TEXT_BOUNDARY_LINE_END;
55 case SPI_TEXT_BOUNDARY_ATTRIBUTE_RANGE:
57 return Accessibility_TEXT_BOUNDARY_CHAR;
65 * @obj: a pointer to the #AccessibleText object on which to operate.
67 * Increment the reference count for an #AccessibleText object.
70 AccessibleText_ref (AccessibleText *obj)
72 cspi_object_ref (obj);
76 * AccessibleText_unref:
77 * @obj: a pointer to the #Accessible object on which to operate.
79 * Decrement the reference count for an #AccessibleText object.
82 AccessibleText_unref (AccessibleText *obj)
84 cspi_object_unref (obj);
88 * AccessibleText_getCharacterCount:
89 * @obj: a pointer to the #AccessibleText object to query.
91 * Get the character count of an #AccessibleText object.
93 * Returns: a long integer indicating the total number of
94 * characters in the #AccessibleText object.
97 AccessibleText_getCharacterCount (AccessibleText *obj)
101 cspi_return_val_if_fail (obj != NULL, -1);
103 retval = Accessibility_Text__get_characterCount (CSPI_OBJREF (obj), cspi_ev ());
105 cspi_return_val_if_ev ("getCharacterCount", -1);
111 * AccessibleText_getText:
112 * @obj: a pointer to the #AccessibleText object to query.
113 * @startOffset: a #long indicating the start of the desired text range.
114 * @endOffset: a #long indicating the first character past the desired range.
116 * Get a range of text from an #AccessibleText object. The number of bytes
117 * in the returned string may exceed endOffset-startOffset, since
118 * UTF-8 is a variable-width encoding.
120 * Returns: a text string containing characters from @startOffset
121 * to @endOffset-1, inclusive, encoded as UTF-8.
124 AccessibleText_getText (AccessibleText *obj,
125 long int startOffset,
130 cspi_return_val_if_fail (obj != NULL, NULL);
133 Accessibility_Text_getText (CSPI_OBJREF (obj),
138 cspi_return_val_if_ev ("getText", NULL);
144 * AccessibleText_getCaretOffset:
145 * @obj: a pointer to the #AccessibleText object to query.
147 * Get the current offset of the text caret in an #AccessibleText object.
149 * Returns: a long integer indicating the current position of the text caret.
152 AccessibleText_getCaretOffset (AccessibleText *obj)
156 cspi_return_val_if_fail (obj != NULL, -1);
159 Accessibility_Text__get_caretOffset (CSPI_OBJREF (obj), cspi_ev ());
161 cspi_return_val_if_ev ("getCaretOffset", -1);
167 * AccessibleText_getAttributes:
168 * @obj: a pointer to the #AccessibleText object to query.
169 * @offset: a long integer indicating the offset from which the attribute
171 * @startOffset: a #long indicating the start of the desired text range.
172 * @endOffset: a #long indicating the first character past the desired range.
174 * Get the attributes applied to a range of text from an #AccessibleText
175 * object, and the bounds of the range.
177 * Returns: a text string describing the attributes occurring within the
178 * attribute run containing @offset, encoded as UTF-8 and
182 AccessibleText_getAttributes (AccessibleText *obj,
184 long int *startOffset,
187 CORBA_long retStartOffset, retEndOffset;
192 *startOffset = *endOffset = -1;
196 retval = Accessibility_Text_getAttributes (CSPI_OBJREF (obj),
202 if (!cspi_check_ev ("getAttributes"))
204 *startOffset = *endOffset = -1;
209 *startOffset = retStartOffset;
210 *endOffset = retEndOffset;
217 * AccessibleText_setCaretOffset:
218 * @obj: a pointer to the #AccessibleText object on which to operate.
219 * @newOffset: the offset to which the text caret is to be moved.
221 * Set the text caret position for an #AccessibleText object.
223 * Returns: #TRUE if successful, #FALSE otherwise.
226 AccessibleText_setCaretOffset (AccessibleText *obj,
231 cspi_return_val_if_fail (obj != NULL, FALSE);
234 Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj),
235 newOffset, cspi_ev ());
237 cspi_return_val_if_ev ("setCaretOffset", FALSE);
243 * AccessibleText_getTextBeforeOffset:
244 * @obj: a pointer to the #AccessibleText object on which to operate.
245 * @offset: a long integer indicating the offset from which the delimiter
247 * @type: an #AccessibleTextBoundaryType indicating whether the desired
248 * text string is a word, sentence, line, or attribute run.
249 * @startOffset: a pointer to a long integer which is assigned the
250 * starting offset of the returned string, relative to the
251 * original #AccessibleText.
252 * @endOffset: a pointer to a long integer which is assigned the
253 * ending offset of the returned string, relative to the original
256 * Get delimited text from an #AccessibleText object which precedes a given
259 * Returns: a UTF-8 string representing the delimited text, both of whose
260 * delimiting boundaries are before the current offset, or
261 * an empty string if no such text exists.
264 AccessibleText_getTextBeforeOffset (AccessibleText *obj,
266 AccessibleTextBoundaryType type,
267 long int *startOffset,
271 CORBA_long retStartOffset, retEndOffset;
275 *startOffset = *endOffset = -1;
279 retval = Accessibility_Text_getTextBeforeOffset (CSPI_OBJREF (obj),
281 get_accessible_text_boundary_type (type),
282 &retStartOffset, &retEndOffset,
284 if (!cspi_check_ev ("getTextBeforeOffset"))
286 *startOffset = *endOffset = -1;
291 *startOffset = retStartOffset;
292 *endOffset = retEndOffset;
298 * AccessibleText_getTextAtOffset:
299 * @obj: a pointer to the #AccessibleText object on which to operate.
300 * @offset: a long integer indicating the offset from which the delimiter
302 * @type: an #AccessibleTextBoundaryType indicating whether the desired
303 * text string is a word, sentence, line, or attribute run.
304 * @startOffset: a pointer to a long integer which is assigned the
305 * starting offset of the returned string, relative to the
306 * original #AccessibleText.
307 * @endOffset: a pointer to a long integer which is assigned the
308 * ending offset of the returned string, relative to the original
311 * Get delimited text from an #AccessibleText object which includes a given
314 * Returns: a UTF-8 string representing the delimited text, whose
315 * delimiting boundaries bracket the current offset, or
316 * an empty string if no such text exists.
319 AccessibleText_getTextAtOffset (AccessibleText *obj,
321 AccessibleTextBoundaryType type,
322 long int *startOffset, long int *endOffset)
324 CORBA_long corbaStartOffset;
325 CORBA_long corbaEndOffset;
330 *startOffset = *endOffset = -1;
334 retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj),
336 get_accessible_text_boundary_type (type),
341 if (!cspi_check_ev ("getTextAtOffset"))
343 *startOffset = *endOffset = -1;
348 *startOffset = corbaStartOffset;
349 *endOffset = corbaEndOffset;
355 * AccessibleText_getTextAfterOffset:
356 * @obj: a pointer to the #AccessibleText object on which to operate.
357 * @offset: a long integer indicating the offset from which the delimiter
359 * @type: an #AccessibleTextBoundaryType indicating whether the desired
360 * text string is a word, sentence, line, or attribute run.
361 * @startOffset: a pointer to a long integer which is assigned the
362 * starting offset of the returned string, relative to the
363 * original #AccessibleText.
364 * @endOffset: a pointer to a long integer which is assigned the
365 * ending offset of the returned string, relative to the original
368 * Get delimited text from an #AccessibleText object which follows a given
371 * Returns: a UTF-8 string representing the delimited text, both of whose
372 * delimiting boundaries are after or inclusive of the current
373 * offset, or an empty string if no such text exists.
376 AccessibleText_getTextAfterOffset (AccessibleText *obj,
378 AccessibleTextBoundaryType type,
379 long int *startOffset, long int *endOffset)
382 CORBA_long retStartOffset, retEndOffset;
386 *startOffset = *endOffset = -1;
390 retval = Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj),
392 get_accessible_text_boundary_type (type),
393 &retStartOffset, &retEndOffset,
396 if (!cspi_check_ev ("getTextAfterOffset"))
398 *startOffset = *endOffset = -1;
403 *startOffset = retStartOffset;
404 *endOffset = retEndOffset;
410 * AccessibleText_getCharacterAtOffset:
411 * @obj: a pointer to the #AccessibleText object on which to operate.
412 * @offset: a long integer indicating the text offset where the desired
413 * character is located.
415 * Get the character at a given offset for an #AccessibleText object.
417 * Returns: an #unsigned long integer which represents the
418 * UCS-4 unicode code point of the given character, or
419 * 0xFFFFFFFF if the character in question cannot be represented
420 * in the UCS-4 encoding.
423 AccessibleText_getCharacterAtOffset (AccessibleText *obj,
428 cspi_return_val_if_fail (obj != NULL, -1);
431 Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj),
435 cspi_return_val_if_ev ("getCharacterAtOffset", -1);
441 * AccessibleText_getCharacterExtents:
442 * @obj: a pointer to the #AccessibleText object on which to operate.
443 * @offset: an integer indicating the offset of the text character for
444 * whom boundary information is requested.
445 * @x: a pointer to a long integer into which the nominal x coordinate
446 * of the corresponding glyph will be returned.
447 * @y:a pointer to a long integer into which the nominal y coordinate
448 * of the corresponding glyph will be returned.
449 * @width:a pointer to a long integer into which the width
450 * of the corresponding glyph will be returned.
451 * @height: a pointer to a long integer into which the height
452 * of the corresponding glyph will be returned.
453 * @type: an #AccessibleCoordType indicating the coordinate system to use
454 * for the returned values.
456 * Get the bounding box containing the glyph representing
457 * the character at a particular text offset.
460 AccessibleText_getCharacterExtents (AccessibleText *obj,
466 AccessibleCoordType type)
468 CORBA_long retX, retY, retWidth, retHeight;
473 *width = *height = -1;
477 Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj),
485 if (!cspi_check_ev ("getCharacterExtents"))
488 *width = *height = -1;
500 * AccessibleText_getOffsetAtPoint:
501 * @obj: a pointer to the #AccessibleText object on which to operate.
502 * @x: the x coordinate of the point to be queried.
503 * @y: the y coordinate of the point to be queried.
504 * @type: an #AccessibleCoordType indicating the coordinate system in which
505 * the values should be returned.
507 * Get the bounding box for a glyph at a certain #AccessibleText offset.
509 * Returns: the offset (as a long integer) at the point (@x, @y)
510 * in the specified coordinate system.
514 AccessibleText_getOffsetAtPoint (AccessibleText *obj,
517 AccessibleCoordType type)
521 cspi_return_val_if_fail (obj != NULL, -1);
524 Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj),
529 cspi_return_val_if_ev ("getOffsetAtPoint", -1);
535 * AccessibleText_getNSelections:
536 * @obj: a pointer to the #AccessibleText object on which to operate.
538 * Get the number of active non-contiguous selections for an
539 * #AccessibleText object.
541 * Returns: a long integer indicating the current
542 * number of non-contiguous text selections active
543 * within an #AccessibleText object.
546 AccessibleText_getNSelections (AccessibleText *obj)
550 cspi_return_val_if_fail (obj != NULL, -1);
553 Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ());
555 cspi_return_val_if_ev ("getNSelections", -1);
561 * AccessibleText_getSelection:
562 * @obj: a pointer to the #AccessibleText object on which to operate.
563 * @selectionNum: an integer indicating which selection to query.
564 * @startOffset: a pointer to a long integer into which the start offset
565 * of the selection will be returned.
566 * @endOffset: a pointer to a long integer into which the start offset
567 * of the selection will be returned.
569 * Get the bounds of the @selectionNum-th active text selection for an
570 * #AccessibleText object.
573 AccessibleText_getSelection (AccessibleText *obj,
574 long int selectionNum,
575 long int *startOffset,
578 CORBA_long retStartOffset, retEndOffset;
582 *endOffset = *startOffset = -1;
586 Accessibility_Text_getSelection (CSPI_OBJREF (obj),
588 &retStartOffset, &retEndOffset,
591 if (!cspi_check_ev ("getSelection"))
593 *startOffset = *endOffset = -1;
597 *startOffset = retStartOffset;
598 *endOffset = retEndOffset;
603 * AccessibleText_addSelection:
604 * @obj: a pointer to the #AccessibleText object on which to operate.
605 * @startOffset: the starting offset of the desired new selection.
606 * @endOffset: the offset of the first character after the new selection.
608 * Select some text (add a text selection) in an #AccessibleText object.
610 * Returns: #TRUE if successful, #FALSE otherwise.
613 AccessibleText_addSelection (AccessibleText *obj,
614 long int startOffset, long int endOffset)
618 cspi_return_val_if_fail (obj != NULL, FALSE);
621 Accessibility_Text_addSelection (
622 CSPI_OBJREF (obj), startOffset,
623 endOffset, cspi_ev ());
625 cspi_return_val_if_ev ("addSelection", FALSE);
631 * AccessibleText_removeSelection:
632 * @obj: a pointer to the #AccessibleText object on which to operate.
633 * @selectionNum: an integer indicating which (possibly of several)
634 * text selection to remove.
636 * De-select a text selection.
638 * Returns: #TRUE if successful, #FALSE otherwise.
641 AccessibleText_removeSelection (AccessibleText *obj,
642 long int selectionNum)
646 cspi_return_val_if_fail (obj != NULL, FALSE);
649 Accessibility_Text_removeSelection (
650 CSPI_OBJREF (obj), selectionNum, cspi_ev ());
652 cspi_return_val_if_ev ("removeSelection", FALSE);
658 * AccessibleText_setSelection:
659 * @obj: a pointer to the #AccessibleText object on which to operate.
660 * @selectionNum: a zero-offset index indicating which text selection to modify.
661 * @startOffset: a long int, the new starting offset for the selection.
662 * @endOffset: a long int, the desired new offset of the first character
663 * after the selection.
665 * Change the bounds of an existing #AccessibleText text selection.
667 * Returns: #TRUE if successful, #FALSE otherwise.
670 AccessibleText_setSelection (AccessibleText *obj,
671 long int selectionNum,
672 long int startOffset,
677 cspi_return_val_if_fail (obj != NULL, FALSE);
679 retval = Accessibility_Text_setSelection (CSPI_OBJREF (obj),
682 endOffset, cspi_ev ());
684 cspi_return_val_if_ev ("setSelection", FALSE);