1 /* ATK - Accessibility Toolkit
2 * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser 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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
23 * @Short_description: The ATK interface implemented by valuators and
24 * components which display or select a value from a bounded range of
28 * #AtkValue should be implemented for components which either display
29 * a value from a bounded range, or which allow the user to specify a
30 * value from a bounded range, or both. For instance, most sliders
31 * and range controls, as well as dials, should have #AtkObject
32 * representations which implement #AtkValue on the component's
33 * behalf. #AtKValues may be read-only, in which case attempts to
34 * alter the value return FALSE to indicate failure.
38 atk_value_get_type (void)
40 static GType type = 0;
45 sizeof (AtkValueIface),
47 (GBaseFinalizeFunc) NULL,
51 type = g_type_register_static (G_TYPE_INTERFACE, "AtkValue", &tinfo, 0);
58 * atk_value_get_current_value:
59 * @obj: a GObject instance that implements AtkValueIface
60 * @value: a #GValue representing the current accessible value
62 * Gets the value of this object.
65 atk_value_get_current_value (AtkValue *obj,
70 g_return_if_fail (value != NULL);
71 g_return_if_fail (ATK_IS_VALUE (obj));
73 iface = ATK_VALUE_GET_IFACE (obj);
75 if (iface->get_current_value)
77 if (G_IS_VALUE (value))
78 g_value_unset (value);
80 memset (value, 0, sizeof (*value));
82 (iface->get_current_value) (obj, value);
87 * atk_value_get_maximum_value:
88 * @obj: a GObject instance that implements AtkValueIface
89 * @value: a #GValue representing the maximum accessible value
91 * Gets the maximum value of this object.
94 atk_value_get_maximum_value (AtkValue *obj,
99 g_return_if_fail (value != NULL);
100 g_return_if_fail (ATK_IS_VALUE (obj));
102 iface = ATK_VALUE_GET_IFACE (obj);
104 if (iface->get_maximum_value)
106 if (G_IS_VALUE (value))
107 g_value_unset (value);
109 memset (value, 0, sizeof (*value));
111 (iface->get_maximum_value) (obj, value);
116 * atk_value_get_minimum_value:
117 * @obj: a GObject instance that implements AtkValueIface
118 * @value: a #GValue representing the minimum accessible value
120 * Gets the minimum value of this object.
123 atk_value_get_minimum_value (AtkValue *obj,
126 AtkValueIface *iface;
128 g_return_if_fail (value != NULL);
129 g_return_if_fail (ATK_IS_VALUE (obj));
131 iface = ATK_VALUE_GET_IFACE (obj);
133 if (iface->get_minimum_value)
135 if (G_IS_VALUE (value))
136 g_value_unset (value);
138 memset (value, 0, sizeof (*value));
140 (iface->get_minimum_value) (obj, value);
145 * atk_value_get_minimum_increment:
146 * @obj: a GObject instance that implements AtkValueIface
147 * @value: a #GValue representing the minimum increment by which the accessible value may be changed
149 * Gets the minimum increment by which the value of this object may be changed. If zero,
150 * the minimum increment is undefined, which may mean that it is limited only by the
151 * floating point precision of the platform.
156 atk_value_get_minimum_increment (AtkValue *obj,
159 AtkValueIface *iface;
161 g_return_if_fail (value != NULL);
162 g_return_if_fail (ATK_IS_VALUE (obj));
164 iface = ATK_VALUE_GET_IFACE (obj);
166 if (iface->get_minimum_increment)
168 if (G_IS_VALUE (value))
169 g_value_unset (value);
171 memset (value, 0, sizeof (*value));
173 (iface->get_minimum_increment) (obj, value);
178 * atk_value_set_current_value:
179 * @obj: a GObject instance that implements AtkValueIface
180 * @value: a #GValue which is the desired new accessible value.
182 * Sets the value of this object.
184 * Returns: %TRUE if new value is successfully set, %FALSE otherwise.
187 atk_value_set_current_value (AtkValue *obj,
190 AtkValueIface *iface;
192 g_return_val_if_fail (ATK_IS_VALUE (obj), FALSE);
193 g_return_val_if_fail (G_IS_VALUE (value), FALSE);
195 iface = ATK_VALUE_GET_IFACE (obj);
197 if (iface->set_current_value)
198 return (iface->set_current_value) (obj, value);