Merge "Remove '-' from month picker." into tizen_2.1
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / tizen / InputPicker.cpp
1 /*
2  * Copyright (C) 2012 Samsung Electronics
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #include "config.h"
21 #include "InputPicker.h"
22
23 #include "ewk_view.h"
24
25 #include <Elementary.h>
26
27 #include <ctime>
28 #include <stdlib.h>
29 #include <string.h>
30
31
32 #if OS(TIZEN) && ENABLE(TIZEN_INPUT_TAG_EXTENSION)
33
34 Input_Picker_Layout::Input_Picker_Layout(Evas_Object* ewkView)
35     : m_ewkView(ewkView)
36     , popup(0)
37     , layout(0)
38     , timePicker(0)
39     , datePicker(0)
40     , colorRect(0)
41     , okButton(0)
42     , dataListEditField(0)
43     , datetimeLocal(false)
44 {
45     evas_object_focus_set(m_ewkView, false);
46
47     /* FIXME : Workaround. OSP requirement.
48        OSP want to block own touch event while webkit internal picker is running. */
49     evas_object_smart_callback_call(m_ewkView, "input,picker,show", 0);
50 }
51
52 Input_Picker_Layout::~Input_Picker_Layout()
53 {
54     /* FIXME : Workaround. OSP requirement.
55        OSP want to block own touch event while webkit internal picker is running. */
56     evas_object_smart_callback_call(m_ewkView, "input,picker,hide", 0);
57 }
58
59 namespace WebKit {
60
61 InputPicker::InputPicker(Evas_Object* ewkView)
62     : m_ewkView(ewkView)
63     , m_pickerLayout(0)
64     , m_dataList(0)
65 {
66 }
67
68 InputPicker::~InputPicker()
69 {
70     if (m_pickerLayout) {
71         if (m_pickerLayout->popup)
72             evas_object_del(m_pickerLayout->popup);
73         delete m_pickerLayout;
74     }
75 }
76
77 void InputPicker::show(Ewk_Input_Type inputType, const char* inputValue)
78 {
79     if(inputType == EWK_INPUT_TYPE_DATE)
80         ewk_date_popup(inputValue);
81     else if(inputType == EWK_INPUT_TYPE_TIME)
82         ewk_time_popup(inputValue);
83     else if(inputType == EWK_INPUT_TYPE_DATETIME)
84         ewk_datetime_popup(inputValue, false);
85     else if(inputType == EWK_INPUT_TYPE_DATETIMELOCAL)
86         ewk_datetime_popup(inputValue, true);
87     else if(inputType == EWK_INPUT_TYPE_MONTH)
88         ewk_month_popup(inputValue);
89     else if(inputType == EWK_INPUT_TYPE_WEEK)
90         ewk_week_popup(inputValue);
91 }
92
93 #if ENABLE(TIZEN_DATALIST_ELEMENT)
94 void InputPicker::_data_list_popup_response_cb(void* data,  Evas_Object* obj, void* eventInfo)
95 {
96     InputPicker* inputPicker = static_cast<InputPicker*>(data);
97     const char* selectedItem = elm_entry_entry_get(inputPicker->m_pickerLayout->dataListEditField);
98     ewk_view_data_list_close(inputPicker->m_ewkView, selectedItem);
99
100     if (inputPicker->m_pickerLayout->popup) {
101         evas_object_del(inputPicker->m_pickerLayout->popup);
102         inputPicker->m_pickerLayout->popup = 0;
103     }
104
105     delete inputPicker->m_pickerLayout;
106     inputPicker->m_pickerLayout = 0;
107
108     inputPicker->m_dataList = 0;
109 }
110
111 void InputPicker::_data_list_popup_response_cancel_cb(void* data,  Evas_Object* obj, void* eventInfo)
112 {
113     InputPicker* inputPicker = static_cast<InputPicker*>(data);
114
115     if (inputPicker->m_pickerLayout->popup) {
116         evas_object_del(inputPicker->m_pickerLayout->popup);
117         inputPicker->m_pickerLayout->popup = 0;
118     }
119
120     delete inputPicker->m_pickerLayout;
121     inputPicker->m_pickerLayout = 0;
122
123     inputPicker->m_dataList = 0;
124 }
125
126 void InputPicker::_data_list_selected_cb(void* data, Evas_Object* obj, void* eventInfo)
127 {
128     InputPicker* inputPicker = static_cast<InputPicker*>(data);
129     Elm_Object_Item* selectedItem = static_cast<Elm_Object_Item*>(eventInfo);
130     Elm_Object_Item* item = elm_list_first_item_get(obj);
131
132     int index = 0;
133     while (item) {
134         if (item == selectedItem)
135             break;
136         index++;
137         item = elm_list_item_next(item);
138     }
139
140     Eina_List* list = 0;
141     void* listItem = 0;
142     int listIndex = 0;
143     EINA_LIST_FOREACH(inputPicker->m_dataList, list, listItem) {
144         if (listItem && index == listIndex)
145             elm_entry_entry_set(inputPicker->m_pickerLayout->dataListEditField, static_cast<char*>(listItem));
146
147         listIndex++;
148     }
149 }
150
151 static void _eraser_clicked_cb(void* data, Evas_Object* obj, const char* emission, const char* source)
152 {
153     Evas_Object* entry = static_cast<Evas_Object*>(data);
154     elm_entry_entry_set(entry, "");
155 }
156
157 static void _changed_cb(void* data, Evas_Object* obj, void* eventInfo)
158 {
159     Evas_Object* layout = static_cast<Evas_Object*>(data);
160
161     if (elm_object_focus_get(layout)) {
162         if (elm_entry_is_empty(obj))
163             elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
164         else
165             elm_object_signal_emit(layout, "elm,state,eraser,show", "elm");
166     }
167 }
168
169 static void _focused_cb(void* data, Evas_Object* obj, void* eventInfo)
170 {
171     Evas_Object* layout = static_cast<Evas_Object*>(data);
172
173     if (!elm_entry_is_empty(obj))
174         elm_object_signal_emit(layout, "elm,state,eraser,show", "elm");
175 }
176
177 static void _unfocused_cb(void* data, Evas_Object* obj, void* eventInfo)
178 {
179     Evas_Object* layout = static_cast<Evas_Object*>(data);
180     elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
181 }
182
183 void InputPicker::showDataList(Ewk_Input_Type inputType, Eina_List* optionList)
184 {
185     Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
186     Evas_Object* win = parent;
187
188     m_dataList = optionList;
189
190     if (m_pickerLayout)
191         return;
192
193     m_pickerLayout = new Input_Picker_Layout(m_ewkView);
194
195     /* FIXME: If the entry is in the popup, the parent should be naviframe for uifw limitation. */
196     Evas_Object* naviframe = elm_naviframe_add(m_ewkView);
197     while (parent) {
198         const char* type = elm_object_widget_type_get(parent);
199         if (type) {
200             if (!strcmp(type, elm_object_widget_type_get(naviframe))) {
201                 win =  parent;
202                 break;
203             }
204         }
205         parent = elm_object_parent_widget_get(parent);
206     }
207
208     evas_object_del(naviframe);
209
210     if (!win)
211         win = m_ewkView;
212
213     m_pickerLayout->popup = elm_popup_add(win);
214     elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select data list");
215
216     m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
217     elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","data_list_picker");
218     evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
219     evas_object_show(m_pickerLayout->layout);
220     elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
221
222     Evas_Object* elmList = elm_list_add(m_pickerLayout->layout);
223     Eina_List* list = 0;
224     void* listItem = 0;
225     EINA_LIST_FOREACH(optionList, list, listItem) {
226         if (listItem)
227             elm_list_item_append(elmList, static_cast<char*>(listItem), 0, 0, _data_list_selected_cb, this);
228     }
229     evas_object_size_hint_weight_set(elmList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
230     evas_object_show(elmList);
231     elm_object_part_content_set(m_pickerLayout->layout, "data_list", elmList);
232
233     Evas_Object* editFieldLayout = elm_layout_add(m_pickerLayout->layout);
234     elm_layout_theme_set(editFieldLayout, "layout", "editfield", "default");
235
236     m_pickerLayout->dataListEditField = elm_entry_add(editFieldLayout);
237     elm_object_part_content_set(editFieldLayout, "elm.swallow.content", m_pickerLayout->dataListEditField);
238
239     elm_object_signal_emit(editFieldLayout, "elm,state,guidetext,hide", "elm");
240     elm_object_signal_callback_add(editFieldLayout, "elm,eraser,clicked", "elm", _eraser_clicked_cb, m_pickerLayout->dataListEditField);
241     evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "changed", _changed_cb, editFieldLayout);
242     evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "focused", _focused_cb, editFieldLayout);
243     evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "unfocused", _unfocused_cb, editFieldLayout);
244
245     elm_object_part_content_set(m_pickerLayout->layout, "selected_item", editFieldLayout);
246     evas_object_show(editFieldLayout);
247
248     m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
249     elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
250     elm_object_text_set(m_pickerLayout->okButton, "OK");
251     elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
252     evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _data_list_popup_response_cb, this);
253     evas_object_show(m_pickerLayout->popup);
254
255     Evas_Object* cancelButton = elm_button_add(m_pickerLayout->popup);
256     elm_object_style_set(cancelButton, "popup_button/default");
257     elm_object_text_set(cancelButton, "Cancel");
258     elm_object_part_content_set(m_pickerLayout->popup, "button2", cancelButton);
259     evas_object_smart_callback_add(cancelButton, "clicked", _data_list_popup_response_cancel_cb, this);
260     evas_object_show(cancelButton);
261 }
262
263 void InputPicker::hideDataList(Ewk_Input_Type inputType)
264 {
265     if (!m_dataList)
266         return;
267
268     if(m_pickerLayout->popup){
269         evas_object_del(m_pickerLayout->popup);
270         m_pickerLayout->popup = 0;
271     }
272
273     delete m_pickerLayout;
274     m_pickerLayout = 0;
275
276     m_dataList = 0;
277 }
278 #endif
279
280 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
281 void InputPicker::showColorPicker(int r, int g, int b, int)
282 {
283     ewk_color_popup(r, g, b);
284 }
285
286 void InputPicker::hideColorPicker()
287 {
288     if (!m_pickerLayout)
289         return;
290
291     if (m_pickerLayout->popup) {
292         evas_object_del(m_pickerLayout->popup);
293         m_pickerLayout->popup = 0;
294     }
295
296     delete m_pickerLayout;
297     m_pickerLayout = 0;
298 }
299 #endif
300
301 #if ENABLE(ELM_COLORPALLETE)
302 static void _color_palette_changed_cb(void* data, Evas_Object* obj, void* eventInfo)
303 {
304     int r = 0;
305     int g = 0;
306     int b = 0;
307     int a = 0;
308     Elm_Object_Item *color_it = static_cast<Elm_Object_Item*>(eventInfo);
309     elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
310     evas_object_color_set(static_cast<Evas_Object*>(data), r, g, b , a);
311 }
312 #endif
313
314 void InputPicker::_color_selected_cb(void* data, Evas* evas, Evas_Object* obj, void* eventInfo)
315 {
316     int r = 0;
317     int g = 0;
318     int b = 0;
319     int a = 0;
320     evas_object_color_get(obj, &r, &g, &b, &a);
321
322     evas_object_color_set(static_cast<Evas_Object*>(data), r, g, b, a);
323 }
324
325 void InputPicker::ewk_color_popup(int r, int g, int b)
326 {
327     Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
328     Evas_Object* win = parent;
329
330     if (m_pickerLayout)
331         return;
332
333     m_pickerLayout = new Input_Picker_Layout(m_ewkView);
334
335     while (parent) {
336         const char* type = elm_object_widget_type_get(parent);
337         if (type) {
338             if (!strcmp(type, "elm_win")) {
339                 win =  parent;
340                 break;
341             }
342         }
343         parent = elm_object_parent_widget_get(parent);
344     }
345
346     if (!win)
347     win = m_ewkView;
348
349     m_pickerLayout->popup = elm_popup_add(win);
350     elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select color");
351
352     m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
353     elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","color_picker");
354     evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
355     evas_object_show(m_pickerLayout->layout);
356     elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
357
358     m_pickerLayout->colorRect = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
359     evas_object_size_hint_weight_set(m_pickerLayout->colorRect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
360     evas_object_show(m_pickerLayout->colorRect);
361
362     printf("\n<<<<<<<< r = [%d], g = [%d], b = [%d] >>>>>>>>>>\n", r, g, b);
363
364     evas_object_color_set(m_pickerLayout->colorRect, r, g, b, 255);
365     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color_rect", m_pickerLayout->colorRect);
366 #if ENABLE(ELM_COLORPALLETE)
367     Evas_Object* colorPalette = elm_colorselector_add(m_pickerLayout->popup);
368     elm_colorselector_mode_set(colorPalette, ELM_COLORSELECTOR_PALETTE);
369
370     elm_colorselector_palette_color_add(colorPalette, 128, 0, 0, 255);
371     elm_colorselector_palette_color_add(colorPalette, 255, 0, 128, 255);
372     elm_colorselector_palette_color_add(colorPalette, 255, 0, 0, 255);
373     elm_colorselector_palette_color_add(colorPalette, 255, 127, 39, 255);
374     elm_colorselector_palette_color_add(colorPalette, 255, 255, 0, 255);
375     elm_colorselector_palette_color_add(colorPalette, 0, 255, 0, 255);
376     elm_colorselector_palette_color_add(colorPalette, 0, 255, 255, 255);
377     elm_colorselector_palette_color_add(colorPalette, 0, 0, 255, 255);
378     elm_colorselector_palette_color_add(colorPalette, 0, 0, 128, 255);
379     elm_colorselector_palette_color_add(colorPalette, 64, 0, 64, 255);
380     elm_colorselector_palette_color_add(colorPalette, 0, 0, 0, 255);
381     elm_colorselector_palette_color_add(colorPalette, 255, 255, 255, 255);
382
383     evas_object_size_hint_fill_set(colorPalette, EVAS_HINT_FILL, 0);
384     evas_object_size_hint_weight_set(colorPalette, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
385     evas_object_smart_callback_add(colorPalette, "color,item,selected", _color_palette_changed_cb, m_pickerLayout->colorRect);
386     evas_object_show(colorPalette);
387
388     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color_palette", colorPalette);
389 #else
390     Evas_Object* color1 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
391     evas_object_size_hint_weight_set(color1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
392     evas_object_color_set(color1, 128, 0, 0, 255);
393     evas_object_event_callback_add(color1, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
394     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color1", color1);
395     evas_object_show(color1);
396
397     Evas_Object* color2 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
398     evas_object_size_hint_weight_set(color2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
399     evas_object_color_set(color2, 255, 0, 128, 255);
400     evas_object_event_callback_add(color2, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
401     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color2", color2);
402     evas_object_show(color2);
403
404     Evas_Object* color3 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
405     evas_object_size_hint_weight_set(color3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
406     evas_object_color_set(color3, 255, 0, 0, 255);
407     evas_object_event_callback_add(color3, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
408     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color3", color3);
409     evas_object_show(color3);
410
411     Evas_Object* color4 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
412     evas_object_size_hint_weight_set(color4, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
413     evas_object_color_set(color4, 255, 127, 39, 255);
414     evas_object_event_callback_add(color4, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
415     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color4", color4);
416     evas_object_show(color4);
417
418     Evas_Object* color5 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
419     evas_object_size_hint_weight_set(color5, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
420     evas_object_color_set(color5, 255, 255, 0, 255);
421     evas_object_event_callback_add(color5, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
422     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color5", color5);
423     evas_object_show(color5);
424
425     Evas_Object* color6 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
426     evas_object_size_hint_weight_set(color6, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
427     evas_object_color_set(color6, 0, 255, 0, 255);
428     evas_object_event_callback_add(color6, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
429     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color6", color6);
430     evas_object_show(color6);
431
432     Evas_Object* color7 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
433     evas_object_size_hint_weight_set(color7, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
434     evas_object_color_set(color7, 0, 255, 255, 255);
435     evas_object_event_callback_add(color7, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
436     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color7", color7);
437     evas_object_show(color7);
438
439     Evas_Object* color8 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
440     evas_object_size_hint_weight_set(color8, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
441     evas_object_color_set(color8, 0, 0, 255, 255);
442     evas_object_event_callback_add(color8, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
443     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color8", color8);
444     evas_object_show(color8);
445
446     Evas_Object* color9 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
447     evas_object_size_hint_weight_set(color9, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
448     evas_object_color_set(color9, 0, 0, 128, 255);
449     evas_object_event_callback_add(color9, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
450     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color9", color9);
451     evas_object_show(color9);
452
453     Evas_Object* color10 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
454     evas_object_size_hint_weight_set(color10, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
455     evas_object_color_set(color10, 64, 0, 64, 255);
456     evas_object_event_callback_add(color10, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
457     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color10", color10);
458     evas_object_show(color10);
459
460     Evas_Object* color11 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
461     evas_object_size_hint_weight_set(color11, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
462     evas_object_color_set(color11, 153, 217, 234, 255);
463     evas_object_event_callback_add(color11, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
464     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color11", color11);
465     evas_object_show(color11);
466
467     Evas_Object* color12 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
468     evas_object_size_hint_weight_set(color12, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
469     evas_object_color_set(color12, 128, 128, 128, 255);
470     evas_object_event_callback_add(color12, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
471     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color12", color12);
472     evas_object_show(color12);
473
474     Evas_Object* color13 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
475     evas_object_size_hint_weight_set(color13, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
476     evas_object_color_set(color13, 0, 0, 0, 255);
477     evas_object_event_callback_add(color13, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
478     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color13", color13);
479     evas_object_show(color13);
480
481     Evas_Object* color14 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
482     evas_object_size_hint_weight_set(color14, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
483     evas_object_color_set(color14, 255, 255, 255, 255);
484     evas_object_event_callback_add(color14, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
485     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color14", color14);
486     evas_object_show(color14);
487 #endif
488     m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
489     elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
490     elm_object_text_set(m_pickerLayout->okButton, "OK");
491     elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
492     evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _color_popup_response_cb, this);
493
494     evas_object_show(m_pickerLayout->popup);
495 }
496
497 void InputPicker::_color_popup_response_cb(void* data,  Evas_Object* obj, void* event_info)
498 {
499     InputPicker* inputPicker = static_cast<InputPicker*>(data);
500
501     int r = 0;
502     int g = 0;
503     int b = 0;
504     int a = 0;
505     evas_object_color_get(inputPicker->m_pickerLayout->colorRect, &r, &g, &b, &a);
506
507     ewk_view_color_picker_color_set(inputPicker->m_ewkView, r, g, b, a);
508
509     inputPicker->hideColorPicker();
510 }
511
512 void InputPicker::ewk_date_popup(const char* inputValue)
513 {
514     struct tm* currentTime;
515     time_t cur_time;
516     time(&cur_time);
517     currentTime = localtime(&cur_time);
518
519     Input_Date_Str dateStr;
520     memset(&dateStr, 0, sizeof(Input_Date_Str));
521
522     Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
523     Evas_Object* win = parent;
524
525     if (m_pickerLayout)
526         return;
527
528     m_pickerLayout = new Input_Picker_Layout(m_ewkView);
529
530     if (inputValue && strlen(inputValue)) {
531         char tmpinputValue[30] = {0,};
532
533         sprintf(tmpinputValue, "%s", inputValue);
534         strcpy(dateStr.year, strtok(tmpinputValue,"-"));
535         strcpy(dateStr.mon, strtok(0, "-"));
536         strcpy(dateStr.day, strtok(0, "-"));
537
538         currentTime->tm_year = atoi(dateStr.year);
539         currentTime->tm_mon = atoi(dateStr.mon);
540         currentTime->tm_mday = atoi(dateStr.day);
541
542         currentTime->tm_year = currentTime->tm_year - 1900;
543         currentTime->tm_mon = currentTime->tm_mon - 1;
544     }
545
546     while (parent) {
547         const char* type = elm_object_widget_type_get(parent);
548         if (type) {
549             if (!strcmp(type, "elm_win")) {
550                 win =  parent;
551                 break;
552             }
553         }
554         parent = elm_object_parent_widget_get(parent);
555     }
556
557     if (!win)
558         win = m_ewkView;
559
560     m_pickerLayout->popup = elm_popup_add(win);
561     elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select date");
562
563     m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
564     elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
565     evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
566
567     edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Date (Default format) :");
568
569     m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
570     elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
571
572     elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_HOUR, EINA_FALSE);
573     elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_MINUTE, EINA_FALSE);
574     elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_AMPM, EINA_FALSE);
575     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
576
577     m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
578     elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
579     elm_object_text_set(m_pickerLayout->okButton, "OK");
580     elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
581     evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _date_popup_response_cb, this);
582
583     elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
584     evas_object_show(m_pickerLayout->popup);
585 }
586
587 #define isLeapYear(year) ((!(year % 4) && (year % 100)) || (!(year % 400) && (year % 1000)))
588 static int _calculateMonthAndDay(int year, int totalDays, int* remains)
589 {
590     // Jan.
591     if (totalDays - 31 < 0) {
592         *remains = totalDays;
593         return 0;
594     }
595
596     totalDays = totalDays - 31;
597
598     // Feb.
599     if (isLeapYear(year)) {
600         if (totalDays - 29 < 0) {
601             *remains = totalDays;
602             return 1;
603         }
604         totalDays = totalDays - 29;
605     } else {
606         if (totalDays - 28 < 0) {
607             *remains = totalDays;
608             return 1;
609         }
610         totalDays = totalDays - 28;
611     }
612
613     // Mar.
614     if (totalDays - 31 < 0) {
615         *remains = totalDays;
616         return 2;
617     }
618     totalDays = totalDays - 31;
619
620     // Apr.
621     if (totalDays - 30 < 0) {
622         *remains = totalDays;
623         return 3;
624     }
625     totalDays = totalDays - 30;
626
627     // May
628     if (totalDays - 31 < 0) {
629         *remains = totalDays;
630         return 4;
631     }
632     totalDays = totalDays - 31;
633
634     // Jun.
635     if (totalDays - 30 < 0) {
636         *remains = totalDays;
637         return 5;
638     }
639     totalDays = totalDays - 30;
640
641     // Jul.
642     if (totalDays - 31 < 0) {
643         *remains = totalDays;
644         return 6;
645     }
646     totalDays = totalDays - 31;
647
648     // Aug.
649     if (totalDays - 31 < 0) {
650         *remains = totalDays;
651         return 7;
652     }
653     totalDays = totalDays - 31;
654
655     // Sept.
656     if (totalDays - 30 < 0) {
657         *remains = totalDays;
658         return 8;
659     }
660     totalDays = totalDays - 30;
661
662     // Oct.
663     if (totalDays - 31 < 0) {
664         *remains = totalDays;
665         return 9;
666     }
667     totalDays = totalDays - 31;
668
669     // Nov.
670     if (totalDays - 30 < 0) {
671         *remains = totalDays;
672         return 10;
673     }
674     totalDays = totalDays - 30;
675
676     *remains = totalDays;
677     return 11;
678 }
679
680 void InputPicker::ewk_week_popup(const char* inputValue)
681 {
682     struct tm* currentTime;
683     time_t cur_time;
684     time(&cur_time);
685     currentTime = localtime(&cur_time);
686
687     Input_Date_Str dateStr;
688     memset(&dateStr, 0, sizeof(Input_Date_Str));
689
690     Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
691     Evas_Object* win = parent;
692
693     if (m_pickerLayout)
694         return;
695
696     m_pickerLayout = new Input_Picker_Layout(m_ewkView);
697
698     if (inputValue && strlen(inputValue)) {
699         char tmpinputValue[30] = {0,};
700
701         sprintf(tmpinputValue, "%s", inputValue);
702         strcpy(dateStr.year, strtok(tmpinputValue,"-"));
703         const char* week = strstr(inputValue, "W");
704         int weekNum = 1;
705         if (week)
706             weekNum = atoi(week + 1);
707
708         currentTime->tm_year = atoi(dateStr.year);
709         currentTime->tm_year = currentTime->tm_year - 1900;
710
711         struct tm firtTimeOfyear;
712         memset(&firtTimeOfyear, 0, sizeof(struct tm));
713         firtTimeOfyear.tm_year = currentTime->tm_year;
714         firtTimeOfyear.tm_mon = 0;
715         firtTimeOfyear.tm_mday = 1;
716         mktime(&firtTimeOfyear);
717
718         char firstWeek[10] = {0, };
719         strftime(firstWeek, 10, "%w", &firtTimeOfyear);
720         int firstWeekCount = atoi(firstWeek);
721
722         int totalDays = 1;
723
724         totalDays = weekNum * 7 - firstWeekCount;
725
726         int days = 0;
727         int month = _calculateMonthAndDay(currentTime->tm_year, totalDays, &days);
728
729         currentTime->tm_mon = month;
730         currentTime->tm_mday = days;
731     }
732
733     while (parent) {
734         const char* type = elm_object_widget_type_get(parent);
735         if (type) {
736             if (!strcmp(type, "elm_win")) {
737                 win =  parent;
738                 break;
739             }
740         }
741         parent = elm_object_parent_widget_get(parent);
742     }
743
744     if (!win)
745         win = m_ewkView;
746
747     m_pickerLayout->popup = elm_popup_add(win);
748     elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select date");
749
750     m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
751     elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
752     evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
753
754     edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Date (Default format) :");
755
756     m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
757     elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
758
759     elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_HOUR, EINA_FALSE);
760     elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_MINUTE, EINA_FALSE);
761     elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_AMPM, EINA_FALSE);
762     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
763
764     m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
765     elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
766     elm_object_text_set(m_pickerLayout->okButton, "OK");
767     elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
768     evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _week_popup_response_cb, this);
769
770     elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
771     evas_object_show(m_pickerLayout->popup);
772 }
773
774 void InputPicker::ewk_time_popup(const char* inputValue)
775 {
776     struct tm* currentTime;
777     time_t  cur_time;
778     time(&cur_time);
779     currentTime = localtime(&cur_time);
780
781     Input_Date_Str dateStr;
782     memset(&dateStr, 0, sizeof(Input_Date_Str));
783
784     Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
785     Evas_Object* win = parent;
786
787     if (m_pickerLayout)
788         return;
789
790     m_pickerLayout = new Input_Picker_Layout(m_ewkView);
791
792     if (inputValue && strlen(inputValue)) {
793         char tmpinputValue[30] = {0,};
794
795         sprintf(tmpinputValue, "%s", inputValue);
796         strcpy(dateStr.hour, strtok(tmpinputValue,":"));
797         strcpy(dateStr.min, strtok(0, ":"));
798
799         currentTime->tm_hour = atoi(dateStr.hour);
800         currentTime->tm_min = atoi(dateStr.min);
801     }
802
803     while (parent) {
804         const char* type = elm_object_widget_type_get(parent);
805         if (type) {
806             if (!strcmp(type, "elm_win")) {
807                 win =  parent;
808                 break;
809             }
810         }
811         parent = elm_object_parent_widget_get(parent);
812     }
813
814     if (!win)
815         win = m_ewkView;
816
817     m_pickerLayout->popup = elm_popup_add(win);
818     elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select time");
819
820     m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
821     elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
822     evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
823
824     edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Time (Default format) :");
825
826     m_pickerLayout->timePicker = elm_datetime_add(m_pickerLayout->layout);
827     elm_datetime_format_set(m_pickerLayout->timePicker, "%H:%M");
828     elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
829
830     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->timePicker);
831
832     m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
833     elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
834     elm_object_text_set(m_pickerLayout->okButton, "OK");
835     elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
836
837     evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _time_popup_response_cb, this);
838     elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
839     evas_object_show(m_pickerLayout->popup);
840 }
841
842 void InputPicker::ewk_month_popup(const char* inputValue)
843 {
844     struct tm* currentTime;
845     time_t  cur_time;
846     time(&cur_time);
847     currentTime = localtime(&cur_time);
848
849     Input_Date_Str dateStr;
850     memset(&dateStr, 0, sizeof(Input_Date_Str));
851
852     Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
853     Evas_Object* win = parent;
854
855     if (m_pickerLayout)
856         return;
857
858     m_pickerLayout = new Input_Picker_Layout(m_ewkView);
859
860     if (inputValue && strlen(inputValue)) {
861         char tmpInputValue[30] = {0,};
862
863         sprintf(tmpInputValue, "%s", inputValue);
864         strcpy(dateStr.year, strtok(tmpInputValue,"-"));
865         strcpy(dateStr.mon, strtok(0, "-"));
866
867         currentTime->tm_year = atoi(dateStr.year);
868         currentTime->tm_mon = atoi(dateStr.mon);
869
870         currentTime->tm_year = currentTime->tm_year - 1900;
871         currentTime->tm_mon = currentTime->tm_mon - 1;
872     }
873
874     while (parent) {
875         const char* type = elm_object_widget_type_get(parent);
876         if (type) {
877             if (!strcmp(type, "elm_win")) {
878                 win =  parent;
879                 break;
880             }
881         }
882         parent = elm_object_parent_widget_get(parent);
883     }
884
885     if (!win)
886         win = m_ewkView;
887
888     m_pickerLayout->popup = elm_popup_add(win);
889
890     elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select month");
891
892     m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
893     elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
894
895     evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
896     m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
897
898     elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
899
900     edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text",  "Month (Default format) :");
901
902     elm_datetime_format_set(m_pickerLayout->datePicker, "%Y %m");
903     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date",  m_pickerLayout->datePicker);
904
905     m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
906     elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
907     elm_object_text_set(m_pickerLayout->okButton, "OK");
908     elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
909     evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _month_popup_response_cb, this);
910
911     elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
912     evas_object_show(m_pickerLayout->popup);
913 }
914
915 void InputPicker::ewk_datetime_popup(const char* inputValue, bool local)
916 {
917     struct tm* currentTime;
918     time_t  cur_time;
919     time(&cur_time);
920     currentTime = localtime(&cur_time);
921
922     Input_Date_Str dateStr;
923     memset(&dateStr, 0, sizeof(Input_Date_Str));
924
925     Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
926     Evas_Object* win = parent;
927
928     if (m_pickerLayout)
929         return;
930
931     m_pickerLayout = new Input_Picker_Layout(m_ewkView);
932
933     m_pickerLayout->datetimeLocal = local;
934
935     if (inputValue && strlen(inputValue)) {
936         char tmpInputValue[30] = {0, };
937
938         sprintf(tmpInputValue, "%s", inputValue);
939         strcpy(dateStr.year, strtok(tmpInputValue,"-"));
940         strcpy(dateStr.mon, strtok(0, "-"));
941         strcpy(dateStr.day, strtok(0, "T"));
942         strcpy(dateStr.hour, strtok(0, ":"));
943
944         if (m_pickerLayout->datetimeLocal)
945             strcpy(dateStr.min, strtok(0, "Z"));
946         else
947             strcpy(dateStr.min, strtok(0, ":"));
948
949         currentTime->tm_year = atoi(dateStr.year);
950         currentTime->tm_mon = atoi(dateStr.mon);
951         currentTime->tm_mday = atoi(dateStr.day);
952         currentTime->tm_hour = atoi(dateStr.hour);
953         currentTime->tm_min = atoi(dateStr.min);
954
955         currentTime->tm_year = currentTime->tm_year - 1900;
956         currentTime->tm_mon = currentTime->tm_mon - 1;
957     }
958
959     while (parent) {
960         const char* type = elm_object_widget_type_get(parent);
961         if (type) {
962             if (!strcmp(type, "elm_win")) {
963                 win =  parent;
964                 break;
965             }
966         }
967         parent = elm_object_parent_widget_get(parent);
968     }
969
970     if (!win)
971         win = m_ewkView;
972
973     m_pickerLayout->popup = elm_popup_add(win);
974     elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select datetime");
975
976     m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
977     elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","datepicker_popup");
978     evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
979
980     m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
981     elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
982
983     elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_HOUR, EINA_FALSE);
984     elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_MINUTE, EINA_FALSE);
985     elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_AMPM, EINA_FALSE);
986     elm_object_part_content_set(m_pickerLayout->layout , "elm.swallow.content.date", m_pickerLayout->datePicker);
987
988     m_pickerLayout->timePicker = elm_datetime_add(m_pickerLayout->layout);
989     elm_datetime_format_set(m_pickerLayout->timePicker, "%H:%M");
990     elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
991     elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.time", m_pickerLayout->timePicker);
992
993     m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
994     elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
995     elm_object_text_set(m_pickerLayout->okButton, "OK");
996     elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
997
998     evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _datetime_popup_response_cb, this);
999     elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
1000     evas_object_show(m_pickerLayout->popup);
1001
1002 }
1003
1004 void InputPicker::_date_popup_response_cb(void* data,  Evas_Object* obj, void* event_info)
1005 {
1006     struct tm currentTime;
1007     memset(&currentTime, 0, sizeof(struct tm));
1008     Input_Date date;
1009     char dateStr[20] = {0, };
1010
1011     InputPicker* inputPicker = static_cast<InputPicker*>(data);
1012
1013     elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, &currentTime);
1014
1015     date.day =  currentTime.tm_mday;
1016     date.mon = currentTime.tm_mon;
1017     date.year = currentTime.tm_year;
1018
1019     if(inputPicker->m_pickerLayout->popup){
1020         evas_object_del(inputPicker->m_pickerLayout->popup);
1021         inputPicker->m_pickerLayout->popup = 0;
1022     }
1023
1024     date.year = 1900 + date.year;
1025     sprintf(dateStr, "%d-%02d-%02d" , date.year, date.mon + 1, date.day);
1026
1027     ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1028
1029     delete inputPicker->m_pickerLayout;
1030     inputPicker->m_pickerLayout = 0;
1031 }
1032
1033 void InputPicker::_week_popup_response_cb(void* data,  Evas_Object* obj, void* event_info)
1034 {
1035     struct tm currentTime;
1036     memset(&currentTime, 0, sizeof(struct tm));
1037     Input_Date date;
1038     char dateStr[20] = {0, };
1039
1040     InputPicker* inputPicker = static_cast<InputPicker*>(data);
1041
1042     elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, &currentTime);
1043
1044     date.day =  currentTime.tm_mday;
1045     date.mon = currentTime.tm_mon;
1046     date.year = currentTime.tm_year;
1047     mktime(&currentTime);
1048
1049     if(inputPicker->m_pickerLayout->popup){
1050         evas_object_del(inputPicker->m_pickerLayout->popup);
1051         inputPicker->m_pickerLayout->popup = 0;
1052     }
1053
1054     struct tm firtTimeOfyear;
1055     memset(&firtTimeOfyear, 0, sizeof(struct tm));
1056     firtTimeOfyear.tm_year = date.year;
1057     firtTimeOfyear.tm_mon = 0;
1058     firtTimeOfyear.tm_mday = 1;
1059     mktime(&firtTimeOfyear);
1060
1061     char firstWeek[10] = {0, };
1062     strftime(firstWeek, 10, "%w", &firtTimeOfyear);
1063     int firstWeekCount = atoi(firstWeek);
1064
1065     char totalDay[10] = {0, };
1066     strftime(totalDay, 10, "%j", &currentTime);
1067     int totalDayCount = atoi(totalDay);
1068
1069     int weekNum = (totalDayCount + firstWeekCount) / 7;
1070     if (totalDayCount + firstWeekCount > weekNum * 7)
1071         weekNum++;
1072
1073     date.year = 1900 + date.year;
1074     sprintf(dateStr, "%d-W%02d" , date.year, weekNum);
1075
1076     ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1077
1078     delete inputPicker->m_pickerLayout;
1079     inputPicker->m_pickerLayout = 0;
1080 }
1081
1082 void InputPicker::_time_popup_response_cb(void* data,  Evas_Object* obj, void* event_info)
1083 {
1084     struct tm currentTime;
1085     memset(&currentTime, 0, sizeof(struct tm));
1086     Input_Date date;
1087     char dateStr[20] = {0, };
1088
1089     InputPicker* inputPicker = static_cast<InputPicker*>(data);
1090
1091     elm_datetime_value_get(inputPicker->m_pickerLayout->timePicker, &currentTime);
1092
1093     date.hour =  currentTime.tm_hour;
1094     date.min = currentTime.tm_min;
1095
1096     if(inputPicker->m_pickerLayout->popup){
1097         evas_object_del(inputPicker->m_pickerLayout->popup);
1098         inputPicker->m_pickerLayout->popup = 0;
1099     }
1100
1101     sprintf(dateStr, "%02d:%02d" , date.hour, date.min);
1102     ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1103
1104     delete inputPicker->m_pickerLayout;
1105     inputPicker->m_pickerLayout = 0;
1106 }
1107
1108 void InputPicker::_month_popup_response_cb(void* data,  Evas_Object* obj, void* event_info)
1109 {
1110     struct tm currentTime;
1111     memset(&currentTime, 0, sizeof(struct tm));
1112     Input_Date date;
1113     char dateStr[20] = {0, };
1114
1115     InputPicker* inputPicker = static_cast<InputPicker*>(data);
1116
1117     elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, &currentTime);
1118
1119     date.mon = currentTime.tm_mon;
1120     date.year = currentTime.tm_year;
1121
1122     if(inputPicker->m_pickerLayout->popup){
1123         evas_object_del(inputPicker->m_pickerLayout->popup);
1124         inputPicker->m_pickerLayout->popup = 0;
1125     }
1126
1127     date.year = 1900 + date.year;
1128     sprintf(dateStr, "%02d-%02d" , date.year, date.mon + 1);
1129
1130     ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1131
1132     delete inputPicker->m_pickerLayout;
1133     inputPicker->m_pickerLayout = 0;
1134 }
1135
1136 void InputPicker::_datetime_popup_response_cb(void* data,  Evas_Object* obj, void* event_info)
1137 {
1138     struct tm currentTime;
1139     memset(&currentTime, 0, sizeof(struct tm));
1140     Input_Date date;
1141     char dateStr[50] = {0, };
1142
1143     InputPicker* inputPicker = static_cast<InputPicker*>(data);
1144
1145     elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, &currentTime);
1146     date.year = currentTime.tm_year;
1147     date.day =  currentTime.tm_mday;
1148     date.mon = currentTime.tm_mon;
1149
1150     elm_datetime_value_get(inputPicker->m_pickerLayout->timePicker, &currentTime);
1151     date.hour =  currentTime.tm_hour;
1152     date.min = currentTime.tm_min;
1153
1154     if (inputPicker->m_pickerLayout->popup) {
1155         evas_object_del(inputPicker->m_pickerLayout->popup);
1156         inputPicker->m_pickerLayout->popup = 0;
1157     }
1158
1159     date.year = 1900 + date.year;
1160
1161     if (inputPicker->m_pickerLayout->datetimeLocal)
1162         sprintf(dateStr, "%d-%02d-%02dT%02d:%02d" , date.year, date.mon + 1, date.day, date.hour, date.min);
1163     else
1164         sprintf(dateStr, "%d-%02d-%02dT%02d:%02dZ" , date.year, date.mon + 1, date.day, date.hour, date.min);
1165
1166     ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1167
1168     delete inputPicker->m_pickerLayout;
1169     inputPicker->m_pickerLayout = 0;
1170 }
1171
1172 } // namespace WebKit
1173
1174 #endif // OS(TIZEN) && ENABLE(TIZEN_INPUT_TAG_EXTENSION)