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_OUTPUT_AMPM)
593 __isPmButtonPressed = true;
594 __pView->Invalidate(true);
602 _DateTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
604 if (__pView != &source)
613 _DateTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
615 result r = E_SUCCESS;
617 if (__pView != &source)
622 int touchedAreaId = CalculateTouchArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
624 if (__isPmButtonPressed == true)
626 if (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM)
629 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pView);
632 __inputComposing = DATETIME_INPUT_END;
633 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
634 __isPmButtonPressed = false;
635 AdjustDisplayValue(__selectedBoxIndex);
636 __pView->Invalidate(true);
641 if ((touchedAreaId == DATETIME_AREA_NONE) || (touchedAreaId == DATETIME_AREA_INPUT) ||
642 (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM))
644 __isPmButtonPressed = false;
645 __pView->Invalidate(true);
650 int newOutputFocusedIndex = -1;
652 if (touchedAreaId == DATETIME_AREA_OUTPUT)
654 newOutputFocusedIndex = CalculateTouchOutputArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
656 if (newOutputFocusedIndex == (-1))
661 for (int i = 0; i < __outputBoxMaxCount; i++)
663 AdjustDisplayValue(i);
666 if (newOutputFocusedIndex != __selectedBoxIndex)
668 __selectedBoxIndex = newOutputFocusedIndex;
671 _VisualElement* pVisualElement = null;
672 Canvas* pCanvas = null;
674 pVisualElement = __pView->GetDisplayVisualElement();
676 SysTryReturn(NID_UI_CTRL, (pVisualElement != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
678 pCanvas = pVisualElement->GetCanvasN();
680 SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
682 DrawDateTimeDisplayBox(*pCanvas, __selectedBoxIndex);
686 __inputComposing = DATETIME_INPUT_END;
687 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
689 int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
690 ChangeInputPadStyle(boxId);
692 __pView->Invalidate(true);
701 _DateTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
703 if (__pView != &source)
708 __isPmButtonPressed = false;
709 __inputComposing = DATETIME_INPUT_END;
710 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
712 __pView->Invalidate(true);
718 _DateTimePresenter::OnInputPadValueChanged(const _Control& source, int inputPadReturnValue)
720 HandleInputPadValueChange(inputPadReturnValue);
724 _DateTimePresenter::OnActionPerformed(const _Control& source, int actionId)
726 HandleSaveCancelAction(actionId);
730 _DateTimePresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
732 if (!__keypadEnabled)
737 _KeyCode keyCode = keyInfo.GetKeyCode();
743 if (__pickerStyle != DATETIME_OUTPUT_STYLE_DATE && __focusedBoxIndex < __outputBoxMaxCount)
746 SetFocusBox(__focusedBoxIndex);
748 else if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATE && __focusedBoxIndex < __outputBoxMaxCount-1)
751 SetFocusBox(__focusedBoxIndex);
761 if (__focusedBoxIndex > 0)
764 SetFocusBox(__focusedBoxIndex);
774 if (__focusedBoxIndex == __outputBoxMaxCount)
776 __isPmButtonPressed = true;
782 HandleInputPadValueChange(0);
786 HandleInputPadValueChange(1);
790 HandleInputPadValueChange(2);
794 HandleInputPadValueChange(3);
798 HandleInputPadValueChange(4);
802 HandleInputPadValueChange(5);
806 HandleInputPadValueChange(6);
810 HandleInputPadValueChange(7);
814 HandleInputPadValueChange(8);
818 HandleInputPadValueChange(9);
824 __pView->Invalidate(true);
829 _DateTimePresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
831 _KeyCode keyCode = keyInfo.GetKeyCode();
833 if (keyCode == _KEY_ESC || keyCode == _KEY_BACK)
835 HandleSaveCancelAction(DATETIME_EVENT_ID_CANCEL);
839 if (!__keypadEnabled)
844 if (__isPmButtonPressed == true && keyCode == _KEY_ENTER)
847 __isPmButtonPressed = false;
848 __pView->Invalidate(true);
855 _DateTimePresenter::DrawFocus(void)
857 result r = E_SUCCESS;
858 __keypadEnabled = true;
861 __pView->Invalidate(true);
866 _DateTimePresenter::ReleaseFocus(void)
868 result r = E_SUCCESS;
869 __keypadEnabled = false;
871 if (__pickerStyle != DATETIME_OUTPUT_STYLE_DATE && __focusedBoxIndex == __outputBoxMaxCount)
873 __selectedBoxIndex = __outputBoxMaxCount - 1; //minute
877 __selectedBoxIndex = __focusedBoxIndex;
879 __focusedBoxIndex = 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, __pView);
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, __pView);
935 if (__inputComposing == DATETIME_INPUT_BEGIN && __keypadEnabled)
937 currentNumber = GetNumberInBox(boxId);
938 newNumber = currentNumber * 10 + inputPadReturnValue;
944 else if (newNumber < 1)
953 if (inputPadReturnValue == 0)
957 newNumber = inputPadReturnValue;
958 __inputComposing = DATETIME_INPUT_BEGIN;
960 if (!__keypadEnabled || newNumber > 1)
966 SetNumberInBox(boxId, newNumber);
970 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_SIP, __pView);
971 __changeFocusCounter++;
973 if (__isFocusBoxChanged == true)
975 newNumber = inputPadReturnValue;
976 __isFocusBoxChanged = false;
980 newNumber = SetTwoDigit(currentNumber, inputPadReturnValue);
983 __inputComposing = DATETIME_INPUT_BEGIN;
985 SetNumberInBox(boxId, newNumber);
987 if (newNumber > DATETIME_ONE_DIGIT_MAX || __changeFocusCounter == DATE_TIME_CHANGE_FOCUS_COUNTER_MAX / 2)
993 __pView->Invalidate(true);
997 _DateTimePresenter::HandleSaveCancelAction(int actionId)
999 result r = E_SUCCESS;
1001 if (__pView == null)
1006 if (actionId != DATETIME_EVENT_ID_SAVE && actionId != DATETIME_EVENT_ID_CANCEL )
1013 __inputComposing = DATETIME_INPUT_END;
1014 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
1015 __focusedBoxIndex = 0;
1016 __selectedBoxIndex = 0;
1018 int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
1020 SetFocusBoxId(boxId);
1023 if (actionId == DATETIME_EVENT_ID_SAVE)
1025 for (int i = 0; i < __outputBoxMaxCount; i++)
1027 AdjustDisplayValue(i);
1032 switch (__pickerStyle)
1034 case DATETIME_OUTPUT_STYLE_DATE:
1035 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1036 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1038 r = __pView->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_SAVED, dateTime);
1039 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.");
1042 case DATETIME_OUTPUT_STYLE_TIME:
1043 r = dateTime.SetValue(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
1044 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1046 r = __pView->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED, dateTime);
1047 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.");
1050 case DATETIME_OUTPUT_STYLE_DATETIME:
1051 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
1052 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1054 r = __pView->FireDateTimeChangeEvent(DATETIME_INTERNAL_CHANGE_SAVED, dateTime);
1055 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.");
1062 else if (actionId == DATETIME_EVENT_ID_CANCEL)
1066 switch (__pickerStyle)
1068 case DATETIME_OUTPUT_STYLE_DATE:
1069 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
1070 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1072 r = __pView->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_CANCELED, dateTime);
1073 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.");
1076 case DATETIME_OUTPUT_STYLE_TIME:
1077 r = dateTime.SetValue(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
1078 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1080 r = __pView->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_CANCELED, dateTime);
1081 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.");
1084 case DATETIME_OUTPUT_STYLE_DATETIME:
1085 r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), dateTime.GetSecond());
1086 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1088 r = __pView->FireDateTimeChangeEvent(DATETIME_INTERNAL_CHANGE_CANCELED, dateTime);
1089 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.");
1099 _DateTimePresenter::UpdateDateTimeOutputConfig(void)
1101 _ControlOrientation orientation = __pView->GetOrientation();
1102 _DateTimeDisplayBox* pPmBox = null;
1103 _DateTimeDisplayBox* pDisplayBox[DATETIME_ID_MAX];
1105 FloatRectangle outputAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
1106 FloatRectangle dateBounds(0.0f, 0.0f, 0.0f, 0.0f);
1107 FloatRectangle monthBounds(0.0f, 0.0f, 0.0f, 0.0f);
1108 FloatRectangle yearBounds(0.0f, 0.0f, 0.0f, 0.0f);
1109 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
1110 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1111 FloatRectangle amPmBounds(0.0f, 0.0f, 0.0f, 0.0f);
1116 float dateTimeDisplayBoxHeight = 0.0f;
1117 float amPmDisplayBoxHeight = 0.0f;
1119 float dateTimeElementY = 0.0f;
1120 float amPmElementY = 0.0f;
1121 float dateElementGapWidth = 0.0f;
1122 float timeOutputMargin = 0.0f;
1123 float timeElementWidth = 0.0f;
1124 float colonWidth = 0.0f;
1125 float colonMargin = 0.0f;
1126 float amPmWidth = 0.0f;
1127 float amPmMargin = 0.0f;
1129 float dividerWidth = 0.0f;
1130 float dividerMargin = 0.0f;
1132 for (indexBox = 0; indexBox < DATETIME_ID_MAX; indexBox++)
1134 pDisplayBox[indexBox] = null;
1137 outputAreaBounds = GetOutputArea();
1138 __pView->SetDisplayVisualElementBounds(outputAreaBounds);
1140 GET_SHAPE_CONFIG(DATETIMEPICKER::DATE_ELEMENT_GAP_WIDTH, orientation, dateElementGapWidth);
1142 GET_SHAPE_CONFIG(DATETIMEPICKER::DATE_ELEMENT_WIDTH, orientation, dateBounds.width);
1143 GET_SHAPE_CONFIG(DATETIMEPICKER::MONTH_ELEMENT_WIDTH, orientation, monthBounds.width);
1144 GET_SHAPE_CONFIG(DATETIMEPICKER::YEAR_ELEMENT_WIDTH, orientation, yearBounds.width);
1146 GET_SHAPE_CONFIG(DATETIMEPICKER::DATETIME_DISPLAY_BOX_HEIGHT, orientation, dateTimeDisplayBoxHeight);
1147 GET_SHAPE_CONFIG(DATETIMEPICKER::AMPM_DISPLAY_BOX_HEIGHT, orientation, amPmDisplayBoxHeight);
1149 GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_OUTPUT_MARGIN, orientation, timeOutputMargin);
1150 GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_ELEMENT_WIDTH, orientation, timeElementWidth);
1152 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_WIDTH, orientation, colonWidth);
1153 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_MARGIN, orientation, colonMargin);
1155 GET_SHAPE_CONFIG(DATETIMEPICKER::AMPM_WIDTH, orientation, amPmWidth);
1156 GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_AMPM_MARGIN, orientation, amPmMargin);
1158 GET_FIXED_VALUE_CONFIG(DATETIMEPICKER::DIVIDER_WIDTH, orientation, dividerWidth);
1159 GET_SHAPE_CONFIG(DATETIMEPICKER::DIVIDER_MARGIN, orientation, dividerMargin);
1161 hourBounds.width = minuteBounds.width = timeElementWidth;
1162 amPmBounds.width = amPmWidth;
1164 dateBounds.height = monthBounds.height = yearBounds.height = hourBounds.height = minuteBounds.height = dateTimeDisplayBoxHeight;
1165 amPmBounds.height = amPmDisplayBoxHeight;
1167 if (__title.IsEmpty())
1169 dateTimeElementY = (outputAreaBounds.height - dateTimeDisplayBoxHeight) / 2.0f;
1170 amPmElementY = (outputAreaBounds.height - amPmDisplayBoxHeight) / 2.0f;
1174 float topMargin = 0.0f;
1175 float bottomMargin = 0.0f;
1176 float titleHeight = 0.0f;
1178 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, topMargin);
1179 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_BOTTOM_MARGIN, orientation, bottomMargin);
1180 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_HEIGHT, orientation, titleHeight);
1182 dateTimeElementY = topMargin + titleHeight + bottomMargin;
1183 amPmElementY = topMargin + titleHeight;
1186 dateBounds.y = monthBounds.y = yearBounds.y = hourBounds.y = minuteBounds.y = dateTimeElementY;
1187 amPmBounds.y = amPmElementY;
1189 if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATE || __pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
1191 float leftMargin = 0.0f;
1192 GET_SHAPE_CONFIG(DATETIMEPICKER::DATETIME_OUTPUT_LEFT_MARGIN, orientation, leftMargin);
1194 _DateTimeUtils dateTimeUtils;
1195 int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
1197 switch (localeDateFormat)
1199 case DATE_FORMAT_DDMMYYYY:
1201 dateBounds.x = leftMargin;
1202 monthBounds.x = dateBounds.x + dateBounds.width + dateElementGapWidth;
1203 yearBounds.x = monthBounds.x + monthBounds.width + dateElementGapWidth;
1204 hourBounds.x = yearBounds.x + yearBounds.width + (2 * dividerMargin + dividerWidth);
1207 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
1208 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1213 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
1214 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1219 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
1220 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1225 case DATE_FORMAT_MMDDYYYY:
1227 monthBounds.x = leftMargin;
1228 dateBounds.x = monthBounds.x + monthBounds.width + dateElementGapWidth;
1229 yearBounds.x = dateBounds.x + dateBounds.width + dateElementGapWidth;
1230 hourBounds.x = yearBounds.x + yearBounds.width + (2 * dividerMargin + dividerWidth);
1233 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
1234 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1239 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
1240 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1245 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
1246 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1251 case DATE_FORMAT_YYYYMMDD:
1253 yearBounds.x = leftMargin;
1254 monthBounds.x = yearBounds.x + yearBounds.width + dateElementGapWidth;
1255 dateBounds.x = monthBounds.x + monthBounds.width + dateElementGapWidth;
1256 hourBounds.x = dateBounds.x + dateBounds.width + (2 * dividerMargin + dividerWidth);
1259 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
1260 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1265 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
1266 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1271 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
1272 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1277 case DATE_FORMAT_YYYYDDMM:
1279 yearBounds.x = leftMargin;
1280 dateBounds.x = yearBounds.x + yearBounds.width + dateElementGapWidth;
1281 monthBounds.x = dateBounds.x + dateBounds.width + dateElementGapWidth;
1282 hourBounds.x = monthBounds.x + monthBounds.width + (2 * dividerMargin + dividerWidth);
1285 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR);
1286 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1291 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY);
1292 SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1297 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH);
1298 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1306 if (__pickerStyle == DATETIME_OUTPUT_STYLE_TIME || __pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
1308 if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME)
1310 minuteBounds.x = hourBounds.x + hourBounds.width + colonWidth + 2 * colonMargin;
1311 amPmBounds.x = minuteBounds.x + minuteBounds.width + amPmMargin;
1315 hourBounds.x = timeOutputMargin;
1316 minuteBounds.x = hourBounds.x + hourBounds.width + colonWidth + 2 * colonMargin;
1317 amPmBounds.x = minuteBounds.x + minuteBounds.width + amPmMargin;
1321 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(hourBounds, DATETIME_ID_HOUR);
1322 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1327 pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(minuteBounds, DATETIME_ID_MINUTE);
1328 SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1333 if (__is24HourNotation == false)
1335 pPmBox = new (std::nothrow) _DateTimeDisplayBox(amPmBounds, DATETIME_ID_AMPM);
1336 SysTryCatch(NID_UI_CTRL, (pPmBox != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1338 pPmBox->SetBackgroundBitmap(__pAmPmNormalBitmap, __pAmPmEffectBitmap);
1345 __outputBoxMaxCount = boxCount;
1347 for (indexBox = 0; indexBox < DATETIME_ID_MAX; indexBox++)
1349 delete __pDisplayBox[indexBox];
1351 if (pDisplayBox[indexBox] != null)
1353 pDisplayBox[indexBox]->SetBackgroundBitmap(__pDisplayBoxNormalBitmap, __pDisplayBoxEffectBitmap);
1356 __pDisplayBox[indexBox] = pDisplayBox[indexBox];
1364 for (int i = 0; i < DATETIME_ID_MAX; i++)
1366 delete pDisplayBox[i];
1367 pDisplayBox[i] = null;
1374 _DateTimePresenter::LoadResource(void)
1376 result r = E_SUCCESS;
1378 Color replacementColor = Color::GetColor(COLOR_ID_MAGENTA);
1379 Color backgroundColor[DATETIME_STATUS_MAX];
1380 bool isDisplayBoxCustomBitmap[DATETIME_STATUS_MAX];
1381 bool isAmPmCustomBitmap[DATETIME_STATUS_MAX];
1383 Bitmap* pDisplayBoxNormalBitmap[DATETIME_STATUS_MAX];
1384 Bitmap* pAmPmNormalBitmap[DATETIME_STATUS_MAX];
1385 Bitmap* pBgBitmap = null;
1386 Bitmap* pColonBitmap = null;
1388 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1390 pDisplayBoxNormalBitmap[i] = null;
1391 pAmPmNormalBitmap[i] = null;
1392 backgroundColor[i] = Color();
1393 isDisplayBoxCustomBitmap[i] = false;
1394 isAmPmCustomBitmap[i] = false;
1397 GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_NORMAL, backgroundColor[DATETIME_STATUS_NORMAL]);
1398 GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_PRESSED, backgroundColor[DATETIME_STATUS_SELECTED]);
1399 GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED, backgroundColor[DATETIME_STATUS_HIGHLIGHTED]);
1400 GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_DISABLED, backgroundColor[DATETIME_STATUS_DISABLED]);
1403 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBgBitmap);
1404 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1406 GET_COLOR_CONFIG(DATETIMEPICKER::DISPLAY_BG_NORMAL, color);
1407 __pBgNormalBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgBitmap, replacementColor, color);
1408 r = GetLastResult();
1409 SysTryCatch(NID_UI_CTRL, (__pBgNormalBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1411 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pColonBitmap);
1412 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1414 GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_NORMAL, color);
1415 __pColonBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pColonBitmap, replacementColor, color);
1416 r = GetLastResult();
1417 SysTryCatch(NID_UI_CTRL, (__pColonBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1419 GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_DISABLED, color);
1420 __pColonDisabledBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pColonBitmap, replacementColor, color);
1421 r = GetLastResult();
1422 SysTryCatch(NID_UI_CTRL, (__pColonDisabledBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1424 //display area bg effect
1425 if (!IS_CUSTOM_BITMAP(DATETIMEPICKER::BG_NORMAL))
1427 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBgEffectBitmap);
1428 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1432 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_NORMAL]);
1433 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1435 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_SELECTED]);
1436 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1438 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_HIGHLIGHTED]);
1439 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1441 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_DISABLED]);
1442 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1445 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_NORMAL]);
1446 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1448 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_SELECTED]);
1449 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1451 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_HIGHLIGHTED]);
1452 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1454 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_DISABLED]);
1455 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1457 isDisplayBoxCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_NORMAL);
1458 isDisplayBoxCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_PRESSED);
1459 isDisplayBoxCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_HIGHLIGHTED);
1460 isDisplayBoxCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_DISABLED);
1462 isAmPmCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_NORMAL);
1463 isAmPmCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_PRESSED);
1464 isAmPmCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED);
1465 isAmPmCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_DISABLED);
1468 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1470 if (isDisplayBoxCustomBitmap[i])
1472 __pDisplayBoxNormalBitmap[i] = pDisplayBoxNormalBitmap[i];
1476 __pDisplayBoxNormalBitmap[i] = _BitmapImpl::GetColorReplacedBitmapN(*pDisplayBoxNormalBitmap[i], replacementColor, backgroundColor[i]);
1477 SysTryCatch(NID_UI_CTRL, (__pDisplayBoxNormalBitmap[i] != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1481 if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_NORMAL])
1483 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_NORMAL]);
1484 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1487 if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_SELECTED])
1489 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_SELECTED]);
1490 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1493 if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_HIGHLIGHTED])
1495 Bitmap* pTempBitmap = null;
1497 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
1498 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1501 __pDisplayBoxEffectBitmap[DATETIME_STATUS_HIGHLIGHTED] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), backgroundColor[DATETIME_STATUS_HIGHLIGHTED]);
1502 SysTryCatch(NID_UI_CTRL, (__pDisplayBoxEffectBitmap[DATETIME_STATUS_HIGHLIGHTED] != null), r = GetLastResult(), GetLastResult(),
1503 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1508 if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_DISABLED])
1510 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_DISABLED]);
1511 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1516 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1518 if (isAmPmCustomBitmap[i])
1520 __pAmPmNormalBitmap[i] = pAmPmNormalBitmap[i];
1524 __pAmPmNormalBitmap[i] = _BitmapImpl::GetColorReplacedBitmapN(*pAmPmNormalBitmap[i], replacementColor, backgroundColor[i]);
1525 SysTryCatch(NID_UI_CTRL, (__pAmPmNormalBitmap[i] != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1529 if (!isAmPmCustomBitmap[DATETIME_STATUS_NORMAL])
1531 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_NORMAL]);
1532 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1535 if (!isAmPmCustomBitmap[DATETIME_STATUS_SELECTED])
1537 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_SELECTED]);
1538 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1541 if (!isAmPmCustomBitmap[DATETIME_STATUS_HIGHLIGHTED])
1543 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_HIGHLIGHTED]);
1544 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1547 if (!isAmPmCustomBitmap[DATETIME_STATUS_DISABLED])
1549 r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_DISABLED]);
1550 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1553 delete pColonBitmap;
1556 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1558 delete pDisplayBoxNormalBitmap[i];
1559 delete pAmPmNormalBitmap[i];
1565 delete pColonBitmap;
1567 delete __pColonBitmap;
1568 __pColonBitmap = null;
1570 delete __pColonDisabledBitmap;
1571 __pColonDisabledBitmap = null;
1575 delete __pBgNormalBitmap;
1576 __pBgNormalBitmap = null;
1578 delete __pBgEffectBitmap;
1579 __pBgEffectBitmap = null;
1581 for (int i = 0; i < DATETIME_STATUS_MAX; i++)
1583 delete pDisplayBoxNormalBitmap[i];
1585 delete __pDisplayBoxNormalBitmap[i];
1586 __pDisplayBoxNormalBitmap[i] = null;
1588 delete __pDisplayBoxEffectBitmap[i];
1589 __pDisplayBoxEffectBitmap[i] = null;
1591 delete pAmPmNormalBitmap[i];
1593 delete __pAmPmNormalBitmap[i];
1594 __pAmPmNormalBitmap[i] = null;
1596 delete __pAmPmEffectBitmap[i];
1597 __pAmPmEffectBitmap[i] = null;
1604 _DateTimePresenter::DrawColon(Canvas& canvas)
1606 result r = E_SUCCESS;
1607 _ControlOrientation orientation = __pView->GetOrientation();
1609 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
1610 FloatRectangle colonBounds(0.0f, 0.0f, 0.0f, 0.0f);
1612 float colonWidth = 0.0f;
1613 float colonMargin = 0.0f;
1615 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_WIDTH, orientation, colonWidth);
1616 GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_MARGIN, orientation, colonMargin);
1618 for (int i = 0; i < __outputBoxMaxCount; i++)
1620 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_HOUR)
1622 hourBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
1626 colonBounds.x = hourBounds.x + hourBounds.width + colonMargin;
1627 colonBounds.y = hourBounds.y;
1628 colonBounds.width = colonWidth;
1629 colonBounds.height = hourBounds.height;
1631 if (__pView->IsEnabled() && __pColonBitmap != null)
1633 r = canvas.DrawBitmap(colonBounds, *__pColonBitmap);
1634 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1636 else if (!__pView->IsEnabled() && __pColonDisabledBitmap != null)
1638 r = canvas.DrawBitmap(colonBounds, *__pColonDisabledBitmap);
1639 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1644 _DateTimePresenter::DrawDateTimeDisplayBox(Canvas& canvas, int index)
1646 result r = E_SUCCESS;
1650 int boxId = __pDisplayBox[index]->GetDisplayBoxId();
1651 number = GetNumberInBox(boxId);
1652 DateTimePickerStatus status = DATETIME_STATUS_NORMAL;
1654 GET_SHAPE_CONFIG(DATETIMEPICKER::FONT_SIZE, __pView->GetOrientation(), fontSize);
1656 r = _FontImpl::GetInstance(*__pFont)->SetSize(fontSize);
1657 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1659 if (__pView->IsEnabled() == false)
1661 status = DATETIME_STATUS_DISABLED;
1665 if (__keypadEnabled)
1667 if (index == __focusedBoxIndex)
1669 status = DATETIME_STATUS_HIGHLIGHTED;
1674 if (index == __selectedBoxIndex)
1676 status = DATETIME_STATUS_SELECTED;
1681 if (boxId == DATETIME_ID_YEAR)
1683 if ((__inputComposing == DATETIME_INPUT_BEGIN) && ((__keypadEnabled && status == DATETIME_STATUS_HIGHLIGHTED)
1684 || (!__keypadEnabled && status == DATETIME_STATUS_SELECTED)))
1686 String length = L"%0d";
1688 r = length.Insert(__changeFocusCounter,2);
1689 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1691 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, length.GetPointer(), number);
1692 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1696 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%04d", number);
1697 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1700 else if (boxId == DATETIME_ID_MONTH)
1702 if (__pInputPad != null)
1705 _DateTimeUtils dateTimeUtils;
1706 text = dateTimeUtils.GetMonthString(number);
1710 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%02d", number);
1711 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1716 if ((__inputComposing == DATETIME_INPUT_BEGIN) && ((__keypadEnabled && status == DATETIME_STATUS_HIGHLIGHTED)
1717 || (!__keypadEnabled && status == DATETIME_STATUS_SELECTED)))
1719 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%d", number);
1720 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1724 r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%02d", number);
1725 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1729 __pDisplayBox[index]->SetText(text);
1730 __pDisplayBox[index]->DrawDisplayBox(canvas, status);
1736 _DateTimePresenter::DrawPm(Canvas& canvas)
1740 if ((__is24HourNotation == true) || (__pPmBox == null))
1745 _DateTimeUtils dateTimeUtils;
1747 if (__isPm == false)
1749 dateTimeUtils.GetAmPm(text, AM_TYPE);
1753 dateTimeUtils.GetAmPm(text, PM_TYPE);
1756 __pPmBox->SetText(text);
1758 if (__pView->IsEnabled() == false)
1760 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_DISABLED);
1762 else if (__isPmButtonPressed == true)
1764 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_SELECTED);
1768 if (__keypadEnabled && __focusedBoxIndex == __outputBoxMaxCount)
1770 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_HIGHLIGHTED);
1774 __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_NORMAL);
1780 _DateTimePresenter::DrawBackground(Canvas& canvas)
1782 result r = E_SUCCESS;
1783 FloatRectangle bounds = canvas.GetBoundsF();
1784 Color backgroundColor(0, 0, 0, 0);
1786 GET_COLOR_CONFIG(DATETIMEPICKER::BG_NORMAL, backgroundColor);
1787 canvas.SetBackgroundColor(backgroundColor);
1790 if (__pBgNormalBitmap)
1792 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pBgNormalBitmap))
1794 canvas.DrawNinePatchedBitmap(bounds, *__pBgNormalBitmap);
1795 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1799 canvas.DrawBitmap(bounds, *__pBgNormalBitmap);
1800 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1804 if (__pBgEffectBitmap)
1806 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pBgEffectBitmap))
1808 canvas.DrawNinePatchedBitmap(bounds, *__pBgEffectBitmap);
1809 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1813 canvas.DrawBitmap(bounds, *__pBgEffectBitmap);
1814 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1822 _DateTimePresenter::DrawTitle(Canvas& canvas)
1824 result r = E_SUCCESS;
1825 float marginX = 0.0f;
1826 float marginY = 0.0f;
1828 Color color(0, 0, 0, 0);
1829 _ControlOrientation orientation = __pView->GetOrientation();
1831 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_LEFT_MARGIN, orientation, marginX);
1832 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, marginY);
1834 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_FONT_SIZE, orientation, fontSize);
1836 r = _FontImpl::GetInstance(*__pFont)->SetSize(fontSize);
1837 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1839 if (__pView->IsEnabled())
1841 GET_COLOR_CONFIG(DATETIMEPICKER::TITLE_NORMAL, color);
1845 GET_COLOR_CONFIG(DATETIMEPICKER::TITLE_DISABLED, color);
1848 canvas.SetForegroundColor(color);
1849 canvas.SetFont(*__pFont);
1850 canvas.DrawText(FloatPoint(marginX, marginY), __title);
1856 _DateTimePresenter::DrawDividers(Canvas& canvas)
1858 result r = E_SUCCESS;
1859 float dividerWidth = 0.0f;
1860 float dividerHeight = 0.0f;
1861 float dividerMargin = 0.0f;
1862 float displayBoxheight = 0.0f;
1863 FloatPoint lineStart(0.0f,0.0f);
1864 FloatPoint lineEnd(0.0f,0.0f);
1865 Color colorHalfLeft;
1866 Color colorHalfRight;
1868 _ControlOrientation orientation = __pView->GetOrientation();
1870 GET_FIXED_VALUE_CONFIG(DATETIMEPICKER::DIVIDER_WIDTH, orientation, dividerWidth);
1871 GET_SHAPE_CONFIG(DATETIMEPICKER::DIVIDER_HEIGHT, orientation, dividerHeight);
1872 GET_SHAPE_CONFIG(DATETIMEPICKER::DIVIDER_MARGIN, orientation, dividerMargin);
1873 GET_SHAPE_CONFIG(DATETIMEPICKER::DATETIME_DISPLAY_BOX_HEIGHT, orientation, displayBoxheight);
1875 GET_COLOR_CONFIG(DATETIMEPICKER::DIVIDER_LEFT_HALF, colorHalfLeft);
1876 GET_COLOR_CONFIG(DATETIMEPICKER::DIVIDER_RIGHT_HALF, colorHalfRight);
1878 if (__title.IsEmpty())
1880 lineStart.y = (GetOutputArea().height - dividerHeight) / 2.0f;
1881 lineEnd.y = lineStart.y + dividerHeight;
1885 float topMargin = 0.0f;
1886 float bottomMargin = 0.0f;
1887 float titleHeight = 0.0f;
1889 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, topMargin);
1890 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_BOTTOM_MARGIN, orientation, bottomMargin);
1891 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_HEIGHT, orientation, titleHeight);
1893 lineStart.y = topMargin + titleHeight + bottomMargin + ((displayBoxheight - dividerHeight) / 2.0f);
1894 lineEnd.y = lineStart.y + dividerHeight;
1897 canvas.SetLineWidth(dividerWidth/2.0f);
1899 FloatRectangle lastDateDisplayBoxBounds(0.0f, 0.0f, 0.0f, 0.0f);
1901 _DateTimeUtils dateTimeUtils;
1902 int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
1904 for (int i = 0; i < __outputBoxMaxCount; i++)
1906 switch (localeDateFormat)
1908 case DATE_FORMAT_DDMMYYYY:
1909 case DATE_FORMAT_MMDDYYYY:
1911 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_YEAR)
1913 lastDateDisplayBoxBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
1917 case DATE_FORMAT_YYYYMMDD:
1919 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_DAY)
1921 lastDateDisplayBoxBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
1925 case DATE_FORMAT_YYYYDDMM:
1927 if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_MONTH)
1929 lastDateDisplayBoxBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
1936 lineStart.x = lastDateDisplayBoxBounds.x + lastDateDisplayBoxBounds.width + dividerMargin;
1937 lineEnd.x = lineStart.x;
1939 canvas.SetForegroundColor(colorHalfLeft);
1940 r = canvas.DrawLine(lineStart, lineEnd);
1941 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1943 lineStart.x += dividerWidth/2;
1944 lineEnd.x = lineStart.x;
1946 canvas.SetForegroundColor(colorHalfRight);
1947 r = canvas.DrawLine(lineStart, lineEnd);
1948 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1954 _DateTimePresenter::GetOutputArea(void)
1956 _ControlOrientation orientation = __pView->GetOrientation();
1958 FloatRectangle outputArea(0.0f, 0.0f, 0.0f, 0.0f);
1960 GET_SHAPE_CONFIG(DATETIMEPICKER::LEFT_MARGIN, orientation, outputArea.x);
1961 GET_SHAPE_CONFIG(DATETIMEPICKER::TOP_MARGIN, orientation, outputArea.y);
1963 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1965 float headerHeight = 0.0f;
1967 GET_SHAPE_CONFIG(HEADER::HEIGHT, orientation, headerHeight);
1968 outputArea.y += headerHeight;
1971 outputArea.width = __pView->GetBounds().width - 2 * outputArea.x;
1973 GET_SHAPE_CONFIG(DATETIMEPICKER::OUTPUT_AREA_HEIGHT, orientation, outputArea.height);
1979 _DateTimePresenter::ChangeInputPadStyle(int boxId)
1981 if (__inputPadEnabled == false)
1986 SysTryReturnVoidResult(NID_UI_CTRL, __pInputPad != null, E_SYSTEM,
1987 "[E_SYSTEM] A system error has occurred. The instance of Inputpad is null.");
1989 _InputPadStyle inputPadType = INPUTPAD_STYLE_NORMAL;
1992 case DATETIME_ID_MONTH:
1993 inputPadType = INPUTPAD_STYLE_ALPHA;
1996 case DATETIME_ID_YEAR:
1997 // fall through intentional
1998 case DATETIME_ID_DAY:
1999 // fall through intentional
2000 case DATETIME_ID_HOUR:
2001 // fall through intentional
2002 case DATETIME_ID_MINUTE:
2003 // fall through intentional
2005 inputPadType = INPUTPAD_STYLE_NORMAL;
2009 if (__inputPadType == inputPadType)
2013 __inputPadType = inputPadType;
2015 __pInputPad->SetInputPadStyle(inputPadType);
2016 result r = GetLastResult();
2017 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
2021 _DateTimePresenter::CalculateTouchArea(float posX, float posY)
2023 _ControlOrientation orientation = __pView->GetOrientation();
2024 FloatRectangle outputArea = GetOutputArea();
2026 float margin = 0.0f;
2028 GET_SHAPE_CONFIG(DATETIMEPICKER::TOP_MARGIN, orientation, margin);
2030 if ((posX < outputArea.x) || (posY < outputArea.y))
2032 return DATETIME_AREA_NONE;
2035 int touched = DATETIME_AREA_NONE;
2037 if (posY < outputArea.y + outputArea.height)
2039 float displayBoxHeight = 0.0f;
2040 float amPmBoxHeight = 0.0f;
2042 GET_SHAPE_CONFIG(DATETIMEPICKER::DATETIME_DISPLAY_BOX_HEIGHT, orientation, displayBoxHeight);
2043 GET_SHAPE_CONFIG(DATETIMEPICKER::AMPM_DISPLAY_BOX_HEIGHT, orientation, amPmBoxHeight);
2045 float displayBoxPosY = outputArea.y + ((outputArea.height - displayBoxHeight) / 2.0f);
2046 float amPmBoxPosY = outputArea.y + ((outputArea.height - amPmBoxHeight) / 2.0f);
2048 if (__title.IsEmpty())
2050 displayBoxPosY = outputArea.y + ((outputArea.height - displayBoxHeight) / 2.0f);
2051 amPmBoxPosY = outputArea.y + ((outputArea.height - amPmBoxHeight) / 2.0f);
2055 float topMargin = 0.0f;
2056 float bottomMargin = 0.0f;
2057 float titleHeight = 0.0f;
2059 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, topMargin);
2060 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_BOTTOM_MARGIN, orientation, bottomMargin);
2061 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_HEIGHT, orientation, titleHeight);
2063 displayBoxPosY = outputArea.y + topMargin + bottomMargin + titleHeight;
2064 amPmBoxPosY = outputArea.y + topMargin + titleHeight;
2067 if ((posY >= amPmBoxPosY) && (posY <= amPmBoxPosY + amPmBoxHeight))
2069 if ((posY >= displayBoxPosY) && (posY <= displayBoxPosY + displayBoxHeight))
2072 touched = DATETIME_AREA_OUTPUT;
2075 if (__pPmBox != null)
2078 FloatRectangle boxBounds = __pPmBox->GetDisplayBoxBounds();
2080 if ((posX >= boxBounds.x) && (posX < boxBounds.x + boxBounds.width))
2082 touched = DATETIME_AREA_OUTPUT_AMPM;
2090 touched = DATETIME_AREA_INPUT;
2097 _DateTimePresenter::CalculateTouchOutputArea(float posX, float posY)
2099 FloatRectangle outputArea = GetOutputArea();
2100 _ControlOrientation orientation = __pView->GetOrientation();
2102 for (int i = 0; i < __outputBoxMaxCount; i++)
2104 FloatRectangle boxBounds = __pDisplayBox[i]->GetDisplayBoxBounds();
2106 if (__title.IsEmpty())
2108 boxBounds.y = outputArea.y + ((outputArea.height - boxBounds.height) / 2.0f);
2112 float topMargin = 0.0f;
2113 float bottomMargin = 0.0f;
2114 float titleHeight = 0.0f;
2116 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_TOP_MARGIN, orientation, topMargin);
2117 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_BOTTOM_MARGIN, orientation, bottomMargin);
2118 GET_SHAPE_CONFIG(DATETIMEPICKER::TITLE_HEIGHT, orientation, titleHeight);
2120 boxBounds.y = outputArea.y + topMargin + titleHeight + bottomMargin;
2123 if ((posX >= boxBounds.x) && (posX < boxBounds.x + boxBounds.width)
2124 && (posY >= boxBounds.y) && (posY < boxBounds.y + boxBounds.height))
2134 _DateTimePresenter::CalculateTwoDigit(int originalNumber, int number)
2136 int twoDigit = (originalNumber * 10) + number;
2143 if ((twoDigit > 0) && (twoDigit > DATETIME_TWO_DIGIT_MAX))
2145 twoDigit = twoDigit % (DATETIME_TWO_DIGIT_MAX + 1);
2152 _DateTimePresenter::CalculateFourDigit(int originalNumber, int number)
2154 int fourDigit = (originalNumber * 10) + number;
2161 if ((fourDigit > 0) && (fourDigit > DATETIME_FOUR_DIGIT_MAX))
2163 fourDigit = fourDigit % (DATETIME_FOUR_DIGIT_MAX + 1);
2169 _DateTimePresenter::SetTwoDigit(int originalNumber, int number)
2173 if ((originalNumber <= DATETIME_ONE_DIGIT_MAX) && (__inputComposing == DATETIME_INPUT_BEGIN))
2175 twoDigit = (originalNumber * 10) + number;
2185 _DateTimePresenter::SetFourDigit(int originalNumber, int number)
2191 GetYearRange(minYear, maxYear);
2192 if ((originalNumber <= DATETIME_THREE_DIGIT_MAX) && (__inputComposing == DATETIME_INPUT_BEGIN))
2194 fourDigit = (originalNumber * 10) + number;
2195 if (fourDigit > maxYear)
2197 fourDigit = maxYear;
2209 _DateTimePresenter::SetNumberInBox(int boxId, int number)
2213 case DATETIME_ID_YEAR:
2217 case DATETIME_ID_MONTH:
2221 case DATETIME_ID_DAY:
2225 case DATETIME_ID_HOUR:
2229 case DATETIME_ID_MINUTE:
2239 _DateTimePresenter::GetNumberInBox(int boxId) const
2245 case DATETIME_ID_YEAR:
2249 case DATETIME_ID_MONTH:
2253 case DATETIME_ID_DAY:
2257 case DATETIME_ID_HOUR:
2261 case DATETIME_ID_MINUTE:
2273 _DateTimePresenter::SetFocusBox(int index)
2275 if (__keypadEnabled)
2277 __focusedBoxIndex = index;
2279 if (__focusedBoxIndex < __outputBoxMaxCount)
2281 __selectedBoxIndex = __focusedBoxIndex;
2285 __isFocusBoxChanged = true;
2286 __inputComposing = DATETIME_INPUT_END;
2287 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
2289 int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
2291 ChangeInputPadStyle(boxId);
2295 _DateTimePresenter::LoadPickerData(void)
2297 _DateTimeUtils dateTimeUtils;
2300 __month = GetMonth();
2304 if (__is24HourNotation == false)
2306 int max = DATETIME_HOUR_MAX_FOR_24NOTATION;
2308 if (__hour == DATETIME_HOUR_MIN)
2310 __hour = __hour + max;
2313 else if (__hour < max && __hour != DATETIME_HOUR_MIN)
2317 else if (__hour == max)
2321 else if (__hour > max && __hour <= DATETIME_HOUR_MAX)
2323 __hour = __hour - max;
2326 else if (__hour == DATETIME_HOUR_MAX + 1)
2333 __minute = GetMinute();
2337 _DateTimePresenter::SavePickerData(void)
2343 if (__is24HourNotation == false)
2345 int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION;
2349 if (__hour < maxHour)
2351 SetHour(__hour + maxHour);
2360 if (__hour < maxHour)
2366 SetHour(__hour - maxHour);
2375 SetMinute(__minute);
2379 _DateTimePresenter::UpdateDisplayData(int boxId)
2383 case DATETIME_ID_YEAR:
2387 case DATETIME_ID_MONTH:
2388 __month = GetMonth();
2391 case DATETIME_ID_DAY:
2395 case DATETIME_ID_HOUR:
2398 if (__is24HourNotation == false)
2400 int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION;
2402 if (__hour == DATETIME_HOUR_MIN)
2407 else if (__hour < maxHour && __hour != DATETIME_HOUR_MIN)
2411 else if (__hour == maxHour)
2415 else if (__hour > maxHour && __hour <= DATETIME_HOUR_MAX)
2417 __hour = __hour - maxHour;
2420 else if (__hour == DATETIME_HOUR_MAX + 1)
2422 __hour = __hour - maxHour;
2428 case DATETIME_ID_MINUTE:
2429 __minute = GetMinute();
2438 _DateTimePresenter::AdjustValue(int& value, int minValue, int maxValue)
2440 if (value < minValue)
2444 else if (maxValue < value)
2451 _DateTimePresenter::AdjustDisplayValue(int index)
2453 int boxId = __pDisplayBox[index]->GetDisplayBoxId();
2454 _DateTimeUtils dateTimeUtils;
2460 case DATETIME_ID_YEAR:
2463 GetYearRange(minValue, maxValue);
2464 AdjustValue(__year, minValue, maxValue);
2467 case DATETIME_ID_MONTH:
2468 minValue = DATETIME_MONTH_MIN;
2469 maxValue = DATETIME_MONTH_MAX;
2470 AdjustValue(__month, minValue, maxValue);
2473 case DATETIME_ID_DAY:
2475 maxValue = dateTimeUtils.CalculateMaxDay(__year, __month);
2476 AdjustValue(__day, minValue, maxValue);
2479 case DATETIME_ID_HOUR:
2480 minValue = DATETIME_HOUR_MIN;
2481 maxValue = DATETIME_HOUR_MAX;
2482 if (__is24HourNotation == false)
2484 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
2486 if (__hour == DATETIME_HOUR_MIN)
2488 minValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
2491 AdjustValue(__hour, minValue, maxValue);
2494 case DATETIME_ID_MINUTE:
2495 minValue = DATETIME_MINUTE_MIN;
2496 maxValue = DATETIME_MINUTE_MAX;
2497 AdjustValue(__minute, minValue, maxValue);
2506 _DateTimePresenter::ChangeFocusBox(void)
2508 if (__keypadEnabled)
2510 if (__focusedBoxIndex < __outputBoxMaxCount - 1)
2512 __focusedBoxIndex++;
2513 __selectedBoxIndex = __focusedBoxIndex;
2514 int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
2515 ChangeInputPadStyle(boxId);
2516 __isFocusBoxChanged = true;
2521 if (__selectedBoxIndex < (__outputBoxMaxCount - 1))
2523 __selectedBoxIndex++;
2524 __focusedBoxIndex = __selectedBoxIndex;
2525 int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
2526 ChangeInputPadStyle(boxId);
2527 __isFocusBoxChanged = true;
2531 for (int i = 0; i < __outputBoxMaxCount; i++)
2533 AdjustDisplayValue(i);
2536 __inputComposing = DATETIME_INPUT_END;
2537 __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
2541 _DateTimePresenter::SetAccessibilityElementText(void)
2543 for (int index = 0; index < __outputBoxMaxCount; ++index)
2545 if (__pDisplayBox[index]->GetDisplayBoxId() == DATETIME_ID_MONTH)
2547 int number = GetNumberInBox(__pDisplayBox[index]->GetDisplayBoxId());
2548 __pView->SetAccessibilityElementText(index, __pInputPad->GetAccessibilityElementMonthName(number-1), false);
2552 __pView->SetAccessibilityElementText(index, __pDisplayBox[index]->GetText(), false);
2558 __pView->SetAccessibilityElementText(__outputBoxMaxCount, __pPmBox->GetText(), true);
2562 }}} // Tizen::Ui::Controls