added evas object box
[ego.git] / src / lib / part.c
blob665d498415b7c2e2881edf3690b87cdb54ca3b69
1 #include "part.h"
2 #include "class.h"
3 #include "object.h"
5 /*
6 * edje part functions implementations
7 */
9 static int
10 lpart_fn_unswallow (lua_State * L)
12 /* 1: part
14 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
15 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
16 const char *key = evas_object_data_get (obj->data, "key");
17 Evas_Object *swa = edje_object_part_swallow_get (edj, key);
18 edje_object_part_unswallow (edj, swa);
19 return 0;
23 * edje part get implementations
26 static int
27 lpart_get_geometry (lua_State * L)
29 /* 1: part
31 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
32 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
33 const char *key = evas_object_data_get (obj->data, "key");
34 int x, y, w, h;
35 edje_object_part_geometry_get (edj, key, &x, &y, &w, &h);
36 lua_newtable (L);
37 lua_pushnumber (L, x);
38 lua_rawseti (L, -2, 1);
39 lua_pushnumber (L, y);
40 lua_rawseti (L, -2, 2);
41 lua_pushnumber (L, w);
42 lua_rawseti (L, -2, 3);
43 lua_pushnumber (L, h);
44 lua_rawseti (L, -2, 4);
45 return 1;
48 static int
49 lpart_get_text (lua_State * L)
51 /* 1: part
53 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
54 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
55 const char *key = evas_object_data_get (obj->data, "key");
56 lua_pushstring (L, edje_object_part_text_get (edj, key));
57 return 1;
60 static int
61 lpart_get_swallow (lua_State * L)
63 /* 1: part
65 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
66 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
67 const char *key = evas_object_data_get (obj->data, "key");
68 Evas_Object *swa = edje_object_part_swallow_get (edj, key);
69 if (swa)
71 luaobj_Ref *ref = (luaobj_Ref *) evas_object_data_get (swa, "luaobj");
72 luaobj_get_ref (L, ref);
74 else
75 lua_pushnil (L);
76 return 1;
79 static int
80 lpart_get_state (lua_State * L)
82 /* 1: part
84 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
85 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
86 const char *key = evas_object_data_get (obj->data, "key");
87 double val;
88 const char *state = edje_object_part_state_get (edj, key, &val);
89 lua_newtable (L);
90 lua_pushstring (L, state);
91 lua_rawseti (L, -2, 1);
92 lua_pushnumber (L, val);
93 lua_rawseti (L, -2, 2);
94 return 1;
97 static int
98 lpart_get_drag_dir (lua_State * L)
100 /* 1: part
102 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
103 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
104 const char *key = evas_object_data_get (obj->data, "key");
105 lua_pushnumber (L, edje_object_part_drag_dir_get (edj, key));
106 return 1;
109 static int
110 lpart_get_drag_value (lua_State * L)
112 /* 1: part
114 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
115 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
116 const char *key = evas_object_data_get (obj->data, "key");
117 double dx, dy;
118 edje_object_part_drag_value_get (edj, key, &dx, &dy);
119 lua_newtable (L);
120 lua_pushnumber (L, dx);
121 lua_rawseti (L, -2, 1);
122 lua_pushnumber (L, dy);
123 lua_rawseti (L, -2, 2);
124 return 1;
127 static int
128 lpart_get_drag_size (lua_State * L)
130 /* 1: part
132 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
133 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
134 const char *key = evas_object_data_get (obj->data, "key");
135 double dx, dy;
136 edje_object_part_drag_size_get (edj, key, &dx, &dy);
137 lua_newtable (L);
138 lua_pushnumber (L, dx);
139 lua_rawseti (L, -2, 1);
140 lua_pushnumber (L, dy);
141 lua_rawseti (L, -2, 2);
142 return 1;
145 static int
146 lpart_get_drag_step (lua_State * L)
148 /* 1: part
150 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
151 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
152 const char *key = evas_object_data_get (obj->data, "key");
153 double dx, dy;
154 edje_object_part_drag_step_get (edj, key, &dx, &dy);
155 lua_newtable (L);
156 lua_pushnumber (L, dx);
157 lua_rawseti (L, -2, 1);
158 lua_pushnumber (L, dy);
159 lua_rawseti (L, -2, 2);
160 return 1;
163 static int
164 lpart_get_drag_page (lua_State * L)
166 /* 1: part
168 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
169 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
170 const char *key = evas_object_data_get (obj->data, "key");
171 double dx, dy;
172 edje_object_part_drag_page_get (edj, key, &dx, &dy);
173 lua_newtable (L);
174 lua_pushnumber (L, dx);
175 lua_rawseti (L, -2, 1);
176 lua_pushnumber (L, dy);
177 lua_rawseti (L, -2, 2);
178 return 1;
182 * edje part set implementtions
185 static int
186 lpart_set_swallow (lua_State * L)
188 /* 1: part
189 * 2: swallow
191 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
192 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
193 const char *key = evas_object_data_get (obj->data, "key");
194 luaobj_Object *swa = (luaobj_Object *) lua_touserdata (L, 2);
195 edje_object_part_swallow (edj, key, swa->data);
196 // FIXME set clip for elementary objects
197 return 0;
200 static int
201 lpart_set_text (lua_State * L)
203 /* 1: part
204 * 2: text
206 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
207 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
208 const char *key = evas_object_data_get (obj->data, "key");
209 edje_object_part_text_set (edj, key, luaL_checkstring (L, 2));
210 return 0;
213 static int
214 lpart_set_drag_value (lua_State * L)
216 /* 1: part
217 * 2: table {dx,dy}
219 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
220 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
221 const char *key = evas_object_data_get (obj->data, "key");
222 lua_rawgeti (L, 2, 1);
223 lua_rawgeti (L, 2, 2);
224 edje_object_part_drag_value_set (edj, key,
225 (int) luaL_checknumber (L, -2),
226 (int) luaL_checknumber (L, -1));
227 return 0;
230 static int
231 lpart_set_drag_size (lua_State * L)
233 /* 1: part
234 * 2: table {dx,dy}
236 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
237 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
238 const char *key = evas_object_data_get (obj->data, "key");
239 lua_rawgeti (L, 2, 1);
240 lua_rawgeti (L, 2, 2);
241 edje_object_part_drag_size_set (edj, key,
242 (int) luaL_checknumber (L, -2),
243 (int) luaL_checknumber (L, -1));
244 return 0;
247 static int
248 lpart_set_drag_step (lua_State * L)
250 /* 1: part
251 * 2: table {dx,dy}
253 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
254 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
255 const char *key = evas_object_data_get (obj->data, "key");
256 lua_rawgeti (L, 2, 1);
257 lua_rawgeti (L, 2, 2);
258 edje_object_part_drag_step_set (edj, key,
259 (int) luaL_checknumber (L, -2),
260 (int) luaL_checknumber (L, -1));
261 return 0;
264 static int
265 lpart_set_drag_page (lua_State * L)
267 /* 1: part
268 * 2: table {dx,dy}
270 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
271 Evas_Object *edj = evas_object_data_get (obj->data, "edje");
272 const char *key = evas_object_data_get (obj->data, "key");
273 lua_rawgeti (L, 2, 1);
274 lua_rawgeti (L, 2, 2);
275 edje_object_part_drag_page_set (edj, key,
276 (int) luaL_checknumber (L, -2),
277 (int) luaL_checknumber (L, -1));
278 return 0;
283 * edje part function definitions
286 const struct luaL_Reg lPart_fn[] = {
287 {"unswallow", lpart_fn_unswallow},
289 /* FIXME
290 {"drag_step",lpart_fn_drag_step},
291 {"drag_page",lpart_fn_drag_page},
294 {NULL, NULL} // sentinel
298 * edje part get definitions
301 const struct luaL_Reg lPart_get[] = {
302 {"geometry", lpart_get_geometry},
303 {"text", lpart_get_text},
305 {"swallow", lpart_get_swallow},
306 {"state", lpart_get_state},
308 {"drag_dir", lpart_get_drag_dir},
309 {"drag_value", lpart_get_drag_value},
310 {"drag_size", lpart_get_drag_size},
311 {"drag_step", lpart_get_drag_step},
312 {"drag_page", lpart_get_drag_page},
313 {NULL, NULL} // sentinel
317 * edje part set definitions
320 const struct luaL_Reg lPart_set[] = {
321 {"swallow", lpart_set_swallow},
322 {"text", lpart_set_text},
324 {"drag_value", lpart_set_drag_value},
325 {"drag_size", lpart_set_drag_size},
326 {"drag_step", lpart_set_drag_step},
327 {"drag_page", lpart_set_drag_page},
328 {NULL, NULL} // sentinel
332 * edje part definitions
335 const luaL_Reg lPart_nil [] = {
336 {NULL, NULL} // sentinel
339 const luaobj_Reg mPart = {
340 lPart_nil,
341 lPart_get,
342 lPart_set,
343 lPart_fn
346 const luaobj_Reg *cPart[] = {
347 &mClass,
348 &mObject,
349 &mPart,
350 NULL