2733bcd64538ec96d7f2aeabc7e69e1530b591e2
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / browser / input_picker / input_picker.h
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 BUILDFLAG(IS_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   InputPicker(const InputPicker&) = delete;
29   InputPicker& operator=(const InputPicker&) = delete;
30
31   void ShowColorPicker(int r, int g, int b, int a);
32   void ShowDatePicker(ui::TextInputType input_type, double input_date);
33
34  private:
35   class Layout {
36    public:
37     static Layout* CreateAndShowColorPickerLayout(InputPicker* parent,
38                                                   int r,
39                                                   int g,
40                                                   int b);
41     static Layout* CreateAndShowDateLayout(InputPicker* parent,
42                                            struct tm* currentTime,
43                                            ui::TextInputType type);
44     static Layout* CreateAndShowDateTimeLayout(InputPicker* parent,
45                                                struct tm* currentTime,
46                                                ui::TextInputType type);
47     static Layout* CreateAndShowTimeLayout(InputPicker* parent,
48                                            struct tm* currentTime);
49
50     ~Layout();
51
52    private:
53     explicit Layout(InputPicker* parent);
54
55     Layout(const Layout&) = delete;
56     Layout& operator=(const Layout&) = delete;
57
58     bool AddBaseLayout(const char* title, const char* layout_group);
59     bool AddButtons();
60     bool AddColorSelector(int r, int g, int b);
61     void AddColorPickerCallbacks();
62     void DeleteColorPickerCallbacks();
63     void AddDatePickerCallbacks();
64     void DeleteDatePickerCallbacks();
65
66     bool SetDatetimePicker(Evas_Object* picker, const char* style);
67
68     static void ColorPickerSelectFinishedCallback(void* data,
69                                                   Evas_Object* obj,
70                                                   void* event_info);
71     static void ColorPickerItemSelectedCallback(void* data,
72                                                 Evas_Object* obj,
73                                                 void* event_info);
74     static void DatePickerSelectFinishedCallback(void* data,
75                                                  Evas_Object* obj,
76                                                  void* event_info);
77     static void DatePickerItemChangedCallback(void* data,
78                                               Evas_Object* obj,
79                                               void* event_info);
80
81     static void ColorPickerBackKeyCallback(void* data,
82                                            Evas_Object* obj,
83                                            void* event_info);
84     static void DatePickerBackKeyCallback(void* data,
85                                           Evas_Object* obj,
86                                           void* event_info);
87
88     InputPicker* parent_;
89
90     Evas_Object* conformant_ = nullptr;
91     Evas_Object* popup_ = nullptr;
92     Evas_Object* layout_ = nullptr;
93     Evas_Object* set_button_ = nullptr;
94     Evas_Object* cancel_button_ = nullptr;
95     Evas_Object* color_picker_ = nullptr;
96     Evas_Object* color_rect_ = nullptr;
97     Evas_Object* date_picker_ = nullptr;
98     Evas_Object* time_picker_ = nullptr;
99 #if BUILDFLAG(IS_TIZEN) && !BUILDFLAG(IS_TIZEN_TV)
100     Eext_Circle_Surface* circle_surface_ = nullptr;
101 #endif
102     ui::TextInputType input_type_ = ui::TEXT_INPUT_TYPE_NONE;
103     bool is_color_picker_ = false;
104     int red_ = 0;
105     int green_ = 0;
106     int blue_ = 0;
107   };
108
109   void RemoveColorPicker();
110   void RemoveDatePicker(bool cancel);
111
112   EWebView* web_view_;
113   std::unique_ptr<Layout> picker_layout_;
114 };
115
116 }  // namespace content
117
118 #endif  // EWK_EFL_INTEGRATION_BROWSER_INPUT_PICKER_INPUT_PICKER_H_