2002-05-09 Marc Mulcahy <marc.mulcahy@sun.com>
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_editabletext.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 #include <cspi/spi-private.h>
24
25 /**
26  * AccessibleEditableText_ref:
27  * @obj: a pointer to the #AccessibleEditableText object on which to operate.
28  *
29  * Increment the reference count for an #AccessibleEditableText object.
30  *       Since AccessibleEditableText is derived from AccessibleText,
31  *       this is the same as AccessibleText_ref().
32  **/
33 void
34 AccessibleEditableText_ref (AccessibleEditableText *obj)
35 {
36   cspi_object_ref (obj);
37 }
38
39 /**
40  * AccessibleEditableText_unref:
41  * @obj: a pointer to the #AccessibleEditableText object on which to operate.
42  *
43  * Decrement the reference count for an #AccessibleEdiitableText object.
44  *       Since AccessibleEditableText is derived from AccessibleText,
45  *       this is the same as AccessibleText_unref().
46  **/
47 void
48 AccessibleEditableText_unref (AccessibleEditableText *obj)
49 {
50   cspi_object_unref (obj);
51 }
52
53 /**
54  * AccessibleEditableText_setAttributes:
55  * @obj: a pointer to the #AccessibleEditableText object to modify.
56  * @attributes: a character string indicating the attributes to apply to the range,
57  *        delimited by ':'.
58  * @startOffset: a #long indicating the start of the desired text range.
59  * @endOffset: a #long indicating the first character past the desired range.
60  *
61  * Set the attributes applied to a range of text from an #AccessibleEditableText
62  *          object, and the bounds of the range.
63  *
64  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
65  **/
66 SPIBoolean
67 AccessibleEditableText_setAttributes (AccessibleEditableText *obj,
68                                       const char *attributes,
69                                       long int startPos,
70                                       long int endPos)
71 {
72   SPIBoolean retval;
73
74   cspi_return_val_if_fail (obj != NULL, FALSE);
75
76   retval = 
77     Accessibility_EditableText_setAttributes (CSPI_OBJREF (obj),
78                                               attributes,
79                                               startPos,
80                                               endPos, cspi_ev ());
81
82   cspi_return_val_if_ev ("setAttributes", FALSE);
83
84   return retval;
85 }
86
87 /**
88  * AccessibleEditableText_setTextContents:
89  * @obj: a pointer to the #AccessibleEditableText object to modify.
90  * @newContents: a character string, encoded in UTF-8, which is to
91  *      become the new text contents of the #AccessibleEditableText object.
92  *
93  * Replace the entire text contents of an #AccessibleEditableText object.
94  *
95  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
96  **/
97 SPIBoolean
98 AccessibleEditableText_setTextContents (AccessibleEditableText *obj,
99                                         const char *newContents)
100 {
101   SPIBoolean retval;
102
103   cspi_return_val_if_fail (obj != NULL, FALSE);
104
105   retval = Accessibility_EditableText_setTextContents (CSPI_OBJREF (obj),
106                                                                           newContents, cspi_ev ());
107
108   cspi_return_val_if_ev ("setTextContents", FALSE);
109
110   return retval;
111 }
112
113 /**
114  * AccessibleEditableText_insertText:
115  * @obj: a pointer to the #AccessibleEditableText object to modify.
116  * @position: an integer indicating the character offset at which to insert
117  *       the new text.  
118  * @text: a char* pointer to the text to insert, in UTF-8 encoding.
119  * @length: (frankly I'm not sure this parameter should be here)
120  *
121  * Insert text into an #AccessibleEditableText object.
122  * As with all character offsets, the specified @position may not be the
123  *       same as the resulting byte offset, since the text is in a
124  *       variable-width encoding.
125  *
126  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
127  **/
128 SPIBoolean
129 AccessibleEditableText_insertText (AccessibleEditableText *obj,
130                                    long int position,
131                                    const char *text,
132                                    long int length)
133 {
134   SPIBoolean retval;
135
136   cspi_return_val_if_fail (obj != NULL, FALSE);
137
138   retval = Accessibility_EditableText_insertText (CSPI_OBJREF (obj),
139                                          position, text,
140                                          length, cspi_ev ());
141
142   cspi_return_val_if_ev ("insertText", FALSE);
143
144   return retval;
145 }
146
147 /**
148  * AccessibleEditableText_copyText:
149  * @obj: a pointer to the #AccessibleEditableText object to modify.
150  * @startPos: an integer indicating the starting character offset
151  *       of the text to copy.
152  * @endPos: an integer indicating the offset of the first character
153  *       past the end of the text section to be copied.
154  *
155  * Copy text from an #AccessibleEditableText object into the clipboard.
156  *
157  * @see: AccessibleEditableText_pasteText 
158  *
159  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
160  **/
161 SPIBoolean
162 AccessibleEditableText_copyText (AccessibleText *obj,
163                                  long int startPos,
164                                  long int endPos)
165 {
166   cspi_return_val_if_fail (obj != NULL, FALSE);
167
168   Accessibility_EditableText_copyText (
169     CSPI_OBJREF (obj), startPos,
170     endPos, cspi_ev ());
171
172   cspi_return_val_if_ev ("copyText", FALSE);
173
174   return TRUE;
175 }
176
177 /**
178  * AccessibleEditableText_cutText:
179  * @obj: a pointer to the #AccessibleEditableText object to modify.
180  * @startPos: an integer indicating the starting character offset
181  *       of the text to cut.
182  * @endPos: an integer indicating the offset of the first character
183  *       past the end of the text section to be cut.
184  *
185  * Delete text from an #AccessibleEditableText object, copying the
186  *       excised portion into the clipboard.
187  *
188  * @see: AccessibleEditableText_pasteText
189  *
190  * Returns: #TRUE if operation was successful, #FALSE otherwise.
191  **/
192 SPIBoolean
193 AccessibleEditableText_cutText (AccessibleEditableText *obj,
194                                 long int startPos,
195                                 long int endPos)
196 {
197   SPIBoolean retval;
198
199   cspi_return_val_if_fail (obj != NULL, FALSE);
200
201   retval = Accessibility_EditableText_cutText (
202     CSPI_OBJREF (obj),
203     startPos, endPos, cspi_ev ());
204
205   cspi_return_val_if_ev ("cutText", FALSE);
206
207   return retval;
208 }
209
210 /**
211  * AccessibleEditableText_deleteText:
212  * @obj: a pointer to the #AccessibleEditableText object to modify.
213  * @startPos: an integer indicating the starting character offset
214  *       of the text to delete.
215  * @endPos: an integer indicating the offset of the first character
216  *       past the end of the text section to be deleted.
217  *
218  * Delete text from an #AccessibleEditableText object, without copying the
219  *       excised portion into the clipboard.
220  *
221  * @see: AccessibleEditableText_cutText
222  *
223  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
224  **/
225 SPIBoolean
226 AccessibleEditableText_deleteText (AccessibleEditableText *obj,
227                                    long startPos,
228                                    long endPos)
229 {
230   SPIBoolean retval;
231
232   cspi_return_val_if_fail (obj != NULL, FALSE);
233
234   retval = Accessibility_EditableText_deleteText (
235     CSPI_OBJREF (obj),
236     startPos, endPos, cspi_ev ());
237
238   cspi_return_val_if_ev ("deleteText", FALSE);
239
240   return retval;
241 }
242
243 /**
244  * AccessibleEditableText_pasteText:
245  * @obj: a pointer to the #AccessibleEditableText object to modify.
246  * @position: an integer indicating the character offset at which to insert
247  *       the new text.  
248  *
249  * Insert text from the clipboard into an #AccessibleEditableText object.
250  * As with all character offsets, the specified @position may not be the
251  *       same as the resulting byte offset, since the text is in a
252  *       variable-width encoding.
253  *
254  * Returns: #TRUE if the operation was successful, otherwise #FALSE.
255  **/
256 SPIBoolean
257 AccessibleEditableText_pasteText (AccessibleEditableText *obj,
258                                   long int position)
259 {
260   SPIBoolean retval;
261
262   cspi_return_val_if_fail (obj != NULL, FALSE);
263
264   retval = Accessibility_EditableText_pasteText (
265     CSPI_OBJREF (obj), position, cspi_ev ());
266
267   cspi_return_val_if_ev ("pasteText", FALSE);
268
269   return retval;
270 }