6a110cdfa72cc1c4eba46a9cdcb81ce68855817d
[platform/framework/web/crosswalk-tizen.git] /
1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef EWK_EFL_INTEGRATION_BROWSER_INPUT_PICKER_INPUT_PICKER_H_
6 #define EWK_EFL_INTEGRATION_BROWSER_INPUT_PICKER_INPUT_PICKER_H_
7
8 #include <Evas.h>
9 #include <ctime>
10 #include <string>
11
12 #include "ewk/efl_integration/eweb_view.h"
13 #include "ui/base/ime/text_input_type.h"
14
15 #if defined(OS_TIZEN)
16 #include <efl_extension.h>
17 #endif
18
19 class EWebView;
20
21 namespace content {
22
23 class InputPicker {
24  public:
25   explicit InputPicker(EWebView* view);
26   ~InputPicker();
27
28   void ShowColorPicker(int r, int g, int b, int a);
29   void ShowDatePicker(ui::TextInputType input_type, double input_date);
30
31  private:
32   class Layout {
33    public:
34     static Layout* CreateAndShowColorPickerLayout(
35         InputPicker* parent, int r, int g, int b);
36     static Layout* CreateAndShowDateLayout(
37         InputPicker* parent, struct tm* currentTime, ui::TextInputType type);
38     static Layout* CreateAndShowDateTimeLayout(
39         InputPicker* parent, struct tm* currentTime, ui::TextInputType type);
40     static Layout* CreateAndShowTimeLayout(
41         InputPicker* parent, struct tm* currentTime);
42
43     ~Layout();
44
45    private:
46     explicit Layout(InputPicker* parent);
47
48     bool AddBaseLayout(const char* title, const char* layout_group);
49     bool AddButtons();
50     bool AddColorSelector(int r, int g, int b);
51     void AddColorPickerCallbacks();
52     void DeleteColorPickerCallbacks();
53     void AddDatePickerCallbacks();
54     void DeleteDatePickerCallbacks();
55
56     bool SetDatetimePicker(Evas_Object* picker, const char* style);
57
58     static void ColorPickerSelectFinishedCallback(
59         void* data, Evas_Object* obj, void* event_info);
60     static void ColorPickerItemSelectedCallback(
61         void* data, Evas_Object* obj, void* event_info);
62     static void DatePickerSelectFinishedCallback(
63         void* data, Evas_Object* obj, void* event_info);
64     static void DatePickerItemChangedCallback(
65         void* data,  Evas_Object* obj, void* event_info);
66     static void ColorPickerBackKeyCallback(
67         void* data,  Evas_Object* obj, void* event_info);
68     static void DatePickerBackKeyCallback(
69         void* data, Evas_Object* obj, void* event_info);
70
71     InputPicker* parent_;
72
73     Evas_Object* conformant_;
74     Evas_Object* popup_;
75     Evas_Object* layout_;
76     Evas_Object* set_button_;
77     Evas_Object* cancel_button_;
78     Evas_Object* color_picker_;
79     Evas_Object* color_rect_;
80     Evas_Object* date_picker_;
81     Evas_Object* time_picker_;
82 #if defined(OS_TIZEN) && !defined(OS_TIZEN_TV_PRODUCT)
83     Eext_Circle_Surface* circle_surface_;
84 #endif
85     ui::TextInputType input_type_;
86     bool is_color_picker_;
87     int red_;
88     int green_;
89     int blue_;
90   };
91
92   void RemoveColorPicker();
93   void RemoveDatePicker(bool cancel);
94
95   EWebView* web_view_;
96   std::unique_ptr<Layout> picker_layout_;
97 };
98
99 }  // namespace content
100
101 #endif  // EWK_EFL_INTEGRATION_BROWSER_INPUT_PICKER_INPUT_PICKER_H_