Eobj: s/__UNUSED__/EINA_UNUSED/ I had no idea that exists.
[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 #include "config.h"
8
9 EAPI Eobj_Op ELW_BOX_BASE_ID = 0;
10
11 typedef struct
12 {
13    Evas_Object *bx;
14 } Widget_Data;
15
16 static const Eobj_Class *_my_class = NULL;
17
18 static void
19 _pack_end(Eobj *obj EINA_UNUSED, void *class_data, va_list *list)
20 {
21    Widget_Data *wd = class_data;
22    Eobj *child_obj;
23    child_obj = va_arg(*list, Eobj *);
24    /* FIXME: Ref and the later uref child_obj here... */
25    elm_box_pack_end(wd->bx, eobj_evas_object_get(child_obj));
26 }
27
28 static void
29 _constructor(Eobj *obj, void *class_data)
30 {
31    eobj_constructor_super(obj);
32
33    Widget_Data *wd = class_data;
34
35    /* FIXME: An hack, because our tree is not yet only Eobj */
36    wd->bx = elm_box_add(eobj_evas_object_get(eobj_parent_get(obj)));
37    evas_object_size_hint_align_set(wd->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
38    evas_object_size_hint_weight_set(wd->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
39
40    eobj_evas_object_set(obj, wd->bx);
41 }
42
43 static void
44 _class_constructor(Eobj_Class *klass)
45 {
46    const Eobj_Op_Func_Description func_desc[] = {
47         EOBJ_OP_FUNC(ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), _pack_end),
48         EOBJ_OP_FUNC_SENTINEL
49    };
50
51    eobj_class_funcs_set(klass, func_desc);
52 }
53
54 const Eobj_Class *
55 elw_box_class_get(void)
56 {
57    if (_my_class) return _my_class;
58
59    static const Eobj_Op_Description op_desc[] = {
60         EOBJ_OP_DESCRIPTION(ELW_BOX_SUB_ID_PACK_END, "o", "Pack obj at the end of box."),
61         EOBJ_OP_DESCRIPTION_SENTINEL
62    };
63
64    static const Eobj_Class_Description class_desc = {
65         "Elw Box",
66         EOBJ_CLASS_TYPE_REGULAR,
67         EOBJ_CLASS_DESCRIPTION_OPS(&ELW_BOX_BASE_ID, op_desc, ELW_BOX_SUB_ID_LAST),
68         NULL,
69         sizeof(Widget_Data),
70         _constructor,
71         NULL,
72         _class_constructor,
73         NULL
74    };
75
76    return _my_class = eobj_class_new(&class_desc, EVAS_OBJ_CLASS, NULL);
77 }
78