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