2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUiCtrl_DateTimePresenter.h
20 * @brief This is the header file for the _DateTimePresenter class.
23 #ifndef _FUI_CTRL_INTERNAL_DATETIME_PRESENTER_H_
24 #define _FUI_CTRL_INTERNAL_DATETIME_PRESENTER_H_
26 #include <FBaseObject.h>
27 #include "FUi_Control.h"
28 #include "FUiCtrl_DateTimeDefine.h"
29 #include "FUiCtrl_IInputPadEventListener.h"
31 namespace Tizen { namespace Ui { namespace Controls
33 class _DateTimePicker;
34 class _DateTimeDisplayBox;
37 }}} // Tizen::Ui::Controls
39 namespace Tizen { namespace Ui { namespace Controls
42 class _DateTimePresenter
43 : public _IInputPadEventListener
44 , virtual public Tizen::Base::Runtime::IEventListener
47 _DateTimePresenter(int pickerStyle, const Tizen::Base::String& title = L"");
49 virtual ~_DateTimePresenter(void);
51 result Construct(_DateTimePicker& view);
53 result SetYear(int year);
55 result SetMonth(int month);
57 result SetDay(int day);
59 result SetHour(int hour);
61 result SetMinute(int minute);
63 result SetYearRange(int minYear, int maxYear);
65 int GetYear(void) const;
67 int GetMonth(void) const;
69 int GetDay(void) const;
71 int GetHour(void) const;
73 int GetMinute(void) const;
75 result GetYearRange(int& minYear, int& maxYear) const;
77 void Set24HourNotationEnabled(bool enable);
79 bool Is24HourNotationEnabled(void) const;
81 void SetCurrentDateTime(void);
83 void SetDateTime(const Tizen::Base::DateTime& dateTime);
85 Tizen::Base::DateTime GetDateTime(void) const;
87 void SetFocusBoxId(int boxId);
89 const _DateTimeDisplayBox* GetDisplayBox(int index) const;
91 const _DateTimeDisplayBox* GetAmPmBox(void) const;
95 result SetFont(Tizen::Graphics::Font* pFont);
97 void UpdateLocaleDateTimeFormat(void);
99 void UpdateTimeFormat(void);
101 virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
103 virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
104 virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
105 virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
106 virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
108 virtual void OnInputPadValueChanged(const Tizen::Ui::_Control& source, int inputPadReturnValue);
110 virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
112 virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
113 virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
114 result DrawFocus(void);
115 result ReleaseFocus(void);
118 void UpdateDateTimeOutputConfig(void);
120 void LoadResource(void);
122 void DrawColon(Tizen::Graphics::Canvas& canvas);
124 void DrawDateTimeDisplayBox(Tizen::Graphics::Canvas& canvas, int index);
126 void DrawPm(Tizen::Graphics::Canvas& canvas);
128 void DrawBackground(Tizen::Graphics::Canvas& canvas);
130 void DrawTitle(Tizen::Graphics::Canvas& canvas);
132 void DrawDividers(Tizen::Graphics::Canvas& canvas);
134 void ChangeInputPadStyle(int boxId);
136 Tizen::Graphics::FloatRectangle GetOutputArea(void);
138 int CalculateTouchArea(float posX, float posY);
140 int CalculateTouchOutputArea(float posX, float posY);
142 int CalculateTwoDigit(int originalNumber, int number);
144 int CalculateFourDigit(int originalNumber, int number);
146 int SetTwoDigit(int originalNumber, int number);
148 int SetFourDigit(int originalNumber, int number);
150 void SetNumberInBox(int boxId, int number);
152 int GetNumberInBox(int boxId) const;
154 void SetFocusBox(int index);
156 void LoadPickerData(void);
158 void SavePickerData(void);
160 void UpdateDisplayData(int boxId);
162 void AdjustDisplayValue(int index);
164 void AdjustValue(int& value, int minValue, int maxValue);
166 void ChangeFocusBox(void);
168 void SetAccessibilityElementText(void);
170 void HandleInputPadValueChange(int inputPadReturnValue);
172 void HandleSaveCancelAction(int actionId);
175 _DateTimePresenter(const _DateTimePresenter&);
177 _DateTimePresenter& operator =(const _DateTimePresenter&);
182 _DateTimePicker* __pView;
184 _DateTimeModel* __pModel;
186 int __selectedBoxIndex;
188 int __focusedBoxIndex;
190 _InputPad* __pInputPad;
192 _InputPadStyle __inputPadType;
196 bool __inputPadEnabled;
198 int __outputBoxMaxCount;
210 bool __is24HourNotation;
216 bool __isPmButtonPressed;
218 bool __isFocusBoxChanged;
220 int __inputComposing;
222 int __changeFocusCounter;
224 Tizen::Base::String __title;
226 Tizen::Graphics::Bitmap* __pDisplayBoxNormalBitmap[DATETIME_STATUS_MAX];
227 Tizen::Graphics::Bitmap* __pDisplayBoxEffectBitmap[DATETIME_STATUS_MAX];
229 Tizen::Graphics::Bitmap* __pAmPmNormalBitmap[DATETIME_STATUS_MAX];
230 Tizen::Graphics::Bitmap* __pAmPmEffectBitmap[DATETIME_STATUS_MAX];
232 Tizen::Graphics::Bitmap* __pColonBitmap;
233 Tizen::Graphics::Bitmap* __pColonDisabledBitmap;
234 Tizen::Graphics::Bitmap* __pBgNormalBitmap;
235 Tizen::Graphics::Bitmap* __pBgEffectBitmap;
237 Tizen::Graphics::Font* __pFont;
239 _DateTimeDisplayBox* __pDisplayBox[DATETIME_ID_MAX];
241 _DateTimeDisplayBox* __pPmBox;
243 bool __keypadEnabled;
244 }; // _DateTimePresenter
246 }}} // Tizen::Ui::Controls
248 #endif // _FUI_CTRL_INTERNAL_DATETIME_PRESENTER_H_