1 /* ATK - The Accessibility Toolkit for GTK+
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 #include "atkeditabletext.h"
21 * SECTION:atkeditabletext
22 * @Short_description: The ATK interface implemented by components
23 * containing user-editable text content.
24 * @Title:AtkEditableText
26 * #AtkEditableText should be implemented by UI components which
27 * contain text which the user can edit, via the #AtkObject
28 * corresponding to that component (see #AtkObject).
30 * #AtkEditableText is a subclass of #AtkText, and as such, an object
31 * which implements #AtkEditableText is by definition an #AtkText
32 * implementor as well.
38 atk_editable_text_get_type (void)
40 static GType type = 0;
43 static const GTypeInfo tinfo =
45 sizeof (AtkEditableTextIface),
47 (GBaseFinalizeFunc) NULL,
51 type = g_type_register_static (G_TYPE_INTERFACE, "AtkEditableText", &tinfo, 0);
58 *atk_editable_text_set_run_attributes:
59 *@text: an #AtkEditableText
60 *@attrib_set: an #AtkAttributeSet
61 *@start_offset: start of range in which to set attributes
62 *@end_offset: end of range in which to set attributes
64 *Sets the attributes for a specified range. See the ATK_ATTRIBUTE
65 *macros (such as #ATK_ATTRIBUTE_LEFT_MARGIN) for examples of attributes
66 *that can be set. Note that other attributes that do not have corresponding
67 *ATK_ATTRIBUTE macros may also be set for certain text widgets.
69 *Returns: %TRUE if attributes successfully set for the specified
70 *range, otherwise %FALSE
73 atk_editable_text_set_run_attributes (AtkEditableText *text,
74 AtkAttributeSet *attrib_set,
78 AtkEditableTextIface *iface;
80 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (text), FALSE);
82 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
84 if (iface->set_run_attributes)
86 return (*(iface->set_run_attributes)) (text, attrib_set, start_offset, end_offset);
96 * atk_editable_text_set_text_contents:
97 * @text: an #AtkEditableText
98 * @string: string to set for text contents of @text
100 * Set text contents of @text.
103 atk_editable_text_set_text_contents (AtkEditableText *text,
106 AtkEditableTextIface *iface;
108 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
110 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
112 if (iface->set_text_contents)
113 (*(iface->set_text_contents)) (text, string);
117 * atk_editable_text_insert_text:
118 * @text: an #AtkEditableText
119 * @string: the text to insert
120 * @length: the length of text to insert, in bytes
121 * @position: The caller initializes this to
122 * the position at which to insert the text. After the call it
123 * points at the position after the newly inserted text.
125 * Insert text at a given position.
128 atk_editable_text_insert_text (AtkEditableText *text,
133 AtkEditableTextIface *iface;
135 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
137 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
139 if (iface->insert_text)
140 (*(iface->insert_text)) (text, string, length, position);
144 * atk_editable_text_copy_text:
145 * @text: an #AtkEditableText
146 * @start_pos: start position
147 * @end_pos: end position
149 * Copy text from @start_pos up to, but not including @end_pos
153 atk_editable_text_copy_text (AtkEditableText *text,
157 AtkEditableTextIface *iface;
159 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
161 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
163 if (iface->copy_text)
164 (*(iface->copy_text)) (text, start_pos, end_pos);
168 * atk_editable_text_cut_text:
169 * @text: an #AtkEditableText
170 * @start_pos: start position
171 * @end_pos: end position
173 * Copy text from @start_pos up to, but not including @end_pos
174 * to the clipboard and then delete from the widget.
177 atk_editable_text_cut_text (AtkEditableText *text,
181 AtkEditableTextIface *iface;
183 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
185 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
188 (*(iface->cut_text)) (text, start_pos, end_pos);
192 * atk_editable_text_delete_text:
193 * @text: an #AtkEditableText
194 * @start_pos: start position
195 * @end_pos: end position
197 * Delete text @start_pos up to, but not including @end_pos.
200 atk_editable_text_delete_text (AtkEditableText *text,
204 AtkEditableTextIface *iface;
206 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
208 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
210 if (iface->delete_text)
211 (*(iface->delete_text)) (text, start_pos, end_pos);
215 * atk_editable_text_paste_text:
216 * @text: an #AtkEditableText
217 * @position: position to paste
219 * Paste text from clipboard to specified @position.
222 atk_editable_text_paste_text (AtkEditableText *text,
225 AtkEditableTextIface *iface;
227 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
229 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
231 if (iface->paste_text)
232 (*(iface->paste_text)) (text, position);