summaryrefslogtreecommitdiff
path: root/src/examples/eolian_cxx/eolian_cxx_complex_types_01.cc
blob: 8dd5d29d87f2677b1106f44d533fdeedfb338612 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <iostream>
#include <thread>
#include <cassert>
#include <sstream>

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <Eo.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>

#include <Eina.hh>
#include <Eo.hh>
#include <Ecore.hh>
#include <Evas.hh>

#include <canvas/evas_canvas.eo.hh>
#include <canvas/evas_text.eo.hh>
#include <canvas/evas_rectangle.eo.hh>
#include <canvas/evas_zoomable_interface.eo.hh>

namespace efl { namespace evas { // XXX only while we don't have namespaces in EFL
using ::evas::canvas;
using ::evas::object;
using ::evas::text;
using ::evas::grid;
using ::evas::rectangle;
using ::evas::common_interface;
using ::evas::zoomable_interface;
} }

namespace {

// EFL Ecore-Evas doesn't have C++ bindings yet.
Ecore_Evas *ee;
void
_ecore_evas_init()
{
   if (!ee)
     {
        ::ecore_evas_init();
        ::evas_init();
        ee = ::ecore_evas_new(NULL, 0, 0, 500, 380, NULL);
        ::ecore_evas_show(ee);
   }
}
void
_ecore_evas_shutdown()
{
   if (ee)
     {
        ::ecore_evas_free(ee);
        ::ecore_evas_shutdown();
        ee = NULL;
     }
}

}

void
example_complex_types()
{
   _ecore_evas_init();
   efl::evas::canvas canvas(::eo_ref(::ecore_evas_get(ee)));

   efl::evas::rectangle bg(efl::eo::parent = canvas);
   bg.color_set(255, 255, 255, 255);
   bg.position_set(0, 0);
   bg.size_set(500, 250);
   bg.visibility_set(true);

   efl::evas::grid grid(efl::eo::parent = canvas);
   grid.position_set(0, 0);
   grid.object_smart::color_set(0, 0, 0, 255);
   grid.size_set(5, 5);
   grid.visibility_set(true);

   efl::evas::text text1(efl::eo::parent = canvas);
   text1.style_set(EVAS_TEXT_STYLE_OUTLINE);
   text1.color_set(255, 0, 0, 255);
   text1.font_set("DejaVu", 32);
   text1.text_set("EFL++ Examples");
   text1.visibility_set(true);
   int t1w, t1h;
   text1.size_get(&t1w, &t1h);
   grid.pack(text1, 1, 1, t1w, t1h);

   efl::evas::text text2(efl::eo::parent = canvas);
   text2.style_set(EVAS_TEXT_STYLE_PLAIN);
   text2.color_set(0, 120, 0, 255);
   text2.position_set(t1w+50, t1h+50);
   text2.font_set("Courier", 16);
   std::stringstream ss;
   ss << "version " << EFL_VERSION_MAJOR << "." << EFL_VERSION_MINOR;
   text2.text_set(ss.str().c_str());
   text2.visibility_set(true);
   int t2w, t2h;
   text2.size_get(&t2w, &t2h);

   canvas.render();
   ::ecore_main_loop_begin();
   _ecore_evas_shutdown();
}

int main()
{
   efl::eina::eina_init eina_;
   efl::eo::eo_init eo_;
   efl::ecore::ecore_init ecore_;

   std::cerr << "[+] Running ELF++ example: Complex Types" << std::endl;
   example_complex_types();

   return 0;
}