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);
56 ewk_view_suspend(m_ewkView);
58 /* FIXME : Workaround. OSP requirement.
59 OSP want to block own touch event while webkit internal picker is running. */
60 evas_object_smart_callback_call(m_ewkView, "input,picker,show", 0);
63 Input_Picker_Layout::~Input_Picker_Layout()
65 /* FIXME : Workaround. OSP requirement.
66 OSP want to block own touch event while webkit internal picker is running. */
67 evas_object_smart_callback_call(m_ewkView, "input,picker,hide", 0);
69 ewk_view_resume(m_ewkView);
74 InputPicker::InputPicker(Evas_Object* ewkView)
78 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
79 , m_isColorPickerShown(false)
84 InputPicker::~InputPicker()
87 if (m_pickerLayout->popup)
88 evas_object_del(m_pickerLayout->popup);
89 delete m_pickerLayout;
93 void InputPicker::show(Ewk_Input_Type inputType, const char* inputValue)
95 if(inputType == EWK_INPUT_TYPE_DATE)
96 ewk_date_popup(inputValue);
97 else if(inputType == EWK_INPUT_TYPE_TIME)
98 ewk_time_popup(inputValue);
99 else if(inputType == EWK_INPUT_TYPE_DATETIME)
100 ewk_datetime_popup(inputValue, false);
101 else if(inputType == EWK_INPUT_TYPE_DATETIMELOCAL)
102 ewk_datetime_popup(inputValue, true);
103 else if(inputType == EWK_INPUT_TYPE_MONTH)
104 ewk_month_popup(inputValue);
105 else if(inputType == EWK_INPUT_TYPE_WEEK)
106 ewk_week_popup(inputValue);
109 #if ENABLE(TIZEN_DATALIST_ELEMENT)
110 void InputPicker::_data_list_popup_response_cb(void* data, Evas_Object* obj, void* eventInfo)
112 InputPicker* inputPicker = static_cast<InputPicker*>(data);
113 const char* selectedItem = elm_entry_entry_get(inputPicker->m_pickerLayout->dataListEditField);
114 ewk_view_data_list_close(inputPicker->m_ewkView, selectedItem);
116 if (inputPicker->m_pickerLayout->popup) {
117 evas_object_del(inputPicker->m_pickerLayout->popup);
118 inputPicker->m_pickerLayout->popup = 0;
121 delete inputPicker->m_pickerLayout;
122 inputPicker->m_pickerLayout = 0;
124 inputPicker->m_dataList = 0;
127 void InputPicker::_data_list_popup_response_cancel_cb(void* data, Evas_Object* obj, void* eventInfo)
129 InputPicker* inputPicker = static_cast<InputPicker*>(data);
131 if (inputPicker->m_pickerLayout->popup) {
132 evas_object_del(inputPicker->m_pickerLayout->popup);
133 inputPicker->m_pickerLayout->popup = 0;
136 delete inputPicker->m_pickerLayout;
137 inputPicker->m_pickerLayout = 0;
139 inputPicker->m_dataList = 0;
142 void InputPicker::_data_list_selected_cb(void* data, Evas_Object* obj, void* eventInfo)
144 InputPicker* inputPicker = static_cast<InputPicker*>(data);
145 Elm_Object_Item* selectedItem = static_cast<Elm_Object_Item*>(eventInfo);
146 Elm_Object_Item* item = elm_list_first_item_get(obj);
150 if (item == selectedItem)
153 item = elm_list_item_next(item);
159 EINA_LIST_FOREACH(inputPicker->m_dataList, list, listItem) {
160 if (listItem && index == listIndex)
161 elm_entry_entry_set(inputPicker->m_pickerLayout->dataListEditField, static_cast<char*>(listItem));
167 static void _eraser_clicked_cb(void* data, Evas_Object* obj, const char* emission, const char* source)
169 Evas_Object* entry = static_cast<Evas_Object*>(data);
170 elm_entry_entry_set(entry, "");
173 static void _changed_cb(void* data, Evas_Object* obj, void* eventInfo)
175 Evas_Object* layout = static_cast<Evas_Object*>(data);
177 if (elm_object_focus_get(layout)) {
178 if (elm_entry_is_empty(obj))
179 elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
181 elm_object_signal_emit(layout, "elm,state,eraser,show", "elm");
185 static void _focused_cb(void* data, Evas_Object* obj, void* eventInfo)
187 Evas_Object* layout = static_cast<Evas_Object*>(data);
189 if (!elm_entry_is_empty(obj))
190 elm_object_signal_emit(layout, "elm,state,eraser,show", "elm");
193 static void _unfocused_cb(void* data, Evas_Object* obj, void* eventInfo)
195 Evas_Object* layout = static_cast<Evas_Object*>(data);
196 elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
199 void InputPicker::showDataList(Ewk_Input_Type inputType, Eina_List* optionList)
201 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
202 Evas_Object* win = parent;
204 m_dataList = optionList;
209 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
211 /* FIXME: If the entry is in the popup, the parent should be naviframe for uifw limitation. */
212 Evas_Object* naviframe = elm_naviframe_add(m_ewkView);
214 const char* type = elm_object_widget_type_get(parent);
216 if (!strcmp(type, elm_object_widget_type_get(naviframe))) {
221 parent = elm_object_parent_widget_get(parent);
224 evas_object_del(naviframe);
229 m_pickerLayout->popup = elm_popup_add(win);
230 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select data list");
232 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
233 if (EflAssistHandle) {
234 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
235 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
236 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _data_list_popup_response_cancel_cb, this);
240 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
241 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","data_list_picker");
242 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
243 evas_object_show(m_pickerLayout->layout);
244 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
246 Evas_Object* elmList = elm_list_add(m_pickerLayout->layout);
249 EINA_LIST_FOREACH(optionList, list, listItem) {
251 elm_list_item_append(elmList, static_cast<char*>(listItem), 0, 0, _data_list_selected_cb, this);
253 evas_object_size_hint_weight_set(elmList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
254 evas_object_show(elmList);
255 elm_object_part_content_set(m_pickerLayout->layout, "data_list", elmList);
257 Evas_Object* editFieldLayout = elm_layout_add(m_pickerLayout->layout);
258 elm_layout_theme_set(editFieldLayout, "layout", "editfield", "default");
260 m_pickerLayout->dataListEditField = elm_entry_add(editFieldLayout);
261 elm_object_part_content_set(editFieldLayout, "elm.swallow.content", m_pickerLayout->dataListEditField);
263 elm_object_signal_emit(editFieldLayout, "elm,state,guidetext,hide", "elm");
264 elm_object_signal_callback_add(editFieldLayout, "elm,eraser,clicked", "elm", _eraser_clicked_cb, m_pickerLayout->dataListEditField);
265 evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "changed", _changed_cb, editFieldLayout);
266 evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "focused", _focused_cb, editFieldLayout);
267 evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "unfocused", _unfocused_cb, editFieldLayout);
269 elm_object_part_content_set(m_pickerLayout->layout, "selected_item", editFieldLayout);
270 evas_object_show(editFieldLayout);
272 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
273 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
274 elm_object_text_set(m_pickerLayout->okButton, "OK");
275 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
276 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _data_list_popup_response_cb, this);
277 evas_object_show(m_pickerLayout->popup);
278 evas_object_focus_set(m_pickerLayout->okButton, true);
280 Evas_Object* cancelButton = elm_button_add(m_pickerLayout->popup);
281 elm_object_style_set(cancelButton, "popup_button/default");
282 elm_object_text_set(cancelButton, "Cancel");
283 elm_object_part_content_set(m_pickerLayout->popup, "button2", cancelButton);
284 evas_object_smart_callback_add(cancelButton, "clicked", _data_list_popup_response_cancel_cb, this);
285 evas_object_show(cancelButton);
288 void InputPicker::hideDataList(Ewk_Input_Type inputType)
293 if(m_pickerLayout->popup){
294 evas_object_del(m_pickerLayout->popup);
295 m_pickerLayout->popup = 0;
298 delete m_pickerLayout;
305 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
306 void InputPicker::showColorPicker(int r, int g, int b, int)
308 m_isColorPickerShown = true;
309 ewk_color_popup(r, g, b);
312 void InputPicker::hideColorPicker()
314 m_isColorPickerShown = false;
318 if (m_pickerLayout->popup) {
319 evas_object_del(m_pickerLayout->popup);
320 m_pickerLayout->popup = 0;
323 delete m_pickerLayout;
328 #if ENABLE(ELM_COLORPALLETE)
329 static void _color_palette_changed_cb(void* data, Evas_Object* obj, void* eventInfo)
335 Elm_Object_Item *color_it = static_cast<Elm_Object_Item*>(eventInfo);
336 elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
337 evas_object_color_set(static_cast<Evas_Object*>(data), r, g, b , a);
341 void InputPicker::_color_selected_cb(void* data, Evas* evas, Evas_Object* obj, void* eventInfo)
347 evas_object_color_get(obj, &r, &g, &b, &a);
349 evas_object_color_set(static_cast<Evas_Object*>(data), r, g, b, a);
352 void InputPicker::ewk_color_popup(int r, int g, int b)
354 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
355 Evas_Object* win = parent;
360 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
363 const char* type = elm_object_widget_type_get(parent);
365 if (!strcmp(type, "elm_win")) {
370 parent = elm_object_parent_widget_get(parent);
376 m_pickerLayout->popup = elm_popup_add(win);
377 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select color");
379 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
380 m_pickerLayout->initial_r = r;
381 m_pickerLayout->initial_g = g;
382 m_pickerLayout->initial_b = b;
383 if (EflAssistHandle) {
384 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
385 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
386 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _color_back_cb, this);
390 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
391 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","color_picker");
392 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
393 evas_object_show(m_pickerLayout->layout);
394 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
396 m_pickerLayout->colorRect = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
397 evas_object_size_hint_weight_set(m_pickerLayout->colorRect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
398 evas_object_show(m_pickerLayout->colorRect);
400 evas_object_color_set(m_pickerLayout->colorRect, r, g, b, 255);
401 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color_rect", m_pickerLayout->colorRect);
402 #if ENABLE(ELM_COLORPALLETE)
403 Evas_Object* colorPalette = elm_colorselector_add(m_pickerLayout->popup);
404 elm_colorselector_mode_set(colorPalette, ELM_COLORSELECTOR_PALETTE);
406 elm_colorselector_palette_color_add(colorPalette, 128, 0, 0, 255);
407 elm_colorselector_palette_color_add(colorPalette, 255, 0, 128, 255);
408 elm_colorselector_palette_color_add(colorPalette, 255, 0, 0, 255);
409 elm_colorselector_palette_color_add(colorPalette, 255, 127, 39, 255);
410 elm_colorselector_palette_color_add(colorPalette, 255, 255, 0, 255);
411 elm_colorselector_palette_color_add(colorPalette, 0, 255, 0, 255);
412 elm_colorselector_palette_color_add(colorPalette, 0, 255, 255, 255);
413 elm_colorselector_palette_color_add(colorPalette, 0, 0, 255, 255);
414 elm_colorselector_palette_color_add(colorPalette, 0, 0, 128, 255);
415 elm_colorselector_palette_color_add(colorPalette, 64, 0, 64, 255);
416 elm_colorselector_palette_color_add(colorPalette, 0, 0, 0, 255);
417 elm_colorselector_palette_color_add(colorPalette, 255, 255, 255, 255);
419 evas_object_size_hint_fill_set(colorPalette, EVAS_HINT_FILL, 0);
420 evas_object_size_hint_weight_set(colorPalette, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
421 evas_object_smart_callback_add(colorPalette, "color,item,selected", _color_palette_changed_cb, m_pickerLayout->colorRect);
422 evas_object_show(colorPalette);
424 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color_palette", colorPalette);
426 Evas_Object* color1 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
427 evas_object_size_hint_weight_set(color1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
428 evas_object_color_set(color1, 128, 0, 0, 255);
429 evas_object_event_callback_add(color1, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
430 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color1", color1);
431 evas_object_show(color1);
433 Evas_Object* color2 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
434 evas_object_size_hint_weight_set(color2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
435 evas_object_color_set(color2, 255, 0, 128, 255);
436 evas_object_event_callback_add(color2, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
437 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color2", color2);
438 evas_object_show(color2);
440 Evas_Object* color3 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
441 evas_object_size_hint_weight_set(color3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
442 evas_object_color_set(color3, 255, 0, 0, 255);
443 evas_object_event_callback_add(color3, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
444 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color3", color3);
445 evas_object_show(color3);
447 Evas_Object* color4 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
448 evas_object_size_hint_weight_set(color4, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
449 evas_object_color_set(color4, 255, 127, 39, 255);
450 evas_object_event_callback_add(color4, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
451 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color4", color4);
452 evas_object_show(color4);
454 Evas_Object* color5 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
455 evas_object_size_hint_weight_set(color5, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
456 evas_object_color_set(color5, 255, 255, 0, 255);
457 evas_object_event_callback_add(color5, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
458 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color5", color5);
459 evas_object_show(color5);
461 Evas_Object* color6 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
462 evas_object_size_hint_weight_set(color6, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
463 evas_object_color_set(color6, 0, 255, 0, 255);
464 evas_object_event_callback_add(color6, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
465 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color6", color6);
466 evas_object_show(color6);
468 Evas_Object* color7 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
469 evas_object_size_hint_weight_set(color7, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
470 evas_object_color_set(color7, 0, 255, 255, 255);
471 evas_object_event_callback_add(color7, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
472 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color7", color7);
473 evas_object_show(color7);
475 Evas_Object* color8 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
476 evas_object_size_hint_weight_set(color8, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
477 evas_object_color_set(color8, 0, 0, 255, 255);
478 evas_object_event_callback_add(color8, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
479 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color8", color8);
480 evas_object_show(color8);
482 Evas_Object* color9 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
483 evas_object_size_hint_weight_set(color9, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
484 evas_object_color_set(color9, 0, 0, 128, 255);
485 evas_object_event_callback_add(color9, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
486 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color9", color9);
487 evas_object_show(color9);
489 Evas_Object* color10 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
490 evas_object_size_hint_weight_set(color10, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
491 evas_object_color_set(color10, 64, 0, 64, 255);
492 evas_object_event_callback_add(color10, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
493 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color10", color10);
494 evas_object_show(color10);
496 Evas_Object* color11 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
497 evas_object_size_hint_weight_set(color11, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
498 evas_object_color_set(color11, 153, 217, 234, 255);
499 evas_object_event_callback_add(color11, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
500 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color11", color11);
501 evas_object_show(color11);
503 Evas_Object* color12 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
504 evas_object_size_hint_weight_set(color12, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
505 evas_object_color_set(color12, 128, 128, 128, 255);
506 evas_object_event_callback_add(color12, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
507 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color12", color12);
508 evas_object_show(color12);
510 Evas_Object* color13 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
511 evas_object_size_hint_weight_set(color13, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
512 evas_object_color_set(color13, 0, 0, 0, 255);
513 evas_object_event_callback_add(color13, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
514 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color13", color13);
515 evas_object_show(color13);
517 Evas_Object* color14 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
518 evas_object_size_hint_weight_set(color14, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
519 evas_object_color_set(color14, 255, 255, 255, 255);
520 evas_object_event_callback_add(color14, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
521 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color14", color14);
522 evas_object_show(color14);
524 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
525 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
526 elm_object_text_set(m_pickerLayout->okButton, "OK");
527 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
528 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _color_popup_response_cb, this);
529 evas_object_focus_set(m_pickerLayout->okButton, true);
531 evas_object_show(m_pickerLayout->popup);
534 void InputPicker::_color_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
536 InputPicker* inputPicker = static_cast<InputPicker*>(data);
542 evas_object_color_get(inputPicker->m_pickerLayout->colorRect, &r, &g, &b, &a);
544 ewk_view_color_picker_color_set(inputPicker->m_ewkView, r, g, b, a);
546 inputPicker->hideColorPicker();
549 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
550 void InputPicker::_color_back_cb(void* data, Evas_Object* obj, void* event_info)
552 InputPicker* inputPicker = static_cast<InputPicker*>(data);
554 int r = inputPicker->m_pickerLayout->initial_r;
555 int g = inputPicker->m_pickerLayout->initial_g;
556 int b = inputPicker->m_pickerLayout->initial_b;
558 ewk_view_color_picker_color_set(inputPicker->m_ewkView, r, g, b, a);
560 inputPicker->hideColorPicker();
564 void InputPicker::ewk_date_popup(const char* inputValue)
566 struct tm* currentTime;
569 currentTime = localtime(&cur_time);
571 Input_Date_Str dateStr;
572 memset(&dateStr, 0, sizeof(Input_Date_Str));
574 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
575 Evas_Object* win = parent;
577 if (inputValue && strlen(inputValue)) {
578 char tmpinputValue[30] = {0,};
580 sprintf(tmpinputValue, "%s", inputValue);
581 strcpy(dateStr.year, strtok(tmpinputValue,"-"));
582 strcpy(dateStr.mon, strtok(0, "-"));
583 strcpy(dateStr.day, strtok(0, "-"));
585 currentTime->tm_year = atoi(dateStr.year);
586 currentTime->tm_mon = atoi(dateStr.mon);
587 currentTime->tm_mday = atoi(dateStr.day);
589 currentTime->tm_year = currentTime->tm_year - 1900;
590 currentTime->tm_mon = currentTime->tm_mon - 1;
593 if (m_pickerLayout) {
594 // Just update the value.
595 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
596 evas_object_focus_set(m_pickerLayout->okButton, true);
600 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
603 const char* type = elm_object_widget_type_get(parent);
605 if (!strcmp(type, "elm_win")) {
610 parent = elm_object_parent_widget_get(parent);
616 m_pickerLayout->popup = elm_popup_add(win);
617 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select date");
619 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
620 if (EflAssistHandle) {
621 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
622 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
623 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
627 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
628 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
629 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
631 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Date (Default format) :");
633 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
634 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
636 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_HOUR, EINA_FALSE);
637 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_MINUTE, EINA_FALSE);
638 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_AMPM, EINA_FALSE);
639 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
641 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
642 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
643 elm_object_text_set(m_pickerLayout->okButton, "OK");
644 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
645 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _date_popup_response_cb, this);
646 evas_object_focus_set(m_pickerLayout->okButton, true);
648 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
649 evas_object_show(m_pickerLayout->popup);
652 #define isLeapYear(year) ((!(year % 4) && (year % 100)) || (!(year % 400) && (year % 1000)))
653 static int _calculateMonthAndDay(int year, int totalDays, int* remains)
656 if (totalDays - 31 < 0) {
657 *remains = totalDays;
661 totalDays = totalDays - 31;
664 if (isLeapYear(year)) {
665 if (totalDays - 29 < 0) {
666 *remains = totalDays;
669 totalDays = totalDays - 29;
671 if (totalDays - 28 < 0) {
672 *remains = totalDays;
675 totalDays = totalDays - 28;
679 if (totalDays - 31 < 0) {
680 *remains = totalDays;
683 totalDays = totalDays - 31;
686 if (totalDays - 30 < 0) {
687 *remains = totalDays;
690 totalDays = totalDays - 30;
693 if (totalDays - 31 < 0) {
694 *remains = totalDays;
697 totalDays = totalDays - 31;
700 if (totalDays - 30 < 0) {
701 *remains = totalDays;
704 totalDays = totalDays - 30;
707 if (totalDays - 31 < 0) {
708 *remains = totalDays;
711 totalDays = totalDays - 31;
714 if (totalDays - 31 < 0) {
715 *remains = totalDays;
718 totalDays = totalDays - 31;
721 if (totalDays - 30 < 0) {
722 *remains = totalDays;
725 totalDays = totalDays - 30;
728 if (totalDays - 31 < 0) {
729 *remains = totalDays;
732 totalDays = totalDays - 31;
735 if (totalDays - 30 < 0) {
736 *remains = totalDays;
739 totalDays = totalDays - 30;
741 *remains = totalDays;
745 void InputPicker::ewk_week_popup(const char* inputValue)
747 struct tm* currentTime;
750 currentTime = localtime(&cur_time);
752 Input_Date_Str dateStr;
753 memset(&dateStr, 0, sizeof(Input_Date_Str));
755 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
756 Evas_Object* win = parent;
758 if (inputValue && strlen(inputValue)) {
759 char tmpinputValue[30] = {0,};
761 sprintf(tmpinputValue, "%s", inputValue);
762 strcpy(dateStr.year, strtok(tmpinputValue,"-"));
763 const char* week = strstr(inputValue, "W");
766 weekNum = atoi(week + 1);
768 currentTime->tm_year = atoi(dateStr.year);
769 currentTime->tm_year = currentTime->tm_year - 1900;
771 struct tm firtTimeOfyear;
772 memset(&firtTimeOfyear, 0, sizeof(struct tm));
773 firtTimeOfyear.tm_year = currentTime->tm_year;
774 firtTimeOfyear.tm_mon = 0;
775 firtTimeOfyear.tm_mday = 1;
776 mktime(&firtTimeOfyear);
778 char firstWeek[10] = {0, };
779 strftime(firstWeek, 10, "%w", &firtTimeOfyear);
780 int firstWeekCount = atoi(firstWeek);
784 totalDays = weekNum * 7 - firstWeekCount;
787 int month = _calculateMonthAndDay(currentTime->tm_year, totalDays, &days);
789 currentTime->tm_mon = month;
790 currentTime->tm_mday = days;
793 if (m_pickerLayout) {
794 // Just update the value.
795 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
796 evas_object_focus_set(m_pickerLayout->okButton, true);
800 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
803 const char* type = elm_object_widget_type_get(parent);
805 if (!strcmp(type, "elm_win")) {
810 parent = elm_object_parent_widget_get(parent);
816 m_pickerLayout->popup = elm_popup_add(win);
817 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select date");
819 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
820 if (EflAssistHandle) {
821 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
822 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
823 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
827 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
828 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
829 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
831 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Date (Default format) :");
833 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
834 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
836 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_HOUR, EINA_FALSE);
837 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_MINUTE, EINA_FALSE);
838 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_AMPM, EINA_FALSE);
839 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
841 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
842 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
843 elm_object_text_set(m_pickerLayout->okButton, "OK");
844 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
845 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _week_popup_response_cb, this);
846 evas_object_focus_set(m_pickerLayout->okButton, true);
848 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
849 evas_object_show(m_pickerLayout->popup);
852 void InputPicker::ewk_time_popup(const char* inputValue)
854 struct tm* currentTime;
857 currentTime = localtime(&cur_time);
859 Input_Date_Str dateStr;
860 memset(&dateStr, 0, sizeof(Input_Date_Str));
862 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
863 Evas_Object* win = parent;
865 if (inputValue && strlen(inputValue)) {
866 char tmpinputValue[30] = {0,};
868 sprintf(tmpinputValue, "%s", inputValue);
869 strcpy(dateStr.hour, strtok(tmpinputValue,":"));
870 strcpy(dateStr.min, strtok(0, ":"));
872 currentTime->tm_hour = atoi(dateStr.hour);
873 currentTime->tm_min = atoi(dateStr.min);
876 if (m_pickerLayout) {
877 // Just update the value.
878 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
879 evas_object_focus_set(m_pickerLayout->okButton, true);
883 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
886 const char* type = elm_object_widget_type_get(parent);
888 if (!strcmp(type, "elm_win")) {
893 parent = elm_object_parent_widget_get(parent);
899 m_pickerLayout->popup = elm_popup_add(win);
900 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select time");
902 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
903 if (EflAssistHandle) {
904 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
905 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
906 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
910 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
911 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
912 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
914 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Time (Default format) :");
916 m_pickerLayout->timePicker = elm_datetime_add(m_pickerLayout->layout);
917 elm_datetime_format_set(m_pickerLayout->timePicker, "%H:%M");
918 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
920 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->timePicker);
922 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
923 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
924 elm_object_text_set(m_pickerLayout->okButton, "OK");
925 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
926 evas_object_focus_set(m_pickerLayout->okButton, true);
928 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _time_popup_response_cb, this);
929 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
930 evas_object_show(m_pickerLayout->popup);
933 void InputPicker::ewk_month_popup(const char* inputValue)
935 struct tm* currentTime;
938 currentTime = localtime(&cur_time);
940 Input_Date_Str dateStr;
941 memset(&dateStr, 0, sizeof(Input_Date_Str));
943 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
944 Evas_Object* win = parent;
946 if (inputValue && strlen(inputValue)) {
947 char tmpInputValue[30] = {0,};
949 sprintf(tmpInputValue, "%s", inputValue);
950 strcpy(dateStr.year, strtok(tmpInputValue,"-"));
951 strcpy(dateStr.mon, strtok(0, "-"));
953 currentTime->tm_year = atoi(dateStr.year);
954 currentTime->tm_mon = atoi(dateStr.mon);
956 currentTime->tm_year = currentTime->tm_year - 1900;
957 currentTime->tm_mon = currentTime->tm_mon - 1;
960 if (m_pickerLayout) {
961 // Just update the value.
962 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
963 evas_object_focus_set(m_pickerLayout->okButton, true);
967 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
970 const char* type = elm_object_widget_type_get(parent);
972 if (!strcmp(type, "elm_win")) {
977 parent = elm_object_parent_widget_get(parent);
983 m_pickerLayout->popup = elm_popup_add(win);
984 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select month");
986 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
987 if (EflAssistHandle) {
988 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
989 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
990 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
994 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
995 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
997 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
998 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
1000 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
1002 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Month (Default format) :");
1004 elm_datetime_format_set(m_pickerLayout->datePicker, "%Y %m");
1005 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
1007 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
1008 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
1009 elm_object_text_set(m_pickerLayout->okButton, "OK");
1010 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
1011 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _month_popup_response_cb, this);
1012 evas_object_focus_set(m_pickerLayout->okButton, true);
1014 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
1015 evas_object_show(m_pickerLayout->popup);
1018 void InputPicker::ewk_datetime_popup(const char* inputValue, bool local)
1020 struct tm* currentTime;
1023 currentTime = localtime(&cur_time);
1025 Input_Date_Str dateStr;
1026 memset(&dateStr, 0, sizeof(Input_Date_Str));
1028 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
1029 Evas_Object* win = parent;
1031 if (inputValue && strlen(inputValue)) {
1032 char tmpInputValue[30] = {0, };
1034 sprintf(tmpInputValue, "%s", inputValue);
1035 strcpy(dateStr.year, strtok(tmpInputValue,"-"));
1036 strcpy(dateStr.mon, strtok(0, "-"));
1037 strcpy(dateStr.day, strtok(0, "T"));
1038 strcpy(dateStr.hour, strtok(0, ":"));
1041 strcpy(dateStr.min, strtok(0, "Z"));
1043 strcpy(dateStr.min, strtok(0, ":"));
1045 currentTime->tm_year = atoi(dateStr.year);
1046 currentTime->tm_mon = atoi(dateStr.mon);
1047 currentTime->tm_mday = atoi(dateStr.day);
1048 currentTime->tm_hour = atoi(dateStr.hour);
1049 currentTime->tm_min = atoi(dateStr.min);
1051 currentTime->tm_year = currentTime->tm_year - 1900;
1052 currentTime->tm_mon = currentTime->tm_mon - 1;
1055 if (m_pickerLayout) {
1056 // Just update the value.
1057 m_pickerLayout->datetimeLocal = local;
1059 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
1060 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
1061 evas_object_focus_set(m_pickerLayout->okButton, true);
1065 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
1067 m_pickerLayout->datetimeLocal = local;
1070 const char* type = elm_object_widget_type_get(parent);
1072 if (!strcmp(type, "elm_win")) {
1077 parent = elm_object_parent_widget_get(parent);
1083 m_pickerLayout->popup = elm_popup_add(win);
1084 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select datetime");
1086 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1087 if (EflAssistHandle) {
1088 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
1089 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
1090 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
1094 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
1095 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","datepicker_popup");
1096 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1098 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
1099 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
1101 elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_HOUR, EINA_FALSE);
1102 elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_MINUTE, EINA_FALSE);
1103 elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_AMPM, EINA_FALSE);
1104 elm_object_part_content_set(m_pickerLayout->layout , "elm.swallow.content.date", m_pickerLayout->datePicker);
1106 m_pickerLayout->timePicker = elm_datetime_add(m_pickerLayout->layout);
1107 elm_datetime_format_set(m_pickerLayout->timePicker, "%H:%M");
1108 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
1109 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.time", m_pickerLayout->timePicker);
1111 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
1112 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
1113 elm_object_text_set(m_pickerLayout->okButton, "OK");
1114 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
1115 evas_object_focus_set(m_pickerLayout->okButton, true);
1117 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _datetime_popup_response_cb, this);
1118 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
1119 evas_object_show(m_pickerLayout->popup);
1123 void InputPicker::_date_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1125 struct tm currentTime;
1126 memset(¤tTime, 0, sizeof(struct tm));
1128 char dateStr[20] = {0, };
1130 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1132 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1134 date.day = currentTime.tm_mday;
1135 date.mon = currentTime.tm_mon;
1136 date.year = currentTime.tm_year;
1138 if(inputPicker->m_pickerLayout->popup){
1139 evas_object_del(inputPicker->m_pickerLayout->popup);
1140 inputPicker->m_pickerLayout->popup = 0;
1143 date.year = 1900 + date.year;
1144 sprintf(dateStr, "%d-%02d-%02d" , date.year, date.mon + 1, date.day);
1146 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1147 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1149 delete inputPicker->m_pickerLayout;
1150 inputPicker->m_pickerLayout = 0;
1153 void InputPicker::_week_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1155 struct tm currentTime;
1156 memset(¤tTime, 0, sizeof(struct tm));
1158 char dateStr[20] = {0, };
1160 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1162 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1164 date.day = currentTime.tm_mday;
1165 date.mon = currentTime.tm_mon;
1166 date.year = currentTime.tm_year;
1167 mktime(¤tTime);
1169 if(inputPicker->m_pickerLayout->popup){
1170 evas_object_del(inputPicker->m_pickerLayout->popup);
1171 inputPicker->m_pickerLayout->popup = 0;
1174 struct tm firtTimeOfyear;
1175 memset(&firtTimeOfyear, 0, sizeof(struct tm));
1176 firtTimeOfyear.tm_year = date.year;
1177 firtTimeOfyear.tm_mon = 0;
1178 firtTimeOfyear.tm_mday = 1;
1179 mktime(&firtTimeOfyear);
1181 char firstWeek[10] = {0, };
1182 strftime(firstWeek, 10, "%w", &firtTimeOfyear);
1183 int firstWeekCount = atoi(firstWeek);
1185 char totalDay[10] = {0, };
1186 strftime(totalDay, 10, "%j", ¤tTime);
1187 int totalDayCount = atoi(totalDay);
1189 int weekNum = (totalDayCount + firstWeekCount) / 7;
1190 if (totalDayCount + firstWeekCount > weekNum * 7)
1193 date.year = 1900 + date.year;
1194 sprintf(dateStr, "%d-W%02d" , date.year, weekNum);
1196 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1197 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1199 delete inputPicker->m_pickerLayout;
1200 inputPicker->m_pickerLayout = 0;
1203 void InputPicker::_time_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1205 struct tm currentTime;
1206 memset(¤tTime, 0, sizeof(struct tm));
1208 char dateStr[20] = {0, };
1210 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1212 elm_datetime_value_get(inputPicker->m_pickerLayout->timePicker, ¤tTime);
1214 date.hour = currentTime.tm_hour;
1215 date.min = currentTime.tm_min;
1217 if(inputPicker->m_pickerLayout->popup){
1218 evas_object_del(inputPicker->m_pickerLayout->popup);
1219 inputPicker->m_pickerLayout->popup = 0;
1222 sprintf(dateStr, "%02d:%02d" , date.hour, date.min);
1223 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1224 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1226 delete inputPicker->m_pickerLayout;
1227 inputPicker->m_pickerLayout = 0;
1230 void InputPicker::_month_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1232 struct tm currentTime;
1233 memset(¤tTime, 0, sizeof(struct tm));
1235 char dateStr[20] = {0, };
1237 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1239 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1241 date.mon = currentTime.tm_mon;
1242 date.year = currentTime.tm_year;
1244 if(inputPicker->m_pickerLayout->popup){
1245 evas_object_del(inputPicker->m_pickerLayout->popup);
1246 inputPicker->m_pickerLayout->popup = 0;
1249 date.year = 1900 + date.year;
1250 sprintf(dateStr, "%02d-%02d" , date.year, date.mon + 1);
1252 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1253 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1255 delete inputPicker->m_pickerLayout;
1256 inputPicker->m_pickerLayout = 0;
1259 void InputPicker::_datetime_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1261 struct tm currentTime;
1262 memset(¤tTime, 0, sizeof(struct tm));
1264 char dateStr[50] = {0, };
1266 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1268 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1269 date.year = currentTime.tm_year;
1270 date.day = currentTime.tm_mday;
1271 date.mon = currentTime.tm_mon;
1273 elm_datetime_value_get(inputPicker->m_pickerLayout->timePicker, ¤tTime);
1274 date.hour = currentTime.tm_hour;
1275 date.min = currentTime.tm_min;
1277 if (inputPicker->m_pickerLayout->popup) {
1278 evas_object_del(inputPicker->m_pickerLayout->popup);
1279 inputPicker->m_pickerLayout->popup = 0;
1282 date.year = 1900 + date.year;
1284 if (inputPicker->m_pickerLayout->datetimeLocal)
1285 sprintf(dateStr, "%d-%02d-%02dT%02d:%02d" , date.year, date.mon + 1, date.day, date.hour, date.min);
1287 sprintf(dateStr, "%d-%02d-%02dT%02d:%02dZ" , date.year, date.mon + 1, date.day, date.hour, date.min);
1289 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1290 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1292 delete inputPicker->m_pickerLayout;
1293 inputPicker->m_pickerLayout = 0;
1296 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1297 void InputPicker::_popup_back_cb(void* data, Evas_Object* obj, void* event_info)
1299 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1301 if (!inputPicker->m_pickerLayout)
1304 if (inputPicker->m_pickerLayout->popup) {
1305 evas_object_del(inputPicker->m_pickerLayout->popup);
1306 inputPicker->m_pickerLayout->popup = 0;
1309 delete inputPicker->m_pickerLayout;
1310 inputPicker->m_pickerLayout = 0;
1314 } // namespace WebKit
1316 #endif // OS(TIZEN) && ENABLE(TIZEN_INPUT_TAG_EXTENSION)