1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4 #include <Efl_Ui.h>
5 #include <Elementary.h>
6
7 #define NUM_OF_VALS 12
8
9 static void
_spin_delay_changed_cb(void * data EINA_UNUSED,const Efl_Event * ev)10 _spin_delay_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
11 {
12 printf("Value delay changed %d\n", (int)efl_ui_range_value_get(ev->object));
13 }
14
15 static void
_spin_changed_cb(void * data EINA_UNUSED,const Efl_Event * ev)16 _spin_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
17 {
18 printf("Value changed %d\n", (int)efl_ui_range_value_get(ev->object));
19 }
20
21 void
test_ui_spin_button(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)22 test_ui_spin_button(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
23 {
24 Eo *win, *bx;
25 Efl_Ui_Format_Value special_values[] = {
26 {1, "January"}, {2, "February"}, {3, "March"}, {4, "April"},
27 {5, "May"}, {6, "June"}, {7, "July"}, {8, "August"},
28 {9, "September"}, {10, "October"}, {11, "November"}, {12, "December"}
29 };
30
31 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
32 efl_text_set(efl_added, "Efl.Ui.Spin_Button"),
33 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
34
35 bx = efl_add(EFL_UI_BOX_CLASS, win,
36 efl_content_set(win, efl_added),
37 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL));
38
39 efl_add(EFL_UI_SPIN_BUTTON_CLASS, bx,
40 efl_ui_range_limits_set(efl_added, 0, 10),
41 efl_ui_range_value_set(efl_added, 6),
42 efl_ui_range_step_set(efl_added, 2),
43 efl_ui_spin_button_wraparound_set(efl_added, EINA_TRUE),
44 efl_ui_spin_button_direct_text_input_set(efl_added, EINA_TRUE),
45 efl_event_callback_add(efl_added, EFL_UI_RANGE_EVENT_STEADY,_spin_delay_changed_cb, NULL),
46 efl_event_callback_add(efl_added, EFL_UI_RANGE_EVENT_CHANGED, _spin_changed_cb, NULL),
47 efl_pack(bx, efl_added));
48
49 efl_add(EFL_UI_SPIN_BUTTON_CLASS, bx,
50 efl_ui_range_limits_set(efl_added, -100.0, 100.0),
51 efl_ui_range_value_set(efl_added, 0),
52 efl_ui_format_string_set(efl_added, "test float %0.2f", EFL_UI_FORMAT_STRING_TYPE_SIMPLE),
53 efl_ui_spin_button_direct_text_input_set(efl_added, EINA_FALSE),
54 efl_pack(bx, efl_added));
55
56 efl_add(EFL_UI_SPIN_BUTTON_CLASS, bx,
57 efl_ui_range_limits_set(efl_added, 1, 12),
58 efl_ui_range_value_set(efl_added, 1),
59 efl_ui_spin_button_direct_text_input_set(efl_added, EINA_FALSE),
60 efl_ui_format_values_set(efl_added, EINA_C_ARRAY_ACCESSOR_PTR_NEW(special_values)),
61 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL),
62 efl_pack(bx, efl_added));
63
64 efl_gfx_entity_size_set(win, EINA_SIZE2D(180, 140));
65 }
66