diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/elementary/src/bin/test_label.c | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_label.c b/libraries/elementary/src/bin/test_label.c new file mode 100644 index 0000000..b217407 --- /dev/null +++ b/libraries/elementary/src/bin/test_label.c | |||
@@ -0,0 +1,218 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "elementary_config.h" | ||
3 | #endif | ||
4 | #include <Elementary.h> | ||
5 | #ifndef ELM_LIB_QUICKLAUNCH | ||
6 | |||
7 | enum _slide_style | ||
8 | { | ||
9 | SLIDE_SHORT, | ||
10 | SLIDE_LONG, | ||
11 | SLIDE_BOUNCE, | ||
12 | SLIDE_STYLE_LAST | ||
13 | }; | ||
14 | |||
15 | void | ||
16 | test_label(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
17 | { | ||
18 | Evas_Object *win, *bx, *lb; | ||
19 | |||
20 | win = elm_win_util_standard_add("label", "Label"); | ||
21 | elm_win_autodel_set(win, EINA_TRUE); | ||
22 | |||
23 | bx = elm_box_add(win); | ||
24 | evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
25 | evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
26 | |||
27 | lb = elm_label_add(win); | ||
28 | elm_object_text_set(lb, | ||
29 | "<b>This is a small label</b>" | ||
30 | ); | ||
31 | evas_object_size_hint_weight_set(lb, 0.0, 0.0); | ||
32 | evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
33 | elm_box_pack_end(bx, lb); | ||
34 | evas_object_show(lb); | ||
35 | |||
36 | lb = elm_label_add(win); | ||
37 | elm_object_text_set(lb, | ||
38 | "This is a larger label with newlines<br/>" | ||
39 | "to make it bigger, bit it won't expand or wrap<br/>" | ||
40 | "just be a block of text that can't change its<br/>" | ||
41 | "formatting as it's fixed based on text<br/>" | ||
42 | ); | ||
43 | evas_object_size_hint_weight_set(lb, 0.0, 0.0); | ||
44 | evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
45 | elm_box_pack_end(bx, lb); | ||
46 | evas_object_show(lb); | ||
47 | |||
48 | lb = elm_label_add(win); | ||
49 | elm_label_line_wrap_set(lb, ELM_WRAP_CHAR); | ||
50 | elm_object_text_set(lb, | ||
51 | "<b>" | ||
52 | "This is more text designed to line-wrap here as " | ||
53 | "This object is resized horizontally. As it is " | ||
54 | "resized vertically though, nothing should change. " | ||
55 | "The amount of space allocated vertically should " | ||
56 | "change as horizontal size changes." | ||
57 | "</b>" | ||
58 | ); | ||
59 | evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); | ||
60 | evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
61 | elm_box_pack_end(bx, lb); | ||
62 | evas_object_show(lb); | ||
63 | |||
64 | lb = elm_label_add(win); | ||
65 | elm_object_text_set(lb, | ||
66 | "This small label set to wrap" | ||
67 | ); | ||
68 | evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); | ||
69 | evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
70 | elm_box_pack_end(bx, lb); | ||
71 | evas_object_show(lb); | ||
72 | |||
73 | |||
74 | evas_object_resize(win, 320, 300); | ||
75 | |||
76 | evas_object_show(bx); | ||
77 | evas_object_show(win); | ||
78 | elm_win_resize_object_add(win, bx); | ||
79 | } | ||
80 | |||
81 | static void | ||
82 | _cb_size_radio_changed(void *data, Evas_Object *obj, void *event __UNUSED__) | ||
83 | { | ||
84 | Evas_Object *lb = (Evas_Object *)data; | ||
85 | int style = elm_radio_value_get((Evas_Object *)obj); | ||
86 | switch (style) | ||
87 | { | ||
88 | case SLIDE_SHORT: | ||
89 | elm_object_style_set(lb, "slide_short"); | ||
90 | break; | ||
91 | |||
92 | case SLIDE_LONG: | ||
93 | elm_object_style_set(lb, "slide_long"); | ||
94 | break; | ||
95 | |||
96 | case SLIDE_BOUNCE: | ||
97 | elm_object_style_set(lb, "slide_bounce"); | ||
98 | break; | ||
99 | |||
100 | default: | ||
101 | return; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | static void | ||
106 | _change_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__) | ||
107 | { | ||
108 | Evas_Object *lb = (Evas_Object *)data; | ||
109 | double val = elm_slider_value_get(obj); | ||
110 | elm_label_slide_set(lb, EINA_FALSE); | ||
111 | elm_label_slide_duration_set(lb, val); | ||
112 | elm_label_slide_set(lb, EINA_TRUE); | ||
113 | } | ||
114 | |||
115 | void | ||
116 | test_label2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
117 | { | ||
118 | Evas_Object *win, *gd, *rect, *lb, *rd, *rdg, *sl; | ||
119 | |||
120 | win = elm_win_util_standard_add("label2", "Label 2"); | ||
121 | elm_win_autodel_set(win, EINA_TRUE); | ||
122 | |||
123 | gd = elm_grid_add(win); | ||
124 | elm_grid_size_set(gd, 100, 100); | ||
125 | evas_object_size_hint_weight_set(gd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
126 | elm_win_resize_object_add(win, gd); | ||
127 | evas_object_show(gd); | ||
128 | |||
129 | /* Test Label Ellipsis */ | ||
130 | lb = elm_label_add(win); | ||
131 | elm_object_text_set(lb, "Test Label Ellipsis:"); | ||
132 | elm_label_slide_set(lb, EINA_TRUE); | ||
133 | elm_grid_pack(gd, lb, 5, 5, 90, 10); | ||
134 | evas_object_show(lb); | ||
135 | |||
136 | rect = evas_object_rectangle_add(evas_object_evas_get(win)); | ||
137 | elm_grid_pack(gd, rect, 5, 15, 90, 10); | ||
138 | evas_object_color_set(rect, 255, 125, 125, 255); | ||
139 | evas_object_show(rect); | ||
140 | |||
141 | lb = elm_label_add(win); | ||
142 | elm_object_text_set(lb, | ||
143 | "This is a label set to ellipsis. " | ||
144 | "If set ellipsis to true and the text doesn't fit " | ||
145 | "in the label an ellipsis(\"...\") will be shown " | ||
146 | "at the end of the widget." | ||
147 | ); | ||
148 | elm_label_ellipsis_set(lb, EINA_TRUE); | ||
149 | elm_grid_pack(gd, lb, 5, 15, 90, 10); | ||
150 | evas_object_show(lb); | ||
151 | |||
152 | /* Test Label Slide */ | ||
153 | lb = elm_label_add(win); | ||
154 | elm_object_text_set(lb, "Test Label Slide:"); | ||
155 | elm_label_slide_set(lb, EINA_TRUE); | ||
156 | elm_grid_pack(gd, lb, 5, 30, 90, 10); | ||
157 | evas_object_show(lb); | ||
158 | |||
159 | rect = evas_object_rectangle_add(evas_object_evas_get(win)); | ||
160 | elm_grid_pack(gd, rect, 5, 40, 90, 10); | ||
161 | evas_object_color_set(rect, 255, 125, 125, 255); | ||
162 | evas_object_show(rect); | ||
163 | |||
164 | lb = elm_label_add(win); | ||
165 | elm_object_style_set(lb, "slide_short"); | ||
166 | elm_object_text_set(lb, | ||
167 | "This is a label set to slide. " | ||
168 | "If set slide to true the text of the label " | ||
169 | "will slide/scroll through the length of label." | ||
170 | "This only works with the themes \"slide_short\", " | ||
171 | "\"slide_long\" and \"slide_bounce\"." | ||
172 | ); | ||
173 | elm_label_slide_set(lb, EINA_TRUE); | ||
174 | elm_grid_pack(gd, lb, 5, 40, 90, 10); | ||
175 | evas_object_show(lb); | ||
176 | |||
177 | rd = elm_radio_add(win); | ||
178 | elm_radio_state_value_set(rd, SLIDE_SHORT); | ||
179 | elm_object_text_set(rd, "slide_short"); | ||
180 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
181 | evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb); | ||
182 | elm_grid_pack(gd, rd, 5, 50, 30, 10); | ||
183 | evas_object_show(rd); | ||
184 | rdg = rd; | ||
185 | |||
186 | rd = elm_radio_add(win); | ||
187 | elm_radio_state_value_set(rd, SLIDE_LONG); | ||
188 | elm_radio_group_add(rd, rdg); | ||
189 | elm_object_text_set(rd, "slide_long"); | ||
190 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
191 | evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb); | ||
192 | elm_grid_pack(gd, rd, 35, 50, 30, 10); | ||
193 | evas_object_show(rd); | ||
194 | |||
195 | rd = elm_radio_add(win); | ||
196 | elm_radio_state_value_set(rd, SLIDE_BOUNCE); | ||
197 | elm_radio_group_add(rd, rdg); | ||
198 | elm_object_text_set(rd, "slide_bounce"); | ||
199 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
200 | evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb); | ||
201 | elm_grid_pack(gd, rd, 65, 50, 30, 10); | ||
202 | evas_object_show(rd); | ||
203 | |||
204 | sl = elm_slider_add(win); | ||
205 | elm_object_text_set(sl, "Slide Duration"); | ||
206 | elm_slider_unit_format_set(sl, "%1.1f units"); | ||
207 | elm_slider_min_max_set(sl, 1, 20); | ||
208 | elm_slider_value_set(sl, 10); | ||
209 | evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5); | ||
210 | evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
211 | evas_object_smart_callback_add(sl, "changed", _change_cb, lb); | ||
212 | elm_grid_pack(gd, sl, 5, 60, 90, 10); | ||
213 | evas_object_show(sl); | ||
214 | |||
215 | evas_object_resize(win, 320, 320); | ||
216 | evas_object_show(win); | ||
217 | } | ||
218 | #endif | ||