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.
178 * Returns: a text string describing the attributes occurring within the
179 * attribute run containing @offset, encoded as UTF-8 and
183 AccessibleText_getAttributes (AccessibleText *obj,
185 long int *startOffset,
188 CORBA_long retStartOffset, retEndOffset;
193 *startOffset = *endOffset = -1;
197 retval = Accessibility_Text_getAttributes (CSPI_OBJREF (obj),
203 if (!cspi_check_ev ("getAttributes"))
205 *startOffset = *endOffset = -1;
210 *startOffset = retStartOffset;
211 *endOffset = retEndOffset;
218 * AccessibleText_setCaretOffset:
219 * @obj: a pointer to the #AccessibleText object on which to operate.
220 * @newOffset: the offset to which the text caret is to be moved.
222 * Set the text caret position for an #AccessibleText object.
224 * Returns: #TRUE if successful, #FALSE otherwise.
227 AccessibleText_setCaretOffset (AccessibleText *obj,
232 cspi_return_val_if_fail (obj != NULL, FALSE);
235 Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj),
236 newOffset, cspi_ev ());
238 cspi_return_val_if_ev ("setCaretOffset", FALSE);
244 * AccessibleText_getTextBeforeOffset:
245 * @obj: a pointer to the #AccessibleText object on which to operate.
246 * @offset: a long integer indicating the offset from which the delimiter
248 * @type: an #AccessibleTextBoundaryType indicating whether the desired
249 * text string is a word, sentence, line, or attribute run.
250 * @startOffset: a pointer to a long integer which is assigned the
251 * starting offset of the returned string, relative to the
252 * original #AccessibleText.
253 * @endOffset: a pointer to a long integer which is assigned the
254 * ending offset of the returned string, relative to the original
257 * Get delimited text from an #AccessibleText object which precedes a given
260 * Returns: a UTF-8 string representing the delimited text, both of whose
261 * delimiting boundaries are before the current offset, or
262 * an empty string if no such text exists.
265 AccessibleText_getTextBeforeOffset (AccessibleText *obj,
267 AccessibleTextBoundaryType type,
268 long int *startOffset,
272 CORBA_long retStartOffset, retEndOffset;
276 *startOffset = *endOffset = -1;
280 retval = Accessibility_Text_getTextBeforeOffset (CSPI_OBJREF (obj),
282 get_accessible_text_boundary_type (type),
283 &retStartOffset, &retEndOffset,
285 if (!cspi_check_ev ("getTextBeforeOffset"))
287 *startOffset = *endOffset = -1;
292 *startOffset = retStartOffset;
293 *endOffset = retEndOffset;
299 * AccessibleText_getTextAtOffset:
300 * @obj: a pointer to the #AccessibleText object on which to operate.
301 * @offset: a long integer indicating the offset from which the delimiter
303 * @type: an #AccessibleTextBoundaryType indicating whether the desired
304 * text string is a word, sentence, line, or attribute run.
305 * @startOffset: a pointer to a long integer which is assigned the
306 * starting offset of the returned string, relative to the
307 * original #AccessibleText.
308 * @endOffset: a pointer to a long integer which is assigned the
309 * ending offset of the returned string, relative to the original
312 * Get delimited text from an #AccessibleText object which includes a given
315 * Returns: a UTF-8 string representing the delimited text, whose
316 * delimiting boundaries bracket the current offset, or
317 * an empty string if no such text exists.
320 AccessibleText_getTextAtOffset (AccessibleText *obj,
322 AccessibleTextBoundaryType type,
323 long int *startOffset, long int *endOffset)
325 CORBA_long corbaStartOffset;
326 CORBA_long corbaEndOffset;
331 *startOffset = *endOffset = -1;
335 retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj),
337 get_accessible_text_boundary_type (type),
342 if (!cspi_check_ev ("getTextAtOffset"))
344 *startOffset = *endOffset = -1;
349 *startOffset = corbaStartOffset;
350 *endOffset = corbaEndOffset;
356 * AccessibleText_getTextAfterOffset:
357 * @obj: a pointer to the #AccessibleText object on which to operate.
358 * @offset: a long integer indicating the offset from which the delimiter
360 * @type: an #AccessibleTextBoundaryType indicating whether the desired
361 * text string is a word, sentence, line, or attribute run.
362 * @startOffset: a pointer to a long integer which is assigned the
363 * starting offset of the returned string, relative to the
364 * original #AccessibleText.
365 * @endOffset: a pointer to a long integer which is assigned the
366 * ending offset of the returned string, relative to the original
369 * Get delimited text from an #AccessibleText object which follows a given
372 * Returns: a UTF-8 string representing the delimited text, both of whose
373 * delimiting boundaries are after or inclusive of the current
374 * offset, or an empty string if no such text exists.
377 AccessibleText_getTextAfterOffset (AccessibleText *obj,
379 AccessibleTextBoundaryType type,
380 long int *startOffset, long int *endOffset)
383 CORBA_long retStartOffset, retEndOffset;
387 *startOffset = *endOffset = -1;
391 retval = Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj),
393 get_accessible_text_boundary_type (type),
394 &retStartOffset, &retEndOffset,
397 if (!cspi_check_ev ("getTextAfterOffset"))
399 *startOffset = *endOffset = -1;
404 *startOffset = retStartOffset;
405 *endOffset = retEndOffset;
411 * AccessibleText_getCharacterAtOffset:
412 * @obj: a pointer to the #AccessibleText object on which to operate.
413 * @offset: a long integer indicating the text offset where the desired
414 * character is located.
416 * Get the character at a given offset for an #AccessibleText object.
418 * Returns: an #unsigned long integer which represents the
419 * UCS-4 unicode code point of the given character, or
420 * 0xFFFFFFFF if the character in question cannot be represented
421 * in the UCS-4 encoding.
424 AccessibleText_getCharacterAtOffset (AccessibleText *obj,
429 cspi_return_val_if_fail (obj != NULL, -1);
432 Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj),
436 cspi_return_val_if_ev ("getCharacterAtOffset", -1);
442 * AccessibleText_getCharacterExtents:
443 * @obj: a pointer to the #AccessibleText object on which to operate.
444 * @offset: an integer indicating the offset of the text character for
445 * whom boundary information is requested.
446 * @x: a pointer to a long integer into which the nominal x coordinate
447 * of the corresponding glyph will be returned.
448 * @y:a pointer to a long integer into which the nominal y coordinate
449 * of the corresponding glyph will be returned.
450 * @width:a pointer to a long integer into which the width
451 * of the corresponding glyph will be returned.
452 * @height: a pointer to a long integer into which the height
453 * of the corresponding glyph will be returned.
454 * @type: an #AccessibleCoordType indicating the coordinate system to use
455 * for the returned values.
457 * Get the bounding box containing the glyph representing
458 * the character at a particular text offset.
461 AccessibleText_getCharacterExtents (AccessibleText *obj,
467 AccessibleCoordType type)
469 CORBA_long retX, retY, retWidth, retHeight;
474 *width = *height = -1;
478 Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj),
486 if (!cspi_check_ev ("getCharacterExtents"))
489 *width = *height = -1;
501 * AccessibleText_getOffsetAtPoint:
502 * @obj: a pointer to the #AccessibleText object on which to operate.
503 * @x: the x coordinate of the point to be queried.
504 * @y: the y coordinate of the point to be queried.
505 * @type: an #AccessibleCoordType indicating the coordinate system in which
506 * the values should be returned.
508 * Get the bounding box for a glyph at a certain #AccessibleText offset.
510 * Returns: the offset (as a long integer) at the point (@x, @y)
511 * in the specified coordinate system.
515 AccessibleText_getOffsetAtPoint (AccessibleText *obj,
518 AccessibleCoordType type)
522 cspi_return_val_if_fail (obj != NULL, -1);
525 Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj),
530 cspi_return_val_if_ev ("getOffsetAtPoint", -1);
536 * AccessibleText_getNSelections:
537 * @obj: a pointer to the #AccessibleText object on which to operate.
539 * Get the number of active non-contiguous selections for an
540 * #AccessibleText object.
542 * Returns: a long integer indicating the current
543 * number of non-contiguous text selections active
544 * within an #AccessibleText object.
547 AccessibleText_getNSelections (AccessibleText *obj)
551 cspi_return_val_if_fail (obj != NULL, -1);
554 Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ());
556 cspi_return_val_if_ev ("getNSelections", -1);
562 * AccessibleText_getSelection:
563 * @obj: a pointer to the #AccessibleText object on which to operate.
564 * @selectionNum: an integer indicating which selection to query.
565 * @startOffset: a pointer to a long integer into which the start offset
566 * of the selection will be returned.
567 * @endOffset: a pointer to a long integer into which the start offset
568 * of the selection will be returned.
570 * Get the bounds of the @selectionNum-th active text selection for an
571 * #AccessibleText object.
574 AccessibleText_getSelection (AccessibleText *obj,
575 long int selectionNum,
576 long int *startOffset,
579 CORBA_long retStartOffset, retEndOffset;
583 *endOffset = *startOffset = -1;
587 Accessibility_Text_getSelection (CSPI_OBJREF (obj),
589 &retStartOffset, &retEndOffset,
592 if (!cspi_check_ev ("getSelection"))
594 *startOffset = *endOffset = -1;
598 *startOffset = retStartOffset;
599 *endOffset = retEndOffset;
604 * AccessibleText_addSelection:
605 * @obj: a pointer to the #AccessibleText object on which to operate.
606 * @startOffset: the starting offset of the desired new selection.
607 * @endOffset: the offset of the first character after the new selection.
609 * Select some text (add a text selection) in an #AccessibleText object.
611 * Returns: #TRUE if successful, #FALSE otherwise.
614 AccessibleText_addSelection (AccessibleText *obj,
615 long int startOffset, long int endOffset)
619 cspi_return_val_if_fail (obj != NULL, FALSE);
622 Accessibility_Text_addSelection (
623 CSPI_OBJREF (obj), startOffset,
624 endOffset, cspi_ev ());
626 cspi_return_val_if_ev ("addSelection", FALSE);
632 * AccessibleText_removeSelection:
633 * @obj: a pointer to the #AccessibleText object on which to operate.
634 * @selectionNum: an integer indicating which (possibly of several)
635 * text selection to remove.
637 * De-select a text selection.
639 * Returns: #TRUE if successful, #FALSE otherwise.
642 AccessibleText_removeSelection (AccessibleText *obj,
643 long int selectionNum)
647 cspi_return_val_if_fail (obj != NULL, FALSE);
650 Accessibility_Text_removeSelection (
651 CSPI_OBJREF (obj), selectionNum, cspi_ev ());
653 cspi_return_val_if_ev ("removeSelection", FALSE);
659 * AccessibleText_setSelection:
660 * @obj: a pointer to the #AccessibleText object on which to operate.
661 * @selectionNum: a zero-offset index indicating which text selection to modify.
662 * @startOffset: a long int, the new starting offset for the selection.
663 * @endOffset: a long int, the desired new offset of the first character
664 * after the selection.
666 * Change the bounds of an existing #AccessibleText text selection.
668 * Returns: #TRUE if successful, #FALSE otherwise.
671 AccessibleText_setSelection (AccessibleText *obj,
672 long int selectionNum,
673 long int startOffset,
678 cspi_return_val_if_fail (obj != NULL, FALSE);
680 retval = Accessibility_Text_setSelection (CSPI_OBJREF (obj),
683 endOffset, cspi_ev ());
685 cspi_return_val_if_ev ("setSelection", FALSE);