2 * Copyright (C) 2012 Samsung Electronics
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.
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.
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.
21 #include "InputPicker.h"
25 #include <Elementary.h>
31 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
33 #include <efl_assist.h>
34 extern void* EflAssistHandle;
37 #if OS(TIZEN) && ENABLE(TIZEN_INPUT_TAG_EXTENSION)
39 Input_Picker_Layout::Input_Picker_Layout(Evas_Object* ewkView)
47 , dataListEditField(0)
48 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
53 , datetimeLocal(false)
55 evas_object_focus_set(m_ewkView, false);
57 /* FIXME : Workaround. OSP requirement.
58 OSP want to block own touch event while webkit internal picker is running. */
59 evas_object_smart_callback_call(m_ewkView, "input,picker,show", 0);
62 Input_Picker_Layout::~Input_Picker_Layout()
64 /* FIXME : Workaround. OSP requirement.
65 OSP want to block own touch event while webkit internal picker is running. */
66 evas_object_smart_callback_call(m_ewkView, "input,picker,hide", 0);
71 InputPicker::InputPicker(Evas_Object* ewkView)
75 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
76 , m_isColorPickerShown(false)
81 InputPicker::~InputPicker()
84 if (m_pickerLayout->popup)
85 evas_object_del(m_pickerLayout->popup);
86 delete m_pickerLayout;
90 void InputPicker::show(Ewk_Input_Type inputType, const char* inputValue)
92 if(inputType == EWK_INPUT_TYPE_DATE)
93 ewk_date_popup(inputValue);
94 else if(inputType == EWK_INPUT_TYPE_TIME)
95 ewk_time_popup(inputValue);
96 else if(inputType == EWK_INPUT_TYPE_DATETIME)
97 ewk_datetime_popup(inputValue, false);
98 else if(inputType == EWK_INPUT_TYPE_DATETIMELOCAL)
99 ewk_datetime_popup(inputValue, true);
100 else if(inputType == EWK_INPUT_TYPE_MONTH)
101 ewk_month_popup(inputValue);
102 else if(inputType == EWK_INPUT_TYPE_WEEK)
103 ewk_week_popup(inputValue);
106 #if ENABLE(TIZEN_DATALIST_ELEMENT)
107 void InputPicker::_data_list_popup_response_cb(void* data, Evas_Object* obj, void* eventInfo)
109 InputPicker* inputPicker = static_cast<InputPicker*>(data);
110 const char* selectedItem = elm_entry_entry_get(inputPicker->m_pickerLayout->dataListEditField);
111 ewk_view_data_list_close(inputPicker->m_ewkView, selectedItem);
113 if (inputPicker->m_pickerLayout->popup) {
114 evas_object_del(inputPicker->m_pickerLayout->popup);
115 inputPicker->m_pickerLayout->popup = 0;
118 delete inputPicker->m_pickerLayout;
119 inputPicker->m_pickerLayout = 0;
121 inputPicker->m_dataList = 0;
124 void InputPicker::_data_list_popup_response_cancel_cb(void* data, Evas_Object* obj, void* eventInfo)
126 InputPicker* inputPicker = static_cast<InputPicker*>(data);
128 if (inputPicker->m_pickerLayout->popup) {
129 evas_object_del(inputPicker->m_pickerLayout->popup);
130 inputPicker->m_pickerLayout->popup = 0;
133 delete inputPicker->m_pickerLayout;
134 inputPicker->m_pickerLayout = 0;
136 inputPicker->m_dataList = 0;
139 void InputPicker::_data_list_selected_cb(void* data, Evas_Object* obj, void* eventInfo)
141 InputPicker* inputPicker = static_cast<InputPicker*>(data);
142 Elm_Object_Item* selectedItem = static_cast<Elm_Object_Item*>(eventInfo);
143 Elm_Object_Item* item = elm_list_first_item_get(obj);
147 if (item == selectedItem)
150 item = elm_list_item_next(item);
156 EINA_LIST_FOREACH(inputPicker->m_dataList, list, listItem) {
157 if (listItem && index == listIndex)
158 elm_entry_entry_set(inputPicker->m_pickerLayout->dataListEditField, static_cast<char*>(listItem));
164 static void _eraser_clicked_cb(void* data, Evas_Object* obj, const char* emission, const char* source)
166 Evas_Object* entry = static_cast<Evas_Object*>(data);
167 elm_entry_entry_set(entry, "");
170 static void _changed_cb(void* data, Evas_Object* obj, void* eventInfo)
172 Evas_Object* layout = static_cast<Evas_Object*>(data);
174 if (elm_object_focus_get(layout)) {
175 if (elm_entry_is_empty(obj))
176 elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
178 elm_object_signal_emit(layout, "elm,state,eraser,show", "elm");
182 static void _focused_cb(void* data, Evas_Object* obj, void* eventInfo)
184 Evas_Object* layout = static_cast<Evas_Object*>(data);
186 if (!elm_entry_is_empty(obj))
187 elm_object_signal_emit(layout, "elm,state,eraser,show", "elm");
190 static void _unfocused_cb(void* data, Evas_Object* obj, void* eventInfo)
192 Evas_Object* layout = static_cast<Evas_Object*>(data);
193 elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
196 void InputPicker::showDataList(Ewk_Input_Type inputType, Eina_List* optionList)
198 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
199 Evas_Object* win = parent;
201 m_dataList = optionList;
206 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
208 /* FIXME: If the entry is in the popup, the parent should be naviframe for uifw limitation. */
209 Evas_Object* naviframe = elm_naviframe_add(m_ewkView);
211 const char* type = elm_object_widget_type_get(parent);
213 if (!strcmp(type, elm_object_widget_type_get(naviframe))) {
218 parent = elm_object_parent_widget_get(parent);
221 evas_object_del(naviframe);
226 m_pickerLayout->popup = elm_popup_add(win);
227 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select data list");
229 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
230 if (EflAssistHandle) {
231 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
232 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
233 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _data_list_popup_response_cancel_cb, this);
237 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
238 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","data_list_picker");
239 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
240 evas_object_show(m_pickerLayout->layout);
241 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
243 Evas_Object* elmList = elm_list_add(m_pickerLayout->layout);
246 EINA_LIST_FOREACH(optionList, list, listItem) {
248 elm_list_item_append(elmList, static_cast<char*>(listItem), 0, 0, _data_list_selected_cb, this);
250 evas_object_size_hint_weight_set(elmList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
251 evas_object_show(elmList);
252 elm_object_part_content_set(m_pickerLayout->layout, "data_list", elmList);
254 Evas_Object* editFieldLayout = elm_layout_add(m_pickerLayout->layout);
255 elm_layout_theme_set(editFieldLayout, "layout", "editfield", "default");
257 m_pickerLayout->dataListEditField = elm_entry_add(editFieldLayout);
258 elm_object_part_content_set(editFieldLayout, "elm.swallow.content", m_pickerLayout->dataListEditField);
260 elm_object_signal_emit(editFieldLayout, "elm,state,guidetext,hide", "elm");
261 elm_object_signal_callback_add(editFieldLayout, "elm,eraser,clicked", "elm", _eraser_clicked_cb, m_pickerLayout->dataListEditField);
262 evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "changed", _changed_cb, editFieldLayout);
263 evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "focused", _focused_cb, editFieldLayout);
264 evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "unfocused", _unfocused_cb, editFieldLayout);
266 elm_object_part_content_set(m_pickerLayout->layout, "selected_item", editFieldLayout);
267 evas_object_show(editFieldLayout);
269 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
270 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
271 elm_object_text_set(m_pickerLayout->okButton, "OK");
272 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
273 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _data_list_popup_response_cb, this);
274 evas_object_show(m_pickerLayout->popup);
275 evas_object_focus_set(m_pickerLayout->okButton, true);
277 Evas_Object* cancelButton = elm_button_add(m_pickerLayout->popup);
278 elm_object_style_set(cancelButton, "popup_button/default");
279 elm_object_text_set(cancelButton, "Cancel");
280 elm_object_part_content_set(m_pickerLayout->popup, "button2", cancelButton);
281 evas_object_smart_callback_add(cancelButton, "clicked", _data_list_popup_response_cancel_cb, this);
282 evas_object_show(cancelButton);
285 void InputPicker::hideDataList(Ewk_Input_Type inputType)
290 if(m_pickerLayout->popup){
291 evas_object_del(m_pickerLayout->popup);
292 m_pickerLayout->popup = 0;
295 delete m_pickerLayout;
302 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
303 void InputPicker::showColorPicker(int r, int g, int b, int)
305 m_isColorPickerShown = true;
306 ewk_color_popup(r, g, b);
309 void InputPicker::hideColorPicker()
311 m_isColorPickerShown = false;
315 if (m_pickerLayout->popup) {
316 evas_object_del(m_pickerLayout->popup);
317 m_pickerLayout->popup = 0;
320 delete m_pickerLayout;
325 #if ENABLE(ELM_COLORPALLETE)
326 static void _color_palette_changed_cb(void* data, Evas_Object* obj, void* eventInfo)
332 Elm_Object_Item *color_it = static_cast<Elm_Object_Item*>(eventInfo);
333 elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
334 evas_object_color_set(static_cast<Evas_Object*>(data), r, g, b , a);
338 void InputPicker::_color_selected_cb(void* data, Evas* evas, Evas_Object* obj, void* eventInfo)
344 evas_object_color_get(obj, &r, &g, &b, &a);
346 evas_object_color_set(static_cast<Evas_Object*>(data), r, g, b, a);
349 void InputPicker::ewk_color_popup(int r, int g, int b)
351 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
352 Evas_Object* win = parent;
357 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
360 const char* type = elm_object_widget_type_get(parent);
362 if (!strcmp(type, "elm_win")) {
367 parent = elm_object_parent_widget_get(parent);
373 m_pickerLayout->popup = elm_popup_add(win);
374 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select color");
376 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
377 m_pickerLayout->initial_r = r;
378 m_pickerLayout->initial_g = g;
379 m_pickerLayout->initial_b = b;
380 if (EflAssistHandle) {
381 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
382 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
383 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _color_back_cb, this);
387 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
388 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","color_picker");
389 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
390 evas_object_show(m_pickerLayout->layout);
391 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
393 m_pickerLayout->colorRect = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
394 evas_object_size_hint_weight_set(m_pickerLayout->colorRect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
395 evas_object_show(m_pickerLayout->colorRect);
397 evas_object_color_set(m_pickerLayout->colorRect, r, g, b, 255);
398 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color_rect", m_pickerLayout->colorRect);
399 #if ENABLE(ELM_COLORPALLETE)
400 Evas_Object* colorPalette = elm_colorselector_add(m_pickerLayout->popup);
401 elm_colorselector_mode_set(colorPalette, ELM_COLORSELECTOR_PALETTE);
403 elm_colorselector_palette_color_add(colorPalette, 128, 0, 0, 255);
404 elm_colorselector_palette_color_add(colorPalette, 255, 0, 128, 255);
405 elm_colorselector_palette_color_add(colorPalette, 255, 0, 0, 255);
406 elm_colorselector_palette_color_add(colorPalette, 255, 127, 39, 255);
407 elm_colorselector_palette_color_add(colorPalette, 255, 255, 0, 255);
408 elm_colorselector_palette_color_add(colorPalette, 0, 255, 0, 255);
409 elm_colorselector_palette_color_add(colorPalette, 0, 255, 255, 255);
410 elm_colorselector_palette_color_add(colorPalette, 0, 0, 255, 255);
411 elm_colorselector_palette_color_add(colorPalette, 0, 0, 128, 255);
412 elm_colorselector_palette_color_add(colorPalette, 64, 0, 64, 255);
413 elm_colorselector_palette_color_add(colorPalette, 0, 0, 0, 255);
414 elm_colorselector_palette_color_add(colorPalette, 255, 255, 255, 255);
416 evas_object_size_hint_fill_set(colorPalette, EVAS_HINT_FILL, 0);
417 evas_object_size_hint_weight_set(colorPalette, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
418 evas_object_smart_callback_add(colorPalette, "color,item,selected", _color_palette_changed_cb, m_pickerLayout->colorRect);
419 evas_object_show(colorPalette);
421 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color_palette", colorPalette);
423 Evas_Object* color1 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
424 evas_object_size_hint_weight_set(color1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
425 evas_object_color_set(color1, 128, 0, 0, 255);
426 evas_object_event_callback_add(color1, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
427 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color1", color1);
428 evas_object_show(color1);
430 Evas_Object* color2 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
431 evas_object_size_hint_weight_set(color2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
432 evas_object_color_set(color2, 255, 0, 128, 255);
433 evas_object_event_callback_add(color2, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
434 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color2", color2);
435 evas_object_show(color2);
437 Evas_Object* color3 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
438 evas_object_size_hint_weight_set(color3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
439 evas_object_color_set(color3, 255, 0, 0, 255);
440 evas_object_event_callback_add(color3, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
441 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color3", color3);
442 evas_object_show(color3);
444 Evas_Object* color4 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
445 evas_object_size_hint_weight_set(color4, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
446 evas_object_color_set(color4, 255, 127, 39, 255);
447 evas_object_event_callback_add(color4, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
448 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color4", color4);
449 evas_object_show(color4);
451 Evas_Object* color5 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
452 evas_object_size_hint_weight_set(color5, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
453 evas_object_color_set(color5, 255, 255, 0, 255);
454 evas_object_event_callback_add(color5, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
455 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color5", color5);
456 evas_object_show(color5);
458 Evas_Object* color6 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
459 evas_object_size_hint_weight_set(color6, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
460 evas_object_color_set(color6, 0, 255, 0, 255);
461 evas_object_event_callback_add(color6, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
462 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color6", color6);
463 evas_object_show(color6);
465 Evas_Object* color7 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
466 evas_object_size_hint_weight_set(color7, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
467 evas_object_color_set(color7, 0, 255, 255, 255);
468 evas_object_event_callback_add(color7, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
469 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color7", color7);
470 evas_object_show(color7);
472 Evas_Object* color8 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
473 evas_object_size_hint_weight_set(color8, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
474 evas_object_color_set(color8, 0, 0, 255, 255);
475 evas_object_event_callback_add(color8, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
476 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color8", color8);
477 evas_object_show(color8);
479 Evas_Object* color9 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
480 evas_object_size_hint_weight_set(color9, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
481 evas_object_color_set(color9, 0, 0, 128, 255);
482 evas_object_event_callback_add(color9, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
483 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color9", color9);
484 evas_object_show(color9);
486 Evas_Object* color10 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
487 evas_object_size_hint_weight_set(color10, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
488 evas_object_color_set(color10, 64, 0, 64, 255);
489 evas_object_event_callback_add(color10, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
490 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color10", color10);
491 evas_object_show(color10);
493 Evas_Object* color11 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
494 evas_object_size_hint_weight_set(color11, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
495 evas_object_color_set(color11, 153, 217, 234, 255);
496 evas_object_event_callback_add(color11, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
497 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color11", color11);
498 evas_object_show(color11);
500 Evas_Object* color12 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
501 evas_object_size_hint_weight_set(color12, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
502 evas_object_color_set(color12, 128, 128, 128, 255);
503 evas_object_event_callback_add(color12, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
504 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color12", color12);
505 evas_object_show(color12);
507 Evas_Object* color13 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
508 evas_object_size_hint_weight_set(color13, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
509 evas_object_color_set(color13, 0, 0, 0, 255);
510 evas_object_event_callback_add(color13, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
511 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color13", color13);
512 evas_object_show(color13);
514 Evas_Object* color14 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
515 evas_object_size_hint_weight_set(color14, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
516 evas_object_color_set(color14, 255, 255, 255, 255);
517 evas_object_event_callback_add(color14, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
518 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color14", color14);
519 evas_object_show(color14);
521 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
522 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
523 elm_object_text_set(m_pickerLayout->okButton, "OK");
524 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
525 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _color_popup_response_cb, this);
526 evas_object_focus_set(m_pickerLayout->okButton, true);
528 evas_object_show(m_pickerLayout->popup);
531 void InputPicker::_color_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
533 InputPicker* inputPicker = static_cast<InputPicker*>(data);
539 evas_object_color_get(inputPicker->m_pickerLayout->colorRect, &r, &g, &b, &a);
541 ewk_view_color_picker_color_set(inputPicker->m_ewkView, r, g, b, a);
543 inputPicker->hideColorPicker();
546 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
547 void InputPicker::_color_back_cb(void* data, Evas_Object* obj, void* event_info)
549 InputPicker* inputPicker = static_cast<InputPicker*>(data);
551 int r = inputPicker->m_pickerLayout->initial_r;
552 int g = inputPicker->m_pickerLayout->initial_g;
553 int b = inputPicker->m_pickerLayout->initial_b;
555 ewk_view_color_picker_color_set(inputPicker->m_ewkView, r, g, b, a);
557 inputPicker->hideColorPicker();
561 void InputPicker::ewk_date_popup(const char* inputValue)
563 struct tm* currentTime;
566 currentTime = localtime(&cur_time);
568 Input_Date_Str dateStr;
569 memset(&dateStr, 0, sizeof(Input_Date_Str));
571 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
572 Evas_Object* win = parent;
574 if (inputValue && strlen(inputValue)) {
575 char tmpinputValue[30] = {0,};
577 sprintf(tmpinputValue, "%s", inputValue);
578 strcpy(dateStr.year, strtok(tmpinputValue,"-"));
579 strcpy(dateStr.mon, strtok(0, "-"));
580 strcpy(dateStr.day, strtok(0, "-"));
582 currentTime->tm_year = atoi(dateStr.year);
583 currentTime->tm_mon = atoi(dateStr.mon);
584 currentTime->tm_mday = atoi(dateStr.day);
586 currentTime->tm_year = currentTime->tm_year - 1900;
587 currentTime->tm_mon = currentTime->tm_mon - 1;
590 if (m_pickerLayout) {
591 // Just update the value.
592 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
593 evas_object_focus_set(m_pickerLayout->okButton, true);
597 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
600 const char* type = elm_object_widget_type_get(parent);
602 if (!strcmp(type, "elm_win")) {
607 parent = elm_object_parent_widget_get(parent);
613 m_pickerLayout->popup = elm_popup_add(win);
614 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select date");
616 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
617 if (EflAssistHandle) {
618 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
619 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
620 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
624 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
625 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
626 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
628 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Date (Default format) :");
630 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
631 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
633 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_HOUR, EINA_FALSE);
634 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_MINUTE, EINA_FALSE);
635 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_AMPM, EINA_FALSE);
636 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
638 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
639 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
640 elm_object_text_set(m_pickerLayout->okButton, "OK");
641 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
642 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _date_popup_response_cb, this);
643 evas_object_focus_set(m_pickerLayout->okButton, true);
645 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
646 evas_object_show(m_pickerLayout->popup);
649 #define isLeapYear(year) ((!(year % 4) && (year % 100)) || (!(year % 400) && (year % 1000)))
650 static int _calculateMonthAndDay(int year, int totalDays, int* remains)
653 if (totalDays - 31 < 0) {
654 *remains = totalDays;
658 totalDays = totalDays - 31;
661 if (isLeapYear(year)) {
662 if (totalDays - 29 < 0) {
663 *remains = totalDays;
666 totalDays = totalDays - 29;
668 if (totalDays - 28 < 0) {
669 *remains = totalDays;
672 totalDays = totalDays - 28;
676 if (totalDays - 31 < 0) {
677 *remains = totalDays;
680 totalDays = totalDays - 31;
683 if (totalDays - 30 < 0) {
684 *remains = totalDays;
687 totalDays = totalDays - 30;
690 if (totalDays - 31 < 0) {
691 *remains = totalDays;
694 totalDays = totalDays - 31;
697 if (totalDays - 30 < 0) {
698 *remains = totalDays;
701 totalDays = totalDays - 30;
704 if (totalDays - 31 < 0) {
705 *remains = totalDays;
708 totalDays = totalDays - 31;
711 if (totalDays - 31 < 0) {
712 *remains = totalDays;
715 totalDays = totalDays - 31;
718 if (totalDays - 30 < 0) {
719 *remains = totalDays;
722 totalDays = totalDays - 30;
725 if (totalDays - 31 < 0) {
726 *remains = totalDays;
729 totalDays = totalDays - 31;
732 if (totalDays - 30 < 0) {
733 *remains = totalDays;
736 totalDays = totalDays - 30;
738 *remains = totalDays;
742 void InputPicker::ewk_week_popup(const char* inputValue)
744 struct tm* currentTime;
747 currentTime = localtime(&cur_time);
749 Input_Date_Str dateStr;
750 memset(&dateStr, 0, sizeof(Input_Date_Str));
752 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
753 Evas_Object* win = parent;
755 if (inputValue && strlen(inputValue)) {
756 char tmpinputValue[30] = {0,};
758 sprintf(tmpinputValue, "%s", inputValue);
759 strcpy(dateStr.year, strtok(tmpinputValue,"-"));
760 const char* week = strstr(inputValue, "W");
763 weekNum = atoi(week + 1);
765 currentTime->tm_year = atoi(dateStr.year);
766 currentTime->tm_year = currentTime->tm_year - 1900;
768 struct tm firtTimeOfyear;
769 memset(&firtTimeOfyear, 0, sizeof(struct tm));
770 firtTimeOfyear.tm_year = currentTime->tm_year;
771 firtTimeOfyear.tm_mon = 0;
772 firtTimeOfyear.tm_mday = 1;
773 mktime(&firtTimeOfyear);
775 char firstWeek[10] = {0, };
776 strftime(firstWeek, 10, "%w", &firtTimeOfyear);
777 int firstWeekCount = atoi(firstWeek);
781 totalDays = weekNum * 7 - firstWeekCount;
784 int month = _calculateMonthAndDay(currentTime->tm_year, totalDays, &days);
786 currentTime->tm_mon = month;
787 currentTime->tm_mday = days;
790 if (m_pickerLayout) {
791 // Just update the value.
792 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
793 evas_object_focus_set(m_pickerLayout->okButton, true);
797 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
800 const char* type = elm_object_widget_type_get(parent);
802 if (!strcmp(type, "elm_win")) {
807 parent = elm_object_parent_widget_get(parent);
813 m_pickerLayout->popup = elm_popup_add(win);
814 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select date");
816 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
817 if (EflAssistHandle) {
818 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
819 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
820 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
824 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
825 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
826 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
828 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Date (Default format) :");
830 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
831 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
833 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_HOUR, EINA_FALSE);
834 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_MINUTE, EINA_FALSE);
835 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_AMPM, EINA_FALSE);
836 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
838 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
839 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
840 elm_object_text_set(m_pickerLayout->okButton, "OK");
841 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
842 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _week_popup_response_cb, this);
843 evas_object_focus_set(m_pickerLayout->okButton, true);
845 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
846 evas_object_show(m_pickerLayout->popup);
849 void InputPicker::ewk_time_popup(const char* inputValue)
851 struct tm* currentTime;
854 currentTime = localtime(&cur_time);
856 Input_Date_Str dateStr;
857 memset(&dateStr, 0, sizeof(Input_Date_Str));
859 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
860 Evas_Object* win = parent;
862 if (inputValue && strlen(inputValue)) {
863 char tmpinputValue[30] = {0,};
865 sprintf(tmpinputValue, "%s", inputValue);
866 strcpy(dateStr.hour, strtok(tmpinputValue,":"));
867 strcpy(dateStr.min, strtok(0, ":"));
869 currentTime->tm_hour = atoi(dateStr.hour);
870 currentTime->tm_min = atoi(dateStr.min);
873 if (m_pickerLayout) {
874 // Just update the value.
875 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
876 evas_object_focus_set(m_pickerLayout->okButton, true);
880 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
883 const char* type = elm_object_widget_type_get(parent);
885 if (!strcmp(type, "elm_win")) {
890 parent = elm_object_parent_widget_get(parent);
896 m_pickerLayout->popup = elm_popup_add(win);
897 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select time");
899 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
900 if (EflAssistHandle) {
901 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
902 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
903 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
907 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
908 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
909 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
911 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Time (Default format) :");
913 m_pickerLayout->timePicker = elm_datetime_add(m_pickerLayout->layout);
914 elm_datetime_format_set(m_pickerLayout->timePicker, "%H:%M");
915 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
917 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->timePicker);
919 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
920 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
921 elm_object_text_set(m_pickerLayout->okButton, "OK");
922 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
923 evas_object_focus_set(m_pickerLayout->okButton, true);
925 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _time_popup_response_cb, this);
926 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
927 evas_object_show(m_pickerLayout->popup);
930 void InputPicker::ewk_month_popup(const char* inputValue)
932 struct tm* currentTime;
935 currentTime = localtime(&cur_time);
937 Input_Date_Str dateStr;
938 memset(&dateStr, 0, sizeof(Input_Date_Str));
940 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
941 Evas_Object* win = parent;
943 if (inputValue && strlen(inputValue)) {
944 char tmpInputValue[30] = {0,};
946 sprintf(tmpInputValue, "%s", inputValue);
947 strcpy(dateStr.year, strtok(tmpInputValue,"-"));
948 strcpy(dateStr.mon, strtok(0, "-"));
950 currentTime->tm_year = atoi(dateStr.year);
951 currentTime->tm_mon = atoi(dateStr.mon);
953 currentTime->tm_year = currentTime->tm_year - 1900;
954 currentTime->tm_mon = currentTime->tm_mon - 1;
957 if (m_pickerLayout) {
958 // Just update the value.
959 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
960 evas_object_focus_set(m_pickerLayout->okButton, true);
964 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
967 const char* type = elm_object_widget_type_get(parent);
969 if (!strcmp(type, "elm_win")) {
974 parent = elm_object_parent_widget_get(parent);
980 m_pickerLayout->popup = elm_popup_add(win);
981 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select month");
983 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
984 if (EflAssistHandle) {
985 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
986 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
987 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
991 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
992 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
994 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
995 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
997 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
999 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Month (Default format) :");
1001 elm_datetime_format_set(m_pickerLayout->datePicker, "%Y %m");
1002 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
1004 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
1005 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
1006 elm_object_text_set(m_pickerLayout->okButton, "OK");
1007 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
1008 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _month_popup_response_cb, this);
1009 evas_object_focus_set(m_pickerLayout->okButton, true);
1011 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
1012 evas_object_show(m_pickerLayout->popup);
1015 void InputPicker::ewk_datetime_popup(const char* inputValue, bool local)
1017 struct tm* currentTime;
1020 currentTime = localtime(&cur_time);
1022 Input_Date_Str dateStr;
1023 memset(&dateStr, 0, sizeof(Input_Date_Str));
1025 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
1026 Evas_Object* win = parent;
1028 if (inputValue && strlen(inputValue)) {
1029 char tmpInputValue[30] = {0, };
1031 sprintf(tmpInputValue, "%s", inputValue);
1032 strcpy(dateStr.year, strtok(tmpInputValue,"-"));
1033 strcpy(dateStr.mon, strtok(0, "-"));
1034 strcpy(dateStr.day, strtok(0, "T"));
1035 strcpy(dateStr.hour, strtok(0, ":"));
1038 strcpy(dateStr.min, strtok(0, "Z"));
1040 strcpy(dateStr.min, strtok(0, ":"));
1042 currentTime->tm_year = atoi(dateStr.year);
1043 currentTime->tm_mon = atoi(dateStr.mon);
1044 currentTime->tm_mday = atoi(dateStr.day);
1045 currentTime->tm_hour = atoi(dateStr.hour);
1046 currentTime->tm_min = atoi(dateStr.min);
1048 currentTime->tm_year = currentTime->tm_year - 1900;
1049 currentTime->tm_mon = currentTime->tm_mon - 1;
1052 if (m_pickerLayout) {
1053 // Just update the value.
1054 m_pickerLayout->datetimeLocal = local;
1056 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
1057 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
1058 evas_object_focus_set(m_pickerLayout->okButton, true);
1062 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
1064 m_pickerLayout->datetimeLocal = local;
1067 const char* type = elm_object_widget_type_get(parent);
1069 if (!strcmp(type, "elm_win")) {
1074 parent = elm_object_parent_widget_get(parent);
1080 m_pickerLayout->popup = elm_popup_add(win);
1081 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select datetime");
1083 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1084 if (EflAssistHandle) {
1085 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
1086 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
1087 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
1091 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
1092 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","datepicker_popup");
1093 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1095 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
1096 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
1098 elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_HOUR, EINA_FALSE);
1099 elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_MINUTE, EINA_FALSE);
1100 elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_AMPM, EINA_FALSE);
1101 elm_object_part_content_set(m_pickerLayout->layout , "elm.swallow.content.date", m_pickerLayout->datePicker);
1103 m_pickerLayout->timePicker = elm_datetime_add(m_pickerLayout->layout);
1104 elm_datetime_format_set(m_pickerLayout->timePicker, "%H:%M");
1105 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
1106 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.time", m_pickerLayout->timePicker);
1108 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
1109 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
1110 elm_object_text_set(m_pickerLayout->okButton, "OK");
1111 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
1112 evas_object_focus_set(m_pickerLayout->okButton, true);
1114 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _datetime_popup_response_cb, this);
1115 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
1116 evas_object_show(m_pickerLayout->popup);
1120 void InputPicker::_date_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1122 struct tm currentTime;
1123 memset(¤tTime, 0, sizeof(struct tm));
1125 char dateStr[20] = {0, };
1127 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1129 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1131 date.day = currentTime.tm_mday;
1132 date.mon = currentTime.tm_mon;
1133 date.year = currentTime.tm_year;
1135 if(inputPicker->m_pickerLayout->popup){
1136 evas_object_del(inputPicker->m_pickerLayout->popup);
1137 inputPicker->m_pickerLayout->popup = 0;
1140 date.year = 1900 + date.year;
1141 sprintf(dateStr, "%d-%02d-%02d" , date.year, date.mon + 1, date.day);
1143 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1144 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1146 delete inputPicker->m_pickerLayout;
1147 inputPicker->m_pickerLayout = 0;
1150 void InputPicker::_week_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1152 struct tm currentTime;
1153 memset(¤tTime, 0, sizeof(struct tm));
1155 char dateStr[20] = {0, };
1157 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1159 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1161 date.day = currentTime.tm_mday;
1162 date.mon = currentTime.tm_mon;
1163 date.year = currentTime.tm_year;
1164 mktime(¤tTime);
1166 if(inputPicker->m_pickerLayout->popup){
1167 evas_object_del(inputPicker->m_pickerLayout->popup);
1168 inputPicker->m_pickerLayout->popup = 0;
1171 struct tm firtTimeOfyear;
1172 memset(&firtTimeOfyear, 0, sizeof(struct tm));
1173 firtTimeOfyear.tm_year = date.year;
1174 firtTimeOfyear.tm_mon = 0;
1175 firtTimeOfyear.tm_mday = 1;
1176 mktime(&firtTimeOfyear);
1178 char firstWeek[10] = {0, };
1179 strftime(firstWeek, 10, "%w", &firtTimeOfyear);
1180 int firstWeekCount = atoi(firstWeek);
1182 char totalDay[10] = {0, };
1183 strftime(totalDay, 10, "%j", ¤tTime);
1184 int totalDayCount = atoi(totalDay);
1186 int weekNum = (totalDayCount + firstWeekCount) / 7;
1187 if (totalDayCount + firstWeekCount > weekNum * 7)
1190 date.year = 1900 + date.year;
1191 sprintf(dateStr, "%d-W%02d" , date.year, weekNum);
1193 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1194 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1196 delete inputPicker->m_pickerLayout;
1197 inputPicker->m_pickerLayout = 0;
1200 void InputPicker::_time_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1202 struct tm currentTime;
1203 memset(¤tTime, 0, sizeof(struct tm));
1205 char dateStr[20] = {0, };
1207 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1209 elm_datetime_value_get(inputPicker->m_pickerLayout->timePicker, ¤tTime);
1211 date.hour = currentTime.tm_hour;
1212 date.min = currentTime.tm_min;
1214 if(inputPicker->m_pickerLayout->popup){
1215 evas_object_del(inputPicker->m_pickerLayout->popup);
1216 inputPicker->m_pickerLayout->popup = 0;
1219 sprintf(dateStr, "%02d:%02d" , date.hour, date.min);
1220 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1221 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1223 delete inputPicker->m_pickerLayout;
1224 inputPicker->m_pickerLayout = 0;
1227 void InputPicker::_month_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1229 struct tm currentTime;
1230 memset(¤tTime, 0, sizeof(struct tm));
1232 char dateStr[20] = {0, };
1234 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1236 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1238 date.mon = currentTime.tm_mon;
1239 date.year = currentTime.tm_year;
1241 if(inputPicker->m_pickerLayout->popup){
1242 evas_object_del(inputPicker->m_pickerLayout->popup);
1243 inputPicker->m_pickerLayout->popup = 0;
1246 date.year = 1900 + date.year;
1247 sprintf(dateStr, "%02d-%02d" , date.year, date.mon + 1);
1249 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1250 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1252 delete inputPicker->m_pickerLayout;
1253 inputPicker->m_pickerLayout = 0;
1256 void InputPicker::_datetime_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1258 struct tm currentTime;
1259 memset(¤tTime, 0, sizeof(struct tm));
1261 char dateStr[50] = {0, };
1263 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1265 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1266 date.year = currentTime.tm_year;
1267 date.day = currentTime.tm_mday;
1268 date.mon = currentTime.tm_mon;
1270 elm_datetime_value_get(inputPicker->m_pickerLayout->timePicker, ¤tTime);
1271 date.hour = currentTime.tm_hour;
1272 date.min = currentTime.tm_min;
1274 if (inputPicker->m_pickerLayout->popup) {
1275 evas_object_del(inputPicker->m_pickerLayout->popup);
1276 inputPicker->m_pickerLayout->popup = 0;
1279 date.year = 1900 + date.year;
1281 if (inputPicker->m_pickerLayout->datetimeLocal)
1282 sprintf(dateStr, "%d-%02d-%02dT%02d:%02d" , date.year, date.mon + 1, date.day, date.hour, date.min);
1284 sprintf(dateStr, "%d-%02d-%02dT%02d:%02dZ" , date.year, date.mon + 1, date.day, date.hour, date.min);
1286 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1287 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1289 delete inputPicker->m_pickerLayout;
1290 inputPicker->m_pickerLayout = 0;
1293 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1294 void InputPicker::_popup_back_cb(void* data, Evas_Object* obj, void* event_info)
1296 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1298 if (!inputPicker->m_pickerLayout)
1301 if (inputPicker->m_pickerLayout->popup) {
1302 evas_object_del(inputPicker->m_pickerLayout->popup);
1303 inputPicker->m_pickerLayout->popup = 0;
1306 delete inputPicker->m_pickerLayout;
1307 inputPicker->m_pickerLayout = 0;
1311 } // namespace WebKit
1313 #endif // OS(TIZEN) && ENABLE(TIZEN_INPUT_TAG_EXTENSION)