2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 * @file FUiCtrl_DateTimePresenter.cpp
19 * @brief This is the implementation file for the _DateTimePresenter class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseSysLog.h>
25 #include <FGrp_TextTextObject.h>
26 #include <FGrp_CanvasImpl.h>
27 #include <FGrp_BitmapImpl.h>
28 #include "FUi_ResourceManager.h"
29 #include "FUiAnim_VisualElement.h"
30 #include "FUiCtrl_DateTimePresenter.h"
31 #include "FUiCtrl_InputPad.h"
32 #include "FUiCtrl_DateTimeDefine.h"
33 #include "FUiCtrl_DateTimeModel.h"
34 #include "FUiCtrl_DateTimeDisplayBox.h"
35 #include "FUiCtrl_DateTimePicker.h"
36 #include "FUiCtrl_DateTimeUtils.h"
37 #include "FUi_AccessibilityManager.h"
39 using namespace Tizen::Ui;
40 using namespace Tizen::Base;
41 using namespace Tizen::Graphics;
42 using namespace Tizen::Graphics::_Text;
43 using namespace Tizen::Ui::Animations;
45 namespace Tizen { namespace Ui { namespace Controls
47 const int DATETIME_DISPLAY_STRING_MAX_LENGTH = 10;
49 _DateTimePresenter::_DateTimePresenter(int pickerStyle, const String& title)
52 , __selectedBoxIndex(-1)
53 , __focusedBoxIndex(0)
55 , __inputPadType(INPUTPAD_STYLE_NORMAL)
56 , __pickerStyle(pickerStyle)
57 , __inputPadEnabled(true)
58 , __outputBoxMaxCount(0)
64 , __is24HourNotation(false)
66 , __isPmButtonPressed(false)
67 , __isFocusBoxChanged(false)
68 , __inputComposing(DATETIME_INPUT_END)
69 , __changeFocusCounter(DATE_TIME_CHANGE_FOCUS_COUNTER_MIN)
70 , __pPmBoxNormalBitmap(null)
71 , __pPmBoxEffectBitmap(null)
72 , __pPmBoxPressedEffectBitmap(null)
73 , __pPmBoxDisabledEffectBitmap(null)
74 , __pColonBitmap(null)
78 for (int i = 0; i < DATETIME_ID_MAX; i++)
80 __pDisplayBox[i] = null;
84 _DateTimePresenter::~_DateTimePresenter(void)
90 _DateTimePresenter::Dispose(void)
92 delete __pPmBoxNormalBitmap;
93 __pPmBoxNormalBitmap = null;
95 delete __pPmBoxEffectBitmap;
96 __pPmBoxEffectBitmap = null;
98 delete __pPmBoxPressedEffectBitmap;
99 __pPmBoxPressedEffectBitmap = null;
101 delete __pPmBoxDisabledEffectBitmap;
102 __pPmBoxDisabledEffectBitmap = null;
104 delete __pColonBitmap;
105 __pColonBitmap = null;
107 for (int i = 0; i < DATETIME_ID_MAX; i++)
109 delete __pDisplayBox[i];
110 __pDisplayBox[i] = null;
116 if ((__inputPadEnabled == true) && (__pInputPad != null))
118 __pView->DetachChild(*__pInputPad);
128 _DateTimePresenter::Construct(_DateTimePicker& view)
130 result r = E_SUCCESS;
133 _ControlOrientation orientation = __pView->GetOrientation();
135 __pFont = __pView->GetDateTimeFont();
136 SysTryReturnResult(NID_UI_CTRL, (__pFont != null), E_SYSTEM, "A system error has occurred. Failed to get the font.");
139 UpdateDateTimeOutputConfig();
141 Rectangle inputPadBounds(0, 0, 0, 0);
142 Rectangle pickerBounds(0, 0, 0, 0);
144 pickerBounds = __pView->GetBounds();
146 GET_SHAPE_CONFIG(DATETIMEPICKER::INPUTPAD_HEIGHT, orientation, inputPadBounds.height);
148 inputPadBounds.x = 0;
149 inputPadBounds.width = pickerBounds.width;
150 inputPadBounds.y = pickerBounds.height - inputPadBounds.height;
152 __pModel = new (std::nothrow) _DateTimeModel;
153 SysTryReturnResult(NID_UI_CTRL, (__pModel != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
155 // Load display data for sync with model data
158 if (__inputPadEnabled == true)
160 __pInputPad = new (std::nothrow) _InputPad;
161 SysTryCatch(NID_UI_CTRL, (__pInputPad != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
163 r = __pInputPad->Construct(inputPadBounds);
164 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
165 "[E_SYSTEM] A system error has occurred. Failed to construct the instance of Inputpad.");
167 r = __pView->AttachChild(*__pInputPad);
168 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
170 r = __pInputPad->SetInputPadEventListener(*this);
171 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
172 "[E_SYSTEM] A system error has occurred. Failed to set InputPadEventListener to the Inputpad.");
174 __pInputPad->SetInputPadStyle(INPUTPAD_STYLE_NORMAL);
176 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
177 "[E_SYSTEM] A system error has occurred. Failed to set InputPadStyle to the Inputpad.");
179 __pInputPad->SetFont(__pFont);
181 _DateTimeDisplayBox* pDisplayBox = __pDisplayBox[__focusedBoxIndex];
182 SysTryCatch(NID_UI_CTRL, (pDisplayBox != null), , E_SYSTEM,
183 "[E_SYSTEM] A system error has occurred. Failed to get Display box.");
185 SetFocusBoxId(pDisplayBox->GetDisplayBoxId());
197 _DateTimePresenter::SetYear(int year)
199 result r = E_SUCCESS;
203 GetYearRange(minYear, maxYear);
209 else if (year > maxYear)
214 r = __pModel->SetYear(year);
218 UpdateDisplayData(DATETIME_ID_YEAR);
225 _DateTimePresenter::SetMonth(int month)
227 result r = __pModel->SetMonth(month);
231 UpdateDisplayData(DATETIME_ID_MONTH);
238 _DateTimePresenter::SetDay(int day)
240 result r = __pModel->SetDay(day);
244 UpdateDisplayData(DATETIME_ID_DAY);
251 _DateTimePresenter::SetHour(int hour)
253 result r = __pModel->SetHour(hour);
257 UpdateDisplayData(DATETIME_ID_HOUR);
264 _DateTimePresenter::SetMinute(int minute)
266 result r = __pModel->SetMinute(minute);
270 UpdateDisplayData(DATETIME_ID_MINUTE);
277 _DateTimePresenter::SetYearRange(int minYear, int maxYear)
279 __pModel->SetMinYear(minYear);
280 __pModel->SetMaxYear(maxYear);
286 _DateTimePresenter::GetYear(void) const
288 return __pModel->GetYear();
292 _DateTimePresenter::GetMonth(void) const
294 return __pModel->GetMonth();
298 _DateTimePresenter::GetDay(void) const
300 return __pModel->GetDay();
304 _DateTimePresenter::GetHour(void) const
306 return __pModel->GetHour();
310 _DateTimePresenter::GetMinute(void) const
312 return __pModel->GetMinute();
316 _DateTimePresenter::GetYearRange(int& minYear, int& maxYear) const
318 return __pModel->GetYearRange(minYear, maxYear);
322 _DateTimePresenter::Set24HourNotationEnabled(bool enable)
324 __is24HourNotation = enable;
326 UpdateDateTimeOutputConfig();
330 _DateTimePresenter::Is24HourNotationEnabled(void) const
332 return __is24HourNotation;
336 _DateTimePresenter::SetCurrentDateTime(void)
338 __pModel->SetCurrentDateTime();
340 UpdateDisplayData(DATETIME_ID_YEAR);
341 UpdateDisplayData(DATETIME_ID_MONTH);
342 UpdateDisplayData(DATETIME_ID_DAY);
343 UpdateDisplayData(DATETIME_ID_HOUR);
344 UpdateDisplayData(DATETIME_ID_MINUTE);
348 _DateTimePresenter::SetDateTime(const DateTime& dateTime)
350 __pModel->SetDateTime(dateTime);
352 UpdateDisplayData(DATETIME_ID_YEAR);
353 UpdateDisplayData(DATETIME_ID_MONTH);
354 UpdateDisplayData(DATETIME_ID_DAY);
355 UpdateDisplayData(DATETIME_ID_HOUR);
356 UpdateDisplayData(DATETIME_ID_MINUTE);
360 _DateTimePresenter::GetDateTime(void) const
362 return __pModel->GetDateTime();
366 _DateTimePresenter::SetFocusBoxId(int boxId)
368 for (int i = 0; i < __outputBoxMaxCount; i++)
370 int displayBoxId = __pDisplayBox[i]->GetDisplayBoxId();
372 if (boxId == displayBoxId)
375 ChangeInputPadStyle(boxId);
381 const _DateTimeDisplayBox*
382 _DateTimePresenter::GetDisplayBox(int index) const
384 return __pDisplayBox[index];
387 const _DateTimeDisplayBox*
388 _DateTimePresenter::GetAmPmBox(void) const
394 _DateTimePresenter::Draw(void)
396 result r = E_SUCCESS;
398 _VisualElement* pVisualElement = null;
399 Canvas* pCanvas = null;
400 Color backgroundColor;
402 pVisualElement = __pView->GetDisplayVisualElement();
404 SysTryReturn(NID_UI_CTRL, (pVisualElement != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
406 pCanvas = pVisualElement->GetCanvasN();
408 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
411 GET_COLOR_CONFIG(DATETIMEPICKER::BG_NORMAL, backgroundColor);
412 __pView->SetBackgroundColor(backgroundColor);
414 // Draw DisplayBox Background
415 pCanvas->SetBackgroundColor(backgroundColor);
418 DrawDividers(*pCanvas);
420 for (int i = 0; i < __outputBoxMaxCount; i++)
422 DrawDateTimeDisplayBox(*pCanvas, i);
425 if ((__pickerStyle & DATETIME_OUTPUT_STYLE_DATE) && (__pickerStyle & DATETIME_OUTPUT_STYLE_TIME))
430 else if (__pickerStyle & DATETIME_OUTPUT_STYLE_TIME)
436 if (likely(_AccessibilityManager::IsActivated()))
438 SetAccessibilityElementText();
447 _DateTimePresenter::SetFont(Font* pFont)
449 result r = E_SUCCESS;
457 GET_SHAPE_CONFIG(DATETIMEPICKER::FONT_SIZE, __pView->GetOrientation(), fontSize);
459 r = _FontImpl::GetInstance(*pFont)->SetStyle(FONT_STYLE_PLAIN);
460 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating.");
462 r = _FontImpl::GetInstance(*pFont)->SetSize(fontSize);
463 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating.");
465 for (int i = 0; i < DATETIME_ID_MAX; i++)
467 if (__pDisplayBox[i] != null)
469 __pDisplayBox[i]->SetFont(pFont);
473 if (__pPmBox != null)
475 __pPmBox->SetFont(pFont);
478 if (__pInputPad != null)
480 __pInputPad->SetFont(pFont);
487 _DateTimePresenter::OnChangeLayout(_ControlOrientation orientation)
489 result r = E_SUCCESS;
490 Rectangle inputPadBounds(0, 0, 0, 0);
491 Rectangle pickerBounds(0, 0, 0, 0);
493 pickerBounds = __pView->GetBounds();
495 UpdateDateTimeOutputConfig();
497 inputPadBounds.x = 0;
499 GET_SHAPE_CONFIG(DATETIMEPICKER::INPUTPAD_HEIGHT, orientation, inputPadBounds.height);
501 inputPadBounds.width = pickerBounds.width;
502 inputPadBounds.y = pickerBounds.height - inputPadBounds.height;
504 if (__pInputPad != null)
506 r = __pInputPad->SetBounds(inputPadBounds);
507 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
512 _DateTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
514 if (__pView != &source)
519 int touchedAreaId = CalculateTouchArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
521 if (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM)
523 __isPmButtonPressed = true;
528 __selectedBoxIndex = CalculateTouchOutputArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
530 if (__selectedBoxIndex != -1 && __selectedBoxIndex != __focusedBoxIndex)
532 result r = E_SUCCESS;
533 _VisualElement* pVisualElement = null;
534 Canvas* pCanvas = null;
536 pVisualElement = __pView->GetDisplayVisualElement();
538 SysTryReturn(NID_UI_CTRL, (pVisualElement != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
540 pCanvas = pVisualElement->GetCanvasN();
542 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
544 DrawDateTimeDisplayBox(*pCanvas, __selectedBoxIndex);
557 _DateTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
559 if (__pView != &source)
568 _DateTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
570 result r = E_SUCCESS;
572 if (__pView != &source)
577 int touchedAreaId = CalculateTouchArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
579 if (__isPmButtonPressed == true)
581 if (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM)
586 __inputComposing = DATETIME_INPUT_END;
587 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
588 __isPmButtonPressed = false;
594 if ((touchedAreaId == DATETIME_AREA_NONE) || (touchedAreaId == DATETIME_AREA_INPUT) ||
595 (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM))
597 __selectedBoxIndex = -1;
598 __isPmButtonPressed = false;
604 int newOutputFocusedIndex = -1;
606 if (touchedAreaId == DATETIME_AREA_OUTPUT)
608 newOutputFocusedIndex = CalculateTouchOutputArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
609 if ((newOutputFocusedIndex == (-1)) || (newOutputFocusedIndex == __focusedBoxIndex))
611 __selectedBoxIndex = -1;
617 if (newOutputFocusedIndex == __selectedBoxIndex)
619 for (int i = 0; i < __outputBoxMaxCount; i++)
621 AdjustDisplayValue(i);
624 SetFocusBox(newOutputFocusedIndex);
627 _VisualElement* pVisualElement = null;
628 Canvas* pCanvas = null;
630 pVisualElement = __pView->GetDisplayVisualElement();
632 SysTryReturn(NID_UI_CTRL, (pVisualElement != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
634 pCanvas = pVisualElement->GetCanvasN();
636 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
638 DrawDateTimeDisplayBox(*pCanvas, __focusedBoxIndex);
642 __selectedBoxIndex = -1;
643 __inputComposing = DATETIME_INPUT_END;
644 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
646 int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
647 ChangeInputPadStyle(boxId);
658 _DateTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
660 if (__pView != &source)
665 __selectedBoxIndex = -1;
666 __isPmButtonPressed = false;
667 __inputComposing = DATETIME_INPUT_END;
668 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
676 _DateTimePresenter::OnInputPadValueChanged(const _Control& source, int inputPadReturnValue)
678 if ((__inputPadEnabled == false) || (inputPadReturnValue == -1))
683 int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
684 int currentNumber = GetNumberInBox(boxId);
687 if (boxId == DATETIME_ID_YEAR)
689 __changeFocusCounter++;
691 if (__isFocusBoxChanged == true)
693 newNumber = inputPadReturnValue;
694 __isFocusBoxChanged = false;
698 newNumber = SetFourDigit(currentNumber, inputPadReturnValue);
701 __inputComposing = DATETIME_INPUT_BEGIN;
702 SetNumberInBox(boxId, newNumber);
707 GetYearRange(min, max);
709 if ((newNumber >= max) || (newNumber > DATETIME_THREE_DIGIT_MAX) || __changeFocusCounter == DATE_TIME_CHANGE_FOCUS_COUNTER_MAX)
714 else if (boxId == DATETIME_ID_MONTH)
716 newNumber = inputPadReturnValue;
717 __inputComposing = DATETIME_INPUT_BEGIN;
719 SetNumberInBox(boxId, newNumber);
724 __changeFocusCounter++;
726 if (__isFocusBoxChanged == true)
728 newNumber = inputPadReturnValue;
729 __isFocusBoxChanged = false;
733 newNumber = SetTwoDigit(currentNumber, inputPadReturnValue);
736 __inputComposing = DATETIME_INPUT_BEGIN;
738 SetNumberInBox(boxId, newNumber);
740 if (newNumber > DATETIME_ONE_DIGIT_MAX || __changeFocusCounter == DATE_TIME_CHANGE_FOCUS_COUNTER_MAX / 2)
750 _DateTimePresenter::OnActionPerformed(const _Control& source, int actionId)
752 result r = E_SUCCESS;
759 if (actionId != DATETIME_EVENT_ID_SAVE && actionId != DATETIME_EVENT_ID_CANCEL )
766 __inputComposing = DATETIME_INPUT_END;
767 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
768 __focusedBoxIndex = 0;
770 int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
772 SetFocusBoxId(boxId);
775 if (actionId == DATETIME_EVENT_ID_SAVE)
777 for (int i = 0; i < __outputBoxMaxCount; i++)
779 AdjustDisplayValue(i);
784 switch (__pickerStyle)
786 case DATETIME_OUTPUT_STYLE_DATE:
787 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
788 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
790 r = __pView->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_SAVED, dateTime);
791 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change saved.");
794 case DATETIME_OUTPUT_STYLE_TIME:
795 r = dateTime.SetValue(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
796 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
798 r = __pView->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED, dateTime);
799 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change saved.");
802 case DATETIME_OUTPUT_STYLE_DATETIME:
803 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
804 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
806 r = __pView->FireDateTimeChangeEvent(DATETIME_INTERNAL_CHANGE_SAVED, dateTime);
807 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change saved.");
814 else if (actionId == DATETIME_EVENT_ID_CANCEL)
818 switch (__pickerStyle)
820 case DATETIME_OUTPUT_STYLE_DATE:
821 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
822 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
824 r = __pView->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_CANCELED, dateTime);
825 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change canceled.");
828 case DATETIME_OUTPUT_STYLE_TIME:
829 r = dateTime.SetValue(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
830 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
832 r = __pView->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_CANCELED, dateTime);
833 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change canceled.");
836 case DATETIME_OUTPUT_STYLE_DATETIME:
837 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
838 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
840 r = __pView->FireDateTimeChangeEvent(DATETIME_INTERNAL_CHANGE_CANCELED, dateTime);
841 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change canceled.");
851 _DateTimePresenter::UpdateDateTimeOutputConfig(void)
853 _ControlOrientation orientation = __pView->GetOrientation();
854 _DateTimeDisplayBox* pPmBox = null;
855 _DateTimeDisplayBox* pDisplayBox[DATETIME_ID_MAX];
857 Rectangle outputAreaBounds(0, 0, 0, 0);
858 Rectangle dateBounds(0, 0, 0, 0);
859 Rectangle monthBounds(0, 0, 0, 0);
860 Rectangle yearBounds(0, 0, 0, 0);
861 Rectangle hourBounds(0, 0, 0, 0);
862 Rectangle minuteBounds(0, 0, 0, 0);
863 Rectangle amPmBounds(0, 0, 0, 0);
867 int dateElementWidth = 0;
868 int displayBoxHeight = 0;
869 int dateTimeElementY = 0;
870 int dividerMargin = 0;
871 int dateTimeMargin = 0;
873 int timeOutputMargin = 0;
874 int timeElementWidth = 0;
880 for (indexBox = 0; indexBox < DATETIME_ID_MAX; indexBox++)
882 pDisplayBox[indexBox] = null;
885 outputAreaBounds = GetOutputArea();
886 __pView->SetDisplayVisualElementBounds(outputAreaBounds);
888 GET_FIXED_VALUE_CONFIG(DATETIMEPICKER::DIVIDER_WIDTH, orientation, dividerMargin);
889 GET_SHAPE_CONFIG(DATETIMEPICKER::DATE_ELEMENT_WIDTH, orientation, dateElementWidth);
890 GET_SHAPE_CONFIG(DATETIMEPICKER::DISPLAY_BOX_HEIGHT, orientation, displayBoxHeight);
891 GET_SHAPE_CONFIG(DATETIMEPICKER::DATE_TIME_MARGIN, orientation, dateTimeMargin);
892 GET_SHAPE_CONFIG(DATETIMEPICKER::LEFT_MARGIN, orientation, leftMargin);
893 GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_OUTPUT_MARGIN, orientation, timeOutputMargin);
894 GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_ELEMENT_WIDTH, orientation, timeElementWidth);
895 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_WIDTH, orientation, colonWidth);
896 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_MARGIN, orientation, colonMargin);
897 GET_SHAPE_CONFIG(DATETIMEPICKER::AMPM_WIDTH, orientation, amPmWidth);
898 GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_AMPM_MARGIN, orientation, amPmMargin);
900 dateTimeElementY = (outputAreaBounds.height - displayBoxHeight) / 2;
902 dateBounds.width = monthBounds.width = yearBounds.width = dateElementWidth;
903 hourBounds.width = minuteBounds.width = timeElementWidth;
904 amPmBounds.width = amPmWidth;
906 dateBounds.height = monthBounds.height = yearBounds.height = hourBounds.height = minuteBounds.height = amPmBounds.height = displayBoxHeight;
907 dateBounds.y = monthBounds.y = yearBounds.y = hourBounds.y = minuteBounds.y = amPmBounds.y = dateTimeElementY;
909 if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATE || __pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
911 switch (GetLocaleDateFormat())
913 case DATE_FORMAT_DDMMYYYY:
915 dateBounds.x = leftMargin;
916 monthBounds.x = dateBounds.x + dateBounds.width + dividerMargin;
917 yearBounds.x = monthBounds.x + monthBounds.width + dividerMargin;
918 hourBounds.x = yearBounds.x + yearBounds.width + dateTimeMargin;
921 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
922 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
927 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
928 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
933 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
934 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
939 case DATE_FORMAT_MMDDYYYY:
941 monthBounds.x = leftMargin;
942 dateBounds.x = monthBounds.x + monthBounds.width + dividerMargin;
943 yearBounds.x = dateBounds.x + dateBounds.width + dividerMargin;
944 hourBounds.x = yearBounds.x + yearBounds.width + dateTimeMargin;
947 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
948 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
953 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
954 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
959 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
960 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
965 case DATE_FORMAT_YYYYMMDD:
967 yearBounds.x = leftMargin;
968 monthBounds.x = yearBounds.x + yearBounds.width + dividerMargin;
969 dateBounds.x = monthBounds.x + monthBounds.width + dividerMargin;
970 hourBounds.x = dateBounds.x + dateBounds.width + dateTimeMargin;
973 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
974 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
979 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
980 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
985 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
986 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
991 case DATE_FORMAT_YYYYDDMM:
993 yearBounds.x = leftMargin;
994 dateBounds.x = yearBounds.x + yearBounds.width + dividerMargin;
995 monthBounds.x = dateBounds.x + dateBounds.width + dividerMargin;
996 hourBounds.x = monthBounds.x + monthBounds.width + dateTimeMargin;
999 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
1000 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1005 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
1006 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1011 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
1012 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1020 if (__pickerStyle == DATETIME_OUTPUT_STYLE_TIME || __pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
1022 if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
1024 minuteBounds.x = hourBounds.x + hourBounds.width + colonWidth;
1025 amPmBounds.x = minuteBounds.x + minuteBounds.width + amPmMargin;
1029 hourBounds.x = dateTimeMargin + leftMargin + timeOutputMargin;
1030 minuteBounds.x = hourBounds.x + hourBounds.width + colonWidth + 2 * colonMargin;
1031 amPmBounds.x = minuteBounds.x + minuteBounds.width + amPmMargin;
1035 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(hourBounds, DATETIME_ID_HOUR);
1036 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1041 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(minuteBounds, DATETIME_ID_MINUTE);
1042 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1047 if (__is24HourNotation == false)
1049 pPmBox = new (std::nothrow) _DateTimeDisplayBox(amPmBounds, DATETIME_ID_AMPM);
1050 SysTryCatch(NID_UI_CTRL, (pPmBox != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1052 pPmBox->SetBackgroundBitmap(__pPmBoxNormalBitmap, __pPmBoxEffectBitmap, __pPmBoxPressedEffectBitmap, __pPmBoxDisabledEffectBitmap);
1059 __outputBoxMaxCount = boxCount;
1061 for (indexBox = 0; indexBox < DATETIME_ID_MAX; indexBox++)
1063 delete __pDisplayBox[indexBox];
1064 __pDisplayBox[indexBox] = pDisplayBox[indexBox];
1072 for (int i = 0; i < DATETIME_ID_MAX; i++)
1074 delete pDisplayBox[i];
1075 pDisplayBox[i] = null;
1082 _DateTimePresenter::LoadResource(void)
1085 result r = E_SUCCESS;
1086 Bitmap* pColonBitmap = null;
1088 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pPmBoxNormalBitmap);
1089 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1091 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPmBoxEffectBitmap);
1092 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1094 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_PRESSED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPmBoxPressedEffectBitmap);
1095 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1097 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_DISABLED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPmBoxDisabledEffectBitmap);
1098 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1100 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pColonBitmap);
1101 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1103 GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_NORMAL, colonColor);
1105 __pColonBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pColonBitmap, Color::GetColor(COLOR_ID_WHITE), colonColor);
1106 r = GetLastResult();
1107 SysTryCatch(NID_UI_CTRL, (__pColonBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1109 delete pColonBitmap;
1114 delete __pPmBoxNormalBitmap;
1115 __pPmBoxNormalBitmap = null;
1117 delete __pPmBoxEffectBitmap;
1118 __pPmBoxEffectBitmap = null;
1120 delete __pPmBoxPressedEffectBitmap;
1121 __pPmBoxPressedEffectBitmap = null;
1123 delete __pPmBoxDisabledEffectBitmap;
1124 __pPmBoxDisabledEffectBitmap = null;
1126 delete __pColonBitmap;
1127 __pColonBitmap = null;
1129 delete pColonBitmap;
1135 _DateTimePresenter::DrawColon(Canvas& canvas)
1137 result r = E_SUCCESS;
1138 _ControlOrientation orientation = __pView->GetOrientation();
1140 Rectangle hourBounds(0, 0, 0, 0);
1141 Rectangle colonBounds(0, 0, 0, 0);
1144 int colonMargin = 0;
1146 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_WIDTH, orientation, colonWidth);
1147 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_MARGIN, orientation, colonMargin);
1149 for (int i = 0; i < __outputBoxMaxCount; i++)
1151 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_HOUR)
1153 hourBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
1157 colonBounds.x = hourBounds.x + hourBounds.width;
1158 colonBounds.y = hourBounds.y;
1159 colonBounds.width = colonWidth;
1160 colonBounds.height = hourBounds.height;
1162 if (__pickerStyle == DATETIME_OUTPUT_STYLE_TIME)
1164 colonBounds.x += colonMargin;
1167 if (__pColonBitmap != null)
1169 r = canvas.DrawBitmap(colonBounds, *__pColonBitmap);
1170 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1175 _DateTimePresenter::DrawDateTimeDisplayBox(Canvas& canvas, int index)
1177 result r = E_SUCCESS;
1180 int boxId = __pDisplayBox[index]->GetDisplayBoxId();
1181 number = GetNumberInBox(boxId);
1182 DateTimePickerStatus status = DATETIME_STATUS_NORMAL;
1184 if (__pView->IsEnabled() == false)
1186 status = DATETIME_STATUS_DISABLED;
1188 else if (index == __selectedBoxIndex)
1190 status = DATETIME_STATUS_SELECTED;
1192 else if (index == __focusedBoxIndex)
1194 status = DATETIME_STATUS_FOCUSED;
1197 if (boxId == DATETIME_ID_YEAR)
1199 if ((__inputComposing == DATETIME_INPUT_BEGIN) && (status == DATETIME_STATUS_FOCUSED))
1201 String length = L"%0d";
1203 r = length.Insert(__changeFocusCounter,2);
1204 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1206 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, length.GetPointer(), number);
1207 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1211 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%04d", number);
1212 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1215 else if (boxId == DATETIME_ID_MONTH)
1217 if (__pInputPad != null)
1220 _DateTimeUtils dateTimeUtils;
1221 text = dateTimeUtils.GetMonthString(number);
1225 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%02d", number);
1226 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1231 if ((__inputComposing == DATETIME_INPUT_BEGIN) && (status == DATETIME_STATUS_FOCUSED))
1233 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%d", number);
1234 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1238 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%02d", number);
1239 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1243 __pDisplayBox[index]->SetText(text);
1244 __pDisplayBox[index]->DrawDisplayBox(canvas, status);
1250 _DateTimePresenter::DrawPm(Canvas& canvas)
1254 if ((__is24HourNotation == true) || (__pPmBox == null))
1259 if (__isPm == false)
1261 GET_STRING_CONFIG(IDS_COM_BODY_AM, text);
1265 GET_STRING_CONFIG(IDS_COM_POP_PM, text);
1268 __pPmBox->SetText(text);
1270 if (__pView->IsEnabled() == false)
1272 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_DISABLED);
1274 else if (__isPmButtonPressed == true)
1276 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_SELECTED);
1280 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_NORMAL);
1285 _DateTimePresenter::DrawDividers(Canvas& canvas)
1287 result r = E_SUCCESS;
1288 int dividerWidth = 0;
1289 int dividerHeight = 0;
1290 Point lineStart(0,0);
1292 Color colorHalfLeft;
1293 Color colorHalfRight;
1295 _ControlOrientation orientation = __pView->GetOrientation();
1297 GET_FIXED_VALUE_CONFIG(DATETIMEPICKER::DIVIDER_WIDTH, orientation, dividerWidth);
1298 GET_SHAPE_CONFIG(DATETIMEPICKER::DIVIDER_HEIGHT, orientation, dividerHeight);
1300 GET_COLOR_CONFIG(DATETIMEPICKER::DIVIDER_LEFT_HALF, colorHalfLeft);
1301 GET_COLOR_CONFIG(DATETIMEPICKER::DIVIDER_RIGHT_HALF, colorHalfRight);
1303 lineStart.y = (GetOutputArea().height - dividerHeight) / 2;
1304 lineEnd.y = lineStart.y + dividerHeight;
1306 canvas.SetLineWidth(dividerWidth/2);
1308 for (int i = 0; i < __outputBoxMaxCount; i++)
1310 bool isDrawDivider = false;
1312 if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
1314 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_DAY ||
1315 __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_MONTH ||
1316 __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_YEAR)
1318 isDrawDivider = true;
1321 else if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATE)
1323 if (GetLocaleDateFormat() == DATE_FORMAT_YYYYMMDD)
1325 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_YEAR ||
1326 __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_MONTH)
1328 isDrawDivider = true;
1331 else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYDDMM)
1333 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_YEAR ||
1334 __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_DAY)
1336 isDrawDivider = true;
1341 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_MONTH ||
1342 __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_DAY)
1344 isDrawDivider = true;
1351 lineStart.x = __pDisplayBox[i]->GetDisplayBoxBounds().x + __pDisplayBox[i]->GetDisplayBoxBounds().width;
1352 lineEnd.x = lineStart.x;
1354 canvas.SetForegroundColor(colorHalfLeft);
1355 r = canvas.DrawLine(lineStart, lineEnd);
1356 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1358 lineStart.x += dividerWidth/2;
1359 lineEnd.x = lineStart.x;
1361 canvas.SetForegroundColor(colorHalfRight);
1362 r = canvas.DrawLine(lineStart, lineEnd);
1363 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1371 _DateTimePresenter::GetOutputArea(void)
1373 _ControlOrientation orientation = __pView->GetOrientation();
1375 Rectangle outputArea(0, 0, 0, 0);
1376 Rectangle headerBounds = __pView->GetHeaderBounds();
1379 GET_SHAPE_CONFIG(DATETIMEPICKER::TOP_MARGIN, orientation, margin);
1381 outputArea.y = headerBounds.y + headerBounds.height + margin;
1382 outputArea.width = __pView->GetBounds().width;
1384 GET_SHAPE_CONFIG(DATETIMEPICKER::OUTPUT_AREA_HEIGHT, orientation, outputArea.height);
1390 _DateTimePresenter::ChangeInputPadStyle(int boxId)
1392 if (__inputPadEnabled == false)
1397 SysTryReturnVoidResult(NID_UI_CTRL, __pInputPad != null, E_SYSTEM,
1398 "[E_SYSTEM] A system error has occurred. The instance of Inputpad is null.");
1400 _InputPadStyle inputPadType = INPUTPAD_STYLE_NORMAL;
1403 case DATETIME_ID_MONTH:
1404 inputPadType = INPUTPAD_STYLE_ALPHA;
1407 case DATETIME_ID_YEAR:
1408 // fall through intentional
1409 case DATETIME_ID_DAY:
1410 // fall through intentional
1411 case DATETIME_ID_HOUR:
1412 // fall through intentional
1413 case DATETIME_ID_MINUTE:
1414 // fall through intentional
1416 inputPadType = INPUTPAD_STYLE_NORMAL;
1420 if (__inputPadType == inputPadType)
1424 __inputPadType = inputPadType;
1426 __pInputPad->SetInputPadStyle(inputPadType);
1427 result r = GetLastResult();
1428 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1432 _DateTimePresenter::CalculateTouchArea(int posX, int posY)
1434 _ControlOrientation orientation = __pView->GetOrientation();
1435 Rectangle outputArea = GetOutputArea();
1439 GET_SHAPE_CONFIG(DATETIMEPICKER::TOP_MARGIN, orientation, margin);
1441 if ((posX < outputArea.x) || (posY < outputArea.y))
1443 return DATETIME_AREA_NONE;
1446 int touched = DATETIME_AREA_NONE;
1448 if (posY < outputArea.y + outputArea.height)
1451 GET_SHAPE_CONFIG(DATETIMEPICKER::DISPLAY_BOX_HEIGHT, orientation, boxHeight);
1453 int boxPosY = outputArea.y + ((outputArea.height - boxHeight) / 2);
1455 if ((posY >= boxPosY) && (posY <= boxPosY + boxHeight))
1458 touched = DATETIME_AREA_OUTPUT;
1460 if (__pPmBox != null)
1462 Rectangle boxBounds = __pPmBox->GetDisplayBoxBounds();
1464 boxBounds.y = outputArea.y + ((outputArea.height - boxBounds.height) / 2);
1466 if ((posX >= boxBounds.x) && (posX < boxBounds.x + boxBounds.width)
1467 && (posY >= boxBounds.y) && (posY < boxBounds.y + boxBounds.height))
1469 touched = DATETIME_AREA_OUTPUT_AMPM;
1476 touched = DATETIME_AREA_INPUT;
1483 _DateTimePresenter::CalculateTouchOutputArea(int posX, int posY)
1485 Rectangle outputArea = GetOutputArea();
1487 for (int i = 0; i < __outputBoxMaxCount; i++)
1489 Rectangle boxBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
1491 boxBounds.y = outputArea.y + ((outputArea.height - boxBounds.height) / 2);
1493 if ((posX >= boxBounds.x) && (posX < boxBounds.x + boxBounds.width)
1494 && (posY >= boxBounds.y) && (posY < boxBounds.y + boxBounds.height))
1504 _DateTimePresenter::CalculateTwoDigit(int originalNumber, int number)
1506 int twoDigit = (originalNumber * 10) + number;
1513 if ((twoDigit > 0) && (twoDigit > DATETIME_TWO_DIGIT_MAX))
1515 twoDigit = twoDigit % (DATETIME_TWO_DIGIT_MAX + 1);
1522 _DateTimePresenter::CalculateFourDigit(int originalNumber, int number)
1524 int fourDigit = (originalNumber * 10) + number;
1531 if ((fourDigit > 0) && (fourDigit > DATETIME_FOUR_DIGIT_MAX))
1533 fourDigit = fourDigit % (DATETIME_FOUR_DIGIT_MAX + 1);
1539 _DateTimePresenter::SetTwoDigit(int originalNumber, int number)
1543 if ((originalNumber <= DATETIME_ONE_DIGIT_MAX) && (__inputComposing == DATETIME_INPUT_BEGIN))
1545 twoDigit = (originalNumber * 10) + number;
1555 _DateTimePresenter::SetFourDigit(int originalNumber, int number)
1561 GetYearRange(minYear, maxYear);
1562 if ((originalNumber <= DATETIME_THREE_DIGIT_MAX) && (__inputComposing == DATETIME_INPUT_BEGIN))
1564 fourDigit = (originalNumber * 10) + number;
1565 if (fourDigit > maxYear)
1567 fourDigit = maxYear;
1579 _DateTimePresenter::SetNumberInBox(int boxId, int number)
1583 case DATETIME_ID_YEAR:
1587 case DATETIME_ID_MONTH:
1591 case DATETIME_ID_DAY:
1595 case DATETIME_ID_HOUR:
1599 case DATETIME_ID_MINUTE:
1609 _DateTimePresenter::GetNumberInBox(int boxId) const
1615 case DATETIME_ID_YEAR:
1619 case DATETIME_ID_MONTH:
1623 case DATETIME_ID_DAY:
1627 case DATETIME_ID_HOUR:
1631 case DATETIME_ID_MINUTE:
1643 _DateTimePresenter::SetFocusBox(int index)
1645 __focusedBoxIndex = index;
1646 __isFocusBoxChanged = true;
1650 _DateTimePresenter::LoadPickerData(void)
1653 __month = GetMonth();
1657 if (__is24HourNotation == false)
1659 int max = DATETIME_HOUR_MAX_FOR_24NOTATION;
1661 if (__hour == DATETIME_HOUR_MIN)
1663 __hour = __hour + max;
1666 else if (__hour < max && __hour != DATETIME_HOUR_MIN)
1670 else if (__hour == max)
1674 else if (__hour > max && __hour <= DATETIME_HOUR_MAX)
1676 __hour = __hour - max;
1679 else if (__hour == DATETIME_HOUR_MAX + 1)
1685 __minute = GetMinute();
1689 _DateTimePresenter::SavePickerData(void)
1695 if (__is24HourNotation == false)
1697 int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION;
1701 if (__hour < maxHour)
1703 SetHour(__hour + maxHour);
1712 if (__hour < maxHour)
1718 SetHour(__hour - maxHour);
1727 SetMinute(__minute);
1731 _DateTimePresenter::UpdateDisplayData(int boxId)
1735 case DATETIME_ID_YEAR:
1739 case DATETIME_ID_MONTH:
1740 __month = GetMonth();
1743 case DATETIME_ID_DAY:
1747 case DATETIME_ID_HOUR:
1750 if (__is24HourNotation == false)
1752 int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION;
1754 if (__hour == DATETIME_HOUR_MIN)
1759 else if (__hour < maxHour && __hour != DATETIME_HOUR_MIN)
1763 else if (__hour == maxHour)
1767 else if (__hour > maxHour && __hour <= DATETIME_HOUR_MAX)
1769 __hour = __hour - maxHour;
1772 else if (__hour == DATETIME_HOUR_MAX + 1)
1774 __hour = __hour - maxHour;
1780 case DATETIME_ID_MINUTE:
1781 __minute = GetMinute();
1790 _DateTimePresenter::AdjustValue(int& value, int minValue, int maxValue)
1792 if (value < minValue)
1796 else if (maxValue < value)
1803 _DateTimePresenter::AdjustDisplayValue(int index)
1805 int boxId = __pDisplayBox[index]->GetDisplayBoxId();
1806 _DateTimeUtils dateTimeUtils;
1812 case DATETIME_ID_YEAR:
1815 GetYearRange(minValue, maxValue);
1816 AdjustValue(__year, minValue, maxValue);
1819 case DATETIME_ID_MONTH:
1820 minValue = DATETIME_MONTH_MIN;
1821 maxValue = DATETIME_MONTH_MAX;
1822 AdjustValue(__month, minValue, maxValue);
1825 case DATETIME_ID_DAY:
1827 maxValue = dateTimeUtils.CalculateMaxDay(__year, __month);
1828 AdjustValue(__day, minValue, maxValue);
1831 case DATETIME_ID_HOUR:
1832 minValue = DATETIME_HOUR_MIN;
1833 maxValue = DATETIME_HOUR_MAX;
1834 if (__is24HourNotation == false)
1836 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1838 if(__hour == DATETIME_HOUR_MIN)
1840 minValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1843 AdjustValue(__hour, minValue, maxValue);
1846 case DATETIME_ID_MINUTE:
1847 minValue = DATETIME_MINUTE_MIN;
1848 maxValue = DATETIME_MINUTE_MAX;
1849 AdjustValue(__minute, minValue, maxValue);
1858 _DateTimePresenter::ChangeFocusBox(void)
1860 if (__focusedBoxIndex < (__outputBoxMaxCount - 1))
1862 __focusedBoxIndex++;
1863 int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
1864 ChangeInputPadStyle(boxId);
1865 __isFocusBoxChanged = true;
1868 for (int i = 0; i < __outputBoxMaxCount; i++)
1870 AdjustDisplayValue(i);
1873 __inputComposing = DATETIME_INPUT_END;
1874 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
1878 _DateTimePresenter::GetLocaleDateFormat(void) const
1880 int localeDateFormat = -1;
1881 int error = vconf_get_int(VCONFKEY_SETAPPL_DATE_FORMAT_INT, &localeDateFormat);
1884 localeDateFormat = SETTING_DATE_FORMAT_DD_MM_YYYY;
1887 return localeDateFormat;
1891 _DateTimePresenter::SetAccessibilityElementText(void)
1893 for (int index = 0; index < __outputBoxMaxCount; ++index)
1895 if (__pDisplayBox[index]->GetDisplayBoxId() == DATETIME_ID_MONTH)
1897 int number = GetNumberInBox(__pDisplayBox[index]->GetDisplayBoxId());
1898 __pView->SetAccessibilityElementText(index, __pInputPad->GetAccessebilityElementMonthName(number-1), false);
1902 __pView->SetAccessibilityElementText(index, __pDisplayBox[index]->GetText(), false);
1908 __pView->SetAccessibilityElementText(__outputBoxMaxCount, __pPmBox->GetText(), true);
1912 }}} // Tizen::Ui::Controls