aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples/eo/evas/evas_test.c
blob: 6fc50376677d17d40d711e66eb61a3091c52676b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <Elementary.h>

#include "evas_evas_obj.h"
#include "evas_elw_button.h"
#include "evas_elw_box.h"
#include "evas_elw_boxedbutton.h"
#include "evas_elw_win.h"

Eina_Bool
_btn_clicked_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
{
   (void) obj;
   (void) event_info;
   const Eo_Class *klass = eo_class_get(obj);
   printf("%s obj-type:'%s' data:'%s'\n", desc->name, eo_class_name_get(klass), (const char *) data);

   return EO_CALLBACK_CONTINUE;
}

int
main(int argc, char *argv[])
{
   Evas_Coord winw, winh;
     {
        winw = 400;
        winh = 400;
     }

   elm_init(argc, argv);
   eo_init();

   Eo *win;
   eo_add(win, ELW_WIN_CLASS, NULL);
   eo_do(win, exevas_obj_size_set(winw, winh), exevas_obj_visibility_set(EINA_TRUE));

   Eo *bt;
   eo_add(bt, ELW_BUTTON_CLASS, win);
   eo_do(bt, exevas_obj_position_set(25, 25),
         exevas_obj_size_set(50, 50),
         exevas_obj_color_set(255, 0, 0, 255),
         elw_button_text_set("Click"),
         exevas_obj_visibility_set(EINA_TRUE));
   eo_do(bt, eo_event_callback_add(EV_CLICKED, _btn_clicked_cb, "btn"));

   int r, g, b, a;
   eo_do(bt, exevas_obj_color_get(&r, &g, &b, &a));
   printf("RGBa(%d, %d, %d, %d)\n", r, g, b, a);

   Eo *bx;
   eo_add(bx, ELW_BOXEDBUTTON_CLASS, win);
   eo_do(bx, exevas_obj_position_set(100, 100),
         exevas_obj_size_set(70, 70),
         exevas_obj_color_set(0, 0, 255, 255),
         elw_button_text_set("Click2"),
         exevas_obj_visibility_set(EINA_TRUE));
   eo_do(bx, eo_event_callback_add(EV_CLICKED, _btn_clicked_cb, "bxedbtn"));

   elm_run();

   eo_unref(bx);
   eo_unref(bt);
   eo_unref(win);
   eo_shutdown();
   elm_shutdown();
   return 0;
}