efl

Форк
0
/
spinner_cxx_example.cc 
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

25
using namespace std::placeholders;
26
using efl::eo::instantiate;
27

28
static efl::ui::Win win;
29

30
static void
31
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
32
{
33
   efl::ui::Win win(instantiate);
34
   win.text_set("Spinner Example");
35
   win.autohide_set(true);
36

37

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

41
   efl::ui::Spin_Button sp(instantiate, win);
42
   sp.hint_fill_set(true, false);
43
   sp.range_step_set(1.0);
44
   sp.range_limits_set(0.0, 10.0);
45
   sp.wraparound_set(true);
46
   bx.pack_end(sp);
47

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

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

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

67
   efl::ui::Spin_Button sp5(instantiate, win);
68
   sp5.direct_text_input_set(false);
69
   sp5.hint_fill_set(true, false);
70
   bx.pack_end(sp5);
71

72
   Efl_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
   };
86
   efl::eina::accessor<Efl_Ui_Format_Value> values_acc(EINA_C_ARRAY_ACCESSOR_NEW(values));
87
   efl::ui::Spin_Button sp6(instantiate, win);
88
   sp6.direct_text_input_set(false);
89
   sp6.range_limits_set(1, 12);
90
   //sp6.format_values_set(values_acc);
91
   sp6.hint_fill_set(true, false);
92
   bx.pack_end(sp6);
93

94
   efl::ui::Spin_Button sp7(instantiate, win);
95
   sp7.hint_fill_set(true, false);
96
   bx.pack_end(sp7);
97
   sp7.direct_text_input_set(true);
98

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

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

109
}
110
EFL_MAIN()
111

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.