efl
110 строк · 3.4 Кб
1/*
2+ * Copyright 2019 by its authors. See AUTHORS.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16// 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
17
18#define EFL_CXXPERIMENTAL
19#ifndef EFL_BETA_API_SUPPORT
20#define EFL_BETA_API_SUPPORT
21#endif
22#include <Efl_Ui.hh>
23#include <iostream>
24
25using namespace std::placeholders;
26using efl::eo::instantiate;
27
28static efl::ui::Win win;
29
30static void
31efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
32{
33efl::ui::Win win(instantiate);
34win.text_set("Spinner Example");
35win.autohide_set(true);
36
37
38efl::ui::Box bx(instantiate, win);
39win.content_set(bx);
40
41efl::ui::Spin_Button sp(instantiate, win);
42sp.hint_fill_set(true, false);
43sp.range_step_set(1.0);
44sp.range_limits_set(0.0, 10.0);
45sp.wraparound_set(true);
46bx.pack_end(sp);
47
48efl::ui::Spin_Button sp2(instantiate, win);
49sp2.format_string_set("Percentage %%%1.2f something", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
50sp2.hint_fill_set(true, false);
51bx.pack_end(sp2);
52
53efl::ui::Spin_Button sp3(instantiate, win);
54sp3.format_string_set("%1.1f units", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
55sp3.range_step_set(1.5);
56sp3.range_limits_set(-50.0, 250.0);
57sp3.hint_fill_set(true, false);
58bx.pack_end(sp3);
59
60efl::ui::Spin_Button sp4(instantiate, win);
61//FIXME setting the style is propetected...
62//sp4.style_set("vertical");
63sp4.range_step_set(0.2);
64sp4.hint_fill_set(true, false);
65bx.pack_end(sp4);
66
67efl::ui::Spin_Button sp5(instantiate, win);
68sp5.direct_text_input_set(false);
69sp5.hint_fill_set(true, false);
70bx.pack_end(sp5);
71
72Efl_Ui_Format_Value values[] = {
73{1, "January"},
74{2, "February"},
75{3, "March"},
76{4, "April"},
77{5, "May"},
78{6, "June"},
79{7, "July"},
80{8, "August"},
81{9, "September"},
82{10, "October"},
83{11, "November"},
84{12, "December"}
85};
86efl::eina::accessor<Efl_Ui_Format_Value> values_acc(EINA_C_ARRAY_ACCESSOR_NEW(values));
87efl::ui::Spin_Button sp6(instantiate, win);
88sp6.direct_text_input_set(false);
89sp6.range_limits_set(1, 12);
90//sp6.format_values_set(values_acc);
91sp6.hint_fill_set(true, false);
92bx.pack_end(sp6);
93
94efl::ui::Spin_Button sp7(instantiate, win);
95sp7.hint_fill_set(true, false);
96bx.pack_end(sp7);
97sp7.direct_text_input_set(true);
98
99auto changed = std::bind ( [] (efl::ui::Range_Display obj)
100{ std::cout << "Changed to " << obj.range_value_get() << std::endl; }
101, std::placeholders::_1);
102efl::eo::downcast<efl::ui::Range_Display>(sp7).changed_event_cb_add(changed);
103
104auto steady = std::bind ( [] (efl::ui::Range_Interactive obj)
105{ std::cout << "Steady to " << obj.range_value_get() << std::endl; }
106, std::placeholders::_1);
107efl::eo::downcast<efl::ui::Range_Interactive>(sp7).steady_event_cb_add(steady);
108
109}
110EFL_MAIN()
111