Tizen 2.1 base
[framework/osp/web.git] / src / controls / FWebCtrl_InputPickerPopup.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FWebCtrl_InputPickerPopup.h
20  * @brief       The file contains the definition of _InputPickerPopup class.
21  */
22
23 #ifndef _FWEB_CTRL_INTERNAL_INPUT_POPUP_H_
24 #define _FWEB_CTRL_INTERNAL_INPUT_POPUP_H_
25
26 #include <unique_ptr.h>
27 #include <ewk_view.h>
28
29 #include <FBase.h>
30 #include <FBaseString.h>
31 #include <FGrpColor.h>
32 #include <FUi.h>
33 #include <FUiIActionEventListener.h>
34 #include <FUi_ControlManager.h>
35
36 namespace Tizen { namespace Ui
37 {
38 class IActionEventListener;
39 }} // Tizen::Ui
40
41 namespace Tizen { namespace Ui { namespace Controls
42 {
43 class Popup;
44 class EditDate;
45 class EditTime;
46 }}} // Tizen::Ui::Controls
47
48 namespace Tizen { namespace Web { namespace Controls
49 {
50
51 enum _InputPickerButtonId
52 {
53         ID_BUTTON_INPUT_DATE_SELECTION,
54         ID_BUTTON_INPUT_COLOR_SELECTION
55 };
56
57 enum _InputPickerMode
58 {
59         INPUT_MODE_DATE,
60         INPUT_MODE_COLOR
61 };
62
63
64 class _InputPickerPopup
65         : public Tizen::Base::Object
66         , virtual public Tizen::Ui::IActionEventListener
67 {
68
69 public:
70         /**
71          * Constructor
72          */
73         _InputPickerPopup(void);
74
75         /**
76          * Destructor
77          */
78         virtual ~_InputPickerPopup(void);
79
80         result Construct(const Tizen::Base::String& strDate, Ewk_Input_Type inputType);
81
82         result Construct(const Tizen::Graphics::Color& color);
83
84         void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
85
86         result ChangeLayout(Tizen::Ui::_ControlOrientation orientation);
87
88         Tizen::Base::String GetDate(void) const;
89         Tizen::Graphics::Color GetColor(void) const;
90
91         result ShowPopup(void);
92         result HidePopup(void);
93
94 private:
95         _InputPickerPopup(const _InputPickerPopup& rhs);
96
97         _InputPickerPopup& operator =(const _InputPickerPopup& rhs);
98
99         result CreatePopup(void);
100
101         result AddButton(_InputPickerButtonId buttonId);
102
103         void CalculateColorPickerPopupSize(Tizen::Ui::_ControlOrientation orientation);
104
105         result UpdateDate(void);
106         void UpdateColor(void);
107
108         result Parse(const Tizen::Base::String& strDateTime, Tizen::Base::DateTime& dateTime);
109
110         void GetDateTimeForWeek(int year, int totalDays, Tizen::Base::DateTime& dateTime);
111
112 private:
113
114         std::unique_ptr<Tizen::Ui::Controls::Popup> __pPopup;
115         Tizen::Ui::Controls::EditDate* __pEditDate;
116         Tizen::Ui::Controls::EditTime* __pEditTime;
117         Tizen::Ui::Controls::Button* __pSelectionBtn;
118         Tizen::Ui::Controls::ColorPicker* __pColorPicker;
119
120         int __modal;
121         int __popupHeight;
122         int __popupWidth;
123         int __btnHeight;
124
125         Ewk_Input_Type __inputType;
126         Tizen::Base::String __dateStr;
127         Tizen::Graphics::Color __Color;
128
129         _InputPickerMode __inputPickerMode;
130 }; // _InputPickerPopup
131
132 }}} // Tizen::Web::Controls
133 #endif // _FWEB_CTRL_INTERNAL_INPUT_POPUP_H_