summaryrefslogtreecommitdiff
path: root/tutorial/c/eo-multiinherit/src/eo_multiinherit_main.c
blob: 7b2114b85ff8ed085e2210fe278e77a1cf22f131 (plain)
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
72
73
74
75
76
77
78
79
80
#define EFL_BETA_API_SUPPORT 1

#include <Eina.h>
#include <Efl_Core.h>
#include "eo_multiinherit.h"

Example_Circle *
_circle_create()
{
   Example_Circle *circle;

   circle = efl_new(EXAMPLE_CIRCLE_CLASS,
                    efl_name_set(efl_added, "Circle"),
                    example_circle_radius_set(efl_added, 5));

   return circle;
}

Example_Rectangle *
_rectangle_create()
{
   Example_Rectangle *rectangle;

   rectangle = efl_new(EXAMPLE_RECTANGLE_CLASS,
                       efl_name_set(efl_added, "Rectangle"),
                       example_rectangle_width_set(efl_added, 5),
                       example_rectangle_height_set(efl_added, 10),
                       example_colored_color_set(efl_added, 255, 0, 0));

   return rectangle;
}

Example_Square *
_square_create()
{
   Example_Square *square;

   square = efl_new(EXAMPLE_SQUARE_CLASS,
                    efl_name_set(efl_added, "Square"),
                    example_rectangle_width_set(efl_added, 7),
                    example_colored_color_set(efl_added, 64, 64, 64));

   return square;
}

void
_shape_print(Example_Shape *shape)
{
   printf("Shape named %s has area %d\n",
          efl_name_get(shape), example_shape_area(shape));
   if (efl_isa(shape, EXAMPLE_COLORED_MIXIN))
     {
        int red, green, blue;

        example_colored_color_get(shape, &red, &green, &blue);
        printf("  Colored %d, %d, %d\n", red, green, blue);
     }
}

EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
   Eo *shape;

   shape = _circle_create();
   _shape_print(shape);
   efl_unref(shape);

   shape = _rectangle_create();
   _shape_print(shape);
   efl_unref(shape);

   shape = _square_create();
   _shape_print(shape);
   efl_unref(shape);

   efl_exit(0);
}
EFL_MAIN()