Eobj: eobj.h -> Eobj.h
[profile/ivi/eobj.git] / examples / evas / elw_box.c
1 #include <Elementary.h>
2
3 #include "Eobj.h"
4 #include "evas_obj.h"
5 #include "elw_box.h"
6
7 EAPI Eobj_Op ELW_BOX_BASE_ID = 0;
8
9 typedef struct
10 {
11    Evas_Object *bx;
12 } Widget_Data;
13
14 static Eobj_Class *_my_class = NULL;
15
16 static void
17 _pack_end(Eobj *obj, Eobj_Op op, va_list *list)
18 {
19    Widget_Data *wd = eobj_data_get(obj, _my_class);
20    (void) op;
21    Eobj *child_obj;
22    child_obj = va_arg(*list, Eobj *);
23    /* FIXME: Ref and the later uref child_obj here... */
24    elm_box_pack_end(wd->bx, eobj_evas_object_get(child_obj));
25 }
26
27 static void
28 _constructor(Eobj *obj)
29 {
30    eobj_constructor_super(obj);
31
32    Widget_Data *wd = eobj_data_get(obj, _my_class);
33
34    /* FIXME: An hack, because our tree is not yet only Eobj */
35    wd->bx = elm_box_add(eobj_evas_object_get(eobj_parent_get(obj)));
36    evas_object_size_hint_align_set(wd->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
37    evas_object_size_hint_weight_set(wd->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
38
39    eobj_evas_object_set(obj, wd->bx);
40 }
41
42 static void
43 _destructor(Eobj *obj)
44 {
45    eobj_destructor_super(obj);
46
47    //Widget_Data *wd = eobj_data_get(obj, _my_class);
48    /* FIXME: Commented out because it's automatically done because our tree
49     * is not made of only eobj */
50 //   evas_object_del(wd->bx);
51 }
52
53 static void
54 _class_constructor(Eobj_Class *klass)
55 {
56    const Eobj_Op_Func_Description func_desc[] = {
57         EOBJ_OP_FUNC_DESCRIPTION(ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), _pack_end),
58         EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
59    };
60
61    eobj_class_funcs_set(klass, func_desc);
62 }
63
64 const Eobj_Class *
65 elw_box_class_get(void)
66 {
67    if (_my_class) return _my_class;
68
69    static const Eobj_Op_Description op_desc[] = {
70         EOBJ_OP_DESCRIPTION(ELW_BOX_SUB_ID_PACK_END, "o", "Pack obj at the end of box."),
71         EOBJ_OP_DESCRIPTION_SENTINEL
72    };
73
74    static const Eobj_Class_Description class_desc = {
75         "Elw Box",
76         EOBJ_CLASS_TYPE_REGULAR,
77         EOBJ_CLASS_DESCRIPTION_OPS(&ELW_BOX_BASE_ID, op_desc, ELW_BOX_SUB_ID_LAST),
78         NULL,
79         sizeof(Widget_Data),
80         _constructor,
81         _destructor,
82         _class_constructor,
83         NULL
84    };
85
86    return _my_class = eobj_class_new(&class_desc, EVAS_OBJ_CLASS, NULL);
87 }
88