Fix the coding style for the Component scroll methods
[atk.git] / atk / atkeditabletext.c
blobd44f8bff915f8fd2d56ae6d58a7b0421e52b79cb
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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include "config.h"
22 #include "atkeditabletext.h"
24 /**
25 * SECTION:atkeditabletext
26 * @Short_description: The ATK interface implemented by components
27 * containing user-editable text content.
28 * @Title:AtkEditableText
30 * #AtkEditableText should be implemented by UI components which
31 * contain text which the user can edit, via the #AtkObject
32 * corresponding to that component (see #AtkObject).
34 * #AtkEditableText is a subclass of #AtkText, and as such, an object
35 * which implements #AtkEditableText is by definition an #AtkText
36 * implementor as well.
38 * See also: #AtkText
41 GType
42 atk_editable_text_get_type (void)
44 static GType type = 0;
46 if (!type) {
47 static const GTypeInfo tinfo =
49 sizeof (AtkEditableTextIface),
50 (GBaseInitFunc) NULL,
51 (GBaseFinalizeFunc) NULL,
55 type = g_type_register_static (G_TYPE_INTERFACE, "AtkEditableText", &tinfo, 0);
58 return type;
61 /**
62 *atk_editable_text_set_run_attributes:
63 *@text: an #AtkEditableText
64 *@attrib_set: an #AtkAttributeSet
65 *@start_offset: start of range in which to set attributes
66 *@end_offset: end of range in which to set attributes
68 *Sets the attributes for a specified range. See the ATK_ATTRIBUTE
69 *macros (such as #ATK_ATTRIBUTE_LEFT_MARGIN) for examples of attributes
70 *that can be set. Note that other attributes that do not have corresponding
71 *ATK_ATTRIBUTE macros may also be set for certain text widgets.
73 *Returns: %TRUE if attributes successfully set for the specified
74 *range, otherwise %FALSE
75 **/
76 gboolean
77 atk_editable_text_set_run_attributes (AtkEditableText *text,
78 AtkAttributeSet *attrib_set,
79 gint start_offset,
80 gint end_offset)
82 AtkEditableTextIface *iface;
84 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (text), FALSE);
86 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
88 if (iface->set_run_attributes)
90 return (*(iface->set_run_attributes)) (text, attrib_set, start_offset, end_offset);
92 else
94 return FALSE;
99 /**
100 * atk_editable_text_set_text_contents:
101 * @text: an #AtkEditableText
102 * @string: string to set for text contents of @text
104 * Set text contents of @text.
106 void
107 atk_editable_text_set_text_contents (AtkEditableText *text,
108 const gchar *string)
110 AtkEditableTextIface *iface;
112 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
114 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
116 if (iface->set_text_contents)
117 (*(iface->set_text_contents)) (text, string);
121 * atk_editable_text_insert_text:
122 * @text: an #AtkEditableText
123 * @string: the text to insert
124 * @length: the length of text to insert, in bytes
125 * @position: The caller initializes this to
126 * the position at which to insert the text. After the call it
127 * points at the position after the newly inserted text.
129 * Insert text at a given position.
131 void
132 atk_editable_text_insert_text (AtkEditableText *text,
133 const gchar *string,
134 gint length,
135 gint *position)
137 AtkEditableTextIface *iface;
139 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
141 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
143 if (iface->insert_text)
144 (*(iface->insert_text)) (text, string, length, position);
148 * atk_editable_text_copy_text:
149 * @text: an #AtkEditableText
150 * @start_pos: start position
151 * @end_pos: end position
153 * Copy text from @start_pos up to, but not including @end_pos
154 * to the clipboard.
156 void
157 atk_editable_text_copy_text (AtkEditableText *text,
158 gint start_pos,
159 gint end_pos)
161 AtkEditableTextIface *iface;
163 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
165 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
167 if (iface->copy_text)
168 (*(iface->copy_text)) (text, start_pos, end_pos);
172 * atk_editable_text_cut_text:
173 * @text: an #AtkEditableText
174 * @start_pos: start position
175 * @end_pos: end position
177 * Copy text from @start_pos up to, but not including @end_pos
178 * to the clipboard and then delete from the widget.
180 void
181 atk_editable_text_cut_text (AtkEditableText *text,
182 gint start_pos,
183 gint end_pos)
185 AtkEditableTextIface *iface;
187 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
189 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
191 if (iface->cut_text)
192 (*(iface->cut_text)) (text, start_pos, end_pos);
196 * atk_editable_text_delete_text:
197 * @text: an #AtkEditableText
198 * @start_pos: start position
199 * @end_pos: end position
201 * Delete text @start_pos up to, but not including @end_pos.
203 void
204 atk_editable_text_delete_text (AtkEditableText *text,
205 gint start_pos,
206 gint end_pos)
208 AtkEditableTextIface *iface;
210 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
212 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
214 if (iface->delete_text)
215 (*(iface->delete_text)) (text, start_pos, end_pos);
219 * atk_editable_text_paste_text:
220 * @text: an #AtkEditableText
221 * @position: position to paste
223 * Paste text from clipboard to specified @position.
225 void
226 atk_editable_text_paste_text (AtkEditableText *text,
227 gint position)
229 AtkEditableTextIface *iface;
231 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
233 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
235 if (iface->paste_text)
236 (*(iface->paste_text)) (text, position);