Documentation fixes for ref/unref methods that no longer return ints.
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_text.c
1 #include <cspi/spi-private.h>
2
3 /**
4  * AccessibleText_ref:
5  * @obj: a pointer to the #AccessibleText object on which to operate.
6  *
7  * Increment the reference count for an #AccessibleText object.
8  *
9  **/
10 void
11 AccessibleText_ref (AccessibleText *obj)
12 {
13   cspi_object_ref (obj);
14 }
15
16 /**
17  * AccessibleText_unref:
18  * @obj: a pointer to the #Accessible object on which to operate.
19  *
20  * Decrement the reference count for an #AccessibleText object.
21  *
22  **/
23 void
24 AccessibleText_unref (AccessibleText *obj)
25 {
26   cspi_object_unref (obj);
27 }
28
29 /**
30  * AccessibleText_getCharacterCount:
31  * @obj: a pointer to the #AccessibleText object to query.
32  *
33  * Get the character count of an #AccessibleText object.
34  *
35  * Returns: a long integer indicating the total number of
36  *              characters in the #AccessibleText object.
37  *
38  **/
39 long
40 AccessibleText_getCharacterCount (AccessibleText *obj)
41 {
42   long retval;
43
44   cspi_return_val_if_fail (obj != NULL, -1);
45
46   retval = (long)
47     Accessibility_Text__get_characterCount (CSPI_OBJREF (obj), cspi_ev ());
48
49   cspi_return_val_if_ev ("_getCharacterCount", -1);
50
51   return retval;
52 }
53
54 /**
55  * AccessibleText_getText:
56  * @obj: a pointer to the #AccessibleText object to query.
57  * @startOffset: a #long indicating the start of the desired text range.
58  * @endOffset: a #long indicating the first character past the desired range.
59  *
60  * Get a range of text from an #AccessibleText object.  The number of bytes
61  *          in the returned string may exceed endOffset-startOffset, since
62  *          UTF-8 is a variable-width encoding.
63  *
64  * Returns: a text string containing characters from @startOffset
65  *          to @endOffset-1, inclusive, encoded as UTF-8.
66  *
67  **/
68 char *
69 AccessibleText_getText (AccessibleText *obj,
70                         long int startOffset,
71                         long int endOffset)
72 {
73   return (char *)
74     Accessibility_Text_getText (CSPI_OBJREF (obj),
75                                 (CORBA_long) startOffset, (CORBA_long) endOffset, cspi_ev ());
76 }
77
78 /**
79  * AccessibleText_getCaretOffset:
80  * @obj: a pointer to the #AccessibleText object to query.
81  *
82  * Get the current offset of the text caret in an #AccessibleText object.
83  *
84  * Returns: a long integer indicating the current position of the text caret.
85  *
86  **/
87 long
88 AccessibleText_getCaretOffset (AccessibleText *obj)
89 {
90   return (long)
91     Accessibility_Text__get_caretOffset (CSPI_OBJREF (obj), cspi_ev ());
92 }
93
94
95 /**
96  * AccessibleText_getAttributes:
97  * @obj: a pointer to the #AccessibleText object to query.
98  * @offset: a long integer indicating the offset from which the attribute
99  *        search is based.
100  * @startOffset: a #long indicating the start of the desired text range.
101  * @endOffset: a #long indicating the first character past the desired range.
102  *
103  * Get the attributes applied to a range of text from an #AccessibleText
104  *          object, and the bounds of the range.
105  *
106  * Returns: a text string describing the attributes occurring within the
107  *          attribute run containing @offset, encoded as UTF-8 and
108  *          delimited by ':'
109  *
110  **/
111 char *
112 AccessibleText_getAttributes (AccessibleText *obj,
113                               long int offset,
114                               long int *startOffset,
115                               long int *endOffset)
116 {
117   CORBA_long retStartOffset, retEndOffset;
118   char *retval; 
119   retval = (char *)
120     Accessibility_Text_getAttributes (CSPI_OBJREF (obj),
121                                       (CORBA_long) offset,
122                                       &retStartOffset,
123                                       &retEndOffset,
124                                       cspi_ev ());
125   *startOffset = (long) retStartOffset;
126   *endOffset = (long) retEndOffset;
127   return retval;
128 }
129
130
131
132 /**
133  * AccessibleText_setCaretOffset:
134  * @obj: a pointer to the #AccessibleText object on which to operate.
135  * @newOffset: the offset to which the text caret is to be moved.
136  *
137  * Set the text caret position for an #AccessibleText object.
138  *
139  * Returns: #TRUE if successful, #FALSE otherwise.
140  *
141  **/
142 SPIBoolean
143 AccessibleText_setCaretOffset (AccessibleText *obj,
144                                long int newOffset)
145 {
146   return (SPIBoolean)
147     Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj),
148                                        (CORBA_long) newOffset, cspi_ev ());
149 }
150
151 /**
152  * AccessibleText_getTextBeforeOffset:
153  * @obj: a pointer to the #AccessibleText object on which to operate.
154  * @offset: a long integer indicating the offset from which the delimiter
155  *        search is based.
156  * @type: an #AccessibleTextBoundaryType indicating whether the desired
157  *       text string is a word, sentence, line, or attribute run.
158  * @startOffset: a pointer to a long integer which is assigned the
159  *       starting offset of the returned string, relative to the
160  *       original #AccessibleText.
161  * @endOffset: a pointer to a long integer which is assigned the
162  *       ending offset of the returned string, relative to the original
163  *       #AccessibleText.
164  *
165  * Get delimited text from an #AccessibleText object which precedes a given
166  *          text offset.
167  *
168  * Returns: a UTF-8 string representing the delimited text, both of whose
169  *          delimiting boundaries are before the current offset, or
170  *          an empty string if no such text exists.
171  *
172  **/
173 char *
174 AccessibleText_getTextBeforeOffset (AccessibleText *obj,
175                                     long int offset,
176                                     AccessibleTextBoundaryType type,
177                                     long int *startOffset,
178                                     long int *endOffset)
179 {
180   char *retval;
181   CORBA_long retStartOffset, retEndOffset;
182   retval = (char *)
183     Accessibility_Text_getTextBeforeOffset (CSPI_OBJREF (obj),
184                                            (CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type,
185                                            &retStartOffset, &retEndOffset,
186                                            cspi_ev ());
187   *startOffset = (long) retStartOffset;
188   *endOffset = (long) retEndOffset;
189   return retval;
190 }
191
192 /**
193  * AccessibleText_getTextAtOffset:
194  * @obj: a pointer to the #AccessibleText object on which to operate.
195  * @offset: a long integer indicating the offset from which the delimiter
196  *        search is based.
197  * @type: an #AccessibleTextBoundaryType indicating whether the desired
198  *       text string is a word, sentence, line, or attribute run.
199  * @startOffset: a pointer to a long integer which is assigned the
200  *       starting offset of the returned string, relative to the
201  *       original #AccessibleText.
202  * @endOffset: a pointer to a long integer which is assigned the
203  *       ending offset of the returned string, relative to the original
204  *       #AccessibleText.
205  *
206  * Get delimited text from an #AccessibleText object which includes a given
207  *          text offset.
208  *
209  * Returns: a UTF-8 string representing the delimited text, whose
210  *          delimiting boundaries bracket the current offset, or
211  *          an empty string if no such text exists.
212  *
213  **/
214 char *
215 AccessibleText_getTextAtOffset (AccessibleText *obj,
216                                 long int offset,
217                                 AccessibleTextBoundaryType type,
218                                 long int *startOffset, long int *endOffset)
219 {
220   CORBA_long corbaStartOffset;
221   CORBA_long corbaEndOffset;
222   char *retval = "";
223   retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj),
224                                                (CORBA_long) offset,
225                                                (Accessibility_TEXT_BOUNDARY_TYPE) type,
226                                                &corbaStartOffset,
227                                                &corbaEndOffset,
228                                                cspi_ev ());
229   *startOffset = (long) corbaStartOffset;
230   *endOffset = (long) corbaEndOffset;
231 #ifdef CSPI_DEBUG
232   fprintf (stderr, "text offsets %ld to %ld\n", *startOffset, *endOffset);
233 #endif
234   return retval;
235 }
236
237
238 /**
239  * AccessibleText_getTextAfterOffset:
240  * @obj: a pointer to the #AccessibleText object on which to operate.
241  * @offset: a long integer indicating the offset from which the delimiter
242  *        search is based.
243  * @type: an #AccessibleTextBoundaryType indicating whether the desired
244  *       text string is a word, sentence, line, or attribute run.
245  * @startOffset: a pointer to a long integer which is assigned the
246  *       starting offset of the returned string, relative to the
247  *       original #AccessibleText.
248  * @endOffset: a pointer to a long integer which is assigned the
249  *       ending offset of the returned string, relative to the original
250  *       #AccessibleText.
251  *
252  * Get delimited text from an #AccessibleText object which follows a given
253  *          text offset.
254  *
255  * Returns: a UTF-8 string representing the delimited text, both of whose
256  *          delimiting boundaries are after or inclusive of the current
257  *          offset, or an empty string if no such text exists.
258  *
259  **/
260 char *
261 AccessibleText_getTextAfterOffset (AccessibleText *obj,
262                                    long int offset,
263                                    AccessibleTextBoundaryType type,
264                                    long int *startOffset, long int *endOffset)
265 {
266   char *retval;
267   CORBA_long retStartOffset, retEndOffset;
268   retval = (char *)
269     Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj),
270                                            (CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type,
271                                            &retStartOffset, &retEndOffset,
272                                            cspi_ev ());
273   *startOffset = (long) retStartOffset;
274   *endOffset = (long) retEndOffset;
275   return retval;
276 }
277
278
279
280 /**
281  * AccessibleText_getCharacterAtOffset:
282  * @obj: a pointer to the #AccessibleText object on which to operate.
283  * @offset: a long integer indicating the text offset where the desired
284  *          character is located.
285  *
286  * Get the character at a given offset for an #AccessibleText object.
287  *
288  * Returns: an #unsigned long integer which represents the
289  *        UCS-4 unicode code point of the given character, or
290  *        0xFFFFFFFF if the character in question cannot be represented
291  *        in the UCS-4 encoding.
292  *
293  **/
294 unsigned long
295 AccessibleText_getCharacterAtOffset (AccessibleText *obj,
296                                      long int offset)
297 {
298   return (unsigned long)
299     Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj),
300                                              (CORBA_long) offset, cspi_ev ());
301 }
302
303 /**
304  * AccessibleText_getCharacterExtents:
305  * @obj: a pointer to the #AccessibleText object on which to operate.
306  * @offset: an integer indicating the offset of the text character for
307  *        whom boundary information is requested.
308  * @x: a pointer to a long integer into which the nominal x coordinate
309  *     of the corresponding glyph will be returned.
310  * @y:a pointer to a long integer into which the nominal y coordinate
311  *     of the corresponding glyph will be returned.
312  * @width:a pointer to a long integer into which the width
313  *     of the corresponding glyph will be returned.
314  * @height: a pointer to a long integer into which the height
315  *     of the corresponding glyph will be returned.
316  * @type: an #AccessibleCoordType indicating the coordinate system to use
317  *        for the returned values.
318  *
319  * Get the bounding box containing the glyph representing
320  *        the character at a particular text offset.
321  *
322  **/
323 void
324 AccessibleText_getCharacterExtents (AccessibleText *obj,
325                                     long int offset,
326                                     long int *x,
327                                     long int *y,
328                                     long int *width,
329                                     long int *height,
330                                     AccessibleCoordType type)
331 {
332   CORBA_long retX, retY, retWidth, retHeight;
333   Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj),
334                                           (CORBA_long) offset,
335                                           &retX,
336                                           &retY,
337                                           &retWidth,
338                                           &retHeight,
339                                           (CORBA_short) type, cspi_ev ());
340   *x = (long) retX;
341   *y = (long) retY;
342   *width = (long) retWidth;
343   *height = (long) retHeight;
344 }
345
346
347 /**
348  * AccessibleText_getOffsetAtPoint:
349  * @obj: a pointer to the #AccessibleText object on which to operate.
350  * @x: the x coordinate of the point to be queried.
351  * @y: the y coordinate of the point to be queried.
352  * @type: an #AccessibleCoordType indicating the coordinate system in which
353  *       the values should be returned.
354  *
355  * Get the bounding box for a glyph at a certain #AccessibleText offset.
356  *
357  * Returns: the offset (as a long integer) at the point (@x, @y)
358  *       in the specified coordinate system.
359  *
360  **/
361 long
362 AccessibleText_getOffsetAtPoint (AccessibleText *obj,
363                                  long int x,
364                                  long int y,
365                                  AccessibleCoordType type)
366 {
367   return (long)
368     Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj),
369                                          (CORBA_long) x, (CORBA_long) y, (CORBA_short) type, cspi_ev ());
370 }
371
372
373 /**
374  * AccessibleText_getNSelections:
375  * @obj: a pointer to the #AccessibleText object on which to operate.
376  *
377  * Get the number of active non-contiguous selections for an
378  *          #AccessibleText object.
379  *
380  * Returns: a long integer indicating the current
381  *          number of non-contiguous text selections active
382  *          within an #AccessibleText object.
383  *
384  **/
385 long
386 AccessibleText_getNSelections (AccessibleText *obj)
387 {
388   return (long)
389     Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ());
390 }
391
392
393
394 /**
395  * AccessibleText_getSelection:
396  * @obj: a pointer to the #AccessibleText object on which to operate.
397  * @selectionNum: an integer indicating which selection to query.
398  * @startOffset: a pointer to a long integer into which the start offset
399  *           of the selection will be returned.
400  * @endOffset: a pointer to a long integer into which the start offset
401  *           of the selection will be returned.
402  *
403  * Get the bounds of the @selectionNum-th active text selection for an
404  *         #AccessibleText object.
405  *
406  **/
407 void
408 AccessibleText_getSelection (AccessibleText *obj,
409                              long int selectionNum,
410                              long int *startOffset,
411                              long int *endOffset)
412 {
413   CORBA_long retStartOffset, retEndOffset;
414   Accessibility_Text_getSelection (CSPI_OBJREF (obj),
415                                    (CORBA_long) selectionNum,
416                                    &retStartOffset, &retEndOffset, cspi_ev ());
417   
418   *startOffset = (long) retStartOffset;
419   *endOffset = (long) retEndOffset;
420 }
421
422
423
424 /**
425  * AccessibleText_addSelection:
426  * @obj: a pointer to the #AccessibleText object on which to operate.
427  * @startOffset: the starting offset of the desired new selection.
428  * @endOffset: the offset of the first character after the new selection.
429  *
430  * Select some text (add a text selection) in an #AccessibleText object.
431  *
432  * Returns: #TRUE if successful, #FALSE otherwise.
433  *
434  **/
435 SPIBoolean
436 AccessibleText_addSelection (AccessibleText *obj,
437                              long int startOffset, long int endOffset)
438 {
439   return (SPIBoolean)
440     Accessibility_Text_addSelection (CSPI_OBJREF (obj),
441                                      (CORBA_long) startOffset, (CORBA_long) endOffset,
442                                      cspi_ev ());
443 }
444
445
446 /**
447  * AccessibleText_removeSelection:
448  * @obj: a pointer to the #AccessibleText object on which to operate.
449  * @selectionNum: an integer indicating which (possibly of several)
450  *         text selection to remove.
451  *
452  * De-select a text selection.
453  *
454  * Returns: #TRUE if successful, #FALSE otherwise.
455  *
456  **/
457 SPIBoolean
458 AccessibleText_removeSelection (AccessibleText *obj,
459                                 long int selectionNum)
460 {
461   return (SPIBoolean)
462     Accessibility_Text_removeSelection (CSPI_OBJREF (obj),
463                                         (CORBA_long) selectionNum, cspi_ev ());
464 }
465
466 /**
467  * AccessibleText_setSelection:
468  * @obj: a pointer to the #AccessibleText object on which to operate.
469  * @selectionNum: a zero-offset index indicating which text selection to modify.
470  * @startOffset: a long int, the new starting offset for the selection.
471  * @endOffset: a long int, the desired new offset of the first character
472  *             after the selection.
473  *
474  * Change the bounds of an existing #AccessibleText text selection.
475  *
476  * Returns: #TRUE if successful, #FALSE otherwise.
477  *
478  **/
479 SPIBoolean
480 AccessibleText_setSelection (AccessibleText *obj,
481                              long int selectionNum,
482                              long int startOffset,
483                              long int endOffset)
484 {
485   return (SPIBoolean)
486     Accessibility_Text_setSelection (CSPI_OBJREF (obj),
487                                      (CORBA_long) selectionNum,
488                                      (CORBA_long) startOffset,
489                                      (CORBA_long) endOffset, cspi_ev ());
490 }
491
492
493