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>
27 * @obj: a pointer to the #AccessibleText object on which to operate.
29 * Increment the reference count for an #AccessibleText object.
32 AccessibleText_ref (AccessibleText *obj)
34 cspi_object_ref (obj);
38 * AccessibleText_unref:
39 * @obj: a pointer to the #Accessible object on which to operate.
41 * Decrement the reference count for an #AccessibleText object.
44 AccessibleText_unref (AccessibleText *obj)
46 cspi_object_unref (obj);
50 * AccessibleText_getCharacterCount:
51 * @obj: a pointer to the #AccessibleText object to query.
53 * Get the character count of an #AccessibleText object.
55 * Returns: a long integer indicating the total number of
56 * characters in the #AccessibleText object.
59 AccessibleText_getCharacterCount (AccessibleText *obj)
63 cspi_return_val_if_fail (obj != NULL, -1);
66 Accessibility_Text__get_characterCount (CSPI_OBJREF (obj), cspi_ev ());
68 cspi_return_val_if_ev ("getCharacterCount", -1);
74 * AccessibleText_getText:
75 * @obj: a pointer to the #AccessibleText object to query.
76 * @startOffset: a #long indicating the start of the desired text range.
77 * @endOffset: a #long indicating the first character past the desired range.
79 * Get a range of text from an #AccessibleText object. The number of bytes
80 * in the returned string may exceed endOffset-startOffset, since
81 * UTF-8 is a variable-width encoding.
83 * Returns: a text string containing characters from @startOffset
84 * to @endOffset-1, inclusive, encoded as UTF-8.
87 AccessibleText_getText (AccessibleText *obj,
93 cspi_return_val_if_fail (obj != NULL, NULL);
96 Accessibility_Text_getText (CSPI_OBJREF (obj),
97 (CORBA_long) startOffset,
98 (CORBA_long) endOffset,
101 cspi_return_val_if_ev ("getText", NULL);
107 * AccessibleText_getCaretOffset:
108 * @obj: a pointer to the #AccessibleText object to query.
110 * Get the current offset of the text caret in an #AccessibleText object.
112 * Returns: a long integer indicating the current position of the text caret.
115 AccessibleText_getCaretOffset (AccessibleText *obj)
119 cspi_return_val_if_fail (obj != NULL, -1);
122 Accessibility_Text__get_caretOffset (CSPI_OBJREF (obj), cspi_ev ());
124 cspi_return_val_if_ev ("getCaretOffset", -1);
130 * AccessibleText_getAttributes:
131 * @obj: a pointer to the #AccessibleText object to query.
132 * @offset: a long integer indicating the offset from which the attribute
134 * @startOffset: a #long indicating the start of the desired text range.
135 * @endOffset: a #long indicating the first character past the desired range.
137 * Get the attributes applied to a range of text from an #AccessibleText
138 * object, and the bounds of the range.
140 * Returns: a text string describing the attributes occurring within the
141 * attribute run containing @offset, encoded as UTF-8 and
145 AccessibleText_getAttributes (AccessibleText *obj,
147 long int *startOffset,
150 CORBA_long retStartOffset, retEndOffset;
155 *startOffset = *endOffset = 0;
160 Accessibility_Text_getAttributes (CSPI_OBJREF (obj),
166 if (!cspi_check_ev ("getAttributes"))
168 *startOffset = *endOffset = 0;
172 *startOffset = retStartOffset;
173 *endOffset = retEndOffset;
180 * AccessibleText_setCaretOffset:
181 * @obj: a pointer to the #AccessibleText object on which to operate.
182 * @newOffset: the offset to which the text caret is to be moved.
184 * Set the text caret position for an #AccessibleText object.
186 * Returns: #TRUE if successful, #FALSE otherwise.
189 AccessibleText_setCaretOffset (AccessibleText *obj,
194 cspi_return_val_if_fail (obj != NULL, FALSE);
197 Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj),
198 (CORBA_long) newOffset, cspi_ev ());
200 cspi_return_val_if_ev ("setCaretOffset", FALSE);
206 * AccessibleText_getTextBeforeOffset:
207 * @obj: a pointer to the #AccessibleText object on which to operate.
208 * @offset: a long integer indicating the offset from which the delimiter
210 * @type: an #AccessibleTextBoundaryType indicating whether the desired
211 * text string is a word, sentence, line, or attribute run.
212 * @startOffset: a pointer to a long integer which is assigned the
213 * starting offset of the returned string, relative to the
214 * original #AccessibleText.
215 * @endOffset: a pointer to a long integer which is assigned the
216 * ending offset of the returned string, relative to the original
219 * Get delimited text from an #AccessibleText object which precedes a given
222 * Returns: a UTF-8 string representing the delimited text, both of whose
223 * delimiting boundaries are before the current offset, or
224 * an empty string if no such text exists.
227 AccessibleText_getTextBeforeOffset (AccessibleText *obj,
229 AccessibleTextBoundaryType type,
230 long int *startOffset,
234 CORBA_long retStartOffset, retEndOffset;
236 Accessibility_Text_getTextBeforeOffset (CSPI_OBJREF (obj),
237 (CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type,
238 &retStartOffset, &retEndOffset,
240 *startOffset = (long) retStartOffset;
241 *endOffset = (long) retEndOffset;
246 * AccessibleText_getTextAtOffset:
247 * @obj: a pointer to the #AccessibleText object on which to operate.
248 * @offset: a long integer indicating the offset from which the delimiter
250 * @type: an #AccessibleTextBoundaryType indicating whether the desired
251 * text string is a word, sentence, line, or attribute run.
252 * @startOffset: a pointer to a long integer which is assigned the
253 * starting offset of the returned string, relative to the
254 * original #AccessibleText.
255 * @endOffset: a pointer to a long integer which is assigned the
256 * ending offset of the returned string, relative to the original
259 * Get delimited text from an #AccessibleText object which includes a given
262 * Returns: a UTF-8 string representing the delimited text, whose
263 * delimiting boundaries bracket the current offset, or
264 * an empty string if no such text exists.
267 AccessibleText_getTextAtOffset (AccessibleText *obj,
269 AccessibleTextBoundaryType type,
270 long int *startOffset, long int *endOffset)
272 CORBA_long corbaStartOffset;
273 CORBA_long corbaEndOffset;
278 *startOffset = *endOffset = 0;
282 retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj),
284 (Accessibility_TEXT_BOUNDARY_TYPE) type,
289 if (!cspi_check_ev ("getTextAtOffset"))
291 *startOffset = *endOffset = 0;
296 *startOffset = corbaStartOffset;
297 *endOffset = corbaEndOffset;
300 fprintf (stderr, "text offsets %ld to %ld\n", *startOffset, *endOffset);
306 * AccessibleText_getTextAfterOffset:
307 * @obj: a pointer to the #AccessibleText object on which to operate.
308 * @offset: a long integer indicating the offset from which the delimiter
310 * @type: an #AccessibleTextBoundaryType indicating whether the desired
311 * text string is a word, sentence, line, or attribute run.
312 * @startOffset: a pointer to a long integer which is assigned the
313 * starting offset of the returned string, relative to the
314 * original #AccessibleText.
315 * @endOffset: a pointer to a long integer which is assigned the
316 * ending offset of the returned string, relative to the original
319 * Get delimited text from an #AccessibleText object which follows a given
322 * Returns: a UTF-8 string representing the delimited text, both of whose
323 * delimiting boundaries are after or inclusive of the current
324 * offset, or an empty string if no such text exists.
327 AccessibleText_getTextAfterOffset (AccessibleText *obj,
329 AccessibleTextBoundaryType type,
330 long int *startOffset, long int *endOffset)
333 CORBA_long retStartOffset, retEndOffset;
337 *startOffset = *endOffset = 0;
342 Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj),
343 (CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type,
344 &retStartOffset, &retEndOffset,
347 if (!cspi_check_ev ("getTextAfterOffset"))
349 *startOffset = *endOffset = 0;
353 *startOffset = retStartOffset;
354 *endOffset = retEndOffset;
361 * AccessibleText_getCharacterAtOffset:
362 * @obj: a pointer to the #AccessibleText object on which to operate.
363 * @offset: a long integer indicating the text offset where the desired
364 * character is located.
366 * Get the character at a given offset for an #AccessibleText object.
368 * Returns: an #unsigned long integer which represents the
369 * UCS-4 unicode code point of the given character, or
370 * 0xFFFFFFFF if the character in question cannot be represented
371 * in the UCS-4 encoding.
374 AccessibleText_getCharacterAtOffset (AccessibleText *obj,
379 cspi_return_val_if_fail (obj != NULL, -1);
382 Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj),
386 cspi_return_val_if_ev ("getCharacterAtOffset", -1);
392 * AccessibleText_getCharacterExtents:
393 * @obj: a pointer to the #AccessibleText object on which to operate.
394 * @offset: an integer indicating the offset of the text character for
395 * whom boundary information is requested.
396 * @x: a pointer to a long integer into which the nominal x coordinate
397 * of the corresponding glyph will be returned.
398 * @y:a pointer to a long integer into which the nominal y coordinate
399 * of the corresponding glyph will be returned.
400 * @width:a pointer to a long integer into which the width
401 * of the corresponding glyph will be returned.
402 * @height: a pointer to a long integer into which the height
403 * of the corresponding glyph will be returned.
404 * @type: an #AccessibleCoordType indicating the coordinate system to use
405 * for the returned values.
407 * Get the bounding box containing the glyph representing
408 * the character at a particular text offset.
411 AccessibleText_getCharacterExtents (AccessibleText *obj,
417 AccessibleCoordType type)
419 CORBA_long retX, retY, retWidth, retHeight;
424 *width = *height = 0;
428 Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj),
434 (CORBA_short) type, cspi_ev ());
436 if (!cspi_check_ev ("getCharacterExtents"))
439 *width = *height = 0;
451 * AccessibleText_getOffsetAtPoint:
452 * @obj: a pointer to the #AccessibleText object on which to operate.
453 * @x: the x coordinate of the point to be queried.
454 * @y: the y coordinate of the point to be queried.
455 * @type: an #AccessibleCoordType indicating the coordinate system in which
456 * the values should be returned.
458 * Get the bounding box for a glyph at a certain #AccessibleText offset.
460 * Returns: the offset (as a long integer) at the point (@x, @y)
461 * in the specified coordinate system.
465 AccessibleText_getOffsetAtPoint (AccessibleText *obj,
468 AccessibleCoordType type)
472 cspi_return_val_if_fail (obj != NULL, -1);
475 Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj),
478 (CORBA_short) type, cspi_ev ());
480 cspi_return_val_if_ev ("getOffsetAtPoint", -1);
486 * AccessibleText_getNSelections:
487 * @obj: a pointer to the #AccessibleText object on which to operate.
489 * Get the number of active non-contiguous selections for an
490 * #AccessibleText object.
492 * Returns: a long integer indicating the current
493 * number of non-contiguous text selections active
494 * within an #AccessibleText object.
497 AccessibleText_getNSelections (AccessibleText *obj)
501 cspi_return_val_if_fail (obj != NULL, -1);
504 Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ());
506 cspi_return_val_if_ev ("getNSelections", -1);
512 * AccessibleText_getSelection:
513 * @obj: a pointer to the #AccessibleText object on which to operate.
514 * @selectionNum: an integer indicating which selection to query.
515 * @startOffset: a pointer to a long integer into which the start offset
516 * of the selection will be returned.
517 * @endOffset: a pointer to a long integer into which the start offset
518 * of the selection will be returned.
520 * Get the bounds of the @selectionNum-th active text selection for an
521 * #AccessibleText object.
524 AccessibleText_getSelection (AccessibleText *obj,
525 long int selectionNum,
526 long int *startOffset,
529 CORBA_long retStartOffset, retEndOffset;
533 *endOffset = *startOffset = -1;
537 Accessibility_Text_getSelection (CSPI_OBJREF (obj),
538 (CORBA_long) selectionNum,
539 &retStartOffset, &retEndOffset,
542 if (!cspi_check_ev ("getSelection"))
544 *startOffset = *endOffset = 0;
548 *startOffset = retStartOffset;
549 *endOffset = retEndOffset;
554 * AccessibleText_addSelection:
555 * @obj: a pointer to the #AccessibleText object on which to operate.
556 * @startOffset: the starting offset of the desired new selection.
557 * @endOffset: the offset of the first character after the new selection.
559 * Select some text (add a text selection) in an #AccessibleText object.
561 * Returns: #TRUE if successful, #FALSE otherwise.
564 AccessibleText_addSelection (AccessibleText *obj,
565 long int startOffset, long int endOffset)
569 cspi_return_val_if_fail (obj != NULL, FALSE);
572 Accessibility_Text_addSelection (
573 CSPI_OBJREF (obj), (CORBA_long) startOffset,
574 (CORBA_long) endOffset, cspi_ev ());
576 cspi_return_val_if_ev ("addSelection", FALSE);
582 * AccessibleText_removeSelection:
583 * @obj: a pointer to the #AccessibleText object on which to operate.
584 * @selectionNum: an integer indicating which (possibly of several)
585 * text selection to remove.
587 * De-select a text selection.
589 * Returns: #TRUE if successful, #FALSE otherwise.
592 AccessibleText_removeSelection (AccessibleText *obj,
593 long int selectionNum)
597 cspi_return_val_if_fail (obj != NULL, FALSE);
600 Accessibility_Text_removeSelection (
601 CSPI_OBJREF (obj), (CORBA_long) selectionNum, cspi_ev ());
603 cspi_return_val_if_ev ("removeSelection", FALSE);
609 * AccessibleText_setSelection:
610 * @obj: a pointer to the #AccessibleText object on which to operate.
611 * @selectionNum: a zero-offset index indicating which text selection to modify.
612 * @startOffset: a long int, the new starting offset for the selection.
613 * @endOffset: a long int, the desired new offset of the first character
614 * after the selection.
616 * Change the bounds of an existing #AccessibleText text selection.
618 * Returns: #TRUE if successful, #FALSE otherwise.
621 AccessibleText_setSelection (AccessibleText *obj,
622 long int selectionNum,
623 long int startOffset,
626 cspi_return_val_if_fail (obj != NULL, FALSE);
628 Accessibility_Text_setSelection (CSPI_OBJREF (obj),
629 (CORBA_long) selectionNum,
630 (CORBA_long) startOffset,
631 (CORBA_long) endOffset, cspi_ev ());
633 cspi_return_val_if_ev ("setSelection", FALSE);