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 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
40 static inline void _picker_back_cb(void* data, Evas_Object* obj, void* event_info)
42 elm_object_signal_emit(obj, "picker,hide", "");
45 static void _edit_start_cb(void* data, Evas_Object* obj, void* event_info)
50 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
51 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
52 (*webkit_ea_object_event_callback_add)(obj, EA_CALLBACK_BACK, _picker_back_cb, 0);
55 static void _edit_end_cb(void* data, Evas_Object* obj, void* event_info)
60 void (*webkit_ea_object_event_callback_del)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func);
61 webkit_ea_object_event_callback_del = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func))dlsym(EflAssistHandle, "ea_object_event_callback_del");
62 (*webkit_ea_object_event_callback_del)(obj, EA_CALLBACK_BACK, _picker_back_cb);
64 #endif // ENABLE(TIZEN_HW_MORE_BACK_KEY)
66 Input_Picker_Layout::Input_Picker_Layout(Evas_Object* ewkView)
74 , dataListEditField(0)
75 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
80 , datetimeLocal(false)
82 evas_object_focus_set(m_ewkView, false);
84 /* FIXME : Workaround. OSP requirement.
85 OSP want to block own touch event while webkit internal picker is running. */
86 evas_object_smart_callback_call(m_ewkView, "input,picker,show", 0);
89 Input_Picker_Layout::~Input_Picker_Layout()
91 /* FIXME : Workaround. OSP requirement.
92 OSP want to block own touch event while webkit internal picker is running. */
93 evas_object_smart_callback_call(m_ewkView, "input,picker,hide", 0);
98 InputPicker::InputPicker(Evas_Object* ewkView)
102 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
103 , m_isColorPickerShown(false)
108 InputPicker::~InputPicker()
110 if (m_pickerLayout) {
111 if (m_pickerLayout->popup)
112 evas_object_del(m_pickerLayout->popup);
113 delete m_pickerLayout;
117 void InputPicker::show(Ewk_Input_Type inputType, const char* inputValue)
119 if(inputType == EWK_INPUT_TYPE_DATE)
120 ewk_date_popup(inputValue);
121 else if(inputType == EWK_INPUT_TYPE_TIME)
122 ewk_time_popup(inputValue);
123 else if(inputType == EWK_INPUT_TYPE_DATETIME)
124 ewk_datetime_popup(inputValue, false);
125 else if(inputType == EWK_INPUT_TYPE_DATETIMELOCAL)
126 ewk_datetime_popup(inputValue, true);
127 else if(inputType == EWK_INPUT_TYPE_MONTH)
128 ewk_month_popup(inputValue);
129 else if(inputType == EWK_INPUT_TYPE_WEEK)
130 ewk_week_popup(inputValue);
133 #if ENABLE(TIZEN_DATALIST_ELEMENT)
134 void InputPicker::_data_list_popup_response_cb(void* data, Evas_Object* obj, void* eventInfo)
136 InputPicker* inputPicker = static_cast<InputPicker*>(data);
137 const char* selectedItem = elm_entry_entry_get(inputPicker->m_pickerLayout->dataListEditField);
138 ewk_view_data_list_close(inputPicker->m_ewkView, selectedItem);
140 if (inputPicker->m_pickerLayout->popup) {
141 evas_object_del(inputPicker->m_pickerLayout->popup);
142 inputPicker->m_pickerLayout->popup = 0;
145 delete inputPicker->m_pickerLayout;
146 inputPicker->m_pickerLayout = 0;
148 inputPicker->m_dataList = 0;
151 void InputPicker::_data_list_popup_response_cancel_cb(void* data, Evas_Object* obj, void* eventInfo)
153 InputPicker* inputPicker = static_cast<InputPicker*>(data);
155 if (inputPicker->m_pickerLayout->popup) {
156 evas_object_del(inputPicker->m_pickerLayout->popup);
157 inputPicker->m_pickerLayout->popup = 0;
160 delete inputPicker->m_pickerLayout;
161 inputPicker->m_pickerLayout = 0;
163 inputPicker->m_dataList = 0;
166 void InputPicker::_data_list_selected_cb(void* data, Evas_Object* obj, void* eventInfo)
168 InputPicker* inputPicker = static_cast<InputPicker*>(data);
169 Elm_Object_Item* selectedItem = static_cast<Elm_Object_Item*>(eventInfo);
170 Elm_Object_Item* item = elm_list_first_item_get(obj);
174 if (item == selectedItem)
177 item = elm_list_item_next(item);
183 EINA_LIST_FOREACH(inputPicker->m_dataList, list, listItem) {
184 if (listItem && index == listIndex)
185 elm_entry_entry_set(inputPicker->m_pickerLayout->dataListEditField, static_cast<char*>(listItem));
191 static void _eraser_clicked_cb(void* data, Evas_Object* obj, const char* emission, const char* source)
193 Evas_Object* entry = static_cast<Evas_Object*>(data);
194 elm_entry_entry_set(entry, "");
197 static void _changed_cb(void* data, Evas_Object* obj, void* eventInfo)
199 Evas_Object* layout = static_cast<Evas_Object*>(data);
201 if (elm_object_focus_get(layout)) {
202 if (elm_entry_is_empty(obj))
203 elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
205 elm_object_signal_emit(layout, "elm,state,eraser,show", "elm");
209 static void _focused_cb(void* data, Evas_Object* obj, void* eventInfo)
211 Evas_Object* layout = static_cast<Evas_Object*>(data);
213 if (!elm_entry_is_empty(obj))
214 elm_object_signal_emit(layout, "elm,state,eraser,show", "elm");
217 static void _unfocused_cb(void* data, Evas_Object* obj, void* eventInfo)
219 Evas_Object* layout = static_cast<Evas_Object*>(data);
220 elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
223 void InputPicker::showDataList(Ewk_Input_Type inputType, Eina_List* optionList)
225 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
226 Evas_Object* win = parent;
228 m_dataList = optionList;
233 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
235 /* FIXME: If the entry is in the popup, the parent should be naviframe for uifw limitation. */
236 Evas_Object* naviframe = elm_naviframe_add(m_ewkView);
238 const char* type = elm_object_widget_type_get(parent);
240 if (!strcmp(type, elm_object_widget_type_get(naviframe))) {
245 parent = elm_object_parent_widget_get(parent);
248 evas_object_del(naviframe);
253 m_pickerLayout->popup = elm_popup_add(win);
254 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select data list");
256 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
257 if (EflAssistHandle) {
258 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
259 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
260 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _data_list_popup_response_cancel_cb, this);
264 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
265 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","data_list_picker");
266 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
267 evas_object_show(m_pickerLayout->layout);
268 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
270 Evas_Object* elmList = elm_list_add(m_pickerLayout->layout);
273 EINA_LIST_FOREACH(optionList, list, listItem) {
275 elm_list_item_append(elmList, static_cast<char*>(listItem), 0, 0, _data_list_selected_cb, this);
277 evas_object_size_hint_weight_set(elmList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
278 evas_object_show(elmList);
279 elm_object_part_content_set(m_pickerLayout->layout, "data_list", elmList);
281 Evas_Object* editFieldLayout = elm_layout_add(m_pickerLayout->layout);
282 elm_layout_theme_set(editFieldLayout, "layout", "editfield", "default");
284 m_pickerLayout->dataListEditField = elm_entry_add(editFieldLayout);
285 elm_object_part_content_set(editFieldLayout, "elm.swallow.content", m_pickerLayout->dataListEditField);
287 elm_object_signal_emit(editFieldLayout, "elm,state,guidetext,hide", "elm");
288 elm_object_signal_callback_add(editFieldLayout, "elm,eraser,clicked", "elm", _eraser_clicked_cb, m_pickerLayout->dataListEditField);
289 evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "changed", _changed_cb, editFieldLayout);
290 evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "focused", _focused_cb, editFieldLayout);
291 evas_object_smart_callback_add(m_pickerLayout->dataListEditField, "unfocused", _unfocused_cb, editFieldLayout);
293 elm_object_part_content_set(m_pickerLayout->layout, "selected_item", editFieldLayout);
294 evas_object_show(editFieldLayout);
296 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
297 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
298 elm_object_text_set(m_pickerLayout->okButton, "OK");
299 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
300 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _data_list_popup_response_cb, this);
301 evas_object_show(m_pickerLayout->popup);
302 evas_object_focus_set(m_pickerLayout->okButton, true);
304 Evas_Object* cancelButton = elm_button_add(m_pickerLayout->popup);
305 elm_object_style_set(cancelButton, "popup_button/default");
306 elm_object_text_set(cancelButton, "Cancel");
307 elm_object_part_content_set(m_pickerLayout->popup, "button2", cancelButton);
308 evas_object_smart_callback_add(cancelButton, "clicked", _data_list_popup_response_cancel_cb, this);
309 evas_object_show(cancelButton);
312 void InputPicker::hideDataList(Ewk_Input_Type inputType)
317 if(m_pickerLayout->popup){
318 evas_object_del(m_pickerLayout->popup);
319 m_pickerLayout->popup = 0;
322 delete m_pickerLayout;
329 #if ENABLE(TIZEN_INPUT_COLOR_PICKER)
330 void InputPicker::showColorPicker(int r, int g, int b, int)
332 m_isColorPickerShown = true;
333 ewk_color_popup(r, g, b);
336 void InputPicker::hideColorPicker()
338 m_isColorPickerShown = false;
342 if (m_pickerLayout->popup) {
343 evas_object_del(m_pickerLayout->popup);
344 m_pickerLayout->popup = 0;
347 delete m_pickerLayout;
352 #if ENABLE(ELM_COLORPALLETE)
353 static void _color_palette_changed_cb(void* data, Evas_Object* obj, void* eventInfo)
359 Elm_Object_Item *color_it = static_cast<Elm_Object_Item*>(eventInfo);
360 elm_colorselector_palette_item_color_get(color_it, &r, &g, &b, &a);
361 evas_object_color_set(static_cast<Evas_Object*>(data), r, g, b , a);
365 void InputPicker::_color_selected_cb(void* data, Evas* evas, Evas_Object* obj, void* eventInfo)
371 evas_object_color_get(obj, &r, &g, &b, &a);
373 evas_object_color_set(static_cast<Evas_Object*>(data), r, g, b, a);
376 void InputPicker::ewk_color_popup(int r, int g, int b)
378 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
379 Evas_Object* win = parent;
384 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
387 const char* type = elm_object_widget_type_get(parent);
389 if (!strcmp(type, "elm_win")) {
394 parent = elm_object_parent_widget_get(parent);
400 m_pickerLayout->popup = elm_popup_add(win);
401 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select color");
403 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
404 m_pickerLayout->initial_r = r;
405 m_pickerLayout->initial_g = g;
406 m_pickerLayout->initial_b = b;
407 if (EflAssistHandle) {
408 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
409 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
410 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _color_back_cb, this);
414 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
415 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","color_picker");
416 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
417 evas_object_show(m_pickerLayout->layout);
418 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
420 m_pickerLayout->colorRect = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
421 evas_object_size_hint_weight_set(m_pickerLayout->colorRect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
422 evas_object_show(m_pickerLayout->colorRect);
424 evas_object_color_set(m_pickerLayout->colorRect, r, g, b, 255);
425 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color_rect", m_pickerLayout->colorRect);
426 #if ENABLE(ELM_COLORPALLETE)
427 Evas_Object* colorPalette = elm_colorselector_add(m_pickerLayout->popup);
428 elm_colorselector_mode_set(colorPalette, ELM_COLORSELECTOR_PALETTE);
430 elm_colorselector_palette_color_add(colorPalette, 128, 0, 0, 255);
431 elm_colorselector_palette_color_add(colorPalette, 255, 0, 128, 255);
432 elm_colorselector_palette_color_add(colorPalette, 255, 0, 0, 255);
433 elm_colorselector_palette_color_add(colorPalette, 255, 127, 39, 255);
434 elm_colorselector_palette_color_add(colorPalette, 255, 255, 0, 255);
435 elm_colorselector_palette_color_add(colorPalette, 0, 255, 0, 255);
436 elm_colorselector_palette_color_add(colorPalette, 0, 255, 255, 255);
437 elm_colorselector_palette_color_add(colorPalette, 0, 0, 255, 255);
438 elm_colorselector_palette_color_add(colorPalette, 0, 0, 128, 255);
439 elm_colorselector_palette_color_add(colorPalette, 64, 0, 64, 255);
440 elm_colorselector_palette_color_add(colorPalette, 0, 0, 0, 255);
441 elm_colorselector_palette_color_add(colorPalette, 255, 255, 255, 255);
443 evas_object_size_hint_fill_set(colorPalette, EVAS_HINT_FILL, 0);
444 evas_object_size_hint_weight_set(colorPalette, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
445 evas_object_smart_callback_add(colorPalette, "color,item,selected", _color_palette_changed_cb, m_pickerLayout->colorRect);
446 evas_object_show(colorPalette);
448 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color_palette", colorPalette);
450 Evas_Object* color1 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
451 evas_object_size_hint_weight_set(color1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
452 evas_object_color_set(color1, 128, 0, 0, 255);
453 evas_object_event_callback_add(color1, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
454 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color1", color1);
455 evas_object_show(color1);
457 Evas_Object* color2 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
458 evas_object_size_hint_weight_set(color2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
459 evas_object_color_set(color2, 255, 0, 128, 255);
460 evas_object_event_callback_add(color2, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
461 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color2", color2);
462 evas_object_show(color2);
464 Evas_Object* color3 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
465 evas_object_size_hint_weight_set(color3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
466 evas_object_color_set(color3, 255, 0, 0, 255);
467 evas_object_event_callback_add(color3, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
468 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color3", color3);
469 evas_object_show(color3);
471 Evas_Object* color4 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
472 evas_object_size_hint_weight_set(color4, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
473 evas_object_color_set(color4, 255, 127, 39, 255);
474 evas_object_event_callback_add(color4, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
475 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color4", color4);
476 evas_object_show(color4);
478 Evas_Object* color5 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
479 evas_object_size_hint_weight_set(color5, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
480 evas_object_color_set(color5, 255, 255, 0, 255);
481 evas_object_event_callback_add(color5, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
482 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color5", color5);
483 evas_object_show(color5);
485 Evas_Object* color6 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
486 evas_object_size_hint_weight_set(color6, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
487 evas_object_color_set(color6, 0, 255, 0, 255);
488 evas_object_event_callback_add(color6, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
489 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color6", color6);
490 evas_object_show(color6);
492 Evas_Object* color7 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
493 evas_object_size_hint_weight_set(color7, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
494 evas_object_color_set(color7, 0, 255, 255, 255);
495 evas_object_event_callback_add(color7, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
496 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color7", color7);
497 evas_object_show(color7);
499 Evas_Object* color8 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
500 evas_object_size_hint_weight_set(color8, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
501 evas_object_color_set(color8, 0, 0, 255, 255);
502 evas_object_event_callback_add(color8, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
503 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color8", color8);
504 evas_object_show(color8);
506 Evas_Object* color9 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
507 evas_object_size_hint_weight_set(color9, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
508 evas_object_color_set(color9, 0, 0, 128, 255);
509 evas_object_event_callback_add(color9, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
510 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color9", color9);
511 evas_object_show(color9);
513 Evas_Object* color10 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
514 evas_object_size_hint_weight_set(color10, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
515 evas_object_color_set(color10, 64, 0, 64, 255);
516 evas_object_event_callback_add(color10, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
517 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color10", color10);
518 evas_object_show(color10);
520 Evas_Object* color11 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
521 evas_object_size_hint_weight_set(color11, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
522 evas_object_color_set(color11, 153, 217, 234, 255);
523 evas_object_event_callback_add(color11, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
524 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color11", color11);
525 evas_object_show(color11);
527 Evas_Object* color12 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
528 evas_object_size_hint_weight_set(color12, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
529 evas_object_color_set(color12, 128, 128, 128, 255);
530 evas_object_event_callback_add(color12, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
531 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color12", color12);
532 evas_object_show(color12);
534 Evas_Object* color13 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
535 evas_object_size_hint_weight_set(color13, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
536 evas_object_color_set(color13, 0, 0, 0, 255);
537 evas_object_event_callback_add(color13, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
538 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color13", color13);
539 evas_object_show(color13);
541 Evas_Object* color14 = evas_object_rectangle_add(evas_object_evas_get(m_pickerLayout->layout));
542 evas_object_size_hint_weight_set(color14, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
543 evas_object_color_set(color14, 255, 255, 255, 255);
544 evas_object_event_callback_add(color14, EVAS_CALLBACK_MOUSE_DOWN, _color_selected_cb, m_pickerLayout->colorRect);
545 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.color14", color14);
546 evas_object_show(color14);
548 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
549 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
550 elm_object_text_set(m_pickerLayout->okButton, "OK");
551 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
552 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _color_popup_response_cb, this);
553 evas_object_focus_set(m_pickerLayout->okButton, true);
555 evas_object_show(m_pickerLayout->popup);
558 void InputPicker::_color_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
560 InputPicker* inputPicker = static_cast<InputPicker*>(data);
566 evas_object_color_get(inputPicker->m_pickerLayout->colorRect, &r, &g, &b, &a);
568 ewk_view_color_picker_color_set(inputPicker->m_ewkView, r, g, b, a);
570 inputPicker->hideColorPicker();
573 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
574 void InputPicker::_color_back_cb(void* data, Evas_Object* obj, void* event_info)
576 InputPicker* inputPicker = static_cast<InputPicker*>(data);
578 int r = inputPicker->m_pickerLayout->initial_r;
579 int g = inputPicker->m_pickerLayout->initial_g;
580 int b = inputPicker->m_pickerLayout->initial_b;
582 ewk_view_color_picker_color_set(inputPicker->m_ewkView, r, g, b, a);
584 inputPicker->hideColorPicker();
588 void InputPicker::ewk_date_popup(const char* inputValue)
590 struct tm* currentTime;
593 currentTime = localtime(&cur_time);
595 Input_Date_Str dateStr;
596 memset(&dateStr, 0, sizeof(Input_Date_Str));
598 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
599 Evas_Object* win = parent;
601 if (inputValue && strlen(inputValue)) {
602 char tmpinputValue[30] = {0,};
604 sprintf(tmpinputValue, "%s", inputValue);
605 strcpy(dateStr.year, strtok(tmpinputValue,"-"));
606 strcpy(dateStr.mon, strtok(0, "-"));
607 strcpy(dateStr.day, strtok(0, "-"));
609 currentTime->tm_year = atoi(dateStr.year);
610 currentTime->tm_mon = atoi(dateStr.mon);
611 currentTime->tm_mday = atoi(dateStr.day);
613 currentTime->tm_year = currentTime->tm_year - 1900;
614 currentTime->tm_mon = currentTime->tm_mon - 1;
617 if (m_pickerLayout) {
618 // Just update the value.
619 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
620 evas_object_focus_set(m_pickerLayout->okButton, true);
624 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
627 const char* type = elm_object_widget_type_get(parent);
629 if (!strcmp(type, "elm_win")) {
634 parent = elm_object_parent_widget_get(parent);
640 m_pickerLayout->popup = elm_popup_add(win);
641 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select date");
643 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
644 if (EflAssistHandle) {
645 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
646 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
647 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
651 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
652 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
653 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
655 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Date (Default format) :");
657 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
658 elm_datetime_format_set(m_pickerLayout->datePicker, "%Y/%m/%d");
659 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
661 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_HOUR, EINA_FALSE);
662 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_MINUTE, EINA_FALSE);
663 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_AMPM, EINA_FALSE);
664 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
666 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
667 evas_object_smart_callback_add(m_pickerLayout->datePicker, "edit,start", _edit_start_cb, 0);
668 evas_object_smart_callback_add(m_pickerLayout->datePicker, "edit,end", _edit_end_cb, 0);
671 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
672 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
673 elm_object_text_set(m_pickerLayout->okButton, "OK");
674 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
675 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _date_popup_response_cb, this);
676 evas_object_focus_set(m_pickerLayout->okButton, true);
678 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
679 evas_object_show(m_pickerLayout->popup);
682 #define isLeapYear(year) ((!(year % 4) && (year % 100)) || (!(year % 400) && (year % 1000)))
683 static int _calculateMonthAndDay(int year, int totalDays, int* remains)
686 if (totalDays - 31 < 0) {
687 *remains = totalDays;
691 totalDays = totalDays - 31;
694 if (isLeapYear(year)) {
695 if (totalDays - 29 < 0) {
696 *remains = totalDays;
699 totalDays = totalDays - 29;
701 if (totalDays - 28 < 0) {
702 *remains = totalDays;
705 totalDays = totalDays - 28;
709 if (totalDays - 31 < 0) {
710 *remains = totalDays;
713 totalDays = totalDays - 31;
716 if (totalDays - 30 < 0) {
717 *remains = totalDays;
720 totalDays = totalDays - 30;
723 if (totalDays - 31 < 0) {
724 *remains = totalDays;
727 totalDays = totalDays - 31;
730 if (totalDays - 30 < 0) {
731 *remains = totalDays;
734 totalDays = totalDays - 30;
737 if (totalDays - 31 < 0) {
738 *remains = totalDays;
741 totalDays = totalDays - 31;
744 if (totalDays - 31 < 0) {
745 *remains = totalDays;
748 totalDays = totalDays - 31;
751 if (totalDays - 30 < 0) {
752 *remains = totalDays;
755 totalDays = totalDays - 30;
758 if (totalDays - 31 < 0) {
759 *remains = totalDays;
762 totalDays = totalDays - 31;
765 if (totalDays - 30 < 0) {
766 *remains = totalDays;
769 totalDays = totalDays - 30;
771 *remains = totalDays;
775 void InputPicker::ewk_week_popup(const char* inputValue)
777 struct tm* currentTime;
780 currentTime = localtime(&cur_time);
782 Input_Date_Str dateStr;
783 memset(&dateStr, 0, sizeof(Input_Date_Str));
785 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
786 Evas_Object* win = parent;
788 if (inputValue && strlen(inputValue)) {
789 char tmpinputValue[30] = {0,};
791 sprintf(tmpinputValue, "%s", inputValue);
792 strcpy(dateStr.year, strtok(tmpinputValue,"-"));
793 const char* week = strstr(inputValue, "W");
796 weekNum = atoi(week + 1);
798 currentTime->tm_year = atoi(dateStr.year);
799 currentTime->tm_year = currentTime->tm_year - 1900;
801 struct tm firtTimeOfyear;
802 memset(&firtTimeOfyear, 0, sizeof(struct tm));
803 firtTimeOfyear.tm_year = currentTime->tm_year;
804 firtTimeOfyear.tm_mon = 0;
805 firtTimeOfyear.tm_mday = 1;
806 mktime(&firtTimeOfyear);
808 char firstWeek[10] = {0, };
809 strftime(firstWeek, 10, "%w", &firtTimeOfyear);
810 int firstWeekCount = atoi(firstWeek);
814 totalDays = weekNum * 7 - firstWeekCount;
817 int month = _calculateMonthAndDay(currentTime->tm_year, totalDays, &days);
819 currentTime->tm_mon = month;
820 currentTime->tm_mday = days;
823 if (m_pickerLayout) {
824 // Just update the value.
825 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
826 evas_object_focus_set(m_pickerLayout->okButton, true);
830 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
833 const char* type = elm_object_widget_type_get(parent);
835 if (!strcmp(type, "elm_win")) {
840 parent = elm_object_parent_widget_get(parent);
846 m_pickerLayout->popup = elm_popup_add(win);
847 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select date");
849 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
850 if (EflAssistHandle) {
851 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
852 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
853 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
857 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
858 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
859 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
861 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Date (Default format) :");
863 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
864 elm_datetime_format_set(m_pickerLayout->datePicker, "%Y/%m/%d");
865 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
867 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_HOUR, EINA_FALSE);
868 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_MINUTE, EINA_FALSE);
869 elm_datetime_field_visible_set(m_pickerLayout->datePicker, ELM_DATETIME_AMPM, EINA_FALSE);
870 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
872 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
873 evas_object_smart_callback_add(m_pickerLayout->datePicker, "edit,start", _edit_start_cb, 0);
874 evas_object_smart_callback_add(m_pickerLayout->datePicker, "edit,end", _edit_end_cb, 0);
877 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
878 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
879 elm_object_text_set(m_pickerLayout->okButton, "OK");
880 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
881 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _week_popup_response_cb, this);
882 evas_object_focus_set(m_pickerLayout->okButton, true);
884 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
885 evas_object_show(m_pickerLayout->popup);
888 void InputPicker::ewk_time_popup(const char* inputValue)
890 struct tm* currentTime;
893 currentTime = localtime(&cur_time);
895 Input_Date_Str dateStr;
896 memset(&dateStr, 0, sizeof(Input_Date_Str));
898 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
899 Evas_Object* win = parent;
901 if (inputValue && strlen(inputValue)) {
902 char tmpinputValue[30] = {0,};
904 sprintf(tmpinputValue, "%s", inputValue);
905 strcpy(dateStr.hour, strtok(tmpinputValue,":"));
906 strcpy(dateStr.min, strtok(0, ":"));
908 currentTime->tm_hour = atoi(dateStr.hour);
909 currentTime->tm_min = atoi(dateStr.min);
912 if (m_pickerLayout) {
913 // Just update the value.
914 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
915 evas_object_focus_set(m_pickerLayout->okButton, true);
919 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
922 const char* type = elm_object_widget_type_get(parent);
924 if (!strcmp(type, "elm_win")) {
929 parent = elm_object_parent_widget_get(parent);
935 m_pickerLayout->popup = elm_popup_add(win);
936 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select time");
938 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
939 if (EflAssistHandle) {
940 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
941 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
942 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
946 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
947 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
948 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
950 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Time (Default format) :");
952 m_pickerLayout->timePicker = elm_datetime_add(m_pickerLayout->layout);
953 elm_datetime_format_set(m_pickerLayout->timePicker, "%H:%M");
954 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
955 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->timePicker);
957 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
958 evas_object_smart_callback_add(m_pickerLayout->timePicker, "edit,start", _edit_start_cb, 0);
959 evas_object_smart_callback_add(m_pickerLayout->timePicker, "edit,end", _edit_end_cb, 0);
962 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
963 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
964 elm_object_text_set(m_pickerLayout->okButton, "OK");
965 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
966 evas_object_focus_set(m_pickerLayout->okButton, true);
968 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _time_popup_response_cb, this);
969 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
970 evas_object_show(m_pickerLayout->popup);
973 void InputPicker::ewk_month_popup(const char* inputValue)
975 struct tm* currentTime;
978 currentTime = localtime(&cur_time);
980 Input_Date_Str dateStr;
981 memset(&dateStr, 0, sizeof(Input_Date_Str));
983 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
984 Evas_Object* win = parent;
986 if (inputValue && strlen(inputValue)) {
987 char tmpInputValue[30] = {0,};
989 sprintf(tmpInputValue, "%s", inputValue);
990 strcpy(dateStr.year, strtok(tmpInputValue,"-"));
991 strcpy(dateStr.mon, strtok(0, "-"));
993 currentTime->tm_year = atoi(dateStr.year);
994 currentTime->tm_mon = atoi(dateStr.mon);
996 currentTime->tm_year = currentTime->tm_year - 1900;
997 currentTime->tm_mon = currentTime->tm_mon - 1;
1000 if (m_pickerLayout) {
1001 // Just update the value.
1002 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
1003 evas_object_focus_set(m_pickerLayout->okButton, true);
1007 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
1010 const char* type = elm_object_widget_type_get(parent);
1012 if (!strcmp(type, "elm_win")) {
1017 parent = elm_object_parent_widget_get(parent);
1023 m_pickerLayout->popup = elm_popup_add(win);
1024 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select month");
1026 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1027 if (EflAssistHandle) {
1028 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
1029 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
1030 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
1034 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
1035 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","elm/datepicker");
1037 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1039 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
1040 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
1041 edje_object_part_text_set(elm_layout_edje_get(m_pickerLayout->layout), "title_text", "Month (Default format) :");
1042 elm_datetime_format_set(m_pickerLayout->datePicker, "%Y/%m");
1043 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.date", m_pickerLayout->datePicker);
1045 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1046 evas_object_smart_callback_add(m_pickerLayout->datePicker, "edit,start", _edit_start_cb, 0);
1047 evas_object_smart_callback_add(m_pickerLayout->datePicker, "edit,end", _edit_end_cb, 0);
1050 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
1051 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
1052 elm_object_text_set(m_pickerLayout->okButton, "OK");
1053 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
1054 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _month_popup_response_cb, this);
1055 evas_object_focus_set(m_pickerLayout->okButton, true);
1057 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
1058 evas_object_show(m_pickerLayout->popup);
1061 void InputPicker::ewk_datetime_popup(const char* inputValue, bool local)
1063 struct tm* currentTime;
1066 currentTime = localtime(&cur_time);
1068 Input_Date_Str dateStr;
1069 memset(&dateStr, 0, sizeof(Input_Date_Str));
1071 Evas_Object* parent = elm_object_parent_widget_get(m_ewkView);
1072 Evas_Object* win = parent;
1074 if (inputValue && strlen(inputValue)) {
1075 char tmpInputValue[30] = {0, };
1077 sprintf(tmpInputValue, "%s", inputValue);
1078 strcpy(dateStr.year, strtok(tmpInputValue,"-"));
1079 strcpy(dateStr.mon, strtok(0, "-"));
1080 strcpy(dateStr.day, strtok(0, "T"));
1081 strcpy(dateStr.hour, strtok(0, ":"));
1084 strcpy(dateStr.min, strtok(0, "Z"));
1086 strcpy(dateStr.min, strtok(0, ":"));
1088 currentTime->tm_year = atoi(dateStr.year);
1089 currentTime->tm_mon = atoi(dateStr.mon);
1090 currentTime->tm_mday = atoi(dateStr.day);
1091 currentTime->tm_hour = atoi(dateStr.hour);
1092 currentTime->tm_min = atoi(dateStr.min);
1094 currentTime->tm_year = currentTime->tm_year - 1900;
1095 currentTime->tm_mon = currentTime->tm_mon - 1;
1098 if (m_pickerLayout) {
1099 // Just update the value.
1100 m_pickerLayout->datetimeLocal = local;
1102 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
1103 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
1104 evas_object_focus_set(m_pickerLayout->okButton, true);
1108 m_pickerLayout = new Input_Picker_Layout(m_ewkView);
1110 m_pickerLayout->datetimeLocal = local;
1113 const char* type = elm_object_widget_type_get(parent);
1115 if (!strcmp(type, "elm_win")) {
1120 parent = elm_object_parent_widget_get(parent);
1126 m_pickerLayout->popup = elm_popup_add(win);
1127 elm_object_part_text_set(m_pickerLayout->popup, "title,text", "Select datetime");
1129 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1130 if (EflAssistHandle) {
1131 void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
1132 webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
1133 (*webkit_ea_object_event_callback_add)(m_pickerLayout->popup, EA_CALLBACK_BACK, _popup_back_cb, this);
1137 m_pickerLayout->layout = elm_layout_add(m_pickerLayout->popup);
1138 elm_layout_file_set(m_pickerLayout->layout, EDJE_DIR"/control.edj","datepicker_popup");
1139 evas_object_size_hint_weight_set(m_pickerLayout->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1141 m_pickerLayout->datePicker = elm_datetime_add(m_pickerLayout->layout);
1142 elm_datetime_format_set(m_pickerLayout->datePicker, "%Y/%m/%d");
1143 elm_datetime_value_set(m_pickerLayout->datePicker, currentTime);
1144 elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_HOUR, EINA_FALSE);
1145 elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_MINUTE, EINA_FALSE);
1146 elm_datetime_field_visible_set(m_pickerLayout->datePicker , ELM_DATETIME_AMPM, EINA_FALSE);
1147 elm_object_part_content_set(m_pickerLayout->layout , "elm.swallow.content.date", m_pickerLayout->datePicker);
1149 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1150 evas_object_smart_callback_add(m_pickerLayout->datePicker, "edit,start", _edit_start_cb, 0);
1151 evas_object_smart_callback_add(m_pickerLayout->datePicker, "edit,end", _edit_end_cb, 0);
1154 m_pickerLayout->timePicker = elm_datetime_add(m_pickerLayout->layout);
1155 elm_datetime_format_set(m_pickerLayout->timePicker, "%H:%M");
1156 elm_datetime_value_set(m_pickerLayout->timePicker, currentTime);
1157 elm_object_part_content_set(m_pickerLayout->layout, "elm.swallow.content.time", m_pickerLayout->timePicker);
1159 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1160 evas_object_smart_callback_add(m_pickerLayout->timePicker, "edit,start", _edit_start_cb, 0);
1161 evas_object_smart_callback_add(m_pickerLayout->timePicker, "edit,end", _edit_end_cb, 0);
1164 m_pickerLayout->okButton = elm_button_add(m_pickerLayout->popup);
1165 elm_object_style_set(m_pickerLayout->okButton, "popup_button/default");
1166 elm_object_text_set(m_pickerLayout->okButton, "OK");
1167 elm_object_part_content_set(m_pickerLayout->popup, "button1", m_pickerLayout->okButton);
1168 evas_object_focus_set(m_pickerLayout->okButton, true);
1170 evas_object_smart_callback_add(m_pickerLayout->okButton, "clicked", _datetime_popup_response_cb, this);
1171 elm_object_content_set(m_pickerLayout->popup, m_pickerLayout->layout);
1172 evas_object_show(m_pickerLayout->popup);
1176 void InputPicker::_date_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1178 struct tm currentTime;
1179 memset(¤tTime, 0, sizeof(struct tm));
1181 char dateStr[20] = {0, };
1183 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1185 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1187 date.day = currentTime.tm_mday;
1188 date.mon = currentTime.tm_mon;
1189 date.year = currentTime.tm_year;
1191 if(inputPicker->m_pickerLayout->popup){
1192 evas_object_del(inputPicker->m_pickerLayout->popup);
1193 inputPicker->m_pickerLayout->popup = 0;
1196 date.year = 1900 + date.year;
1197 sprintf(dateStr, "%d-%02d-%02d" , date.year, date.mon + 1, date.day);
1199 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1200 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1202 delete inputPicker->m_pickerLayout;
1203 inputPicker->m_pickerLayout = 0;
1206 void InputPicker::_week_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1208 struct tm currentTime;
1209 memset(¤tTime, 0, sizeof(struct tm));
1211 char dateStr[20] = {0, };
1213 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1215 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1217 date.day = currentTime.tm_mday;
1218 date.mon = currentTime.tm_mon;
1219 date.year = currentTime.tm_year;
1220 mktime(¤tTime);
1222 if(inputPicker->m_pickerLayout->popup){
1223 evas_object_del(inputPicker->m_pickerLayout->popup);
1224 inputPicker->m_pickerLayout->popup = 0;
1227 struct tm firtTimeOfyear;
1228 memset(&firtTimeOfyear, 0, sizeof(struct tm));
1229 firtTimeOfyear.tm_year = date.year;
1230 firtTimeOfyear.tm_mon = 0;
1231 firtTimeOfyear.tm_mday = 1;
1232 mktime(&firtTimeOfyear);
1234 char firstWeek[10] = {0, };
1235 strftime(firstWeek, 10, "%w", &firtTimeOfyear);
1236 int firstWeekCount = atoi(firstWeek);
1238 char totalDay[10] = {0, };
1239 strftime(totalDay, 10, "%j", ¤tTime);
1240 int totalDayCount = atoi(totalDay);
1242 int weekNum = (totalDayCount + firstWeekCount) / 7;
1243 if (totalDayCount + firstWeekCount > weekNum * 7)
1246 date.year = 1900 + date.year;
1247 sprintf(dateStr, "%d-W%02d" , date.year, weekNum);
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::_time_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[20] = {0, };
1263 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1265 elm_datetime_value_get(inputPicker->m_pickerLayout->timePicker, ¤tTime);
1267 date.hour = currentTime.tm_hour;
1268 date.min = currentTime.tm_min;
1270 if(inputPicker->m_pickerLayout->popup){
1271 evas_object_del(inputPicker->m_pickerLayout->popup);
1272 inputPicker->m_pickerLayout->popup = 0;
1275 sprintf(dateStr, "%02d:%02d" , date.hour, date.min);
1276 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1277 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1279 delete inputPicker->m_pickerLayout;
1280 inputPicker->m_pickerLayout = 0;
1283 void InputPicker::_month_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1285 struct tm currentTime;
1286 memset(¤tTime, 0, sizeof(struct tm));
1288 char dateStr[20] = {0, };
1290 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1292 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1294 date.mon = currentTime.tm_mon;
1295 date.year = currentTime.tm_year;
1297 if(inputPicker->m_pickerLayout->popup){
1298 evas_object_del(inputPicker->m_pickerLayout->popup);
1299 inputPicker->m_pickerLayout->popup = 0;
1302 date.year = 1900 + date.year;
1303 sprintf(dateStr, "%02d-%02d" , date.year, date.mon + 1);
1305 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1306 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1308 delete inputPicker->m_pickerLayout;
1309 inputPicker->m_pickerLayout = 0;
1312 void InputPicker::_datetime_popup_response_cb(void* data, Evas_Object* obj, void* event_info)
1314 struct tm currentTime;
1315 memset(¤tTime, 0, sizeof(struct tm));
1317 char dateStr[50] = {0, };
1319 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1321 elm_datetime_value_get(inputPicker->m_pickerLayout->datePicker, ¤tTime);
1322 date.year = currentTime.tm_year;
1323 date.day = currentTime.tm_mday;
1324 date.mon = currentTime.tm_mon;
1326 elm_datetime_value_get(inputPicker->m_pickerLayout->timePicker, ¤tTime);
1327 date.hour = currentTime.tm_hour;
1328 date.min = currentTime.tm_min;
1330 if (inputPicker->m_pickerLayout->popup) {
1331 evas_object_del(inputPicker->m_pickerLayout->popup);
1332 inputPicker->m_pickerLayout->popup = 0;
1335 date.year = 1900 + date.year;
1337 if (inputPicker->m_pickerLayout->datetimeLocal)
1338 sprintf(dateStr, "%d-%02d-%02dT%02d:%02d" , date.year, date.mon + 1, date.day, date.hour, date.min);
1340 sprintf(dateStr, "%d-%02d-%02dT%02d:%02dZ" , date.year, date.mon + 1, date.day, date.hour, date.min);
1342 ewk_view_focused_input_element_value_set(inputPicker->m_ewkView, dateStr);
1343 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1345 delete inputPicker->m_pickerLayout;
1346 inputPicker->m_pickerLayout = 0;
1349 #if ENABLE(TIZEN_HW_MORE_BACK_KEY)
1350 void InputPicker::_popup_back_cb(void* data, Evas_Object* obj, void* event_info)
1352 InputPicker* inputPicker = static_cast<InputPicker*>(data);
1354 ewk_view_command_execute(inputPicker->m_ewkView, "Unselect", 0);
1356 if (!inputPicker->m_pickerLayout)
1359 if (inputPicker->m_pickerLayout->popup) {
1360 evas_object_del(inputPicker->m_pickerLayout->popup);
1361 inputPicker->m_pickerLayout->popup = 0;
1364 delete inputPicker->m_pickerLayout;
1365 inputPicker->m_pickerLayout = 0;
1369 } // namespace WebKit
1371 #endif // OS(TIZEN) && ENABLE(TIZEN_INPUT_TAG_EXTENSION)