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.
21 * @file eail_colorselector.c
22 * @brief EailColorselector implementation.
25 #include <Elementary.h>
27 #include "eail_colorselector.h"
28 #include "eail_utils.h"
30 static void atk_value_interface_init(AtkValueIface *iface);
33 * @brief EailColorselector type definition
35 G_DEFINE_TYPE_WITH_CODE(EailColorselector,
38 G_IMPLEMENT_INTERFACE(ATK_TYPE_VALUE,
39 atk_value_interface_init));
42 * @brief handler for changed event
44 * @param data passed to callback
45 * @param obj object that raised event
46 * @param event_info additional event info
50 _eail_colorselector_handle_changed_event(void *data,
55 (ATK_OBJECT(data), "visible-data-changed", ATK_TYPE_OBJECT);
59 * @brief EailColorselector initializer
61 * @param obj AtkObject instance
62 * @param data initialization data
65 eail_colorselector_initialize(AtkObject *obj, gpointer data)
67 Evas_Object *nested_widget = NULL;
68 ATK_OBJECT_CLASS(eail_colorselector_parent_class)->initialize(obj, data);
70 obj->role = ATK_ROLE_COLOR_CHOOSER;
71 g_return_if_fail(EAIL_IS_WIDGET(obj));
73 nested_widget = eail_widget_get_widget(EAIL_WIDGET(obj));
74 evas_object_smart_callback_add(nested_widget, "changed",
75 _eail_colorselector_handle_changed_event, obj);
79 * @brief EailColorselector instance initializer
81 * @param selector EailColorselector instance
84 eail_colorselector_init(EailColorselector *selector)
89 * @brief EailColorselector class initializer
91 * @param klass EailColorselectorClass instance
94 eail_colorselector_class_init(EailColorselectorClass *klass)
96 AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
97 atk_class->initialize = eail_colorselector_initialize;
101 * @brief Gets obj's current value
103 * @param obj AtkValue instance
104 * @param [out] value obj's current value
107 eail_colorselector_get_current_value(AtkValue *obj,
115 Evas_Object *widget = NULL;
117 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
120 elm_colorselector_color_get(widget, &r, &g, &b, &a);
121 color = (a << 24) | (r << 16) | (g << 8) | b;
123 memset(value, 0, sizeof(GValue));
124 g_value_init(value, G_TYPE_INT);
125 g_value_set_int(value, color);
129 * @brief Gets obj's maxiumum value
131 * @param obj AtkValue instance
132 * @param [out] value obj's maximum value
135 eail_colorselector_get_maximum_value(AtkValue *obj,
138 gint max = 0xFFFFFFFF;
139 Evas_Object *widget = NULL;
141 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
144 memset(value, 0, sizeof(GValue));
145 g_value_init(value, G_TYPE_INT);
146 g_value_set_int(value, max);
150 * @brief Gets obj's minimum value
152 * @param obj AtkValue instance
153 * @param [out] value obj's minimum value
156 eail_colorselector_get_minimum_value(AtkValue *obj,
160 Evas_Object *widget = NULL;
162 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
165 memset(value, 0, sizeof(GValue));
166 g_value_init(value, G_TYPE_INT);
167 g_value_set_int(value, min);
171 * @brief Sets obj's current value
173 * @param obj AtkValue instance
174 * @param value obj's current value
175 * @return TRUE if value was set successfully, FALSE otherwise
178 eail_colorselector_set_current_value(AtkValue *obj,
185 gint color = 0xFFFFFFFF;
186 Evas_Object *widget = NULL;
188 widget = eail_widget_get_widget(EAIL_WIDGET(obj));
189 if (!widget) return FALSE;
191 color = g_value_get_int(value);
192 a = (0xFF000000 & (guint)color) >> 24;
193 r = (0x00FF0000 & color) >> 16;
194 g = (0x0000FF00 & color) >> 8;
195 b = 0x000000FF & color;
196 elm_colorselector_color_set(widget, r, g, b, a);
202 * @brief Gets obj's minimum increment
204 * @param obj AtkValue instance
205 * @param [out] value obj's minimum increment
208 eail_colorselector_get_minimum_increment(AtkValue *obj,
211 gint inc = 0x01010101;
213 memset(value, 0, sizeof(GValue));
214 g_value_init(value, G_TYPE_INT);
215 g_value_set_int(value, inc);
219 * @brief AtkValue interface initializer
221 * @param iface AtkValueIface instance
223 static void atk_value_interface_init(AtkValueIface *iface)
225 iface->get_current_value = eail_colorselector_get_current_value;
226 iface->get_maximum_value = eail_colorselector_get_maximum_value;
227 iface->get_minimum_value = eail_colorselector_get_minimum_value;
228 iface->set_current_value = eail_colorselector_set_current_value;
229 iface->get_minimum_increment = eail_colorselector_get_minimum_increment;