MSVC Introspection Build: Fix build
[atk.git] / atk / atkvalue.c
blob2a6b083e94202e64c02eddf37027d381fdd43556
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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include <string.h>
21 #include "atkvalue.h"
23 /**
24 * SECTION:atkvalue
25 * @Short_description: The ATK interface implemented by valuators and
26 * components which display or select a value from a bounded range of
27 * values.
28 * @Title:AtkValue
30 * #AtkValue should be implemented for components which either display
31 * a value from a bounded range, or which allow the user to specify a
32 * value from a bounded range, or both. For instance, most sliders
33 * and range controls, as well as dials, should have #AtkObject
34 * representations which implement #AtkValue on the component's
35 * behalf. #AtKValues may be read-only, in which case attempts to
36 * alter the value return FALSE to indicate failure.
39 GType
40 atk_value_get_type (void)
42 static GType type = 0;
44 if (!type) {
45 GTypeInfo tinfo =
47 sizeof (AtkValueIface),
48 (GBaseInitFunc) NULL,
49 (GBaseFinalizeFunc) NULL,
53 type = g_type_register_static (G_TYPE_INTERFACE, "AtkValue", &tinfo, 0);
56 return type;
59 /**
60 * atk_value_get_current_value:
61 * @obj: a GObject instance that implements AtkValueIface
62 * @value: a #GValue representing the current accessible value
64 * Gets the value of this object.
65 **/
66 void
67 atk_value_get_current_value (AtkValue *obj,
68 GValue *value)
70 AtkValueIface *iface;
72 g_return_if_fail (value != NULL);
73 g_return_if_fail (ATK_IS_VALUE (obj));
75 iface = ATK_VALUE_GET_IFACE (obj);
77 if (iface->get_current_value)
79 if (G_IS_VALUE (value))
80 g_value_unset (value);
81 else
82 memset (value, 0, sizeof (*value));
84 (iface->get_current_value) (obj, value);
88 /**
89 * atk_value_get_maximum_value:
90 * @obj: a GObject instance that implements AtkValueIface
91 * @value: a #GValue representing the maximum accessible value
93 * Gets the maximum value of this object.
94 **/
95 void
96 atk_value_get_maximum_value (AtkValue *obj,
97 GValue *value)
99 AtkValueIface *iface;
101 g_return_if_fail (value != NULL);
102 g_return_if_fail (ATK_IS_VALUE (obj));
104 iface = ATK_VALUE_GET_IFACE (obj);
106 if (iface->get_maximum_value)
108 if (G_IS_VALUE (value))
109 g_value_unset (value);
110 else
111 memset (value, 0, sizeof (*value));
113 (iface->get_maximum_value) (obj, value);
118 * atk_value_get_minimum_value:
119 * @obj: a GObject instance that implements AtkValueIface
120 * @value: a #GValue representing the minimum accessible value
122 * Gets the minimum value of this object.
124 void
125 atk_value_get_minimum_value (AtkValue *obj,
126 GValue *value)
128 AtkValueIface *iface;
130 g_return_if_fail (value != NULL);
131 g_return_if_fail (ATK_IS_VALUE (obj));
133 iface = ATK_VALUE_GET_IFACE (obj);
135 if (iface->get_minimum_value)
137 if (G_IS_VALUE (value))
138 g_value_unset (value);
139 else
140 memset (value, 0, sizeof (*value));
142 (iface->get_minimum_value) (obj, value);
147 * atk_value_get_minimum_increment:
148 * @obj: a GObject instance that implements AtkValueIface
149 * @value: a #GValue representing the minimum increment by which the accessible value may be changed
151 * Gets the minimum increment by which the value of this object may be changed. If zero,
152 * the minimum increment is undefined, which may mean that it is limited only by the
153 * floating point precision of the platform.
155 * Since: 1.12
157 void
158 atk_value_get_minimum_increment (AtkValue *obj,
159 GValue *value)
161 AtkValueIface *iface;
163 g_return_if_fail (value != NULL);
164 g_return_if_fail (ATK_IS_VALUE (obj));
166 iface = ATK_VALUE_GET_IFACE (obj);
168 if (iface->get_minimum_increment)
170 if (G_IS_VALUE (value))
171 g_value_unset (value);
172 else
173 memset (value, 0, sizeof (*value));
175 (iface->get_minimum_increment) (obj, value);
180 * atk_value_set_current_value:
181 * @obj: a GObject instance that implements AtkValueIface
182 * @value: a #GValue which is the desired new accessible value.
184 * Sets the value of this object.
186 * Returns: %TRUE if new value is successfully set, %FALSE otherwise.
188 gboolean
189 atk_value_set_current_value (AtkValue *obj,
190 const GValue *value)
192 AtkValueIface *iface;
194 g_return_val_if_fail (ATK_IS_VALUE (obj), FALSE);
195 g_return_val_if_fail (G_IS_VALUE (value), FALSE);
197 iface = ATK_VALUE_GET_IFACE (obj);
199 if (iface->set_current_value)
200 return (iface->set_current_value) (obj, value);
201 else
202 return FALSE;