added evas object box
[ego.git] / src / lib / box.c
blob49e29367b985c82be342a7be1b7212f8a0490d2a
1 #include "box.h"
2 #include "luaobj.h"
3 #include "class.h"
4 #include "object.h"
5 #include "macro.h"
6 #include <Evas.h>
8 GET_TAB2INTEGER (lbox_get_padding, evas_object_box_padding_get);
9 SET_TAB2INTEGER (lbox_set_padding, evas_object_box_padding_set);
11 GET_TAB2FLOAT (lbox_get_align, evas_object_box_align_get);
12 SET_TAB2FLOAT (lbox_set_align, evas_object_box_align_set);
14 FN_OBJ (lbox_fn_append, evas_object_box_append);
15 FN_OBJ (lbox_fn_prepend, evas_object_box_prepend);
16 FN_2OBJ (lbox_fn_insert_before, evas_object_box_insert_before);
18 static int
19 lbox_fn_insert_at (lua_State *L)
21 luaobj_Object *obj = lua_touserdata (L, 1);
22 luaobj_Object *tar = lua_touserdata (L, 2);
23 evas_object_box_insert_at (
24 obj->data,
25 tar->data,
26 luaL_checkinteger (L, 3));
27 return 0;
30 FN_OBJ (lbox_fn_remove, evas_object_box_remove);
31 FN_INTEGER (lbox_fn_remove_at, evas_object_box_remove_at);
33 static int
34 lbox_set_layout (lua_State *L)
36 luaobj_Object *obj = lua_touserdata (L, 1);
37 const char *layout = luaL_checkstring (L, 2);
38 if (!strcmp (layout, "horizontal"))
39 evas_object_box_layout_set (
40 obj->data,
41 evas_object_box_layout_horizontal,
42 NULL, NULL);
43 else if (!strcmp (layout, "vertical"))
44 evas_object_box_layout_set (
45 obj->data,
46 evas_object_box_layout_vertical,
47 NULL, NULL);
48 else if (!strcmp (layout, "homogeneous_horizontal"))
49 evas_object_box_layout_set (
50 obj->data,
51 evas_object_box_layout_homogeneous_horizontal,
52 NULL, NULL);
53 else if (!strcmp (layout, "homogeneous_vertical"))
54 evas_object_box_layout_set (
55 obj->data,
56 evas_object_box_layout_homogeneous_vertical,
57 NULL, NULL);
58 else if (!strcmp (layout, "homogeneous_max_size_horizontal"))
59 evas_object_box_layout_set (
60 obj->data,
61 evas_object_box_layout_homogeneous_max_size_horizontal,
62 NULL, NULL);
63 else if (!strcmp (layout, "homogeneous_max_size_vertical"))
64 evas_object_box_layout_set (
65 obj->data,
66 evas_object_box_layout_homogeneous_max_size_vertical,
67 NULL, NULL);
68 else if (!strcmp (layout, "flow_horizontal"))
69 evas_object_box_layout_set (
70 obj->data,
71 evas_object_box_layout_flow_horizontal,
72 NULL, NULL);
73 else if (!strcmp (layout, "flow_vertical"))
74 evas_object_box_layout_set (
75 obj->data,
76 evas_object_box_layout_flow_vertical,
77 NULL, NULL);
78 else if (!strcmp (layout, "stack"))
79 evas_object_box_layout_set (
80 obj->data,
81 evas_object_box_layout_stack,
82 NULL, NULL);
83 else
84 printf ("layout <%s> not found\n", layout);
85 return 0;
88 const struct luaL_Reg lBox_fn[] = {
89 {"append", lbox_fn_append},
90 {"prepend", lbox_fn_prepend},
91 {"insert_before", lbox_fn_insert_before},
92 {"insert_at", lbox_fn_insert_at},
93 {"remove", lbox_fn_remove},
94 {"remove_at", lbox_fn_remove_at},
95 {NULL, NULL} // sentinel
98 const struct luaL_Reg lBox_get[] = {
99 {"padding", lbox_get_padding},
100 {"align", lbox_get_align},
101 {NULL, NULL} // sentinel
104 const struct luaL_Reg lBox_set[] = {
105 {"layout", lbox_set_layout},
106 {"padding", lbox_set_padding},
107 {"align", lbox_set_align},
108 {NULL, NULL} // sentinel
110 const luaL_Reg lBox_nil [] = {
111 {NULL, NULL} // sentinel
114 const luaobj_Reg mBox = {
115 lBox_nil, // mt
116 lBox_get,
117 lBox_set,
118 lBox_fn
121 const luaobj_Reg *cBox [] = {
122 &mClass,
123 &mObject,
124 &mBox,
125 NULL // sentinel