aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples/spinner_cxx_example.cc
blob: 561c6adfa2ceb2ece13e8b5fb1a80e353a98adf2 (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
#include <Elementary.hh>

EAPI_MAIN int
elm_main (int argc, char *argv[])
{
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);

   ::elm::win win(elm_win_util_standard_add("spinner", "Spinner Example"));
   win.autohide_set(true);

   ::elm::box bx(efl::eo::parent = win);
   bx.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   win.resize_object_add(bx);
   bx.visible_set(true);

   ::elm::spinner sp(efl::eo::parent = win);
   sp.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   sp.size_hint_align_set(EVAS_HINT_FILL, 0.5);
   bx.pack_end(sp);
   sp.visible_set(true);

   ::elm::spinner sp2(efl::eo::parent = win);
   sp2.label_format_set("Percentage %%%1.2f something");
   sp2.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   sp2.size_hint_align_set(EVAS_HINT_FILL, 0.5);
   bx.pack_end(sp2);
   sp2.visible_set(true);

   ::elm::spinner sp3(efl::eo::parent = win);
   sp3.label_format_set("%1.1f units");
   sp3.step_set(1.5);
   sp3.wrap_set(true);
   sp3.min_max_set(-50.0, 250.0);
   sp3.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   sp3.size_hint_align_set(EVAS_HINT_FILL, 0.5);
   bx.pack_end(sp3);
   sp3.visible_set(true);

   ::elm::spinner sp4(efl::eo::parent = win);
   sp4.style_set("vertical");
   sp4.interval_set(0.2);
   sp4.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   sp4.size_hint_align_set(EVAS_HINT_FILL, 0.5);
   bx.pack_end(sp4);
   sp4.visible_set(true);

   ::elm::spinner sp5(efl::eo::parent = win);
   sp5.editable_set(false);
   sp5.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   sp5.size_hint_align_set(EVAS_HINT_FILL, 0.5);
   bx.pack_end(sp5);
   sp5.visible_set(true);

   ::elm::spinner sp6(efl::eo::parent = win);
   sp6.editable_set(false);
   sp6.min_max_set(1, 12);
   sp6.special_value_add(1, "January");
   sp6.special_value_add(2, "February");
   sp6.special_value_add(3, "March");
   sp6.special_value_add(4, "April");
   sp6.special_value_add(5, "May");
   sp6.special_value_add(6, "June");
   sp6.special_value_add(7, "July");
   sp6.special_value_add(8, "August");
   sp6.special_value_add(9, "September");
   sp6.special_value_add(10, "October");
   sp6.special_value_add(11, "November");
   sp6.special_value_add(12, "December");
   sp6.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   sp6.size_hint_align_set(EVAS_HINT_FILL, 0.5);
   bx.pack_end(sp6);
   sp6.visible_set(true);

   ::elm::spinner sp7(efl::eo::parent = win);
   sp7.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   sp7.size_hint_align_set(EVAS_HINT_FILL, 0.5);
   bx.pack_end(sp7);
   sp7.visible_set(true);
   sp7.editable_set(true);

   auto changed = std::bind([&] () { std::cout << "Value changed to " << sp7.value_get() << std::endl; });

   sp7.callback_changed_add( changed );

   auto delay = std::bind([&] () {std::cout << "Value delay changed to " << sp7.value_get() << std::endl;});

   sp7.callback_delay_changed_add( delay );

   win.visible_set(true);

   elm_run();
   return 0;
}
ELM_MAIN()