summaryrefslogtreecommitdiff
path: root/src/examples/elementary/spinner_cxx_example.cc
blob: a6f583f74583c97487229908690b096092bcd566 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` spinner_cxx_example.cc -o spinner_cxx_example

#define EFL_CXXPERIMENTAL
#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#include <Efl_Ui.hh>
#include <iostream>

using namespace std::placeholders;
using efl::eo::instantiate;

static efl::ui::Win win;

static void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
   efl::ui::Win win(instantiate);
   win.text_set("Spinner Example");
   win.autohide_set(true);


   efl::ui::Box bx(instantiate, win);
   win.content_set(bx);

   efl::ui::Spin_Button sp(instantiate, win);
   sp.hint_fill_set(true, false);
   sp.range_step_set(1.0);
   sp.range_limits_set(0.0, 10.0);
   sp.wraparound_set(true);
   bx.pack_end(sp);

   efl::ui::Spin_Button sp2(instantiate, win);
   sp2.format_string_set("Percentage %%%1.2f something", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
   sp2.hint_fill_set(true, false);
   bx.pack_end(sp2);

   efl::ui::Spin_Button sp3(instantiate, win);
   sp3.format_string_set("%1.1f units", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
   sp3.range_step_set(1.5);
   sp3.range_limits_set(-50.0, 250.0);
   sp3.hint_fill_set(true, false);
   bx.pack_end(sp3);

   efl::ui::Spin_Button sp4(instantiate, win);
   //FIXME setting the style is propetected...
   //sp4.style_set("vertical");
   sp4.range_step_set(0.2);
   sp4.hint_fill_set(true, false);
   bx.pack_end(sp4);

   efl::ui::Spin_Button sp5(instantiate, win);
   sp5.direct_text_input_set(false);
   sp5.hint_fill_set(true, false);
   bx.pack_end(sp5);

   Efl_Ui_Format_Value values[] = {
     {1, "January"},
     {2, "February"},
     {3, "March"},
     {4, "April"},
     {5, "May"},
     {6, "June"},
     {7, "July"},
     {8, "August"},
     {9, "September"},
     {10, "October"},
     {11, "November"},
     {12, "December"}
   };
   efl::eina::accessor<Efl_Ui_Format_Value> values_acc(EINA_C_ARRAY_ACCESSOR_NEW(values));
   efl::ui::Spin_Button sp6(instantiate, win);
   sp6.direct_text_input_set(false);
   sp6.range_limits_set(1, 12);
   //sp6.format_values_set(values_acc);
   sp6.hint_fill_set(true, false);
   bx.pack_end(sp6);

   efl::ui::Spin_Button sp7(instantiate, win);
   sp7.hint_fill_set(true, false);
   bx.pack_end(sp7);
   sp7.direct_text_input_set(true);

   auto changed = std::bind ( [] (efl::ui::Range_Display obj)
   { std::cout << "Changed to " << obj.range_value_get() << std::endl; }
         , std::placeholders::_1);
   efl::eo::downcast<efl::ui::Range_Display>(sp7).changed_event_cb_add(changed);

   auto steady =  std::bind ( [] (efl::ui::Range_Interactive obj)
   { std::cout << "Steady to " << obj.range_value_get() << std::endl; }
         , std::placeholders::_1);
   efl::eo::downcast<efl::ui::Range_Interactive>(sp7).steady_event_cb_add(steady);

}
EFL_MAIN()