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.cpp
20 * @brief This is the implementation file for the _DateTimePresenter class.
23 #include <FSysSettingInfo.h>
24 #include <FBaseErrorDefine.h>
25 #include <FBaseSysLog.h>
26 #include <FGrp_TextTextObject.h>
27 #include <FGrp_CanvasImpl.h>
28 #include <FGrp_BitmapImpl.h>
29 #include "FUi_ResourceManager.h"
30 #include "FUiAnim_VisualElement.h"
31 #include "FUiCtrl_DateTimePresenter.h"
32 #include "FUiCtrl_InputPad.h"
33 #include "FUiCtrl_DateTimeDefine.h"
34 #include "FUiCtrl_DateTimeModel.h"
35 #include "FUiCtrl_DateTimeDisplayBox.h"
36 #include "FUiCtrl_DateTimePicker.h"
37 #include "FUiCtrl_DateTimeUtils.h"
38 #include "FUi_AccessibilityManager.h"
39 #include "FUi_CoordinateSystemUtils.h"
41 using namespace Tizen::Ui;
42 using namespace Tizen::Base;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Graphics::_Text;
45 using namespace Tizen::Ui::Animations;
46 using namespace Tizen::System;
48 namespace Tizen { namespace Ui { namespace Controls
50 const int DATETIME_DISPLAY_STRING_MAX_LENGTH = 10;
52 _DateTimePresenter::_DateTimePresenter(int pickerStyle, const String& title)
55 , __selectedBoxIndex(0)
56 , __focusedBoxIndex(0)
58 , __inputPadType(INPUTPAD_STYLE_NORMAL)
59 , __pickerStyle(pickerStyle)
60 , __inputPadEnabled(true)
61 , __outputBoxMaxCount(0)
67 , __is24HourNotation(false)
68 , __dtp24HourSet(false)
70 , __isPmButtonPressed(false)
71 , __isFocusBoxChanged(false)
72 , __inputComposing(DATETIME_INPUT_END)
73 , __changeFocusCounter(DATE_TIME_CHANGE_FOCUS_COUNTER_MIN)
75 , __pColonBitmap(null)
76 , __pColonDisabledBitmap(null)
77 , __pBgNormalBitmap(null)
78 , __pBgEffectBitmap(null)
81 , __keypadEnabled(false)
83 for (int i = 0; i < DATETIME_ID_MAX; i++)
85 __pDisplayBox[i] = null;
88 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
90 __pDisplayBoxNormalBitmap[i] = null;
91 __pDisplayBoxEffectBitmap[i] = null;
93 __pAmPmNormalBitmap[i] = null;
94 __pAmPmEffectBitmap[i] = null;
98 _DateTimePresenter::~_DateTimePresenter(void)
104 _DateTimePresenter::Dispose(void)
106 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
108 delete __pDisplayBoxNormalBitmap[i];
109 __pDisplayBoxNormalBitmap[i] = null;
111 delete __pDisplayBoxEffectBitmap[i];
112 __pDisplayBoxEffectBitmap[i] = null;
114 delete __pAmPmNormalBitmap[i];
115 __pAmPmNormalBitmap[i] = null;
117 delete __pAmPmEffectBitmap[i];
118 __pAmPmEffectBitmap[i] = null;
121 delete __pColonBitmap;
122 __pColonBitmap = null;
124 delete __pColonDisabledBitmap;
125 __pColonDisabledBitmap = null;
127 delete __pBgNormalBitmap;
128 __pBgNormalBitmap = null;
130 delete __pBgEffectBitmap;
131 __pBgEffectBitmap = null;
133 for (int i = 0; i < DATETIME_ID_MAX; i++)
135 delete __pDisplayBox[i];
136 __pDisplayBox[i] = null;
142 if ((__inputPadEnabled == true) && (__pInputPad != null))
144 __pView->DetachChild(*__pInputPad);
154 _DateTimePresenter::Construct(_DateTimePicker& view)
156 result r = E_SUCCESS;
159 _ControlOrientation orientation = __pView->GetOrientation();
161 __pFont = __pView->GetDateTimeFont();
162 SysTryReturnResult(NID_UI_CTRL, (__pFont != null), E_SYSTEM, "A system error has occurred. Failed to get the font.");
165 UpdateDateTimeOutputConfig();
167 FloatRectangle inputPadBounds(0.0f, 0.0f, 0.0f, 0.0f);
168 FloatRectangle pickerBounds(0.0f, 0.0f, 0.0f, 0.0f);
170 pickerBounds = __pView->GetBoundsF();
172 GET_SHAPE_CONFIG(DATETIMEPICKER::INPUTPAD_HEIGHT, orientation, inputPadBounds.height);
175 dim = CoordinateSystem::AlignToDevice(FloatDimension(pickerBounds.width, inputPadBounds.height));
176 inputPadBounds.height = dim.height;
178 inputPadBounds.x = 0.0f;
179 inputPadBounds.width = pickerBounds.width;
180 inputPadBounds.y = pickerBounds.height - inputPadBounds.height;
182 __pModel = new (std::nothrow) _DateTimeModel;
183 SysTryReturnResult(NID_UI_CTRL, (__pModel != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
185 // Load display data for sync with model data
189 if (__inputPadEnabled == true)
191 __pInputPad = new (std::nothrow) _InputPad;
192 SysTryCatch(NID_UI_CTRL, (__pInputPad != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
194 r = __pInputPad->Construct(inputPadBounds);
195 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
196 "[E_SYSTEM] A system error has occurred. Failed to construct the instance of Inputpad.");
198 r = __pView->AttachChild(*__pInputPad);
199 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
201 r = __pInputPad->SetInputPadEventListener(*this);
202 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
203 "[E_SYSTEM] A system error has occurred. Failed to set InputPadEventListener to the Inputpad.");
205 __pInputPad->SetInputPadStyle(INPUTPAD_STYLE_NORMAL);
207 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
208 "[E_SYSTEM] A system error has occurred. Failed to set InputPadStyle to the Inputpad.");
210 __pInputPad->SetFont(__pFont);
212 if (__pInputPad->IsFocusable() == true)
214 __pInputPad->SetFocusable(false);
217 _DateTimeDisplayBox* pDisplayBox = __pDisplayBox[__selectedBoxIndex];
218 SysTryCatch(NID_UI_CTRL, (pDisplayBox != null), , E_SYSTEM,
219 "[E_SYSTEM] A system error has occurred. Failed to get Display box.");
221 SetFocusBoxId(pDisplayBox->GetDisplayBoxId());
233 _DateTimePresenter::SetYear(int year)
235 result r = E_SUCCESS;
239 GetYearRange(minYear, maxYear);
245 else if (year > maxYear)
250 r = __pModel->SetYear(year);
254 UpdateDisplayData(DATETIME_ID_YEAR);
261 _DateTimePresenter::SetMonth(int month)
263 result r = __pModel->SetMonth(month);
267 UpdateDisplayData(DATETIME_ID_MONTH);
274 _DateTimePresenter::SetDay(int day)
276 result r = __pModel->SetDay(day);
280 UpdateDisplayData(DATETIME_ID_DAY);
287 _DateTimePresenter::SetHour(int hour)
289 result r = __pModel->SetHour(hour);
293 UpdateDisplayData(DATETIME_ID_HOUR);
300 _DateTimePresenter::SetMinute(int minute)
302 result r = __pModel->SetMinute(minute);
306 UpdateDisplayData(DATETIME_ID_MINUTE);
313 _DateTimePresenter::SetYearRange(int minYear, int maxYear)
315 __pModel->SetMinYear(minYear);
316 __pModel->SetMaxYear(maxYear);
322 _DateTimePresenter::GetYear(void) const
324 return __pModel->GetYear();
328 _DateTimePresenter::GetMonth(void) const
330 return __pModel->GetMonth();
334 _DateTimePresenter::GetDay(void) const
336 return __pModel->GetDay();
340 _DateTimePresenter::GetHour(void) const
342 return __pModel->GetHour();
346 _DateTimePresenter::GetMinute(void) const
348 return __pModel->GetMinute();
352 _DateTimePresenter::GetYearRange(int& minYear, int& maxYear) const
354 return __pModel->GetYearRange(minYear, maxYear);
358 _DateTimePresenter::Set24HourNotationEnabled(bool enable)
360 __is24HourNotation = enable;
361 __dtp24HourSet = true;
363 UpdateDateTimeOutputConfig();
367 _DateTimePresenter::Is24HourNotationEnabled(void) const
369 return __is24HourNotation;
373 _DateTimePresenter::SetCurrentDateTime(void)
375 __pModel->SetCurrentDateTime();
377 UpdateDisplayData(DATETIME_ID_YEAR);
378 UpdateDisplayData(DATETIME_ID_MONTH);
379 UpdateDisplayData(DATETIME_ID_DAY);
380 UpdateDisplayData(DATETIME_ID_HOUR);
381 UpdateDisplayData(DATETIME_ID_MINUTE);
385 _DateTimePresenter::SetDateTime(const DateTime& dateTime)
387 __pModel->SetDateTime(dateTime);
389 UpdateDisplayData(DATETIME_ID_YEAR);
390 UpdateDisplayData(DATETIME_ID_MONTH);
391 UpdateDisplayData(DATETIME_ID_DAY);
392 UpdateDisplayData(DATETIME_ID_HOUR);
393 UpdateDisplayData(DATETIME_ID_MINUTE);
397 _DateTimePresenter::GetDateTime(void) const
399 return __pModel->GetDateTime();
403 _DateTimePresenter::SetFocusBoxId(int boxId)
405 for (int i = 0; i < __outputBoxMaxCount; i++)
407 int displayBoxId = __pDisplayBox[i]->GetDisplayBoxId();
409 if (boxId == displayBoxId)
417 const _DateTimeDisplayBox*
418 _DateTimePresenter::GetDisplayBox(int index) const
420 return __pDisplayBox[index];
423 const _DateTimeDisplayBox*
424 _DateTimePresenter::GetAmPmBox(void) const
430 _DateTimePresenter::Draw(void)
432 result r = E_SUCCESS;
434 _VisualElement* pVisualElement = null;
435 Canvas* pCanvas = null;
436 Color backgroundColor;
438 pVisualElement = __pView->GetDisplayVisualElement();
440 SysTryReturn(NID_UI_CTRL, (pVisualElement != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
442 pCanvas = pVisualElement->GetCanvasN();
444 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
447 GET_COLOR_CONFIG(DATETIMEPICKER::BG_NORMAL, backgroundColor);
448 __pView->SetBackgroundColor(backgroundColor);
450 // Draw DisplayBox Background
451 DrawBackground(*pCanvas);
453 if (!__title.IsEmpty())
458 for (int i = 0; i < __outputBoxMaxCount; i++)
460 DrawDateTimeDisplayBox(*pCanvas, i);
463 if ((__pickerStyle & DATETIME_OUTPUT_STYLE_DATE) && (__pickerStyle & DATETIME_OUTPUT_STYLE_TIME))
465 DrawDividers(*pCanvas);
469 else if (__pickerStyle & DATETIME_OUTPUT_STYLE_TIME)
475 if (unlikely(_AccessibilityManager::IsActivated()))
477 SetAccessibilityElementText();
486 _DateTimePresenter::SetFont(Font* pFont)
488 result r = E_SUCCESS;
496 GET_SHAPE_CONFIG(DATETIMEPICKER::FONT_SIZE, __pView->GetOrientation(), fontSize);
498 r = _FontImpl::GetInstance(*pFont)->SetStyle(FONT_STYLE_PLAIN);
499 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating.");
501 r = _FontImpl::GetInstance(*pFont)->SetSize(fontSize);
502 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating.");
504 for (int i = 0; i < DATETIME_ID_MAX; i++)
506 if (__pDisplayBox[i] != null)
508 __pDisplayBox[i]->SetFont(pFont);
512 if (__pPmBox != null)
514 __pPmBox->SetFont(pFont);
517 if (__pInputPad != null)
519 __pInputPad->SetFont(pFont);
528 _DateTimePresenter::UpdateLocaleDateTimeFormat(void)
532 UpdateDateTimeOutputConfig();
536 for (int i = 0; i < __outputBoxMaxCount; i++)
538 AdjustDisplayValue(i);
545 _DateTimePresenter::UpdateTimeFormat(void)
549 String key(L"http://tizen.org/setting/locale.time.format.24hour");
550 SettingInfo::GetValue(key , __is24HourNotation);
557 _DateTimePresenter::OnChangeLayout(_ControlOrientation orientation)
559 result r = E_SUCCESS;
560 FloatRectangle inputPadBounds(0.0f, 0.0f, 0.0f, 0.0f);
561 FloatRectangle pickerBounds(0.0f, 0.0f, 0.0f, 0.0f);
563 pickerBounds = __pView->GetBoundsF();
565 UpdateDateTimeOutputConfig();
567 inputPadBounds.x = 0;
569 GET_SHAPE_CONFIG(DATETIMEPICKER::INPUTPAD_HEIGHT, orientation, inputPadBounds.height);
571 inputPadBounds.width = pickerBounds.width;
572 inputPadBounds.y = pickerBounds.height - inputPadBounds.height;
574 if (__pInputPad != null)
576 r = __pInputPad->SetBounds(inputPadBounds);
577 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
582 _DateTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
584 if (__pView != &source)
589 int touchedAreaId = CalculateTouchArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
591 if (touchedAreaId != DATETIME_AREA_INPUT)
593 __keypadEnabled = false;
596 if (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM)
598 __isPmButtonPressed = true;
599 __pView->Invalidate(true);
607 _DateTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
609 if (__pView != &source)
618 _DateTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
620 result r = E_SUCCESS;
622 if (__pView != &source)
627 int touchedAreaId = CalculateTouchArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
629 if (touchedAreaId != DATETIME_AREA_INPUT)
631 __keypadEnabled = false;
634 if (__isPmButtonPressed == true)
636 if (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM)
639 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
642 __inputComposing = DATETIME_INPUT_END;
643 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
644 __isPmButtonPressed = false;
645 __pView->Invalidate(true);
650 if ((touchedAreaId == DATETIME_AREA_NONE) || (touchedAreaId == DATETIME_AREA_INPUT) ||
651 (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM))
653 __isPmButtonPressed = false;
654 __pView->Invalidate(true);
659 int newOutputFocusedIndex = -1;
661 if (touchedAreaId == DATETIME_AREA_OUTPUT)
663 newOutputFocusedIndex = CalculateTouchOutputArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
665 if (newOutputFocusedIndex == (-1))
670 if (newOutputFocusedIndex == __selectedBoxIndex)
672 for (int i = 0; i < __outputBoxMaxCount; i++)
674 AdjustDisplayValue(i);
679 __selectedBoxIndex = newOutputFocusedIndex;
682 _VisualElement* pVisualElement = null;
683 Canvas* pCanvas = null;
685 pVisualElement = __pView->GetDisplayVisualElement();
687 SysTryReturn(NID_UI_CTRL, (pVisualElement != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
689 pCanvas = pVisualElement->GetCanvasN();
691 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
693 DrawDateTimeDisplayBox(*pCanvas, __selectedBoxIndex);
697 __inputComposing = DATETIME_INPUT_END;
698 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
700 int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
701 ChangeInputPadStyle(boxId);
703 __pView->Invalidate(true);
712 _DateTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
714 if (__pView != &source)
719 __isPmButtonPressed = false;
720 __inputComposing = DATETIME_INPUT_END;
721 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
723 __pView->Invalidate(true);
729 _DateTimePresenter::OnInputPadValueChanged(const _Control& source, int inputPadReturnValue)
731 HandleInputPadValueChange(inputPadReturnValue);
735 _DateTimePresenter::OnActionPerformed(const _Control& source, int actionId)
737 HandleSaveCancelAction(actionId);
741 _DateTimePresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
744 __keypadEnabled = true;
746 _KeyCode keyCode = keyInfo.GetKeyCode();
748 if (__focusedBoxIndex < __outputBoxMaxCount)
750 boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
752 if ((keyCode != _KEY_RIGHT) && (keyCode != _KEY_LEFT) && (boxId == DATETIME_ID_MONTH))
754 //month can be changed only with touch on input pad
763 if (__pickerStyle != DATETIME_OUTPUT_STYLE_DATE && __focusedBoxIndex < __outputBoxMaxCount)
766 SetFocusBox(__focusedBoxIndex);
768 else if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATE && __focusedBoxIndex < __outputBoxMaxCount-1)
771 SetFocusBox(__focusedBoxIndex);
781 if (__focusedBoxIndex > 0)
784 SetFocusBox(__focusedBoxIndex);
794 if (__focusedBoxIndex == __outputBoxMaxCount)
796 __isPmButtonPressed = true;
802 HandleInputPadValueChange(0);
806 HandleInputPadValueChange(1);
810 HandleInputPadValueChange(2);
814 HandleInputPadValueChange(3);
818 HandleInputPadValueChange(4);
822 HandleInputPadValueChange(5);
826 HandleInputPadValueChange(6);
830 HandleInputPadValueChange(7);
834 HandleInputPadValueChange(8);
838 HandleInputPadValueChange(9);
844 __pView->Invalidate(true);
849 _DateTimePresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
851 _KeyCode keyCode = keyInfo.GetKeyCode();
852 if (__isPmButtonPressed == true && keyCode == _KEY_ENTER)
855 __isPmButtonPressed = false;
856 __pView->Invalidate(true);
863 _DateTimePresenter::DrawFocus(void)
865 result r = E_SUCCESS;
866 __keypadEnabled = true;
867 __focusedBoxIndex = __selectedBoxIndex;
869 __pView->Invalidate(true);
874 _DateTimePresenter::ReleaseFocus(void)
876 result r = E_SUCCESS;
877 __keypadEnabled = false;
878 __focusedBoxIndex = 0;
879 __selectedBoxIndex = 0;
881 __pView->Invalidate(true);
886 _DateTimePresenter::HandleInputPadValueChange(int inputPadReturnValue)
888 if ((__inputPadEnabled == false) || (inputPadReturnValue == -1))
893 if ((__keypadEnabled == true) && (__pickerStyle != DATETIME_OUTPUT_STYLE_DATE) && (__focusedBoxIndex == __outputBoxMaxCount))
895 //in case of Am/Pm if keypad enabled, inputpad values need not be handled though in focus
899 int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
900 int currentNumber = GetNumberInBox(boxId);
903 if (boxId == DATETIME_ID_YEAR)
905 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_SIP);
906 __changeFocusCounter++;
908 if (__isFocusBoxChanged == true)
910 newNumber = inputPadReturnValue;
911 __isFocusBoxChanged = false;
915 newNumber = SetFourDigit(currentNumber, inputPadReturnValue);
918 __inputComposing = DATETIME_INPUT_BEGIN;
919 SetNumberInBox(boxId, newNumber);
924 GetYearRange(min, max);
926 if ((newNumber >= max) || (newNumber > DATETIME_THREE_DIGIT_MAX) || __changeFocusCounter == DATE_TIME_CHANGE_FOCUS_COUNTER_MAX)
931 else if (boxId == DATETIME_ID_MONTH)
933 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_SIP);
934 newNumber = inputPadReturnValue;
935 __inputComposing = DATETIME_INPUT_BEGIN;
937 SetNumberInBox(boxId, newNumber);
942 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_SIP);
943 __changeFocusCounter++;
945 if (__isFocusBoxChanged == true)
947 newNumber = inputPadReturnValue;
948 __isFocusBoxChanged = false;
952 newNumber = SetTwoDigit(currentNumber, inputPadReturnValue);
955 __inputComposing = DATETIME_INPUT_BEGIN;
957 SetNumberInBox(boxId, newNumber);
959 if (newNumber > DATETIME_ONE_DIGIT_MAX || __changeFocusCounter == DATE_TIME_CHANGE_FOCUS_COUNTER_MAX / 2)
965 __pView->Invalidate(true);
969 _DateTimePresenter::HandleSaveCancelAction(int actionId)
971 result r = E_SUCCESS;
978 if (actionId != DATETIME_EVENT_ID_SAVE && actionId != DATETIME_EVENT_ID_CANCEL )
985 __inputComposing = DATETIME_INPUT_END;
986 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
987 __focusedBoxIndex = 0;
988 __selectedBoxIndex = 0;
990 int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
992 SetFocusBoxId(boxId);
995 if (actionId == DATETIME_EVENT_ID_SAVE)
997 for (int i = 0; i < __outputBoxMaxCount; i++)
999 AdjustDisplayValue(i);
1004 switch (__pickerStyle)
1006 case DATETIME_OUTPUT_STYLE_DATE:
1007 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1008 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1010 r = __pView->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_SAVED, dateTime);
1011 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.");
1014 case DATETIME_OUTPUT_STYLE_TIME:
1015 r = dateTime.SetValue(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
1016 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1018 r = __pView->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED, dateTime);
1019 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.");
1022 case DATETIME_OUTPUT_STYLE_DATETIME:
1023 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
1024 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1026 r = __pView->FireDateTimeChangeEvent(DATETIME_INTERNAL_CHANGE_SAVED, dateTime);
1027 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.");
1034 else if (actionId == DATETIME_EVENT_ID_CANCEL)
1038 switch (__pickerStyle)
1040 case DATETIME_OUTPUT_STYLE_DATE:
1041 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1042 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1044 r = __pView->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_CANCELED, dateTime);
1045 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.");
1048 case DATETIME_OUTPUT_STYLE_TIME:
1049 r = dateTime.SetValue(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
1050 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1052 r = __pView->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_CANCELED, dateTime);
1053 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.");
1056 case DATETIME_OUTPUT_STYLE_DATETIME:
1057 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
1058 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1060 r = __pView->FireDateTimeChangeEvent(DATETIME_INTERNAL_CHANGE_CANCELED, dateTime);
1061 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.");
1071 _DateTimePresenter::UpdateDateTimeOutputConfig(void)
1073 _ControlOrientation orientation = __pView->GetOrientation();
1074 _DateTimeDisplayBox* pPmBox = null;
1075 _DateTimeDisplayBox* pDisplayBox[DATETIME_ID_MAX];
1077 FloatRectangle outputAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
1078 FloatRectangle dateBounds(0.0f, 0.0f, 0.0f, 0.0f);
1079 FloatRectangle monthBounds(0.0f, 0.0f, 0.0f, 0.0f);
1080 FloatRectangle yearBounds(0.0f, 0.0f, 0.0f, 0.0f);
1081 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
1082 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1083 FloatRectangle amPmBounds(0.0f, 0.0f, 0.0f, 0.0f);
1088 float dateTimeDisplayBoxHeight = 0.0f;
1089 float amPmDisplayBoxHeight = 0.0f;
1091 float dateTimeElementY = 0.0f;
1092 float amPmElementY = 0.0f;
1093 float dateElementGapWidth = 0.0f;
1094 float timeOutputMargin = 0.0f;
1095 float timeElementWidth = 0.0f;
1096 float colonWidth = 0.0f;
1097 float colonMargin = 0.0f;
1098 float amPmWidth = 0.0f;
1099 float amPmMargin = 0.0f;
1101 float dividerWidth = 0.0f;
1102 float dividerMargin = 0.0f;
1104 for (indexBox = 0; indexBox < DATETIME_ID_MAX; indexBox++)
1106 pDisplayBox[indexBox] = null;
1109 outputAreaBounds = GetOutputArea();
1110 __pView->SetDisplayVisualElementBounds(outputAreaBounds);
1112 GET_SHAPE_CONFIG(DATETIMEPICKER::DATE_ELEMENT_GAP_WIDTH, orientation, dateElementGapWidth);
1114 GET_SHAPE_CONFIG(DATETIMEPICKER::DATE_ELEMENT_WIDTH, orientation, dateBounds.width);
1115 GET_SHAPE_CONFIG(DATETIMEPICKER::MONTH_ELEMENT_WIDTH, orientation, monthBounds.width);
1116 GET_SHAPE_CONFIG(DATETIMEPICKER::YEAR_ELEMENT_WIDTH, orientation, yearBounds.width);
1118 GET_SHAPE_CONFIG(DATETIMEPICKER::DATETIME_DISPLAY_BOX_HEIGHT, orientation, dateTimeDisplayBoxHeight);
1119 GET_SHAPE_CONFIG(DATETIMEPICKER::AMPM_DISPLAY_BOX_HEIGHT, orientation, amPmDisplayBoxHeight);
1121 GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_OUTPUT_MARGIN, orientation, timeOutputMargin);
1122 GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_ELEMENT_WIDTH, orientation, timeElementWidth);
1124 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_WIDTH, orientation, colonWidth);
1125 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_MARGIN, orientation, colonMargin);
1127 GET_SHAPE_CONFIG(DATETIMEPICKER::AMPM_WIDTH, orientation, amPmWidth);
1128 GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_AMPM_MARGIN, orientation, amPmMargin);
1130 GET_FIXED_VALUE_CONFIG(DATETIMEPICKER::DIVIDER_WIDTH, orientation, dividerWidth);
1131 GET_SHAPE_CONFIG(DATETIMEPICKER::DIVIDER_MARGIN, orientation, dividerMargin);
1133 hourBounds.width = minuteBounds.width = timeElementWidth;
1134 amPmBounds.width = amPmWidth;
1136 dateBounds.height = monthBounds.height = yearBounds.height = hourBounds.height = minuteBounds.height = dateTimeDisplayBoxHeight;
1137 amPmBounds.height = amPmDisplayBoxHeight;
1139 if (__title.IsEmpty())
1141 dateTimeElementY = (outputAreaBounds.height - dateTimeDisplayBoxHeight) / 2.0f;
1142 amPmElementY = (outputAreaBounds.height - amPmDisplayBoxHeight) / 2.0f;
1146 float topMargin = 0.0f;
1147 float bottomMargin = 0.0f;
1148 float titleHeight = 0.0f;
1150 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, topMargin);
1151 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_BOTTOM_MARGIN, orientation, bottomMargin);
1152 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_HEIGHT, orientation, titleHeight);
1154 dateTimeElementY = topMargin + titleHeight + bottomMargin;
1155 amPmElementY = topMargin + titleHeight;
1158 dateBounds.y = monthBounds.y = yearBounds.y = hourBounds.y = minuteBounds.y = dateTimeElementY;
1159 amPmBounds.y = amPmElementY;
1161 if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATE || __pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
1163 float leftMargin = 0.0f;
1164 GET_SHAPE_CONFIG(DATETIMEPICKER::DATETIME_OUTPUT_LEFT_MARGIN, orientation, leftMargin);
1166 _DateTimeUtils dateTimeUtils;
1167 int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
1169 switch (localeDateFormat)
1171 case DATE_FORMAT_DDMMYYYY:
1173 dateBounds.x = leftMargin;
1174 monthBounds.x = dateBounds.x + dateBounds.width + dateElementGapWidth;
1175 yearBounds.x = monthBounds.x + monthBounds.width + dateElementGapWidth;
1176 hourBounds.x = yearBounds.x + yearBounds.width + (2 * dividerMargin + dividerWidth);
1179 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
1180 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1185 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
1186 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1191 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
1192 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1197 case DATE_FORMAT_MMDDYYYY:
1199 monthBounds.x = leftMargin;
1200 dateBounds.x = monthBounds.x + monthBounds.width + dateElementGapWidth;
1201 yearBounds.x = dateBounds.x + dateBounds.width + dateElementGapWidth;
1202 hourBounds.x = yearBounds.x + yearBounds.width + (2 * dividerMargin + dividerWidth);
1205 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
1206 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1211 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
1212 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1217 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
1218 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1223 case DATE_FORMAT_YYYYMMDD:
1225 yearBounds.x = leftMargin;
1226 monthBounds.x = yearBounds.x + yearBounds.width + dateElementGapWidth;
1227 dateBounds.x = monthBounds.x + monthBounds.width + dateElementGapWidth;
1228 hourBounds.x = dateBounds.x + dateBounds.width + (2 * dividerMargin + dividerWidth);
1231 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
1232 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1237 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
1238 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1243 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
1244 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1249 case DATE_FORMAT_YYYYDDMM:
1251 yearBounds.x = leftMargin;
1252 dateBounds.x = yearBounds.x + yearBounds.width + dateElementGapWidth;
1253 monthBounds.x = dateBounds.x + dateBounds.width + dateElementGapWidth;
1254 hourBounds.x = monthBounds.x + monthBounds.width + (2 * dividerMargin + dividerWidth);
1257 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
1258 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1263 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
1264 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1269 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
1270 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1278 if (__pickerStyle == DATETIME_OUTPUT_STYLE_TIME || __pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
1280 if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
1282 minuteBounds.x = hourBounds.x + hourBounds.width + colonWidth + 2 * colonMargin;
1283 amPmBounds.x = minuteBounds.x + minuteBounds.width + amPmMargin;
1287 hourBounds.x = timeOutputMargin;
1288 minuteBounds.x = hourBounds.x + hourBounds.width + colonWidth + 2 * colonMargin;
1289 amPmBounds.x = minuteBounds.x + minuteBounds.width + amPmMargin;
1293 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(hourBounds, DATETIME_ID_HOUR);
1294 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1299 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(minuteBounds, DATETIME_ID_MINUTE);
1300 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1305 if (__is24HourNotation == false)
1307 pPmBox = new (std::nothrow) _DateTimeDisplayBox(amPmBounds, DATETIME_ID_AMPM);
1308 SysTryCatch(NID_UI_CTRL, (pPmBox != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1310 pPmBox->SetBackgroundBitmap(__pAmPmNormalBitmap, __pAmPmEffectBitmap);
1317 __outputBoxMaxCount = boxCount;
1319 for (indexBox = 0; indexBox < DATETIME_ID_MAX; indexBox++)
1321 delete __pDisplayBox[indexBox];
1323 if (pDisplayBox[indexBox] != null)
1325 pDisplayBox[indexBox]->SetBackgroundBitmap(__pDisplayBoxNormalBitmap, __pDisplayBoxEffectBitmap);
1328 __pDisplayBox[indexBox] = pDisplayBox[indexBox];
1336 for (int i = 0; i < DATETIME_ID_MAX; i++)
1338 delete pDisplayBox[i];
1339 pDisplayBox[i] = null;
1346 _DateTimePresenter::LoadResource(void)
1348 result r = E_SUCCESS;
1350 Color replacementColor = Color::GetColor(COLOR_ID_MAGENTA);
1351 Color backgroundColor[DATETIME_STATUS_MAX];
1352 bool isDisplayBoxCustomBitmap[DATETIME_STATUS_MAX];
1353 bool isAmPmCustomBitmap[DATETIME_STATUS_MAX];
1355 Bitmap* pDisplayBoxNormalBitmap[DATETIME_STATUS_MAX];
1356 Bitmap* pAmPmNormalBitmap[DATETIME_STATUS_MAX];
1357 Bitmap* pBgBitmap = null;
1358 Bitmap* pColonBitmap = null;
1360 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1362 pDisplayBoxNormalBitmap[i] = null;
1363 pAmPmNormalBitmap[i] = null;
1364 backgroundColor[i] = Color();
1365 isDisplayBoxCustomBitmap[i] = false;
1366 isAmPmCustomBitmap[i] = false;
1369 GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_NORMAL, backgroundColor[DATETIME_STATUS_NORMAL]);
1370 GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_PRESSED, backgroundColor[DATETIME_STATUS_SELECTED]);
1371 GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED, backgroundColor[DATETIME_STATUS_HIGHLIGHTED]);
1372 GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_DISABLED, backgroundColor[DATETIME_STATUS_DISABLED]);
1374 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBgBitmap);
1375 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1377 GET_COLOR_CONFIG(DATETIMEPICKER::DISPLAY_BG_NORMAL, color);
1378 __pBgNormalBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgBitmap, replacementColor, color);
1379 r = GetLastResult();
1380 SysTryCatch(NID_UI_CTRL, (__pBgNormalBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1382 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pColonBitmap);
1383 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1385 GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_NORMAL, color);
1386 __pColonBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pColonBitmap, replacementColor, color);
1387 r = GetLastResult();
1388 SysTryCatch(NID_UI_CTRL, (__pColonBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1390 GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_DISABLED, color);
1391 __pColonDisabledBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pColonBitmap, replacementColor, color);
1392 r = GetLastResult();
1393 SysTryCatch(NID_UI_CTRL, (__pColonDisabledBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1395 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBgEffectBitmap);
1396 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1399 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_NORMAL]);
1400 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1402 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_SELECTED]);
1403 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1405 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_HIGHLIGHTED]);
1406 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1408 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_DISABLED]);
1409 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1412 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_NORMAL]);
1413 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1415 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_SELECTED]);
1416 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1418 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_HIGHLIGHTED]);
1419 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1421 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_DISABLED]);
1422 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1424 isDisplayBoxCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_NORMAL);
1425 isDisplayBoxCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_PRESSED);
1426 isDisplayBoxCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_HIGHLIGHTED);
1427 isDisplayBoxCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_DISABLED);
1429 isAmPmCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_NORMAL);
1430 isAmPmCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_PRESSED);
1431 isAmPmCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED);
1432 isAmPmCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_DISABLED);
1435 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1437 if (isDisplayBoxCustomBitmap[i])
1439 __pDisplayBoxNormalBitmap[i] = pDisplayBoxNormalBitmap[i];
1443 __pDisplayBoxNormalBitmap[i] = _BitmapImpl::GetColorReplacedBitmapN(*pDisplayBoxNormalBitmap[i], replacementColor, backgroundColor[i]);
1444 SysTryCatch(NID_UI_CTRL, (__pDisplayBoxNormalBitmap[i] != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1448 if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_NORMAL])
1450 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_NORMAL]);
1451 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1454 if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_SELECTED])
1456 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_SELECTED]);
1457 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1460 if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_HIGHLIGHTED])
1462 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_HIGHLIGHTED]);
1463 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1466 if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_DISABLED])
1468 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_DISABLED]);
1469 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1474 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1476 if (isAmPmCustomBitmap[i])
1478 __pAmPmNormalBitmap[i] = pAmPmNormalBitmap[i];
1482 __pAmPmNormalBitmap[i] = _BitmapImpl::GetColorReplacedBitmapN(*pAmPmNormalBitmap[i], replacementColor, backgroundColor[i]);
1483 SysTryCatch(NID_UI_CTRL, (__pAmPmNormalBitmap[i] != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1487 if (!isAmPmCustomBitmap[DATETIME_STATUS_NORMAL])
1489 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_NORMAL]);
1490 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1493 if (!isAmPmCustomBitmap[DATETIME_STATUS_SELECTED])
1495 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_SELECTED]);
1496 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1499 if (!isAmPmCustomBitmap[DATETIME_STATUS_HIGHLIGHTED])
1501 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_HIGHLIGHTED]);
1502 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1505 if (!isAmPmCustomBitmap[DATETIME_STATUS_DISABLED])
1507 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_DISABLED]);
1508 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1511 delete pColonBitmap;
1514 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1516 delete pDisplayBoxNormalBitmap[i];
1517 delete pAmPmNormalBitmap[i];
1523 delete pColonBitmap;
1525 delete __pColonBitmap;
1526 __pColonBitmap = null;
1528 delete __pColonDisabledBitmap;
1529 __pColonDisabledBitmap = null;
1533 delete __pBgNormalBitmap;
1534 __pBgNormalBitmap = null;
1536 delete __pBgEffectBitmap;
1537 __pBgEffectBitmap = null;
1539 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1541 delete pDisplayBoxNormalBitmap[i];
1543 delete __pDisplayBoxNormalBitmap[i];
1544 __pDisplayBoxNormalBitmap[i] = null;
1546 delete __pDisplayBoxEffectBitmap[i];
1547 __pDisplayBoxEffectBitmap[i] = null;
1549 delete pAmPmNormalBitmap[i];
1551 delete __pAmPmNormalBitmap[i];
1552 __pAmPmNormalBitmap[i] = null;
1554 delete __pAmPmEffectBitmap[i];
1555 __pAmPmEffectBitmap[i] = null;
1562 _DateTimePresenter::DrawColon(Canvas& canvas)
1564 result r = E_SUCCESS;
1565 _ControlOrientation orientation = __pView->GetOrientation();
1567 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
1568 FloatRectangle colonBounds(0.0f, 0.0f, 0.0f, 0.0f);
1570 float colonWidth = 0.0f;
1571 float colonMargin = 0.0f;
1573 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_WIDTH, orientation, colonWidth);
1574 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_MARGIN, orientation, colonMargin);
1576 for (int i = 0; i < __outputBoxMaxCount; i++)
1578 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_HOUR)
1580 hourBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
1584 colonBounds.x = hourBounds.x + hourBounds.width + colonMargin;
1585 colonBounds.y = hourBounds.y;
1586 colonBounds.width = colonWidth;
1587 colonBounds.height = hourBounds.height;
1589 if (__pView->IsEnabled() && __pColonBitmap != null)
1591 r = canvas.DrawBitmap(colonBounds, *__pColonBitmap);
1592 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1594 else if (!__pView->IsEnabled() && __pColonDisabledBitmap != null)
1596 r = canvas.DrawBitmap(colonBounds, *__pColonDisabledBitmap);
1597 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1602 _DateTimePresenter::DrawDateTimeDisplayBox(Canvas& canvas, int index)
1604 result r = E_SUCCESS;
1608 int boxId = __pDisplayBox[index]->GetDisplayBoxId();
1609 number = GetNumberInBox(boxId);
1610 DateTimePickerStatus status = DATETIME_STATUS_NORMAL;
1612 GET_SHAPE_CONFIG(DATETIMEPICKER::FONT_SIZE, __pView->GetOrientation(), fontSize);
1614 r = _FontImpl::GetInstance(*__pFont)->SetSize(fontSize);
1615 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1617 if (__pView->IsEnabled() == false)
1619 status = DATETIME_STATUS_DISABLED;
1623 if (__keypadEnabled)
1625 if (index == __focusedBoxIndex)
1627 status = DATETIME_STATUS_HIGHLIGHTED;
1632 if (index == __selectedBoxIndex)
1634 status = DATETIME_STATUS_SELECTED;
1639 if (boxId == DATETIME_ID_YEAR)
1641 if ((__inputComposing == DATETIME_INPUT_BEGIN) && ((__keypadEnabled && status == DATETIME_STATUS_HIGHLIGHTED)
1642 || (!__keypadEnabled && status == DATETIME_STATUS_SELECTED)))
1644 String length = L"%0d";
1646 r = length.Insert(__changeFocusCounter,2);
1647 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1649 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, length.GetPointer(), number);
1650 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1654 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%04d", number);
1655 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1658 else if (boxId == DATETIME_ID_MONTH)
1660 if (__pInputPad != null)
1663 _DateTimeUtils dateTimeUtils;
1664 text = dateTimeUtils.GetMonthString(number);
1668 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%02d", number);
1669 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1674 if ((__inputComposing == DATETIME_INPUT_BEGIN) && ((__keypadEnabled && status == DATETIME_STATUS_HIGHLIGHTED)
1675 || (!__keypadEnabled && status == DATETIME_STATUS_SELECTED)))
1677 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%d", number);
1678 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1682 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%02d", number);
1683 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1687 __pDisplayBox[index]->SetText(text);
1688 __pDisplayBox[index]->DrawDisplayBox(canvas, status);
1694 _DateTimePresenter::DrawPm(Canvas& canvas)
1698 if ((__is24HourNotation == true) || (__pPmBox == null))
1703 _DateTimeUtils dateTimeUtils;
1705 if (__isPm == false)
1707 dateTimeUtils.GetAmPm(text, AM_TYPE);
1711 dateTimeUtils.GetAmPm(text, PM_TYPE);
1714 __pPmBox->SetText(text);
1716 if (__pView->IsEnabled() == false)
1718 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_DISABLED);
1720 else if (__isPmButtonPressed == true)
1722 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_SELECTED);
1726 if (__keypadEnabled && __focusedBoxIndex == __outputBoxMaxCount)
1728 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_HIGHLIGHTED);
1732 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_NORMAL);
1738 _DateTimePresenter::DrawBackground(Canvas& canvas)
1740 result r = E_SUCCESS;
1741 FloatRectangle bounds = canvas.GetBoundsF();
1742 Color backgroundColor(0, 0, 0, 0);
1744 GET_COLOR_CONFIG(DATETIMEPICKER::BG_NORMAL, backgroundColor);
1745 canvas.SetBackgroundColor(backgroundColor);
1748 if (__pBgEffectBitmap)
1750 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pBgEffectBitmap))
1752 canvas.DrawNinePatchedBitmap(bounds, *__pBgEffectBitmap);
1753 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1757 canvas.DrawBitmap(bounds, *__pBgEffectBitmap);
1758 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1762 if (__pBgNormalBitmap)
1764 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pBgNormalBitmap))
1766 canvas.DrawNinePatchedBitmap(bounds, *__pBgNormalBitmap);
1767 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1771 canvas.DrawBitmap(bounds, *__pBgNormalBitmap);
1772 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1780 _DateTimePresenter::DrawTitle(Canvas& canvas)
1782 result r = E_SUCCESS;
1783 float marginX = 0.0f;
1784 float marginY = 0.0f;
1786 Color color(0, 0, 0, 0);
1787 _ControlOrientation orientation = __pView->GetOrientation();
1789 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_LEFT_MARGIN, orientation, marginX);
1790 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, marginY);
1792 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_FONT_SIZE, orientation, fontSize);
1794 r = _FontImpl::GetInstance(*__pFont)->SetSize(fontSize);
1795 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1797 if (__pView->IsEnabled())
1799 GET_COLOR_CONFIG(DATETIMEPICKER::TITLE_NORMAL, color);
1803 GET_COLOR_CONFIG(DATETIMEPICKER::TITLE_DISABLED, color);
1806 canvas.SetForegroundColor(color);
1807 canvas.SetFont(*__pFont);
1808 canvas.DrawText(FloatPoint(marginX, marginY), __title);
1814 _DateTimePresenter::DrawDividers(Canvas& canvas)
1816 result r = E_SUCCESS;
1817 float dividerWidth = 0.0f;
1818 float dividerHeight = 0.0f;
1819 float dividerMargin = 0.0f;
1820 float displayBoxheight = 0.0f;
1821 FloatPoint lineStart(0.0f,0.0f);
1822 FloatPoint lineEnd(0.0f,0.0f);
1823 Color colorHalfLeft;
1824 Color colorHalfRight;
1826 _ControlOrientation orientation = __pView->GetOrientation();
1828 GET_FIXED_VALUE_CONFIG(DATETIMEPICKER::DIVIDER_WIDTH, orientation, dividerWidth);
1829 GET_SHAPE_CONFIG(DATETIMEPICKER::DIVIDER_HEIGHT, orientation, dividerHeight);
1830 GET_SHAPE_CONFIG(DATETIMEPICKER::DIVIDER_MARGIN, orientation, dividerMargin);
1831 GET_SHAPE_CONFIG(DATETIMEPICKER::DATETIME_DISPLAY_BOX_HEIGHT, orientation, displayBoxheight);
1833 GET_COLOR_CONFIG(DATETIMEPICKER::DIVIDER_LEFT_HALF, colorHalfLeft);
1834 GET_COLOR_CONFIG(DATETIMEPICKER::DIVIDER_RIGHT_HALF, colorHalfRight);
1836 if (__title.IsEmpty())
1838 lineStart.y = (GetOutputArea().height - dividerHeight) / 2.0f;
1839 lineEnd.y = lineStart.y + dividerHeight;
1843 float topMargin = 0.0f;
1844 float bottomMargin = 0.0f;
1845 float titleHeight = 0.0f;
1847 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, topMargin);
1848 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_BOTTOM_MARGIN, orientation, bottomMargin);
1849 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_HEIGHT, orientation, titleHeight);
1851 lineStart.y = topMargin + titleHeight + bottomMargin + ((displayBoxheight - dividerHeight) / 2.0f);
1852 lineEnd.y = lineStart.y + dividerHeight;
1855 canvas.SetLineWidth(dividerWidth/2.0f);
1857 FloatRectangle yearBounds(0.0f, 0.0f, 0.0f, 0.0f);
1859 for (int i = 0; i < __outputBoxMaxCount; i++)
1861 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_YEAR)
1863 yearBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
1867 lineStart.x = yearBounds.x + yearBounds.width + dividerMargin;
1868 lineEnd.x = lineStart.x;
1870 canvas.SetForegroundColor(colorHalfLeft);
1871 r = canvas.DrawLine(lineStart, lineEnd);
1872 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1874 lineStart.x += dividerWidth/2;
1875 lineEnd.x = lineStart.x;
1877 canvas.SetForegroundColor(colorHalfRight);
1878 r = canvas.DrawLine(lineStart, lineEnd);
1879 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1885 _DateTimePresenter::GetOutputArea(void)
1887 _ControlOrientation orientation = __pView->GetOrientation();
1889 FloatRectangle outputArea(0.0f, 0.0f, 0.0f, 0.0f);
1891 GET_SHAPE_CONFIG(DATETIMEPICKER::LEFT_MARGIN, orientation, outputArea.x);
1892 GET_SHAPE_CONFIG(DATETIMEPICKER::TOP_MARGIN, orientation, outputArea.y);
1894 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1896 float headerHeight = 0.0f;
1898 GET_SHAPE_CONFIG(HEADER::HEIGHT, orientation, headerHeight);
1899 outputArea.y += headerHeight;
1902 outputArea.width = __pView->GetBounds().width - 2 * outputArea.x;
1904 GET_SHAPE_CONFIG(DATETIMEPICKER::OUTPUT_AREA_HEIGHT, orientation, outputArea.height);
1910 _DateTimePresenter::ChangeInputPadStyle(int boxId)
1912 if (__inputPadEnabled == false)
1917 SysTryReturnVoidResult(NID_UI_CTRL, __pInputPad != null, E_SYSTEM,
1918 "[E_SYSTEM] A system error has occurred. The instance of Inputpad is null.");
1920 _InputPadStyle inputPadType = INPUTPAD_STYLE_NORMAL;
1923 case DATETIME_ID_MONTH:
1924 inputPadType = INPUTPAD_STYLE_ALPHA;
1927 case DATETIME_ID_YEAR:
1928 // fall through intentional
1929 case DATETIME_ID_DAY:
1930 // fall through intentional
1931 case DATETIME_ID_HOUR:
1932 // fall through intentional
1933 case DATETIME_ID_MINUTE:
1934 // fall through intentional
1936 inputPadType = INPUTPAD_STYLE_NORMAL;
1940 if (__inputPadType == inputPadType)
1944 __inputPadType = inputPadType;
1946 __pInputPad->SetInputPadStyle(inputPadType);
1947 result r = GetLastResult();
1948 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1952 _DateTimePresenter::CalculateTouchArea(float posX, float posY)
1954 _ControlOrientation orientation = __pView->GetOrientation();
1955 FloatRectangle outputArea = GetOutputArea();
1957 float margin = 0.0f;
1959 GET_SHAPE_CONFIG(DATETIMEPICKER::TOP_MARGIN, orientation, margin);
1961 if ((posX < outputArea.x) || (posY < outputArea.y))
1963 return DATETIME_AREA_NONE;
1966 int touched = DATETIME_AREA_NONE;
1968 if (posY < outputArea.y + outputArea.height)
1970 float displayBoxHeight = 0.0f;
1971 float amPmBoxHeight = 0.0f;
1973 GET_SHAPE_CONFIG(DATETIMEPICKER::DATETIME_DISPLAY_BOX_HEIGHT, orientation, displayBoxHeight);
1974 GET_SHAPE_CONFIG(DATETIMEPICKER::AMPM_DISPLAY_BOX_HEIGHT, orientation, amPmBoxHeight);
1976 float displayBoxPosY = outputArea.y + ((outputArea.height - displayBoxHeight) / 2.0f);
1977 float amPmBoxPosY = outputArea.y + ((outputArea.height - amPmBoxHeight) / 2.0f);
1979 if (__title.IsEmpty())
1981 displayBoxPosY = outputArea.y + ((outputArea.height - displayBoxHeight) / 2.0f);
1982 amPmBoxPosY = outputArea.y + ((outputArea.height - amPmBoxHeight) / 2.0f);
1986 float topMargin = 0.0f;
1987 float bottomMargin = 0.0f;
1988 float titleHeight = 0.0f;
1990 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, topMargin);
1991 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_BOTTOM_MARGIN, orientation, bottomMargin);
1992 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_HEIGHT, orientation, titleHeight);
1994 displayBoxPosY = outputArea.y + topMargin + bottomMargin + titleHeight;
1995 amPmBoxPosY = outputArea.y + topMargin + titleHeight;
1998 if ((posY >= amPmBoxPosY) && (posY <= amPmBoxPosY + amPmBoxHeight))
2000 if ((posY >= displayBoxPosY) && (posY <= displayBoxPosY + displayBoxHeight))
2003 touched = DATETIME_AREA_OUTPUT;
2006 if (__pPmBox != null)
2009 FloatRectangle boxBounds = __pPmBox->GetDisplayBoxBounds();
2011 if ((posX >= boxBounds.x) && (posX < boxBounds.x + boxBounds.width))
2013 touched = DATETIME_AREA_OUTPUT_AMPM;
2021 touched = DATETIME_AREA_INPUT;
2028 _DateTimePresenter::CalculateTouchOutputArea(float posX, float posY)
2030 FloatRectangle outputArea = GetOutputArea();
2031 _ControlOrientation orientation = __pView->GetOrientation();
2033 for (int i = 0; i < __outputBoxMaxCount; i++)
2035 FloatRectangle boxBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
2037 if (__title.IsEmpty())
2039 boxBounds.y = outputArea.y + ((outputArea.height - boxBounds.height) / 2.0f);
2043 float topMargin = 0.0f;
2044 float bottomMargin = 0.0f;
2045 float titleHeight = 0.0f;
2047 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, topMargin);
2048 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_BOTTOM_MARGIN, orientation, bottomMargin);
2049 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_HEIGHT, orientation, titleHeight);
2051 boxBounds.y = outputArea.y + topMargin + titleHeight + bottomMargin;
2054 if ((posX >= boxBounds.x) && (posX < boxBounds.x + boxBounds.width)
2055 && (posY >= boxBounds.y) && (posY < boxBounds.y + boxBounds.height))
2065 _DateTimePresenter::CalculateTwoDigit(int originalNumber, int number)
2067 int twoDigit = (originalNumber * 10) + number;
2074 if ((twoDigit > 0) && (twoDigit > DATETIME_TWO_DIGIT_MAX))
2076 twoDigit = twoDigit % (DATETIME_TWO_DIGIT_MAX + 1);
2083 _DateTimePresenter::CalculateFourDigit(int originalNumber, int number)
2085 int fourDigit = (originalNumber * 10) + number;
2092 if ((fourDigit > 0) && (fourDigit > DATETIME_FOUR_DIGIT_MAX))
2094 fourDigit = fourDigit % (DATETIME_FOUR_DIGIT_MAX + 1);
2100 _DateTimePresenter::SetTwoDigit(int originalNumber, int number)
2104 if ((originalNumber <= DATETIME_ONE_DIGIT_MAX) && (__inputComposing == DATETIME_INPUT_BEGIN))
2106 twoDigit = (originalNumber * 10) + number;
2116 _DateTimePresenter::SetFourDigit(int originalNumber, int number)
2122 GetYearRange(minYear, maxYear);
2123 if ((originalNumber <= DATETIME_THREE_DIGIT_MAX) && (__inputComposing == DATETIME_INPUT_BEGIN))
2125 fourDigit = (originalNumber * 10) + number;
2126 if (fourDigit > maxYear)
2128 fourDigit = maxYear;
2140 _DateTimePresenter::SetNumberInBox(int boxId, int number)
2144 case DATETIME_ID_YEAR:
2148 case DATETIME_ID_MONTH:
2152 case DATETIME_ID_DAY:
2156 case DATETIME_ID_HOUR:
2160 case DATETIME_ID_MINUTE:
2170 _DateTimePresenter::GetNumberInBox(int boxId) const
2176 case DATETIME_ID_YEAR:
2180 case DATETIME_ID_MONTH:
2184 case DATETIME_ID_DAY:
2188 case DATETIME_ID_HOUR:
2192 case DATETIME_ID_MINUTE:
2204 _DateTimePresenter::SetFocusBox(int index)
2206 if (__keypadEnabled)
2208 __focusedBoxIndex = index;
2210 if (__focusedBoxIndex < __outputBoxMaxCount)
2212 __selectedBoxIndex = __focusedBoxIndex;
2216 __isFocusBoxChanged = true;
2217 __inputComposing = DATETIME_INPUT_END;
2218 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
2220 int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
2222 ChangeInputPadStyle(boxId);
2226 _DateTimePresenter::LoadPickerData(void)
2228 _DateTimeUtils dateTimeUtils;
2231 __month = GetMonth();
2235 if (__is24HourNotation == false)
2237 int max = DATETIME_HOUR_MAX_FOR_24NOTATION;
2239 if (__hour == DATETIME_HOUR_MIN)
2241 __hour = __hour + max;
2244 else if (__hour < max && __hour != DATETIME_HOUR_MIN)
2248 else if (__hour == max)
2252 else if (__hour > max && __hour <= DATETIME_HOUR_MAX)
2254 __hour = __hour - max;
2257 else if (__hour == DATETIME_HOUR_MAX + 1)
2264 __minute = GetMinute();
2268 _DateTimePresenter::SavePickerData(void)
2274 if (__is24HourNotation == false)
2276 int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION;
2280 if (__hour < maxHour)
2282 SetHour(__hour + maxHour);
2291 if (__hour < maxHour)
2297 SetHour(__hour - maxHour);
2306 SetMinute(__minute);
2310 _DateTimePresenter::UpdateDisplayData(int boxId)
2314 case DATETIME_ID_YEAR:
2318 case DATETIME_ID_MONTH:
2319 __month = GetMonth();
2322 case DATETIME_ID_DAY:
2326 case DATETIME_ID_HOUR:
2329 if (__is24HourNotation == false)
2331 int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION;
2333 if (__hour == DATETIME_HOUR_MIN)
2338 else if (__hour < maxHour && __hour != DATETIME_HOUR_MIN)
2342 else if (__hour == maxHour)
2346 else if (__hour > maxHour && __hour <= DATETIME_HOUR_MAX)
2348 __hour = __hour - maxHour;
2351 else if (__hour == DATETIME_HOUR_MAX + 1)
2353 __hour = __hour - maxHour;
2359 case DATETIME_ID_MINUTE:
2360 __minute = GetMinute();
2369 _DateTimePresenter::AdjustValue(int& value, int minValue, int maxValue)
2371 if (value < minValue)
2375 else if (maxValue < value)
2382 _DateTimePresenter::AdjustDisplayValue(int index)
2384 int boxId = __pDisplayBox[index]->GetDisplayBoxId();
2385 _DateTimeUtils dateTimeUtils;
2391 case DATETIME_ID_YEAR:
2394 GetYearRange(minValue, maxValue);
2395 AdjustValue(__year, minValue, maxValue);
2398 case DATETIME_ID_MONTH:
2399 minValue = DATETIME_MONTH_MIN;
2400 maxValue = DATETIME_MONTH_MAX;
2401 AdjustValue(__month, minValue, maxValue);
2404 case DATETIME_ID_DAY:
2406 maxValue = dateTimeUtils.CalculateMaxDay(__year, __month);
2407 AdjustValue(__day, minValue, maxValue);
2410 case DATETIME_ID_HOUR:
2411 minValue = DATETIME_HOUR_MIN;
2412 maxValue = DATETIME_HOUR_MAX;
2413 if (__is24HourNotation == false)
2415 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
2417 if (__hour == DATETIME_HOUR_MIN)
2419 minValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
2422 AdjustValue(__hour, minValue, maxValue);
2425 case DATETIME_ID_MINUTE:
2426 minValue = DATETIME_MINUTE_MIN;
2427 maxValue = DATETIME_MINUTE_MAX;
2428 AdjustValue(__minute, minValue, maxValue);
2437 _DateTimePresenter::ChangeFocusBox(void)
2439 if (__keypadEnabled)
2441 if (__focusedBoxIndex < __outputBoxMaxCount - 1)
2443 __focusedBoxIndex++;
2444 __selectedBoxIndex = __focusedBoxIndex;
2445 int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
2446 ChangeInputPadStyle(boxId);
2447 __isFocusBoxChanged = true;
2452 if (__selectedBoxIndex < (__outputBoxMaxCount - 1))
2454 __selectedBoxIndex++;
2455 __focusedBoxIndex = __selectedBoxIndex;
2456 int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
2457 ChangeInputPadStyle(boxId);
2458 __isFocusBoxChanged = true;
2462 for (int i = 0; i < __outputBoxMaxCount; i++)
2464 AdjustDisplayValue(i);
2467 __inputComposing = DATETIME_INPUT_END;
2468 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
2472 _DateTimePresenter::SetAccessibilityElementText(void)
2474 for (int index = 0; index < __outputBoxMaxCount; ++index)
2476 if (__pDisplayBox[index]->GetDisplayBoxId() == DATETIME_ID_MONTH)
2478 int number = GetNumberInBox(__pDisplayBox[index]->GetDisplayBoxId());
2479 __pView->SetAccessibilityElementText(index, __pInputPad->GetAccessibilityElementMonthName(number-1), false);
2483 __pView->SetAccessibilityElementText(index, __pDisplayBox[index]->GetText(), false);
2489 __pView->SetAccessibilityElementText(__outputBoxMaxCount, __pPmBox->GetText(), true);
2493 }}} // Tizen::Ui::Controls