summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWoochan Lee <wc0917.lee@samsung.com>2018-04-25 16:43:53 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2018-04-25 16:48:21 +0900
commitef2e6afd1f7c890297900937fa1f12f0f4f76980 (patch)
treede05efce05d3712a76c47b6f7555df3ee51145c0
parent3d6c72438d4d311aabeec5ba90c659ae54f5c6fc (diff)
Intrudoce Efl Ui Date, Time interface and picker.
Summary: Create datepicker, timepicker with one manager class(efl_datetime). Test Plan: datepicker, timepicker sample. Reviewers: herb, Jaehyun_Cho, woohyun, SanghyeonLee Reviewed By: Jaehyun_Cho Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D5871
-rw-r--r--data/elementary/themes/Makefile.am2
-rw-r--r--data/elementary/themes/colorclasses.edc8
-rw-r--r--data/elementary/themes/default.edc2
-rw-r--r--data/elementary/themes/edc/efl/datepicker.edc345
-rw-r--r--data/elementary/themes/edc/efl/spin_button.edc4
-rw-r--r--data/elementary/themes/edc/efl/timepicker.edc409
-rw-r--r--data/elementary/themes/edc/elm/entry.edc2
-rw-r--r--src/Makefile_Elementary.am10
-rw-r--r--src/bin/elementary/Makefile.am2
-rw-r--r--src/bin/elementary/test.c4
-rw-r--r--src/bin/elementary/test_ui_datepicker.c37
-rw-r--r--src/bin/elementary/test_ui_timepicker.c36
-rw-r--r--src/lib/elementary/Elementary.h2
-rw-r--r--src/lib/elementary/efl_datetime_manager.c193
-rw-r--r--src/lib/elementary/efl_datetime_manager.eo50
-rw-r--r--src/lib/elementary/efl_ui_datepicker.c349
-rw-r--r--src/lib/elementary/efl_ui_datepicker.eo75
-rw-r--r--src/lib/elementary/efl_ui_datepicker_private.h22
-rw-r--r--src/lib/elementary/efl_ui_spin_button.c9
-rw-r--r--src/lib/elementary/efl_ui_timepicker.c285
-rw-r--r--src/lib/elementary/efl_ui_timepicker.eo44
-rw-r--r--src/lib/elementary/efl_ui_timepicker_private.h21
-rw-r--r--src/lib/elementary/elm_config.c2
-rw-r--r--src/lib/elementary/elm_priv.h1
24 files changed, 1905 insertions, 9 deletions
diff --git a/data/elementary/themes/Makefile.am b/data/elementary/themes/Makefile.am
index 8ae0844..992d5ca 100644
--- a/data/elementary/themes/Makefile.am
+++ b/data/elementary/themes/Makefile.am
@@ -1035,6 +1035,8 @@ elementary/themes/edc/efl/scroller.edc \
1035elementary/themes/edc/efl/slider.edc \ 1035elementary/themes/edc/efl/slider.edc \
1036elementary/themes/edc/efl/spin.edc \ 1036elementary/themes/edc/efl/spin.edc \
1037elementary/themes/edc/efl/spin_button.edc \ 1037elementary/themes/edc/efl/spin_button.edc \
1038elementary/themes/edc/efl/datepicker.edc \
1039elementary/themes/edc/efl/timepicker.edc \
1038elementary/themes/edc/efl/text.edc \ 1040elementary/themes/edc/efl/text.edc \
1039elementary/themes/edc/efl/textpath.edc \ 1041elementary/themes/edc/efl/textpath.edc \
1040elementary/themes/edc/efl/tooltip.edc \ 1042elementary/themes/edc/efl/tooltip.edc \
diff --git a/data/elementary/themes/colorclasses.edc b/data/elementary/themes/colorclasses.edc
index bf294bf..2500ce7 100644
--- a/data/elementary/themes/colorclasses.edc
+++ b/data/elementary/themes/colorclasses.edc
@@ -208,6 +208,14 @@ color_classes {
208 color: 0 0 0 0; 208 color: 0 0 0 0;
209 desc: "Background of a datetime widget"; 209 desc: "Background of a datetime widget";
210 } 210 }
211 color_class { name: "datepicker_bg";
212 color: 0 0 0 0;
213 desc: "Background of a datepicker widget";
214 }
215 color_class { name: "timepicker_bg";
216 color: 0 0 0 0;
217 desc: "Background of a timepicker widget";
218 }
211 color_class { name: "datetime_separator_text"; 219 color_class { name: "datetime_separator_text";
212 color: FN_COL_DEFAULT; 220 color: FN_COL_DEFAULT;
213 desc: "Text in a datetime separator area"; 221 desc: "Text in a datetime separator area";
diff --git a/data/elementary/themes/default.edc b/data/elementary/themes/default.edc
index 00f8973..67fbd78 100644
--- a/data/elementary/themes/default.edc
+++ b/data/elementary/themes/default.edc
@@ -190,6 +190,8 @@ collections {
190#include "edc/efl/border.edc" 190#include "edc/efl/border.edc"
191#include "edc/efl/spin.edc" 191#include "edc/efl/spin.edc"
192#include "edc/efl/spin_button.edc" 192#include "edc/efl/spin_button.edc"
193#include "edc/efl/datepicker.edc"
194#include "edc/efl/timepicker.edc"
193// XXX: min size calc problems - too wide! ... err ok on my 32bit box... eh? 195// XXX: min size calc problems - too wide! ... err ok on my 32bit box... eh?
194#include "edc/efl/cursor.edc" 196#include "edc/efl/cursor.edc"
195#include "edc/efl/pointer.edc" 197#include "edc/efl/pointer.edc"
diff --git a/data/elementary/themes/edc/efl/datepicker.edc b/data/elementary/themes/edc/efl/datepicker.edc
new file mode 100644
index 0000000..f0fa470
--- /dev/null
+++ b/data/elementary/themes/edc/efl/datepicker.edc
@@ -0,0 +1,345 @@
1group { "efl/datepicker";
2 parts {
3 spacer { "base";
4 scale;
5 desc { "default";
6 min: 150 170;
7 }
8 }
9 rect { "base_bg";
10 scale;
11 desc { "default";
12 rel.to: "base";
13 color_class: "datepicker_bg";
14 }
15 }
16 spacer { "padding_bg_top";
17 scale;
18 desc { "default";
19 min: 0 10;
20 max: -1 10;
21 fixed: 0 1;
22 rel1 {
23 relative: 0.0 0.0;
24 to: "base_bg";
25 }
26 rel2 {
27 relative: 1.0 0.0;
28 to: "base_bg";
29 }
30 align: 0.5 0.0;
31 }
32 }
33 spacer { "padding_bg_bottom";
34 scale;
35 desc { "default";
36 min: 0 10;
37 max: -1 10;
38 fixed: 0 1;
39 rel1 {
40 relative: 0.0 1.0;
41 to: "base_bg";
42 }
43 rel2 {
44 relative: 1.0 1.0;
45 to: "base_bg";
46 }
47 align: 0.5 1.0;
48 }
49 }
50 spacer { "bg";
51 scale;
52 desc { "default";
53 min: 150 150;
54 max: 150 150;
55 rel1 {
56 relative: 0.0 1.0;
57 to: "padding_bg_top";
58 }
59 rel2 {
60 relative: 1.0 0.0;
61 to: "padding_bg_bottom";
62 }
63 }
64 }
65 spacer { "padding_left";
66 scale;
67 desc { "default";
68 min: 5 0;
69 max: 5 -1;
70 fixed: 1 0;
71 rel1 {
72 relative: 0.0 0.0;
73 to: "bg";
74 }
75 rel2 {
76 relative: 0.0 1.0;
77 to: "bg";
78 }
79 align: 0.0 0.0;
80 }
81 }
82 spacer { "padding_right";
83 scale;
84 desc { "default";
85 min: 5 0;
86 max: 5 -1;
87 fixed: 1 0;
88 rel2.to: "bg";
89 rel1 {
90 relative: 1.0 0.0;
91 to: "bg";
92 }
93 rel2 {
94 relative: 1.0 1.0;
95 to: "bg";
96 }
97 align: 1.0 1.0;
98 }
99 }
100 swallow { "field0";
101 mouse;
102 scale;
103 desc { "default";
104 fixed: 1 0;
105 min: 40 0;
106 rel1 {
107 relative: 1.0 0.0;
108 to: "padding_left";
109 }
110 rel2.to: "padding_left";
111 align: 0.0 0.5;
112 }
113 }
114 spacer { "padding_center1";
115 scale;
116 desc { "default";
117 fixed: 1 0;
118 min: 10 0;
119 max: 10 -1;
120 rel1 {
121 relative: 1.0 0.0;
122 to: "field0";
123 }
124 rel2.to: "field0";
125 align: 0.0 0.5;
126 }
127 }
128 swallow { "field1";
129 mouse;
130 scale;
131 desc { "default";
132 fixed: 1 0;
133 min: 40 0;
134 rel1 {
135 relative: 1.0 0.0;
136 to: "padding_center1";
137 }
138 rel2 {
139 relative: 0.0 1.0;
140 to_x: "padding_center2";
141 to_y: "padding_center1";
142 }
143 }
144 }
145 spacer { "padding_center2";
146 scale;
147 desc { "default";
148 fixed: 1 0;
149 min: 10 0;
150 max: 10 -1;
151 rel1.to: "field2";
152 rel2 {
153 relative: 0.0 1.0;
154 to: "field2";
155 }
156 align: 1.0 0.5;
157 }
158 }
159 swallow { "field2";
160 mouse;
161 scale;
162 desc { "default";
163 fixed: 1 0;
164 min: 40 0;
165 rel1.to: "padding_right";
166 rel2 {
167 relative: 0.0 1.0;
168 to: "padding_right";
169 }
170 align: 1.0 0.5;
171 }
172 }
173 rect { "access";
174 repeat;
175 desc { "default";
176 fixed: 1 1;
177 rel1.to: "bg";
178 rel2.to: "bg";
179 color: 0 0 0 0;
180 }
181 }
182 }
183}
184
185group { "efl/datepicker/spin_button";
186 parts {
187 rect { "clip";
188 desc { "default";
189 rel.to: "elm.swallow.text_button";
190 }
191 }
192 spacer { "base";
193 scale;
194 desc { "default";
195 min: 40 150;
196 }
197 }
198 rect { "bg";
199 scale;
200 desc { "default";
201 color_class: "spinner_bg";
202 }
203 }
204 rect { "access";
205 repeat;
206 desc { "default";
207 fixed: 1 1;
208 color: 0 0 0 0;
209 rel1.to: "base";
210 rel2.to: "base";
211 hid;
212 }
213 desc { "active";
214 inherit: "default";
215 vis;
216 }
217 }
218 swallow { "elm.swallow.inc_button";
219 scale;
220 desc { "default";
221 align: 0.5 0.0;
222 min: 40 40;
223 max: 40 40;
224 fixed: 1 1;
225 }
226 }
227 swallow { "elm.swallow.dec_button";
228 scale;
229 desc { "default";
230 align: 0.5 1.0;
231 min: 40 40;
232 max: 40 40;
233 fixed: 1 1;
234 }
235 }
236 swallow { "elm.swallow.entry";
237 clip: "clip";
238 desc { "default";
239 fixed: 1 1;
240 rel1.to: "elm.swallow.text_button";
241 rel2.to: "elm.swallow.text_button";
242 hid;
243 }
244 desc { "active";
245 inherit: "default";
246 vis;
247 }
248 }
249 swallow { "elm.swallow.text_button";
250 scale;
251 desc { "default";
252 rel.to_x: "base";
253 rel1 {
254 to_y: "elm.swallow.inc_button";
255 relative: 0.0 1.0;
256 }
257 rel2 {
258 to_y: "elm.swallow.dec_button";
259 relative: 1.0 0.0;
260 }
261 min: 0 70;
262 max: -1 70;
263 fixed: 0 1;
264 }
265 desc { "inactive";
266 inherit: "default";
267 hid;
268 }
269 }
270 rect { "disabler";
271 norepeat;
272 nomouse;
273 desc { "default";
274 color: 0 0 0 0;
275 hid;
276 }
277 desc { "disabled";
278 inherit: "default";
279 vis;
280 }
281 }
282 }
283 programs {
284 program { "entry_active";
285 signal: "elm,state,entry,active";
286 source: "elm";
287 action: STATE_SET "active";
288 target: "elm.swallow.entry";
289 }
290 program { "entry_inactive";
291 signal: "elm,state,entry,inactive";
292 source: "elm";
293 action: STATE_SET "default";
294 target: "elm.swallow.entry";
295 }
296 program { "text_button_active";
297 signal: "elm,state,button,active";
298 source: "elm";
299 action: STATE_SET "default";
300 target: "elm.swallow.text_button";
301 }
302 program { "text_button_inactive";
303 signal: "elm,state,button,inactive";
304 source: "elm";
305 action: STATE_SET "inactive";
306 target: "elm.swallow.text_button";
307 }
308 program { "access_activate";
309 signal: "elm,state,access,active";
310 source: "elm";
311 action: STATE_SET "active";
312 target: "access";
313 }
314 program { "access_inactivate";
315 signal: "elm,state,access,inactive";
316 source: "elm";
317 action: STATE_SET "default";
318 target: "access";
319 }
320 program { "disable";
321 signal: "elm,state,disabled";
322 source: "elm";
323 action: STATE_SET "disabled";
324 target: "disabler";
325 }
326 program { "enable";
327 signal: "elm,state,enabled";
328 source: "elm";
329 action: STATE_SET "default";
330 target: "disabler";
331 }
332 }
333}
334
335group { "efl/datepicker/spin_button/text_button";
336 inherit: "efl/spin_button/text_button";
337}
338
339group { "efl/datepicker/spin_button/inc_button";
340 inherit: "elm/button/base/spinner/increase/vertical";
341}
342
343group { "efl/datepicker/spin_button/dec_button";
344 inherit: "elm/button/base/spinner/decrease/vertical";
345}
diff --git a/data/elementary/themes/edc/efl/spin_button.edc b/data/elementary/themes/edc/efl/spin_button.edc
index 4d502e3..1873c9c 100644
--- a/data/elementary/themes/edc/efl/spin_button.edc
+++ b/data/elementary/themes/edc/efl/spin_button.edc
@@ -356,6 +356,10 @@ group { name: "efl/spin_button/inc_button";
356 } 356 }
357 } 357 }
358 358
359group { "efl/spin_button/entry";
360 inherit: "efl/text";
361}
362
359group { name: "efl/spin_button/dec_button"; 363group { name: "efl/spin_button/dec_button";
360 inherit: "efl/spin_button/inc_button"; 364 inherit: "efl/spin_button/inc_button";
361 images.image: "sym_left_light_normal.png" COMP; 365 images.image: "sym_left_light_normal.png" COMP;
diff --git a/data/elementary/themes/edc/efl/timepicker.edc b/data/elementary/themes/edc/efl/timepicker.edc
new file mode 100644
index 0000000..a33ada0
--- /dev/null
+++ b/data/elementary/themes/edc/efl/timepicker.edc
@@ -0,0 +1,409 @@
1group { "efl/timepicker";
2 nomouse;
3 parts {
4 spacer { "base";
5 scale;
6 desc { "default";
7 min: 150 170;
8 }
9 desc { "24layout";
10 min: 110 170;
11 }
12 }
13 rect { "base_bg";
14 scale;
15 desc { "default";
16 rel.to: "base";
17 color_class: "timepicker_bg";
18 }
19 }
20 spacer { "padding_bg_top";
21 scale;
22 desc { "default";
23 min: 0 10;
24 max: -1 10;
25 fixed: 0 1;
26 rel1 {
27 relative: 0.0 0.0;
28 to: "base_bg";
29 }
30 rel2 {
31 relative: 1.0 0.0;
32 to: "base_bg";
33 }
34 align: 0.5 0.0;
35 }
36 }
37 spacer { "padding_bg_bottom";
38 scale;
39 desc { "default";
40 min: 0 10;
41 max: -1 10;
42 fixed: 0 1;
43 rel1 {
44 relative: 0.0 1.0;
45 to: "base_bg";
46 }
47 rel2 {
48 relative: 1.0 1.0;
49 to: "base_bg";
50 }
51 align: 0.5 1.0;
52 }
53 }
54 spacer { "bg";
55 scale;
56 desc { "default";
57 min: 150 150;
58 max: 150 150;
59 rel1 {
60 relative: 0.0 1.0;
61 to: "padding_bg_top";
62 }
63 rel2 {
64 relative: 1.0 0.0;
65 to: "padding_bg_bottom";
66 }
67 }
68 desc { "24layout";
69 inherit: "default";
70 min: 110 150;
71 max: 110 150;
72 }
73 }
74 spacer { "padding_left";
75 scale;
76 desc { "default";
77 min: 0 0;
78 max: 0 -1;
79 fixed: 1 0;
80 rel1 {
81 relative: 0.0 0.0;
82 to: "bg";
83 }
84 rel2 {
85 relative: 0.0 1.0;
86 to: "bg";
87 }
88 align: 0.0 0.0;
89 }
90 }
91 spacer { "padding_right";
92 scale;
93 desc { "default";
94 min: 0 0;
95 max: 0 -1;
96 fixed: 1 0;
97 rel1 {
98 relative: 1.0 0.0;
99 to: "bg";
100 }
101 rel2 {
102 relative: 1.0 1.0;
103 to: "bg";
104 }
105 align: 1.0 1.0;
106 }
107 }
108 swallow { "field0";
109 mouse;
110 scale;
111 desc { "default";
112 fixed: 1 0;
113 min: 40 0;
114 rel1 {
115 relative: 1.0 0.0;
116 to: "padding_left";
117 }
118 rel2.to: "padding_left";
119 align: 0.0 0.5;
120 }
121 }
122 spacer{ "padding_center1";
123 scale;
124 desc { "default";
125 fixed: 1 0;
126 min: 3 0;
127 max: 3 -1;
128 rel1 {
129 relative: 1.0 0.0;
130 to: "field0";
131 }
132 rel2.to: "field0";
133 align: 0.0 0.5;
134 }
135 desc { "invisible";
136 inherit: default 0.0;
137 min: 15 0;
138 max: 15 -1;
139 }
140 }
141 spacer { "bg_text";
142 scale;
143 desc { "default";
144 rel1 {
145 relative: 1.0 0.0;
146 to: "padding_center1";
147 }
148 rel2.to: "padding_center1";
149 align: 0.0 0.5;
150 min: 9 0;
151 max: 9 -1;
152 fixed: 1 0;
153 }
154 desc { "invisible";
155 inherit: default 0.0;
156 min: 0 0;
157 max: 0 0;
158 }
159 }
160 text { "hour_minute_colon";
161 scale;
162 desc { "default";
163 rel1.to: "bg_text";
164 rel2.to: "bg_text";
165 color: 255 255 255 255;
166 fixed: 1 1;
167 text {
168 min: 1 0;
169 font: "Sans";
170 size: "15";
171 //text: ":";
172 align: 0.5 0.44;
173 }
174 vis;
175 }
176 desc { "invisible";
177 inherit: default 0.0;
178 hid;
179 }
180 }
181 spacer { "padding_center2";
182 scale;
183 desc { "default";
184 fixed: 1 0;
185 min: 3 0;
186 max: 3 -1;
187 rel1 {
188 relative: 1.0 0.0;
189 to: "bg_text";
190 }
191 rel2.to: "bg_text";
192 align: 0.0 0.5;
193 }
194 desc { "invisible";
195 inherit: default 0.0;
196 min: 0 0;
197 max: 0 0;
198 }
199 }
200 swallow { "field1";
201 mouse;
202 scale;
203 desc { "default";
204 fixed: 1 0;
205 min: 40 0;
206 rel1 {
207 relative: 1.0 0.0;
208 to: "padding_center2";
209 }
210 rel2.to: "padding_center2";
211 align: 0.0 0.5;
212 }
213 }
214 spacer { "padding_center3";
215 scale;
216 desc { "default";
217 fixed: 1 0;
218 min: 3 0;
219 max: 3 -1;
220 rel1 {
221 relative: 1.0 0.0;
222 to: "field1";
223 }
224 rel2.to: "field1";
225 align: 0.0 0.5;
226 }
227 desc { "invisible";
228 inherit: default 0.0;
229 min: 15 0;
230 max: 15 -1;
231 }
232 }
233 spacer { "bg_text2";
234 scale;
235 desc { "default";
236 rel1 {
237 relative: 1.0 0.0;
238 to: "padding_center3";
239 }
240 rel2.to: "padding_center3";
241 align: 0.0 0.5;
242 min: 9 0;
243 max: 9 -1;
244 fixed: 1 0;
245 }
246 desc { "invisible";
247 inherit: default 0.0;
248 min: 0 0;
249 max: 0 0;
250 }
251 }
252 text { "hour_minute_colon2";
253 scale;
254 desc { "default";
255 rel1.to: "bg_text2";
256 rel2.to: "bg_text2";
257 color: 255 255 255 255;
258 fixed: 1 1;
259 text {
260 min: 1 0;
261 font: "Sans";
262 size: "15";
263 //text: ":";
264 align: 0.5 0.44;
265 }
266 vis;
267 }
268 desc { "invisible";
269 inherit: default 0.0;
270 hid;
271 }
272 }
273 spacer { "padding_center4";
274 scale;
275 desc { "default";
276 fixed: 1 0;
277 min: 3 0;
278 max: 3 -1;
279 rel1 {
280 relative: 1.0 0.0;
281 to: "bg_text2";
282 }
283 rel2.to: "bg_text2";
284 align: 0.0 0.5;
285 }
286 desc { "invisible";
287 inherit: default 0.0;
288 min: 0 0;
289 max: 0 0;
290 }
291 }
292 swallow { "field2";
293 mouse;
294 scale;
295 desc { "default";
296 fixed: 1 0;
297 min: 40 0;
298 max: 40 -1;
299 rel1 {
300 relative: 1.0 0.0;
301 to: "padding_center4";
302 }
303 rel2.to: "padding_center4";
304 align: 0.0 0.5;
305 }
306 desc { "24layout";
307 hid;
308 min: 0 0;
309 max: 0 -1;
310 }
311 }
312 rect { "access";
313 repeat;
314 desc { "default";
315 fixed: 1 1;
316 rel1.to: "bg";
317 rel2.to: "bg";
318 color: 0 0 0 0;
319 }
320 }
321 }
322 programs {
323 program { "visible_ampm";
324 signal: "elm,state,ampm,visible";
325 source: "elm";
326 script {
327 set_state(PART:"base", "default", 0.0);
328 set_state(PART:"bg", "default", 0.0);
329 set_state(PART:"field2", "default", 0.0);
330 }
331 }
332 program { "invisible_ampm";
333 signal: "elm,state,ampm,invisible";
334 source: "elm";
335 script {
336 set_state(PART:"base", "24layout", 0.0);
337 set_state(PART:"bg", "24layout", 0.0);
338 set_state(PART:"field2", "24layout", 0.0);
339 }
340 }
341 program { "visible_colon_field0";
342 signal: "elm,state,colon,visible,field0";
343 source: "elm";
344 action: STATE_SET "default";
345 target: "padding_center1";
346 target: "hour_minute_colon";
347 target: "bg_text";
348 target: "padding_center2";
349 }
350 program { "invisible_colon_field0";
351 signal: "elm,state,colon,invisible,field0";
352 source: "elm";
353 action: STATE_SET "invisible";
354 target: "padding_center1";
355 target: "hour_minute_colon";
356 target: "bg_text";
357 target: "padding_center2";
358 }
359 program { "visible_colon_field1";
360 signal: "elm,state,colon,visible,field1";
361 source: "elm";
362 action: STATE_SET "default";
363 target: "padding_center3";
364 target: "hour_minute_colon2";
365 target: "bg_text2";
366 target: "padding_center4";
367 }
368 program { "invisible_colon_field1";
369 signal: "elm,state,colon,invisible,field1";
370 source: "elm";
371 action: STATE_SET "invisible";
372 target: "padding_center3";
373 target: "hour_minute_colon2";
374 target: "bg_text2";
375 target: "padding_center4";
376 }
377 }
378}
379
380group { "efl/timepicker/spin_button";
381 inherit: "efl/datepicker/spin_button";
382}
383
384group { "efl/timepicker/spin_button/text_button";
385 inherit: "efl/spin_button/text_button";
386}
387
388group { "efl/timepicker/spin_button/inc_button";
389 inherit: "elm/button/base/spinner/increase/vertical";
390}
391
392group { "efl/timepicker/spin_button/dec_button";
393 inherit: "elm/button/base/spinner/decrease/vertical";
394}
395group { "efl/timepicker/button";
396 inherit: "efl/button";
397 parts {
398 image { "base";
399 desc { "default";
400 min: 40 40;
401 max: 40 40;
402 }
403 desc { "pressed";
404 min: 40 40;
405 max: 40 40;
406 }
407 }
408 }
409}
diff --git a/data/elementary/themes/edc/elm/entry.edc b/data/elementary/themes/edc/elm/entry.edc
index 189bf96..303857d 100644
--- a/data/elementary/themes/edc/elm/entry.edc
+++ b/data/elementary/themes/edc/elm/entry.edc
@@ -854,8 +854,6 @@ group { name: "elm/entry/base-single/default";
854 854
855group { name: "elm/entry/base-single/spinner/default"; 855group { name: "elm/entry/base-single/spinner/default";
856 alias: "elm/entry/base-single/spinner/vertical"; 856 alias: "elm/entry/base-single/spinner/vertical";
857 alias: "elm/entry/base-single/spin_button/default";
858 alias: "elm/entry/base-single/spin_button/vertical";
859 inherit: "elm/entry/base-single/default"; 857 inherit: "elm/entry/base-single/default";
860 styles { 858 styles {
861 style { name: "entry_single_spinner_style"; 859 style { name: "entry_single_spinner_style";
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index e6a4059..d101d85 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -27,6 +27,8 @@ elm_public_eolian_files = \
27 lib/elementary/efl_ui_slider_interval.eo \ 27 lib/elementary/efl_ui_slider_interval.eo \
28 lib/elementary/efl_ui_spin.eo \ 28 lib/elementary/efl_ui_spin.eo \
29 lib/elementary/efl_ui_spin_button.eo \ 29 lib/elementary/efl_ui_spin_button.eo \
30 lib/elementary/efl_ui_datepicker.eo \
31 lib/elementary/efl_ui_timepicker.eo \
30 lib/elementary/efl_ui_video.eo \ 32 lib/elementary/efl_ui_video.eo \
31 lib/elementary/efl_ui_win.eo \ 33 lib/elementary/efl_ui_win.eo \
32 lib/elementary/efl_ui_win_inlined.eo \ 34 lib/elementary/efl_ui_win_inlined.eo \
@@ -145,6 +147,7 @@ elm_private_eolian_files = \
145 tests/elementary/focus_test.eo \ 147 tests/elementary/focus_test.eo \
146 tests/elementary/focus_test_sub_main.eo \ 148 tests/elementary/focus_test_sub_main.eo \
147 lib/elementary/efl_selection_manager.eo \ 149 lib/elementary/efl_selection_manager.eo \
150 lib/elementary/efl_datetime_manager.eo \
148 $(NULL) 151 $(NULL)
149 152
150# Legacy classes - not part of public EO API 153# Legacy classes - not part of public EO API
@@ -382,6 +385,8 @@ includesunstable_HEADERS = \
382 lib/elementary/elm_widget_spinner.h \ 385 lib/elementary/elm_widget_spinner.h \
383 lib/elementary/efl_ui_spin_private.h \ 386 lib/elementary/efl_ui_spin_private.h \
384 lib/elementary/efl_ui_spin_button_private.h \ 387 lib/elementary/efl_ui_spin_button_private.h \
388 lib/elementary/efl_ui_datepicker_private.h \
389 lib/elementary/efl_ui_timepicker_private.h \
385 lib/elementary/elm_widget_table.h \ 390 lib/elementary/elm_widget_table.h \
386 lib/elementary/elm_widget_thumb.h \ 391 lib/elementary/elm_widget_thumb.h \
387 lib/elementary/elm_widget_toolbar.h \ 392 lib/elementary/elm_widget_toolbar.h \
@@ -742,6 +747,8 @@ lib_elementary_libelementary_la_SOURCES = \
742 lib/elementary/efl_ui_slider_interval.c \ 747 lib/elementary/efl_ui_slider_interval.c \
743 lib/elementary/efl_ui_spin.c \ 748 lib/elementary/efl_ui_spin.c \
744 lib/elementary/efl_ui_spin_button.c \ 749 lib/elementary/efl_ui_spin_button.c \
750 lib/elementary/efl_ui_datepicker.c \
751 lib/elementary/efl_ui_timepicker.c \
745 lib/elementary/elm_slideshow.c \ 752 lib/elementary/elm_slideshow.c \
746 lib/elementary/elm_spinner.c \ 753 lib/elementary/elm_spinner.c \
747 lib/elementary/elm_store.c \ 754 lib/elementary/elm_store.c \
@@ -812,6 +819,7 @@ lib_elementary_libelementary_la_SOURCES = \
812 lib/elementary/efl_selection_manager.c \ 819 lib/elementary/efl_selection_manager.c \
813 lib/elementary/efl_selection_manager_private.h \ 820 lib/elementary/efl_selection_manager_private.h \
814 lib/elementary/efl_selection.c \ 821 lib/elementary/efl_selection.c \
822 lib/elementary/efl_datetime_manager.c \
815 lib/elementary/efl_ui_dnd.c \ 823 lib/elementary/efl_ui_dnd.c \
816 static_libs/buildsystem/buildsystem.h \ 824 static_libs/buildsystem/buildsystem.h \
817 static_libs/buildsystem/buildsystem_autotools.c \ 825 static_libs/buildsystem/buildsystem_autotools.c \
@@ -1000,6 +1008,8 @@ bin/elementary/test_ui_slider.c \
1000bin/elementary/test_ui_slider_interval.c \ 1008bin/elementary/test_ui_slider_interval.c \
1001bin/elementary/test_ui_spin.c \ 1009bin/elementary/test_ui_spin.c \
1002bin/elementary/test_ui_spin_button.c \ 1010bin/elementary/test_ui_spin_button.c \
1011bin/elementary/test_ui_datepicker.c \
1012bin/elementary/test_ui_timepicker.c \
1003bin/elementary/test_slideshow.c \ 1013bin/elementary/test_slideshow.c \
1004bin/elementary/test_spinner.c \ 1014bin/elementary/test_spinner.c \
1005bin/elementary/test_store.c \ 1015bin/elementary/test_store.c \
diff --git a/src/bin/elementary/Makefile.am b/src/bin/elementary/Makefile.am
index 0749293..57c6035 100644
--- a/src/bin/elementary/Makefile.am
+++ b/src/bin/elementary/Makefile.am
@@ -133,6 +133,8 @@ test_slideshow.c \
133test_spinner.c \ 133test_spinner.c \
134test_ui_spinner.c \ 134test_ui_spinner.c \
135test_ui_buttonspin.c \ 135test_ui_buttonspin.c \
136test_ui_datepicker.c \
137test_ui_timepicker.c \
136test_store.c \ 138test_store.c \
137test_sys_notify.c \ 139test_sys_notify.c \
138test_systray.c \ 140test_systray.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 4ef1ac7..3bd23e9 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -183,6 +183,8 @@ void test_efl_ui_scroller2(void *data, Evas_Object *obj, void *event_info);
183void test_spinner(void *data, Evas_Object *obj, void *event_info); 183void test_spinner(void *data, Evas_Object *obj, void *event_info);
184void test_ui_spin(void *data, Evas_Object *obj, void *event_info); 184void test_ui_spin(void *data, Evas_Object *obj, void *event_info);
185void test_ui_spin_button(void *data, Evas_Object *obj, void *event_info); 185void test_ui_spin_button(void *data, Evas_Object *obj, void *event_info);
186void test_ui_datepicker(void *data, Evas_Object *obj, void *event_info);
187void test_ui_timepicker(void *data, Evas_Object *obj, void *event_info);
186void test_index(void *data, Evas_Object *obj, void *event_info); 188void test_index(void *data, Evas_Object *obj, void *event_info);
187void test_index2(void *data, Evas_Object *obj, void *event_info); 189void test_index2(void *data, Evas_Object *obj, void *event_info);
188void test_index3(void *data, Evas_Object *obj, void *event_info); 190void test_index3(void *data, Evas_Object *obj, void *event_info);
@@ -1084,6 +1086,8 @@ add_tests:
1084 ADD_TEST(NULL, "Times & Dates", "Datetime", test_datetime); 1086 ADD_TEST(NULL, "Times & Dates", "Datetime", test_datetime);
1085 ADD_TEST_EO(NULL, "Times & Dates", "Efl.Ui.Calendar", test_efl_ui_calendar); 1087 ADD_TEST_EO(NULL, "Times & Dates", "Efl.Ui.Calendar", test_efl_ui_calendar);
1086 ADD_TEST_EO(NULL, "Times & Dates", "Efl.Ui.Clock", test_ui_clock); 1088 ADD_TEST_EO(NULL, "Times & Dates", "Efl.Ui.Clock", test_ui_clock);
1089 ADD_TEST_EO(NULL, "Times & Dates", "Efl.Ui.Datepicker", test_ui_datepicker);
1090 ADD_TEST_EO(NULL, "Times & Dates", "Efl.Ui.Timepicker", test_ui_timepicker);
1087 1091
1088 //------------------------------// 1092 //------------------------------//
1089 ADD_TEST(NULL, "Text", "Label", test_label); 1093 ADD_TEST(NULL, "Text", "Label", test_label);
diff --git a/src/bin/elementary/test_ui_datepicker.c b/src/bin/elementary/test_ui_datepicker.c
new file mode 100644
index 0000000..1eb0461
--- /dev/null
+++ b/src/bin/elementary/test_ui_datepicker.c
@@ -0,0 +1,37 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5
6static void
7_date_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
8{
9 int year, month, day;
10
11 efl_ui_datepicker_date_get(ev->object, &year, &month, &day);
12 printf("Current date is %d %d %d\n", year, month, day);
13}
14
15void
16test_ui_datepicker(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
17{
18 Eo *win, *bx;
19
20 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
21 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
22 efl_text_set(efl_added, "Efl.Ui.Datepicker"),
23 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
24
25 bx = efl_add(EFL_UI_BOX_CLASS, win,
26 efl_content_set(win, efl_added),
27 efl_ui_direction_set(efl_added, EFL_UI_DIR_DOWN));
28
29 efl_add(EFL_UI_DATEPICKER_CLASS, bx,
30 efl_ui_datepicker_date_set(efl_added, 1987, 9, 17),
31 efl_ui_datepicker_max_set(efl_added, 1990, 9, 17),
32 efl_ui_datepicker_min_set(efl_added, 1980, 9, 17),
33 efl_event_callback_add(efl_added, EFL_UI_DATEPICKER_EVENT_CHANGED,_date_changed_cb, NULL),
34 efl_pack(bx, efl_added));
35
36 efl_gfx_entity_size_set(win, EINA_SIZE2D(150, 170));
37}
diff --git a/src/bin/elementary/test_ui_timepicker.c b/src/bin/elementary/test_ui_timepicker.c
new file mode 100644
index 0000000..cb88ef5
--- /dev/null
+++ b/src/bin/elementary/test_ui_timepicker.c
@@ -0,0 +1,36 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5
6static void
7_time_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
8{
9 int hour, min;
10
11 efl_ui_timepicker_time_get(ev->object, &hour, &min);
12 printf("Current time is %d %d\n", hour, min);
13}
14
15
16void
17test_ui_timepicker(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
18{
19 Eo *win, *bx;
20
21 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
22 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
23 efl_text_set(efl_added, "Efl.Ui.Timepicker"),
24 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
25
26 bx = efl_add(EFL_UI_BOX_CLASS, win,
27 efl_content_set(win, efl_added),
28 efl_ui_direction_set(efl_added, EFL_UI_DIR_DOWN));
29
30 efl_add(EFL_UI_TIMEPICKER_CLASS, bx,
31 efl_ui_timepicker_time_set(efl_added, 11, 35),
32 efl_event_callback_add(efl_added, EFL_UI_TIMEPICKER_EVENT_CHANGED,_time_changed_cb, NULL),
33 efl_pack(bx, efl_added));
34
35 efl_gfx_entity_size_set(win, EINA_SIZE2D(150, 170));
36}
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index 0a79fbb..2853ba2 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -319,6 +319,8 @@ typedef Eo Efl_Ui_Focus_Manager;
319# include <efl_ui_clock.eo.h> 319# include <efl_ui_clock.eo.h>
320# include <efl_ui_spin.eo.h> 320# include <efl_ui_spin.eo.h>
321# include <efl_ui_spin_button.eo.h> 321# include <efl_ui_spin_button.eo.h>
322# include <efl_ui_datepicker.eo.h>
323# include <efl_ui_timepicker.eo.h>
322# include <efl_ui_image_factory.eo.h> 324# include <efl_ui_image_factory.eo.h>
323# include <efl_ui_slider_interval.eo.h> 325# include <efl_ui_slider_interval.eo.h>
324# include <efl_ui_layout_factory.eo.h> 326# include <efl_ui_layout_factory.eo.h>
diff --git a/src/lib/elementary/efl_datetime_manager.c b/src/lib/elementary/efl_datetime_manager.c
new file mode 100644
index 0000000..8739be8
--- /dev/null
+++ b/src/lib/elementary/efl_datetime_manager.c
@@ -0,0 +1,193 @@
1#include <config.h>
2#include "Efl.h"
3
4#ifdef HAVE_LANGINFO_H
5# include <langinfo.h>
6#endif
7
8#include <Elementary.h>
9#include "elm_priv.h"
10
11#define MY_CLASS EFL_DATETIME_MANAGER_CLASS
12
13#define MAX_FORMAT_LEN 32
14
15static const char *multifield_formats = "cxXrRTDF";
16
17typedef struct
18{
19 Efl_Time time;
20 char format[MAX_FORMAT_LEN];
21} Efl_Datetime_Manager_Data;
22
23Eina_Bool init = EINA_FALSE;
24
25static void
26_time_init(Efl_Time *curr_time)
27{
28 time_t t;
29
30 t = time(NULL);
31 localtime_r(&t, curr_time);
32
33 init = EINA_TRUE;
34}
35
36static char *
37_expanded_fmt_str_get(char ch)
38{
39 char *exp_fmt = "";
40 switch (ch)
41 {
42 case 'c':
43#if defined(HAVE_LANGINFO_H) || defined (_WIN32)
44 exp_fmt = nl_langinfo(D_T_FMT);
45#else
46 exp_fmt = "";
47#endif
48 break;
49
50 case 'x':
51#if defined(HAVE_LANGINFO_H) || defined (_WIN32)
52 exp_fmt = nl_langinfo(D_FMT);
53#else
54 exp_fmt = "";
55#endif
56 break;
57
58 case 'X':
59#if defined(HAVE_LANGINFO_H) || defined (_WIN32)
60 exp_fmt = nl_langinfo(T_FMT);
61#else
62 exp_fmt = "";
63#endif
64 break;
65
66 case 'r':
67#if defined(HAVE_LANGINFO_H) || defined (_WIN32)
68 exp_fmt = nl_langinfo(T_FMT_AMPM);
69#else
70 exp_fmt = "";
71#endif
72 break;
73
74 case 'R':
75 exp_fmt = "%H:%M";
76 break;
77
78 case 'T':
79 exp_fmt = "%H:%M:%S";
80 break;
81
82 case 'D':
83 exp_fmt = "%m/%d/%y";
84 break;
85
86 case 'F':
87 exp_fmt = "%Y-%m-%d";
88 break;
89
90 default:
91 exp_fmt = "";
92 break;
93 }
94
95 return exp_fmt;
96}
97
98static void
99_expand_format(char *dt_fmt)
100{
101 char *ptr, *expanded_fmt, ch;
102 unsigned int idx, len = 0;
103 char buf[MAX_FORMAT_LEN] = {0, };
104 Eina_Bool fmt_char, fmt_expanded;
105
106 do {
107 idx = 0;
108 fmt_char = EINA_FALSE;
109 fmt_expanded = EINA_FALSE;
110 ptr = dt_fmt;
111 while ((ch = *ptr))
112 {
113 if ((fmt_char) && (strchr(multifield_formats, ch)))
114 {
115 /* replace the multi-field format characters with
116 * corresponding expanded format */
117 expanded_fmt = _expanded_fmt_str_get(ch);
118 len = strlen(expanded_fmt);
119 if (len > 0) fmt_expanded = EINA_TRUE;
120 buf[--idx] = 0;
121 strncat(buf, expanded_fmt, len);
122 idx += len;
123 }
124 else buf[idx++] = ch;
125
126 if (ch == '%') fmt_char = EINA_TRUE;
127 else fmt_char = EINA_FALSE;
128
129 ptr++;
130 }
131
132 buf[idx] = 0;
133 strncpy(dt_fmt, buf, MAX_FORMAT_LEN);
134 } while (fmt_expanded);
135}
136
137EOLIAN static Eo*
138_efl_datetime_manager_efl_object_constructor(Eo *obj, Efl_Datetime_Manager_Data *pd EINA_UNUSED)
139{
140 obj = efl_constructor(efl_super(obj, MY_CLASS));
141
142 return obj;
143}
144
145
146EOLIAN static void
147_efl_datetime_manager_efl_object_destructor(Eo *obj, Efl_Datetime_Manager_Data *pd EINA_UNUSED)
148{
149 efl_destructor(efl_super(obj, MY_CLASS));
150}
151
152EOLIAN static void
153_efl_datetime_manager_value_set(Eo *obj EINA_UNUSED, Efl_Datetime_Manager_Data *pd, Efl_Time newtime)
154{
155 pd->time = newtime;
156}
157
158EOLIAN static Efl_Time
159_efl_datetime_manager_value_get(const Eo *obj EINA_UNUSED, Efl_Datetime_Manager_Data *pd)
160{
161 if (!init) _time_init(&pd->time);
162
163 return pd->time;
164}
165
166EOLIAN static void
167_efl_datetime_manager_format_set(Eo *obj EINA_UNUSED, Efl_Datetime_Manager_Data *pd EINA_UNUSED, const char *fmt EINA_UNUSED)
168{
169 //Is this needed?
170}
171
172EOLIAN static const char *
173_efl_datetime_manager_format_get(const Eo *obj EINA_UNUSED, Efl_Datetime_Manager_Data *pd)
174{
175#if defined(HAVE_LANGINFO_H) || defined (_WIN32)
176 strncpy(pd->format, nl_langinfo(D_T_FMT), MAX_FORMAT_LEN);
177#else
178 strncpy(pd->format, "", MAX_FORMAT_LEN);
179#endif
180 pd->format[MAX_FORMAT_LEN - 1] = '\0';
181
182 _expand_format(pd->format);
183
184 return pd->format;
185}
186EOLIAN static const char *
187_efl_datetime_manager_string_get(const Eo *obj EINA_UNUSED, Efl_Datetime_Manager_Data *pd EINA_UNUSED, const char *fmt EINA_UNUSED)
188{
189 //TODO: strftime on upsteam, icu module connect here on tizen.
190 return NULL;
191}
192#include "efl_datetime_manager.eo.c"
193
diff --git a/src/lib/elementary/efl_datetime_manager.eo b/src/lib/elementary/efl_datetime_manager.eo
new file mode 100644
index 0000000..0728dc7
--- /dev/null
+++ b/src/lib/elementary/efl_datetime_manager.eo
@@ -0,0 +1,50 @@
1import efl_types;
2
3class Efl.Datetime.Manager (Efl.Object)
4{
5 [[Efl datetime manager class for Datepicker and Timepicker]]
6 methods {
7 @property value {
8 [[The value of a date, time for Datepicker or Timepicker.
9
10 The value for Datepicker contains year, month, and day. (tm_year, tm_mon, and tm_mday in Efl_Time)
11 The value for Timepicker contains hour, and min. (tm_hour, and tm_min in Efl_Time)
12 ]]
13 set {
14 }
15 get {
16 }
17 values {
18 newtime: Efl.Time; [[Time structure containing date or time value.]]
19 }
20 }
21 @property format {
22 [[The format of date or time.
23
24 Default format is taken as per the system locale settings.
25 ]]
26 set {
27 }
28 get {
29 }
30 values {
31 fmt: string; [[The format string]]
32 }
33 }
34 @property string {
35 get {
36 [[Get the string that matches with the format.]]
37 }
38 keys {
39 fmt: string; [[The format string]]
40 }
41 values {
42 string: string; [[The string that matches with the format]]
43 }
44 }
45 }
46 implements {
47 Efl.Object.constructor;
48 Efl.Object.destructor;
49 }
50}
diff --git a/src/lib/elementary/efl_ui_datepicker.c b/src/lib/elementary/efl_ui_datepicker.c
new file mode 100644
index 0000000..2429d21
--- /dev/null
+++ b/src/lib/elementary/efl_ui_datepicker.c
@@ -0,0 +1,349 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6
7#include "elm_priv.h"
8#include "efl_ui_datepicker_private.h"
9
10#define MY_CLASS EFL_UI_DATEPICKER_CLASS
11
12#define MY_CLASS_NAME "Efl.Ui.Datepicker"
13
14#define FMT_LEN_MAX 32
15
16#define DATE_GET() \
17 do { \
18 Efl_Time t = efl_datetime_manager_value_get(pd->dt_manager); \
19 pd->cur_date[DATEPICKER_YEAR] = t.tm_year + 1900; \
20 pd->cur_date[DATEPICKER_MONTH] = t.tm_mon + 1; \
21 pd->cur_date[DATEPICKER_DAY] = t.tm_mday; \
22 } while (0)
23
24#define DATE_SET() \
25 do { \
26 Efl_Time t; \
27 t.tm_year = pd->cur_date[DATEPICKER_YEAR] - 1900; \
28 t.tm_mon = pd->cur_date[DATEPICKER_MONTH] - 1; \
29 t.tm_mday = pd->cur_date[DATEPICKER_DAY]; \
30 efl_datetime_manager_value_set(pd->dt_manager, t); \
31 } while (0)
32
33static const char *fmt_char[] = {"Yy", "mbBh", "de"};
34
35static Eina_Bool
36_validate_params(int year, int month, int day)
37{
38 if (year < 1900 || year > 2037 || month < 1 || month > 12 || day < 0 || day > 31)
39 return EINA_FALSE;
40 else return EINA_TRUE;
41}
42
43static Eina_Bool
44_date_cmp(int time1[], int time2[])
45{
46 unsigned int idx;
47
48 for (idx = 0; idx < EFL_UI_DATEPICKER_TYPE_COUNT; idx++)
49 {
50 if (time1[idx] != time2[idx])
51 return EINA_FALSE;
52 }
53
54 return EINA_TRUE;
55}
56
57static Eina_Bool
58_validate_date_limits(int time1[], int time2[], Eina_Bool swap)
59{
60 unsigned int idx;
61 int *t1, *t2;
62
63 t1 = (swap) ? time2 : time1;
64 t2 = (swap) ? time1 : time2;
65
66 for (idx = 0; idx < EFL_UI_DATEPICKER_TYPE_COUNT; idx++)
67 {
68 if (time1[idx] < time2[idx])
69 {
70 memcpy(t1, t2, (sizeof(int) * EFL_UI_DATEPICKER_TYPE_COUNT));
71 return EINA_TRUE;
72 }
73 else if (time1[idx] > time2[idx])
74 return EINA_FALSE;
75 }
76
77 return EINA_FALSE;
78}
79
80static int
81_max_days_get(int year, int month)
82{
83 struct tm time1;
84 time_t t;
85 int day;
86
87 t = time(NULL);
88 localtime_r(&t, &time1);
89 time1.tm_year = year;
90 time1.tm_mon = month;
91 for (day = 28; day <= 31;
92 day++)
93 {
94 time1.tm_mday = day;
95 mktime(&time1);
96 /* To restrict month wrapping because of summer time in some locales,
97 * ignore day light saving mode in mktime(). */
98 time1.tm_isdst = -1;
99 if (time1.tm_mday == 1) break;
100 }
101 day--;
102
103 return day;
104}
105
106static void
107_field_value_update(Eo *obj)
108{
109 Efl_Ui_Datepicker_Data *pd = efl_data_scope_get(obj, MY_CLASS);
110
111 efl_ui_range_value_set(pd->year, pd->cur_date[DATEPICKER_YEAR]);
112 efl_ui_range_value_set(pd->month, pd->cur_date[DATEPICKER_MONTH]);
113 efl_ui_range_value_set(pd->day, pd->cur_date[DATEPICKER_DAY]);
114
115 DATE_SET();
116}
117
118static void
119_field_changed_cb(void *data, const Efl_Event *ev)
120{
121 int max_day;
122
123 Efl_Ui_Datepicker_Data *pd = efl_data_scope_get(data, MY_CLASS);
124
125 if (ev->object == pd->year)
126 pd->cur_date[DATEPICKER_YEAR] = efl_ui_range_value_get(pd->year);
127 else if (ev->object == pd->month)
128 pd->cur_date[DATEPICKER_MONTH] = efl_ui_range_value_get(pd->month);
129 else
130 pd->cur_date[DATEPICKER_DAY] = efl_ui_range_value_get(pd->day);
131
132 if (!(ev->object == pd->day))
133 {
134 max_day = _max_days_get((pd->cur_date[DATEPICKER_YEAR] - 1900), (pd->cur_date[DATEPICKER_MONTH] - 1));
135 efl_ui_range_min_max_set(pd->day, 1, max_day);
136 }
137
138 if (_validate_date_limits(pd->cur_date, pd->min_date, EINA_FALSE) ||
139 _validate_date_limits(pd->max_date, pd->cur_date, EINA_TRUE))
140 {
141 _field_value_update(data);
142 return;
143 }
144
145 DATE_SET();
146 efl_event_callback_call(data, EFL_UI_DATEPICKER_EVENT_CHANGED, NULL);
147}
148
149static void
150_fields_init(Eo *obj)
151{
152 const char *fmt;
153 char ch;
154 int i;
155 int field = 0;
156 char buf[FMT_LEN_MAX];
157
158 Efl_Ui_Datepicker_Data *pd = efl_data_scope_get(obj, MY_CLASS);
159
160 //Field create.
161 pd->year = efl_add(EFL_UI_SPIN_BUTTON_CLASS, obj,
162 efl_ui_range_min_max_set(efl_added, 1970, 2037),
163 efl_ui_spin_button_circulate_set(efl_added, EINA_TRUE),
164 efl_ui_spin_button_editable_set(efl_added, EINA_TRUE),
165 efl_event_callback_add(efl_added, EFL_UI_SPIN_EVENT_CHANGED,_field_changed_cb, obj),
166 elm_widget_element_update(obj, efl_added, "spin_button"));
167
168 pd->month = efl_add(EFL_UI_SPIN_BUTTON_CLASS, obj,
169 efl_ui_range_min_max_set(efl_added, 1, 12),
170 efl_ui_spin_button_circulate_set(efl_added, EINA_TRUE),
171 efl_ui_spin_button_editable_set(efl_added, EINA_TRUE),
172 efl_event_callback_add(efl_added, EFL_UI_SPIN_EVENT_CHANGED,_field_changed_cb, obj),
173 elm_widget_element_update(obj, efl_added, "spin_button"));
174
175 pd->day = efl_add(EFL_UI_SPIN_BUTTON_CLASS, obj,
176 efl_ui_range_min_max_set(efl_added, 1, 31),
177 efl_ui_spin_button_circulate_set(efl_added, EINA_TRUE),
178 efl_ui_spin_button_editable_set(efl_added, EINA_TRUE),
179 efl_event_callback_add(efl_added, EFL_UI_SPIN_EVENT_CHANGED,_field_changed_cb, obj),
180 elm_widget_element_update(obj, efl_added, "spin_button"));
181
182 DATE_GET();
183 //Using system config?
184 pd->min_date[DATEPICKER_YEAR] = 1970;
185 pd->min_date[DATEPICKER_MONTH] = 1;
186 pd->min_date[DATEPICKER_DAY] = 1;
187 pd->max_date[DATEPICKER_YEAR] = 2037;
188 pd->max_date[DATEPICKER_MONTH] = 12;
189 pd->max_date[DATEPICKER_DAY] = 31;
190
191 _field_value_update(obj);
192
193 fmt = efl_datetime_manager_format_get(pd->dt_manager);
194 if (!fmt)
195 {
196 ERR("Failed to get current format.");
197 //Gives default format when the gets format failed.
198 fmt = "%Y %b %d";
199 }
200
201 //Sort fields by format.
202 while((ch = *fmt))
203 {
204 //TODO: ignore extensions and separators.
205 for (i = 0; i < EFL_UI_DATEPICKER_TYPE_COUNT; i++)
206 {
207 if (strchr(fmt_char[i], ch))
208 {
209 snprintf(buf, sizeof(buf), "field%d", field++);
210 if (i == DATEPICKER_YEAR)
211 efl_content_set(efl_part(obj, buf), pd->year);
212 else if (i == DATEPICKER_MONTH)
213 efl_content_set(efl_part(obj, buf), pd->month);
214 else
215 efl_content_set(efl_part(obj, buf), pd->day);
216
217 break;
218 }
219 }
220 fmt++;
221 }
222}
223
224EOLIAN static void
225_efl_ui_datepicker_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Datepicker_Data *_pd EINA_UNUSED)
226{
227 Evas_Coord minw = -1, minh = -1;
228 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
229
230 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
231 edje_object_size_min_restricted_calc
232 (wd->resize_obj, &minw, &minh, minw, minh);
233 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
234 evas_object_size_hint_min_set(obj, minw, minh);
235 evas_object_size_hint_max_set(obj, -1, -1);
236}
237
238EOLIAN static Eo *
239_efl_ui_datepicker_efl_object_constructor(Eo *obj, Efl_Ui_Datepicker_Data *pd)
240{
241 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
242
243 if (!elm_widget_theme_klass_get(obj))
244 elm_widget_theme_klass_set(obj, "datepicker");
245 obj = efl_constructor(efl_super(obj, MY_CLASS));
246
247 if (!elm_widget_theme_object_set(obj, wd->resize_obj,
248 elm_widget_theme_klass_get(obj),
249 elm_widget_theme_element_get(obj),
250 elm_widget_theme_style_get(obj)))
251 CRI("Failed to set layout!");
252
253 pd->dt_manager = efl_add(EFL_DATETIME_MANAGER_CLASS, obj);
254
255 _fields_init(obj);
256
257 elm_widget_sub_object_parent_add(obj);
258
259 elm_widget_can_focus_set(obj, EINA_TRUE);
260
261 return obj;
262}
263
264EOLIAN static void
265_efl_ui_datepicker_efl_object_destructor(Eo *obj, Efl_Ui_Datepicker_Data *pd)
266{
267 efl_del(pd->dt_manager);
268 efl_destructor(efl_super(obj, MY_CLASS));
269}
270
271EOLIAN static void
272_efl_ui_datepicker_min_set(Eo *obj, Efl_Ui_Datepicker_Data *pd EINA_UNUSED, int year, int month, int day)
273{
274 int new_time[EFL_UI_DATEPICKER_TYPE_COUNT] = {year, month, day};
275
276 if (!_validate_params(year, month, day)) return;
277 if (_date_cmp(pd->min_date, new_time)) return;
278
279 memcpy(pd->min_date, new_time, (sizeof(int) * EFL_UI_DATEPICKER_TYPE_COUNT));
280
281 _validate_date_limits(pd->max_date, pd->min_date, EINA_FALSE);
282 _validate_date_limits(pd->cur_date, pd->min_date, EINA_FALSE);
283
284 DATE_SET();
285 _field_value_update(obj);
286}
287
288EOLIAN static void
289_efl_ui_datepicker_min_get(const Eo *obj EINA_UNUSED, Efl_Ui_Datepicker_Data *pd, int *year, int *month, int *day)
290{
291 *year = pd->min_date[DATEPICKER_YEAR];
292 *month = pd->min_date[DATEPICKER_MONTH];
293 *day = pd->min_date[DATEPICKER_DAY];
294}
295
296EOLIAN static void
297_efl_ui_datepicker_max_set(Eo *obj, Efl_Ui_Datepicker_Data *pd EINA_UNUSED, int year, int month, int day)
298{
299 int new_time[EFL_UI_DATEPICKER_TYPE_COUNT] = {year, month, day};
300
301 if (!_validate_params(year, month, day)) return;
302 if (_date_cmp(pd->max_date, new_time)) return;
303
304 memcpy(pd->max_date, new_time, (sizeof(int) * EFL_UI_DATEPICKER_TYPE_COUNT));
305
306 _validate_date_limits(pd->max_date, pd->min_date, EINA_TRUE);
307 _validate_date_limits(pd->max_date, pd->cur_date, EINA_TRUE);
308
309 DATE_SET();
310 _field_value_update(obj);
311}
312
313EOLIAN static void
314_efl_ui_datepicker_max_get(const Eo *obj EINA_UNUSED, Efl_Ui_Datepicker_Data *pd, int *year, int *month, int *day)
315{
316 *year = pd->max_date[DATEPICKER_YEAR];
317 *month = pd->max_date[DATEPICKER_MONTH];
318 *day = pd->max_date[DATEPICKER_DAY];
319}
320
321EOLIAN static void
322_efl_ui_datepicker_date_set(Eo *obj, Efl_Ui_Datepicker_Data *pd, int year, int month, int day)
323{
324 int new_time[EFL_UI_DATEPICKER_TYPE_COUNT] = {year, month, day};
325
326 if (!_validate_params(year, month, day)) return;
327 if (_date_cmp(pd->cur_date, new_time)) return;
328
329 memcpy(pd->cur_date, new_time, (sizeof(int) * EFL_UI_DATEPICKER_TYPE_COUNT));
330
331 _validate_date_limits(pd->cur_date, pd->min_date, EINA_FALSE);
332 _validate_date_limits(pd->max_date, pd->cur_date, EINA_TRUE);
333
334 DATE_SET();
335 _field_value_update(obj);
336}
337
338EOLIAN static void
339_efl_ui_datepicker_date_get(const Eo *obj EINA_UNUSED, Efl_Ui_Datepicker_Data *pd, int *year, int *month, int *day)
340{
341 *year = pd->cur_date[DATEPICKER_YEAR];
342 *month = pd->cur_date[DATEPICKER_MONTH];
343 *day = pd->cur_date[DATEPICKER_DAY];
344}
345
346#define EFL_UI_DATEPICKER_EXTRA_OPS \
347 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_datepicker), \
348
349#include "efl_ui_datepicker.eo.c"
diff --git a/src/lib/elementary/efl_ui_datepicker.eo b/src/lib/elementary/efl_ui_datepicker.eo
new file mode 100644
index 0000000..2ba8923
--- /dev/null
+++ b/src/lib/elementary/efl_ui_datepicker.eo
@@ -0,0 +1,75 @@
1class Efl.Ui.Datepicker (Efl.Ui.Layout.Object)
2{
3 [[Datepicker widget
4
5 This is a widget which allows the user to pick a date using internal spinner.
6 User can use the internal spinner to select year, month, day or user can input
7 value using internal entry.
8 ]]
9 methods {
10 @property min {
11 [[The lower boundary of date.
12
13 $year: Year. The year range is from 1900 to 2137.
14
15 $month: Month. The month range is from 1 to 12.
16
17 $day: Day. The day range is from 1 to 31 according to $month.
18 ]]
19 set {
20 }
21 get{
22 }
23 values {
24 year: int; [[The year value.]]
25 month: int; [[The month value from 1 to 12.]]
26 day: int; [[The day value from 1 to 31.]]
27 }
28 }
29 @property max {
30 [[The upper boundary of date.
31
32 $year: Year. The year range is from 1900 to 2137.
33
34 $month: Month. The month range is from 1 to 12.
35
36 $day: Day. The day range is from 1 to 31 according to $month.
37 ]]
38 set {
39 }
40 get {
41 }
42 values {
43 year: int; [[The year value.]]
44 month: int; [[The month value from 1 to 12.]]
45 day: int; [[The day value from 1 to 31.]]
46 }
47 }
48 @property date {
49 [[The current value of date.
50
51 $year: Year. The year range is from 1900 to 2137.
52
53 $month: Month. The month range is from 0 to 11.
54
55 $day: Day. The day range is from 1 to 31 according to $month.
56 ]]
57 set {
58 }
59 get{
60 }
61 values {
62 year: int; [[The year value.]]
63 month: int; [[The month value from 1 to 12.]]
64 day: int; [[The day value from 1 to 31.]]
65 }
66 }
67 }
68 implements {
69 Efl.Object.constructor;
70 Efl.Object.destructor;
71 }
72 events {
73 changed; [[Called when date value is changed]]
74 }
75}
diff --git a/src/lib/elementary/efl_ui_datepicker_private.h b/src/lib/elementary/efl_ui_datepicker_private.h
new file mode 100644
index 0000000..0ee265b
--- /dev/null
+++ b/src/lib/elementary/efl_ui_datepicker_private.h
@@ -0,0 +1,22 @@
1#ifndef EFL_UI_DATEPICKER_PRIVATE_H
2#define EFL_UI_DATEPICKER_PRIVATE_H
3
4#define EFL_UI_DATEPICKER_TYPE_COUNT 3
5
6typedef enum _Efl_Ui_Datepicker_Field_Type
7{
8 DATEPICKER_YEAR,
9 DATEPICKER_MONTH,
10 DATEPICKER_DAY
11} Efl_Ui_Datepicker_Field_Type;
12
13typedef struct _Efl_Ui_Datepicker_Data Efl_Ui_Datepicker_Data;
14struct _Efl_Ui_Datepicker_Data
15{
16 Eo *dt_manager, *year, *month, *day;
17 int cur_date[EFL_UI_DATEPICKER_TYPE_COUNT],
18 min_date[EFL_UI_DATEPICKER_TYPE_COUNT],
19 max_date[EFL_UI_DATEPICKER_TYPE_COUNT];
20};
21
22#endif
diff --git a/src/lib/elementary/efl_ui_spin_button.c b/src/lib/elementary/efl_ui_spin_button.c
index fe11db4..bb0e903 100644
--- a/src/lib/elementary/efl_ui_spin_button.c
+++ b/src/lib/elementary/efl_ui_spin_button.c
@@ -20,6 +20,7 @@
20 20
21#define EFL_UI_SPIN_BUTTON_DELAY_CHANGE_TIME 0.2 21#define EFL_UI_SPIN_BUTTON_DELAY_CHANGE_TIME 0.2
22 22
23static const char PART_NAME_ENTRY[] = "entry";
23static const char PART_NAME_DEC_BUTTON[] = "dec_button"; 24static const char PART_NAME_DEC_BUTTON[] = "dec_button";
24static const char PART_NAME_TEXT_BUTTON[] = "text_button"; 25static const char PART_NAME_TEXT_BUTTON[] = "text_button";
25static const char PART_NAME_INC_BUTTON[] = "inc_button"; 26static const char PART_NAME_INC_BUTTON[] = "inc_button";
@@ -723,13 +724,7 @@ _efl_ui_spin_button_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Spin_Button_Data *
723 if (!int_ret) return EFL_UI_THEME_APPLY_FAILED; 724 if (!int_ret) return EFL_UI_THEME_APPLY_FAILED;
724 725
725 if (sd->ent) 726 if (sd->ent)
726 { 727 elm_widget_element_update(obj, sd->ent, PART_NAME_ENTRY);
727 //elm_widget_element_update(obj, sd->ent, PART_NAME_TEXT);
728 Eina_Strbuf *buf = eina_strbuf_new();
729 eina_strbuf_append_printf(buf, "spin_button/%s", elm_widget_style_get(obj));
730 elm_widget_style_set(sd->ent, eina_strbuf_string_get(buf));
731 eina_strbuf_free(buf);
732 }
733 728
734 if (sd->inc_button) 729 if (sd->inc_button)
735 elm_widget_element_update(obj, sd->inc_button, PART_NAME_INC_BUTTON); 730 elm_widget_element_update(obj, sd->inc_button, PART_NAME_INC_BUTTON);
diff --git a/src/lib/elementary/efl_ui_timepicker.c b/src/lib/elementary/efl_ui_timepicker.c
new file mode 100644
index 0000000..49a4e38
--- /dev/null
+++ b/src/lib/elementary/efl_ui_timepicker.c
@@ -0,0 +1,285 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6
7#include "elm_priv.h"
8#include "efl_ui_timepicker_private.h"
9
10#define MY_CLASS EFL_UI_TIMEPICKER_CLASS
11
12#define MY_CLASS_NAME "Efl.Ui.Timepicker"
13
14#define FMT_LEN_MAX 32
15
16#define TIME_GET() \
17 do { \
18 Efl_Time t = efl_datetime_manager_value_get(pd->dt_manager); \
19 pd->cur_time[TIMEPICKER_HOUR] = t.tm_hour; \
20 pd->cur_time[TIMEPICKER_MIN] = t.tm_min; \
21 } while (0)
22
23#define TIME_SET() \
24 do { \
25 Efl_Time t; \
26 t.tm_hour = pd->cur_time[TIMEPICKER_HOUR]; \
27 t.tm_min = pd->cur_time[TIMEPICKER_MIN]; \
28 efl_datetime_manager_value_set(pd->dt_manager, t); \
29 } while (0)
30
31static const char *fmt_char[] = {"IHkl", "M", "Aa"};
32
33static Eina_Bool
34_validate_params(int hour, int min)
35{
36 if (hour < 0 || hour > 23 || min < 0 || min > 59)
37 return EINA_FALSE;
38 else return EINA_TRUE;
39}
40
41static Eina_Bool
42_time_cmp(int time1[], int time2[])
43{
44 unsigned int idx;
45
46 for (idx = 0; idx < EFL_UI_TIMEPICKER_TYPE_COUNT -1; idx++)
47 {
48 if (time1[idx] != time2[idx])
49 return EINA_FALSE;
50 }
51
52 return EINA_TRUE;
53}
54
55static void
56_field_value_update(Eo *obj)
57{
58 Efl_Ui_Timepicker_Data *pd = efl_data_scope_get(obj, MY_CLASS);
59
60 if (!pd->is_24hour)
61 {
62 if (pd->cur_time[TIMEPICKER_HOUR] >= 12)
63 {
64 //TODO: gets text from strftime.
65 efl_text_set(pd->ampm, "PM");
66 efl_ui_range_value_set(pd->hour, pd->cur_time[TIMEPICKER_HOUR] - 12);
67 }
68 else
69 {
70 efl_text_set(pd->ampm, "AM");
71 efl_ui_range_value_set(pd->hour, pd->cur_time[TIMEPICKER_HOUR] + 12);
72 }
73 }
74
75 efl_ui_range_value_set(pd->min, pd->cur_time[TIMEPICKER_MIN]);
76
77 TIME_SET();
78}
79
80static void
81_field_changed_cb(void *data, const Efl_Event *ev)
82{
83 Efl_Ui_Timepicker_Data *pd = efl_data_scope_get(data, MY_CLASS);
84
85 //TODO: hour value increase when min reached max.
86 if (ev->object == pd->hour)
87 {
88 pd->cur_time[TIMEPICKER_HOUR] = efl_ui_range_value_get(pd->hour);
89 if (!pd->is_24hour && !strcmp(efl_text_get(pd->ampm), "PM"))
90 pd->cur_time[TIMEPICKER_HOUR] += 12;
91 }
92 else if (ev->object == pd->min)
93 pd->cur_time[TIMEPICKER_MIN] = efl_ui_range_value_get(pd->min);
94 else
95 {
96 if (!strcmp(efl_text_get(pd->ampm), "PM"))
97 {
98 efl_text_set(pd->ampm, "AM");
99 pd->cur_time[TIMEPICKER_HOUR] -= 12;
100 }
101 else
102 {
103 efl_text_set(pd->ampm, "PM");
104 pd->cur_time[TIMEPICKER_HOUR] += 12;
105 }
106 }
107
108 TIME_SET();
109 efl_event_callback_call(data, EFL_UI_TIMEPICKER_EVENT_CHANGED, NULL);
110}
111
112static void
113_fields_init(Eo *obj)
114{
115 const char *fmt;
116 char ch;
117 int i;
118 int field = 0;
119 char buf[FMT_LEN_MAX];
120
121 Efl_Ui_Timepicker_Data *pd = efl_data_scope_get(obj, MY_CLASS);
122
123 //Field create.
124 pd->hour = efl_add(EFL_UI_SPIN_BUTTON_CLASS, obj,
125 efl_ui_range_min_max_set(efl_added, 1, 12),
126 efl_ui_spin_button_circulate_set(efl_added, EINA_TRUE),
127 efl_ui_spin_button_editable_set(efl_added, EINA_TRUE),
128 efl_event_callback_add(efl_added, EFL_UI_SPIN_EVENT_CHANGED,_field_changed_cb, obj),
129 elm_widget_element_update(obj, efl_added, "spin_button"));
130
131 pd->min = efl_add(EFL_UI_SPIN_BUTTON_CLASS, obj,
132 efl_ui_range_min_max_set(efl_added, 0, 59),
133 efl_ui_spin_button_circulate_set(efl_added, EINA_TRUE),
134 efl_ui_spin_button_editable_set(efl_added, EINA_TRUE),
135 efl_event_callback_add(efl_added, EFL_UI_SPIN_EVENT_CHANGED,_field_changed_cb, obj),
136 elm_widget_element_update(obj, efl_added, "spin_button"));
137
138 pd->ampm = efl_add(EFL_UI_BUTTON_CLASS, obj,
139 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _field_changed_cb, obj),
140 elm_widget_element_update(obj, efl_added, "button"));
141
142 pd->dt_manager = efl_add(EFL_DATETIME_MANAGER_CLASS, obj);
143
144 TIME_GET();
145
146 pd->is_24hour = EINA_FALSE;
147
148 _field_value_update(obj);
149
150 fmt = efl_datetime_manager_format_get(pd->dt_manager);
151 if (!fmt)
152 {
153 ERR("Failed to get current format.");
154 //Gives default format when the gets format failed.
155 fmt = "%H:%M %a";
156 }
157
158 //Sort fields by format.
159 while((ch = *fmt))
160 {
161 //TODO: ignore extensions and separators.
162 for (i = 0; i < EFL_UI_TIMEPICKER_TYPE_COUNT; i++)
163 {
164 if (strchr(fmt_char[i], ch))
165 {
166 snprintf(buf, sizeof(buf), "field%d", field);
167 if (i == TIMEPICKER_HOUR)
168 efl_content_set(efl_part(obj, buf), pd->hour);
169 else if (i == TIMEPICKER_MIN)
170 efl_content_set(efl_part(obj, buf), pd->min);
171 else
172 {
173 //TODO: monitoring locale change and update field location.
174 if (field == 0)
175 {
176 elm_object_signal_emit(obj, "elm,state,colon,visible,field1", "elm");
177 elm_object_signal_emit(obj, "elm,state,colon,invisible,field0", "elm");
178 }
179 else
180 {
181 elm_object_signal_emit(obj, "elm,state,colon,visible,field0", "elm");
182 elm_object_signal_emit(obj, "elm,state,colon,invisible,field1", "elm");
183 }
184
185 elm_layout_signal_emit(obj, "elm,state,ampm,visible", "elm");
186 edje_object_message_signal_process(elm_layout_edje_get(obj));
187 efl_content_set(efl_part(obj, buf), pd->ampm);
188 }
189
190 field++;
191 break;
192 }
193 }
194 fmt++;
195 }
196}
197
198EOLIAN static void
199_efl_ui_timepicker_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Timepicker_Data *_pd EINA_UNUSED)
200{
201 Evas_Coord minw = -1, minh = -1;
202 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
203
204 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
205 edje_object_size_min_restricted_calc
206 (wd->resize_obj, &minw, &minh, minw, minh);
207 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
208 evas_object_size_hint_min_set(obj, minw, minh);
209 evas_object_size_hint_max_set(obj, -1, -1);
210}
211
212EOLIAN static Eo *
213_efl_ui_timepicker_efl_object_constructor(Eo *obj, Efl_Ui_Timepicker_Data *pd EINA_UNUSED)
214{
215 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
216
217 if (!elm_widget_theme_klass_get(obj))
218 elm_widget_theme_klass_set(obj, "timepicker");
219 obj = efl_constructor(efl_super(obj, MY_CLASS));
220
221 if (!elm_widget_theme_object_set(obj, wd->resize_obj,
222 elm_widget_theme_klass_get(obj),
223 elm_widget_theme_element_get(obj),
224 elm_widget_theme_style_get(obj)))
225 CRI("Failed to set layout!");
226
227 _fields_init(obj);
228
229 elm_widget_sub_object_parent_add(obj);
230
231 elm_widget_can_focus_set(obj, EINA_TRUE);
232
233 return obj;
234}
235
236EOLIAN static void
237_efl_ui_timepicker_efl_object_destructor(Eo *obj, Efl_Ui_Timepicker_Data *pd EINA_UNUSED)
238{
239 efl_destructor(efl_super(obj, MY_CLASS));
240}
241
242EOLIAN static void
243_efl_ui_timepicker_time_set(Eo *obj, Efl_Ui_Timepicker_Data *pd, int hour, int min)
244{
245 int new_time[EFL_UI_TIMEPICKER_TYPE_COUNT - 1] = {hour, min};
246
247 if (!_validate_params(hour, min)) return;
248 if (_time_cmp(pd->cur_time, new_time)) return;
249
250 memcpy(pd->cur_time, new_time, (sizeof(int) * (EFL_UI_TIMEPICKER_TYPE_COUNT -1)));
251
252 TIME_SET();
253 _field_value_update(obj);
254}
255
256EOLIAN static void
257_efl_ui_timepicker_time_get(const Eo *obj EINA_UNUSED, Efl_Ui_Timepicker_Data *pd, int *hour, int *min)
258{
259 *hour = pd->cur_time[TIMEPICKER_HOUR];
260 *min = pd->cur_time[TIMEPICKER_MIN];
261}
262
263EOLIAN static void
264_efl_ui_timepicker_ampm_set(Eo *obj, Efl_Ui_Timepicker_Data *pd, Eina_Bool is_24hour)
265{
266 if (pd->is_24hour == is_24hour) return;
267
268 pd->is_24hour = is_24hour;
269 if (pd->is_24hour == EINA_TRUE)
270 elm_layout_signal_emit(obj, "elm,state,ampm,invisible", "elm");
271 else
272 elm_layout_signal_emit(obj, "elm,state,ampm,visible", "elm");
273 _field_value_update(obj);
274}
275
276EOLIAN static Eina_Bool
277_efl_ui_timepicker_ampm_get(const Eo *obj EINA_UNUSED, Efl_Ui_Timepicker_Data *pd)
278{
279 return pd->is_24hour;
280}
281
282#define EFL_UI_TIMEPICKER_EXTRA_OPS \
283 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_timepicker), \
284
285#include "efl_ui_timepicker.eo.c"
diff --git a/src/lib/elementary/efl_ui_timepicker.eo b/src/lib/elementary/efl_ui_timepicker.eo
new file mode 100644
index 0000000..3be8f08
--- /dev/null
+++ b/src/lib/elementary/efl_ui_timepicker.eo
@@ -0,0 +1,44 @@
1class Efl.Ui.Timepicker (Efl.Ui.Layout.Object)
2{
3 [[Timepicker widget
4
5 This is a widget which allows the user to pick a time using internal spinner.
6 User can use the internal spinner to select hour, minute, AM/PM or user can input
7 value using internal entry.
8 ]]
9 methods {
10 @property time {
11 [[The current value of time
12
13 $hour: Hour. The hour value is in terms of 24 hour format from 0 to 23.
14
15 $min: Minute. The minute range is from 0 to 59.
16 ]]
17 set {
18 }
19 get{
20 }
21 values {
22 hour: int; [[The hour value from 0 to 23.]]
23 min: int; [[The minute value from 0 to 59.]]
24 }
25 }
26 @property ampm {
27 [[Control if the Timepicker displays 24 hour time or 12 hour time including AM/PM button.]]
28 set {
29 }
30 get {
31 }
32 values {
33 is_24hour: bool; [[$true to display the 24 hour time, $false to display 12 hour time including AM/PM button.]]
34 }
35 }
36 }
37 implements {
38 Efl.Object.constructor;
39 Efl.Object.destructor;
40 }
41 events {
42 changed; [[Called when date is changed]]
43 }
44}
diff --git a/src/lib/elementary/efl_ui_timepicker_private.h b/src/lib/elementary/efl_ui_timepicker_private.h
new file mode 100644
index 0000000..6c871d7
--- /dev/null
+++ b/src/lib/elementary/efl_ui_timepicker_private.h
@@ -0,0 +1,21 @@
1#ifndef EFL_UI_TIMEPICKER_PRIVATE_H
2#define EFL_UI_TIMEPICKER_PRIVATE_H
3
4#define EFL_UI_TIMEPICKER_TYPE_COUNT 3
5
6typedef enum _Efl_Ui_Timepicker_Field_Type
7{
8 TIMEPICKER_HOUR,
9 TIMEPICKER_MIN,
10 TIMEPICKER_AMPM
11} Efl_Ui_Timepicker_Field_Type;
12
13typedef struct _Efl_Ui_Timepicker_Data Efl_Ui_Timepicker_Data;
14struct _Efl_Ui_Timepicker_Data
15{
16 Eo *dt_manager, *hour, *min, *ampm;
17 int cur_time[EFL_UI_TIMEPICKER_TYPE_COUNT];
18 Eina_Bool is_24hour;
19};
20
21#endif
diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c
index 1d6291f..bfdbd1d 100644
--- a/src/lib/elementary/elm_config.c
+++ b/src/lib/elementary/elm_config.c
@@ -112,6 +112,8 @@ static const Elm_Color_Class _elm_color_classes[] = {
112 {"calendar_day_highlighted", "Highlighted Day Effect"}, 112 {"calendar_day_highlighted", "Highlighted Day Effect"},
113 {"calendar_day_checked", "Checked Day Effect"}, 113 {"calendar_day_checked", "Checked Day Effect"},
114 {"datetime_bg", "Datetime Background"}, 114 {"datetime_bg", "Datetime Background"},
115 {"datepicker_bg", "Datepicker Background"},
116 {"timepicker_bg", "Timepicker Background"},
115 {"datetime_separator_text", "Datetime Separator Text"}, 117 {"datetime_separator_text", "Datetime Separator Text"},
116 {"datetime_separator_text_disabled", "Datetime Separator Disabled Text"}, 118 {"datetime_separator_text_disabled", "Datetime Separator Disabled Text"},
117 {"hoversel_item_active", "Hoversel Item Text"}, 119 {"hoversel_item_active", "Hoversel Item Text"},
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index 6b60160..66814bc 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -67,6 +67,7 @@
67# include "efl_ui_focus_parent_provider_standard.eo.h" 67# include "efl_ui_focus_parent_provider_standard.eo.h"
68# include "elm_widget_item_static_focus.eo.h" 68# include "elm_widget_item_static_focus.eo.h"
69#include "efl_selection_manager.eo.h" 69#include "efl_selection_manager.eo.h"
70# include "efl_datetime_manager.eo.h"
70 71
71# ifdef HAVE_LANGINFO_H 72# ifdef HAVE_LANGINFO_H
72# include <langinfo.h> 73# include <langinfo.h>