2 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
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 License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 * @brief EailPanes implementation
25 #include <Elementary.h>
27 #include "eail_panes.h"
28 #include "eail_factory.h"
29 #include "eail_priv.h"
31 static void atk_value_interface_init(AtkValueIface *iface);
34 * @brief EailPanes type definition
36 G_DEFINE_TYPE_WITH_CODE(EailPanes,
39 G_IMPLEMENT_INTERFACE(ATK_TYPE_VALUE,
40 atk_value_interface_init));
43 * @brief EailPanes initializer
45 * @param obj AtkObject instance
46 * @param data initialization data
49 eail_panes_initialize(AtkObject *obj, gpointer data)
51 ATK_OBJECT_CLASS(eail_panes_parent_class)->initialize(obj, data);
52 obj->role = ATK_ROLE_SPLIT_PANE;
56 * @brief EailPanes instance initializer
58 * @param panes EailPanes instance
61 eail_panes_init(EailPanes *panes)
66 * @brief Gets the number of children of obj
68 * @param obj AtkObject instance
69 * @returns integer representing the number of children
72 eail_panes_n_children_get(AtkObject *obj)
74 g_return_val_if_fail(EAIL_IS_PANES(obj), 0);
80 * @brief Gets the state set of obj
82 * @param obj AtkObject instance
83 * @return AtkStateSet representing the state set of obj
86 eail_panes_ref_state_set(AtkObject *obj)
88 AtkStateSet *state_set;
91 state_set = ATK_OBJECT_CLASS(eail_panes_parent_class)->ref_state_set(obj);
92 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
94 if (widget == NULL) return state_set;
96 if (elm_panes_horizontal_get(widget))
97 atk_state_set_add_state(state_set, ATK_STATE_HORIZONTAL);
99 atk_state_set_add_state(state_set, ATK_STATE_VERTICAL);
105 * @brief Gets the specified child of obj
107 * The caller must unreference it when it is no longer needed.
109 * @param obj AtkObject instance
110 * @param i child index
111 * @return AtkObject representing the specified child of obj
114 eail_panes_ref_child(AtkObject *obj, int i)
116 Evas_Object *e_object, *widget;
119 g_return_val_if_fail(EAIL_IS_PANES(obj), NULL);
120 g_return_val_if_fail((i < 2), NULL);
122 e_object = eail_widget_get_widget(EAIL_WIDGET(obj));
126 widget = elm_object_part_content_get(e_object, "left");
127 child = eail_factory_get_accessible(widget);
130 widget = elm_object_part_content_get(e_object, "right");
131 child = eail_factory_get_accessible(widget);
145 * @brief EailPanes class initializer
147 * @param klass EailPanesClass instance
150 eail_panes_class_init(EailPanesClass *klass)
152 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
154 atk_class->initialize = eail_panes_initialize;
155 atk_class->get_n_children = eail_panes_n_children_get;
156 atk_class->ref_child = eail_panes_ref_child;
157 atk_class->ref_state_set = eail_panes_ref_state_set;
161 * @brief Gets the maximum value of obj
163 * @param obj AtkValue instance
164 * @param [out] value maxiumum value of obj
167 eail_panes_maximum_value_get(AtkValue *obj, GValue *value)
169 g_return_if_fail(EAIL_IS_PANES(obj));
171 memset(value, 0, sizeof(GValue));
172 g_value_init(value, G_TYPE_DOUBLE);
173 g_value_set_double(value, 1.0);
177 * @brief Gets the minimum value of obj
179 * @param obj AtkValue instance
180 * @param [out] value minimum value of obj
183 eail_panes_minimum_value_get(AtkValue *obj, GValue *value)
185 g_return_if_fail(EAIL_IS_PANES(obj));
187 memset(value, 0, sizeof(GValue));
188 g_value_init(value, G_TYPE_DOUBLE);
189 g_value_set_double(value, 0.0);
193 * @brief Sets the current value of obj
195 * @param obj AtkValue instance
196 * @param value new value of obj
197 * @return TRUE if value is set successfully, FALSE otherwise
200 eail_panes_current_value_set(AtkValue *obj, const GValue *value)
205 g_return_val_if_fail(EAIL_IS_PANES(obj), FALSE);
207 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
208 if (!widget) return FALSE;
210 if (G_VALUE_HOLDS_DOUBLE(value))
211 new_value = g_value_get_double(value);
215 if ((new_value >= 0.0) && (new_value <= 1.0))
217 elm_panes_content_left_size_set(widget, new_value);
225 * @brief Gets the current value of obj
227 * @param obj AtkValue instance
228 * @param [out] value current value of obj
231 eail_panes_current_value_get(AtkValue *obj, GValue *value)
234 gdouble current_value;
236 g_return_if_fail(EAIL_IS_PANES(obj));
237 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
240 current_value = elm_panes_content_left_size_get(widget);
241 memset(value, 0, sizeof(GValue));
242 g_value_init(value, G_TYPE_DOUBLE);
243 g_value_set_double(value, current_value);
247 * @brief Gets obj's minimum increment
249 * The minimum increment is limited only by the floating point
250 * precision of the platform.
252 * @param obj AtkValue instance
253 * @param [out] value minimum increment of obj
256 eail_panes_minimum_increment_get(AtkValue *obj,
261 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
264 memset(value, 0, sizeof(GValue));
265 g_value_init(value, G_TYPE_DOUBLE);
266 g_value_set_double(value, 0);
270 * @brief AtkValue interface initializer
272 * @param iface AtkValueIface instance
275 atk_value_interface_init(AtkValueIface *iface)
277 g_return_if_fail(iface != NULL);
279 iface->get_current_value = eail_panes_current_value_get;
280 iface->set_current_value = eail_panes_current_value_set;
281 iface->get_maximum_value = eail_panes_maximum_value_get;
282 iface->get_minimum_value = eail_panes_minimum_value_get;
283 iface->get_minimum_increment = eail_panes_minimum_increment_get;