[SLP Merge] Thu Jul 7 13:20:56 2011 +0900
[framework/uifw/elementary.git] / src / edje_externals / elm_panes.c
1 #include "private.h"
2 #include <assert.h>
3
4
5 typedef struct _Elm_Params_Panes Elm_Params_Panes;
6
7 struct _Elm_Params_Panes {
8         Elm_Params base;
9         Evas_Object *content_left;
10         Evas_Object *content_right;
11         Eina_Bool is_horizontal;
12         Eina_Bool horizontal;
13         Eina_Bool is_left_size;
14         double left_size;
15         Eina_Bool is_fixed;
16         Eina_Bool fixed;
17 };
18
19 static void external_panes_state_set(void *data __UNUSED__,
20                 Evas_Object *obj, const void *from_params,
21                 const void *to_params, float pos __UNUSED__)
22 {
23         const Elm_Params_Panes *p;
24
25         if (to_params) p = to_params;
26         else if (from_params) p = from_params;
27         else return;
28
29         if (p->content_left)
30                 elm_panes_content_left_set(obj, p->content_left);
31
32         if (p->content_right)
33                 elm_panes_content_right_set(obj, p->content_right);
34
35         if(p->is_left_size)
36                 elm_panes_content_left_size_set(obj, p->left_size);
37
38         if(p->is_horizontal)
39                 elm_panes_horizontal_set(obj, p->horizontal);
40
41         if(p->is_fixed)
42                 elm_panes_fixed_set(obj, p->fixed);
43 }
44
45 static Eina_Bool external_panes_param_set(void *data __UNUSED__,
46                 Evas_Object *obj, const Edje_External_Param *param)
47 {
48         if ((!strcmp(param->name, "content left"))
49                         && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
50         {
51                 Evas_Object *content = external_common_param_edje_object_get(obj, param);
52                 if ((strcmp(param->s, "")) && (!content))
53                         return EINA_FALSE;
54                 elm_panes_content_left_set(obj, content);
55                 return EINA_TRUE;
56         }
57         else if ((!strcmp(param->name, "content right"))
58                         && (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
59         {
60                 Evas_Object *content = external_common_param_edje_object_get(obj, param);
61                 if ((strcmp(param->s, "")) && (!content))
62                         return EINA_FALSE;
63                 elm_panes_content_right_set(obj, content);
64                 return EINA_TRUE;
65         }
66         else if ((!strcmp(param->name, "horizontal"))
67                         && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
68         {
69                 elm_panes_horizontal_set(obj, param->i);
70                 return EINA_TRUE;
71         }
72         else if ((!strcmp(param->name, "left size"))
73                         && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
74         {
75                 elm_panes_content_left_size_set(obj, param->d);
76                 return EINA_TRUE;
77         }
78         else if ((!strcmp(param->name, "fixed"))
79                                         && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
80         {
81                         elm_panes_fixed_set(obj, param->i);
82                         return EINA_TRUE;
83         }
84
85         ERR("unknown parameter '%s' of type '%s'",
86                         param->name, edje_external_param_type_str(param->type));
87
88         return EINA_FALSE;
89 }
90
91 static Eina_Bool external_panes_param_get(void *data __UNUSED__,
92                 const Evas_Object *obj, Edje_External_Param *param)
93 {
94         if (!strcmp(param->name, "content left"))
95         {
96                 /* not easy to get content name back from live object */
97                 return EINA_FALSE;
98         }
99         else if (!strcmp(param->name, "content right"))
100         {
101                 /* not easy to get content name back from live object */
102                 return EINA_FALSE;
103         }
104         else if ((!strcmp(param->name, "horizontal"))
105                         && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
106         {
107                 param->i = elm_panes_horizontal_get(obj);
108                 return EINA_TRUE;
109         }
110         else if ((!strcmp(param->name, "left size"))
111                         && (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE))
112         {
113                 param->d = elm_panes_content_left_size_get(obj);
114                 return EINA_TRUE;
115         }
116         else if ((!strcmp(param->name, "fixed"))
117                                         && (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL))
118         {
119                         param->i = elm_panes_fixed_get(obj);
120                         return EINA_TRUE;
121         }
122
123         ERR("unknown parameter '%s' of type '%s'",
124                         param->name, edje_external_param_type_str(param->type));
125
126         return EINA_FALSE;
127 }
128
129 static void * external_panes_params_parse(void *data __UNUSED__, Evas_Object *obj,
130                 const Eina_List *params) {
131         Elm_Params_Panes *mem;
132         Edje_External_Param *param;
133         const Eina_List *l;
134
135         mem = calloc(1, sizeof(Elm_Params_Panes));
136         if (!mem)
137                 return NULL;
138
139         EINA_LIST_FOREACH(params, l, param)
140         {
141                 if (!strcmp(param->name, "content left"))
142                         mem->content_left = external_common_param_edje_object_get(obj, param);
143                 else if (!strcmp(param->name, "content right"))
144                                 mem->content_right = external_common_param_edje_object_get(obj, param);
145                 else if (!strcmp(param->name, "horizontal"))
146                 {
147                         mem->is_horizontal = EINA_TRUE;
148                         mem->horizontal = param->i;
149                 }
150                 else if (!strcmp(param->name, "left size"))
151                 {
152                         mem->is_left_size = EINA_TRUE;
153                         mem->left_size = param->d;
154                 }
155                 else if (!strcmp(param->name, "fixed"))
156                 {
157                                 mem->is_fixed = EINA_TRUE;
158                                 mem->fixed = param->i;
159                 }
160
161         }
162
163         return mem;
164 }
165
166 static Evas_Object *external_panes_content_get(void *data __UNUSED__,
167                 const Evas_Object *obj, const char *content)
168 {
169         if (!strcmp(content, "left"))
170                 return elm_panes_content_left_get(obj);
171         else if (!strcmp(content, "right"))
172                 return elm_panes_content_right_get(obj);
173
174         ERR("unknown content '%s'", content);
175
176         return NULL;
177 }
178
179
180 static void external_panes_params_free(void *params) {
181         free(params);
182 }
183
184 static Edje_External_Param_Info external_panes_params[] = {
185                 DEFINE_EXTERNAL_COMMON_PARAMS,
186                 EDJE_EXTERNAL_PARAM_INFO_STRING("content left"),
187                 EDJE_EXTERNAL_PARAM_INFO_STRING("content right"),
188                 EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal"),
189                 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("left size"),
190                 EDJE_EXTERNAL_PARAM_INFO_BOOL("fixed"),
191                 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
192 };
193
194 DEFINE_EXTERNAL_ICON_ADD(panes, "panes");
195 DEFINE_EXTERNAL_TYPE_SIMPLE(panes, "panes");