Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / eail / eail_mapbuf.c
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 /**
21  * @file eail_mapbuf.c
22  * @brief EailMapbuf implementation
23  */
24
25 #include <Elementary.h>
26
27 #include "eail_mapbuf.h"
28
29 /**
30  * @brief EailMapbuf type definition
31  */
32 G_DEFINE_TYPE(EailMapbuf, eail_mapbuf, EAIL_TYPE_WIDGET);
33
34 /**
35  * @brief EailMapbuf initializer
36  *
37  * @param obj AtkObject instance
38  * @param data initialization data
39  */
40 static void
41 eail_mapbuf_initialize(AtkObject *obj, gpointer data)
42 {
43    ATK_OBJECT_CLASS(eail_mapbuf_parent_class)->initialize(obj, data);
44    obj->role = ATK_ROLE_IMAGE_MAP;
45 }
46 /**
47  * @brief Gets widget's children
48  *
49  * @param widget EailWidget instance
50  * @return Eina_List containing widget's children
51  */
52 static Eina_List*
53 eail_mapbuf_children_get(EailWidget *widget)
54 {
55    Eina_List *list = NULL;
56    Evas_Object *o, *object;
57
58    g_return_val_if_fail(EAIL_IS_WIDGET(widget), NULL);
59
60    object = eail_widget_get_widget(widget);
61
62    o = elm_object_part_content_get(object, "default");
63    if (!o) return NULL;
64
65    list = eina_list_append(list, o);
66    return list;
67 }
68
69 /**
70  * @brief Gets object's state set
71  *
72  * The caller must unreference it when it is no longed needed.
73  *
74  * @param object AtkObject instance
75  * @return AtkStateSet* containing object's state set
76  */
77 static AtkStateSet*
78 eail_mapbuf_ref_state_set(AtkObject *object)
79 {
80    AtkStateSet *state_set;
81    Evas_Object *widget;
82
83    g_return_val_if_fail(EAIL_IS_MAPBUF(object), NULL);
84    widget = eail_widget_get_widget(EAIL_WIDGET(object));
85    if (!widget) return NULL;
86
87    state_set =
88       ATK_OBJECT_CLASS(eail_mapbuf_parent_class)->ref_state_set(object);
89    if (elm_mapbuf_enabled_get(widget))
90      atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
91
92    return state_set;
93 }
94
95 /**
96  * @brief EailMapbuf instance initializer
97  *
98  * @param mapbuf EailMapbuf instance
99  */
100 static void
101 eail_mapbuf_init(EailMapbuf *mapbuf)
102 {
103 }
104
105 /**
106  * @brief EailMapbuf class initializer
107  *
108  * @param klass EailMapbufClass instance
109  */
110 static void
111 eail_mapbuf_class_init(EailMapbufClass *klass)
112 {
113    AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
114    EailWidgetClass *widget_class = EAIL_WIDGET_CLASS(klass);
115
116    atk_class->initialize = eail_mapbuf_initialize;
117    atk_class->ref_state_set = eail_mapbuf_ref_state_set;
118
119    widget_class->get_widget_children = eail_mapbuf_children_get;
120 }