2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_EditDate.cpp
20 * @brief This is the implementation file for the _EditDate class.
24 #include "FUi_AccessibilityContainer.h"
25 #include "FUi_AccessibilityElement.h"
26 #include "FUi_ResourceManager.h"
27 #include "FUiAnim_VisualElement.h"
28 #include "FUiCtrl_EditDate.h"
29 #include "FUiCtrl_EditDatePresenter.h"
30 #include "FUiCtrl_Form.h"
31 #include "FUiCtrl_Frame.h"
32 #include "FUiCtrl_DateTimeUtils.h"
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Ui;
39 namespace Tizen { namespace Ui { namespace Controls
42 IMPLEMENT_PROPERTY(_EditDate);
44 _EditDate::_EditDate(void)
45 : __pEditDatePresenter(null)
46 , __pDateChangeEvent(null)
47 , __pDateTimeBar(null)
48 , __absoluteBounds(Rectangle())
50 , __pAccessibilityTitleElement(null)
51 , __pAccessibilityYearElement(null)
52 , __pAccessibilityMonthElement(null)
53 , __pAccessibilityDayElement(null)
57 _EditDate::~_EditDate(void)
59 delete __pDateTimeBar;
60 __pDateTimeBar = null;
62 delete __pEditDatePresenter;
63 __pEditDatePresenter = null;
65 if (__pDateChangeEvent != null)
67 delete __pDateChangeEvent;
68 __pDateChangeEvent = null;
71 if (__pAccessibilityTitleElement)
73 __pAccessibilityTitleElement->Activate(false);
74 __pAccessibilityTitleElement = null;
76 if (__pAccessibilityYearElement)
78 __pAccessibilityYearElement->Activate(false);
79 __pAccessibilityYearElement = null;
81 if (__pAccessibilityMonthElement)
83 __pAccessibilityMonthElement->Activate(false);
84 __pAccessibilityMonthElement = null;
86 if (__pAccessibilityDayElement)
88 __pAccessibilityDayElement->Activate(false);
89 __pAccessibilityDayElement = null;
94 _EditDate::CreateEditDateN(const String& title)
98 _AccessibilityContainer* pContainer = null;
100 _EditDate* pEditDate = new (std::nothrow) _EditDate;
101 SysTryReturn(NID_UI_CTRL, pEditDate, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
103 pEditDate->GetVisualElement()->SetSurfaceOpaque(false);
105 pEditDate->__pEditDatePresenter = _EditDatePresenter::CreateInstanceN(*pEditDate, title);
107 r = pEditDate->CreateDateTimeBar();
108 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
110 pEditDate->__pEditDatePresenter->Initialize();
112 SysTryCatch(NID_UI_CTRL, pEditDate->__pEditDatePresenter, , r, "[%s] Propagating.", GetErrorMessage(r));
114 pEditDate->__pEditDatePresenter->SetCurrentDate();
116 if (title.IsEmpty() != true)
118 pEditDate->__title = title;
121 pEditDate->SetResizable(false);
123 pContainer = pEditDate->GetAccessibilityContainer();
127 pContainer->Activate(true);
130 pEditDate->AcquireHandle();
140 _EditDate::CreateDateTimeBar(void)
142 result r = E_SUCCESS;
144 __pDateTimeBar = _DateTimeBar::CreateDateTimeBarN();
146 SysTryReturn(NID_UI_CTRL, (__pDateTimeBar != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
148 r = __pDateTimeBar->AddActionEventListener(*this);
149 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
151 r = __pDateTimeBar->AddDateTimeChangeEventListener(*this);
152 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
157 delete __pDateTimeBar;
162 _EditDate::AddDateChangeEventListener(const _IDateTimeChangeEventListener& listener)
164 if (__pDateChangeEvent == null)
166 __pDateChangeEvent = new (std::nothrow) _DateTimeChangeEvent(*this);
167 SysTryReturn(NID_UI_CTRL, (__pDateChangeEvent != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
168 "[E_OUT_OF_MEMORY] Memory allocation failed.");
171 result r = __pDateChangeEvent->AddListener(listener);
172 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
178 _EditDate::RemoveDateChangeEventListener(const _IDateTimeChangeEventListener& listener)
180 result r = E_OBJ_NOT_FOUND;
182 if (__pDateChangeEvent)
184 r = __pDateChangeEvent->RemoveListener(listener);
187 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
193 _EditDate::SetDate(const DateTime& date)
195 SetProperty("date", Variant(date));
200 _EditDate::SetPropertyDate(const Variant& date)
202 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
203 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
205 __pEditDatePresenter->SetDate(date.ToDateTime());
207 UpdateAccessibilityElement();
212 _EditDate::GetDate(void) const
214 Variant date = GetProperty("date");
216 return date.ToDateTime();
220 _EditDate::GetPropertyDate(void) const
224 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
225 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
227 date = __pEditDatePresenter->GetDate();
229 return Variant(date);
233 _EditDate::SetDay(int day)
235 result r = E_SUCCESS;
237 SetProperty("day", Variant(day));
245 _EditDate::SetPropertyDay(const Variant& day)
247 result r = E_SUCCESS;
249 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
250 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
252 r = __pEditDatePresenter->SetDay(day.ToInt());
256 UpdateAccessibilityElement();
263 _EditDate::GetDay(void) const
265 Variant day = GetProperty("day");
271 _EditDate::GetPropertyDay(void) const
275 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
276 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
278 day = __pEditDatePresenter->GetDay();
284 _EditDate::SetMonth(int month)
286 result r = E_SUCCESS;
288 SetProperty("month", Variant(month));
296 _EditDate::SetPropertyMonth(const Variant& month)
298 result r = E_SUCCESS;
300 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
301 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
303 r = __pEditDatePresenter->SetMonth(month.ToInt());
307 UpdateAccessibilityElement();
314 _EditDate::GetMonth(void) const
316 Variant month = GetProperty("month");
318 return month.ToInt();
322 _EditDate::GetPropertyMonth(void) const
326 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
327 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
329 month = __pEditDatePresenter->GetMonth();
331 return Variant(month);
335 _EditDate::SetYear(int year)
337 result r = E_SUCCESS;
339 SetProperty("year", Variant(year));
347 _EditDate::SetPropertyYear(const Variant& year)
349 result r = E_SUCCESS;
351 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
352 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
354 r = __pEditDatePresenter->SetYear(year.ToInt());
358 UpdateAccessibilityElement();
365 _EditDate::GetYear(void) const
367 Variant year = GetProperty("year");
373 _EditDate::GetPropertyYear(void) const
377 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
378 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
380 year = __pEditDatePresenter->GetYear();
382 return Variant(year);
386 _EditDate::SetCurrentDate(void)
388 SysTryReturnVoidResult(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM,
389 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
391 __pEditDatePresenter->SetCurrentDate();
393 UpdateAccessibilityElement();
399 _EditDate::SetDatePickerEnabled(bool enable)
401 SetProperty("datePickerEnabled", Variant(enable));
406 _EditDate::SetPropertyDatePickerEnabled(const Variant& enable)
408 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
409 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
411 __pEditDatePresenter->SetDatePickerEnabled(enable.ToBool());
417 _EditDate::IsDatePickerEnabled(void) const
419 Variant enable = GetProperty("datePickerEnabled");
421 return enable.ToBool();
425 _EditDate::GetPropertyDatePickerEnabled(void) const
429 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
430 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
432 enable = __pEditDatePresenter->IsDatePickerEnabled();
434 return Variant(enable);
438 _EditDate::SetYearRange(int minYear, int maxYear)
440 result r = E_SUCCESS;
442 SysTryReturn(NID_UI_CTRL, (maxYear >= DATETIME_YEAR_MIN && maxYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, E_INVALID_ARG,
443 "[E_INVALID_ARG] maxYear(%d) must be greater than or equal to %d and less than or equal to %d.",
444 maxYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX);
446 SysTryReturn(NID_UI_CTRL, (minYear >= DATETIME_YEAR_MIN && minYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, E_INVALID_ARG,
447 "[E_INVALID_ARG] minYear(%d) must be greater than or equal to %d and less than or equal to %d.",
448 minYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX);
450 SysTryReturn(NID_UI_CTRL, (maxYear >= minYear), E_INVALID_ARG, E_INVALID_ARG,
451 "[E_INVALID_ARG] maxYear(%d) must be greater than or equal to minYear(%d).", maxYear, minYear);
453 Variant oldMinYear = GetPropertyMinYearRange();
455 r = SetPropertyMinYearRange(Variant(minYear));
456 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
458 r = SetPropertyMaxYearRange(Variant(maxYear));
462 SetPropertyMinYearRange(oldMinYear);
469 _EditDate::SetMinYearRange(int minYear)
471 result r = E_SUCCESS;
473 r = SetProperty("minYearRange", Variant(minYear));
479 _EditDate::SetMaxYearRange(int maxYear)
481 result r = E_SUCCESS;
483 r = SetProperty("maxYearRange", Variant(maxYear));
489 _EditDate::SetPropertyMinYearRange(const Variant& minYear)
491 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
492 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
494 return __pEditDatePresenter->SetMinYear(minYear.ToInt());
498 _EditDate::SetPropertyMaxYearRange(const Variant& maxYear)
500 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
501 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
503 return __pEditDatePresenter->SetMaxYear(maxYear.ToInt());
507 _EditDate::GetYearRange(int& minYear, int& maxYear) const
509 result r = E_SUCCESS;
511 minYear = GetMinYearRange();
512 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
513 maxYear = GetMaxYearRange();
514 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
520 _EditDate::GetMinYearRange(void) const
522 Variant minYear = GetProperty("minYearRange");
524 return minYear.ToInt();
528 _EditDate::GetMaxYearRange(void) const
530 Variant maxYear = GetProperty("maxYearRange");
532 return maxYear.ToInt();
536 _EditDate::GetPropertyMinYearRange(void) const
538 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
539 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
543 minYear = __pEditDatePresenter->GetMinYear();
545 return Variant(minYear);
549 _EditDate::GetPropertyMaxYearRange(void) const
551 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
552 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
556 maxYear = __pEditDatePresenter->GetMaxYear();
558 return Variant(maxYear);
562 _EditDate::CalculateDateTimeBarPosition(void)
564 result r = E_SUCCESS;
565 Rectangle absoluteBounds;
566 Rectangle parentBounds;
567 Rectangle frameBounds;
569 absoluteBounds = GetAbsoluteBounds();
571 _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
572 SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, E_SYSTEM,
573 "[E_SYSTEM] A system error has occurred. Failed to get frame instance.");
575 _Form* pForm = pFrame->GetCurrentForm();
576 SysTryReturn(NID_UI_CTRL, pForm != null, E_SYSTEM, E_SYSTEM,
577 "[E_SYSTEM] A system error has occurred. Failed to get form instance.");
579 parentBounds = pForm->GetClientBounds();
580 frameBounds = pFrame->GetAbsoluteBounds();
582 int dateTimeBarHeight = 0;
583 GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, GetOrientation(), dateTimeBarHeight);
585 Rectangle parentWindowBounds = GetParentWindowBounds();
586 int bottomMargin = 0;
587 // DateTimeBar top margin can be used as Editdate's bottom margin.
588 GET_SHAPE_CONFIG(DATETIMEBAR::TOP_MARGIN, GetOrientation(), bottomMargin);
590 int bottomPosition = 0;
591 bottomPosition = absoluteBounds.y + absoluteBounds.height + bottomMargin + dateTimeBarHeight;
593 GetDateTimeBar()->SetParentWindowBounds(parentWindowBounds);
595 if (bottomPosition > frameBounds.y + parentBounds.y + parentBounds.height)
597 r = GetDateTimeBar()->SetPositionAndAlignment(Point(parentWindowBounds.x, absoluteBounds.y), DATETIME_BAR_ALIGN_UP);
598 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
602 r = GetDateTimeBar()->SetPositionAndAlignment(Point(parentWindowBounds.x, absoluteBounds.y + absoluteBounds.height + bottomMargin), DATETIME_BAR_ALIGN_DOWN);
603 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
606 __absoluteBounds = absoluteBounds;
612 _EditDate::OnDraw(void)
614 if (GetDateTimeBar() != null)
616 CalculateDateTimeBarPosition();
619 __pEditDatePresenter->Draw();
624 _EditDate::OnAttachedToMainTree(void)
626 if (likely(!(_AccessibilityManager::IsActivated())))
631 Rectangle dayBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_DAY);
632 Rectangle monthBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_MONTH);
633 Rectangle yearBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_YEAR);
635 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
639 if (__pAccessibilityTitleElement == null)
641 __pAccessibilityTitleElement = new _AccessibilityElement(true);
642 __pAccessibilityTitleElement->SetBounds(GetBounds());
643 __pAccessibilityTitleElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
644 pContainer->AddElement(*__pAccessibilityTitleElement);
647 if (__pAccessibilityYearElement == null && __pAccessibilityMonthElement == null && __pAccessibilityDayElement == null)
649 String hintText(L"Double tap to edit");
651 __pAccessibilityYearElement = new _AccessibilityElement(true);
652 __pAccessibilityYearElement->SetBounds(yearBounds);
653 __pAccessibilityYearElement->SetTrait(ACCESSIBILITY_TRAITS_YEAR);
654 __pAccessibilityYearElement->SetHint(hintText);
656 __pAccessibilityMonthElement = new _AccessibilityElement(true);
657 __pAccessibilityMonthElement->SetBounds(monthBounds);
658 __pAccessibilityMonthElement->SetTrait(ACCESSIBILITY_TRAITS_MONTH);
659 __pAccessibilityMonthElement->SetHint(hintText);
661 __pAccessibilityDayElement = new _AccessibilityElement(true);
662 __pAccessibilityDayElement->SetBounds(dayBounds);
663 __pAccessibilityDayElement->SetTrait(ACCESSIBILITY_TRAITS_DAY);
664 __pAccessibilityDayElement->SetHint(hintText);
666 switch (__pEditDatePresenter->GetLocaleDateFormat())
668 case SETTING_DATE_FORMAT_DD_MM_YYYY:
669 pContainer->AddElement(*__pAccessibilityDayElement);
670 pContainer->AddElement(*__pAccessibilityMonthElement);
671 pContainer->AddElement(*__pAccessibilityYearElement);
673 case SETTING_DATE_FORMAT_MM_DD_YYYY:
674 pContainer->AddElement(*__pAccessibilityMonthElement);
675 pContainer->AddElement(*__pAccessibilityDayElement);
676 pContainer->AddElement(*__pAccessibilityYearElement);
678 case SETTING_DATE_FORMAT_YYYY_MM_DD:
679 pContainer->AddElement(*__pAccessibilityYearElement);
680 pContainer->AddElement(*__pAccessibilityMonthElement);
681 pContainer->AddElement(*__pAccessibilityDayElement);
683 case SETTING_DATE_FORMAT_YYYY_DD_MM:
684 pContainer->AddElement(*__pAccessibilityYearElement);
685 pContainer->AddElement(*__pAccessibilityDayElement);
686 pContainer->AddElement(*__pAccessibilityMonthElement);
692 UpdateAccessibilityElement();
699 _EditDate::OnBoundsChanged(void)
701 __pEditDatePresenter->Initialize();
703 if (__pAccessibilityTitleElement)
705 __pAccessibilityTitleElement->SetBounds(__pEditDatePresenter->GetTitleBounds());
707 if (__pAccessibilityYearElement)
709 __pAccessibilityYearElement->SetBounds(__pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_YEAR));
711 if (__pAccessibilityMonthElement)
713 __pAccessibilityMonthElement->SetBounds(__pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_MONTH));
715 if (__pAccessibilityDayElement)
717 __pAccessibilityDayElement->SetBounds(__pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_DAY));
724 _EditDate::OnChangeLayout(_ControlOrientation orientation)
726 __pEditDatePresenter->OnChangeLayout(orientation);
728 if (GetDateTimeBar() != null)
730 CalculateDateTimeBarPosition();
731 GetDateTimeBar()->Close();
738 _EditDate::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
740 Rectangle absoluteBounds = GetAbsoluteBounds();
742 if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
744 CalculateDateTimeBarPosition();
747 return __pEditDatePresenter->OnTouchPressed(source, touchinfo);
751 _EditDate::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
753 return __pEditDatePresenter->OnTouchReleased(source, touchinfo);
757 _EditDate::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
759 return __pEditDatePresenter->OnTouchCanceled(source, touchinfo);
763 _EditDate::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
765 return __pEditDatePresenter->OnTouchMoved(source, touchinfo);
769 _EditDate::OnTouchMoveHandled(const _Control& control)
771 __pEditDatePresenter->OnTouchMoveHandled(control);
776 _EditDate::FireDateChangeEvent(_DateTimeChangeStatus status)
778 SysTryReturn(NID_UI_CTRL, (__pDateChangeEvent != null), E_INVALID_STATE, E_INVALID_STATE,
779 "[E_INVALID_STATE] The _DateChangeEvent instance is null.");
781 _DateTimeChangeEventArg* pDateTimeEventArg = new (std::nothrow) _DateTimeChangeEventArg(status);
782 SysTryReturn(NID_UI_CTRL, pDateTimeEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
784 pDateTimeEventArg->SetDate(GetYear(), GetMonth(), GetDay());
786 __pDateChangeEvent->Fire(*pDateTimeEventArg);
792 _EditDate::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute)
794 __pEditDatePresenter->Animate();
796 FireDateChangeEvent(DATE_INTERNAL_CHANGE_SAVED);
801 _EditDate::OnDateTimeChangeCanceled(const _Control& source)
805 FireDateChangeEvent(DATE_INTERNAL_CHANGE_CANCELED);
810 _EditDate::OnActionPerformed(const Ui::_Control& source, int actionId)
812 _DateTimeId boxId = __pEditDatePresenter->GetLastSelectedId();
814 if (boxId == DATETIME_ID_YEAR)
817 AdjustDay(actionId, GetMonth());
819 else if (boxId == DATETIME_ID_MONTH)
822 AdjustDay(GetYear(), actionId);
824 else if (boxId == DATETIME_ID_DAY)
835 _EditDate::AdjustDay(int year, int month)
837 _DateTimeUtils dateTimeUtils;
838 int maxValue = dateTimeUtils.CalculateMaxDay(year, month);
840 if (GetDay() > maxValue)
849 _EditDate::GetDateTimeBar(void) const
851 return __pDateTimeBar;
855 _EditDate::OnFontChanged(Font* pFont)
857 __pEditDatePresenter->OnFontChanged(pFont);
863 _EditDate::OnFontInfoRequested(unsigned long& style, int& size)
865 __pEditDatePresenter->OnFontInfoRequested(style, size);
871 _EditDate::GetParentWindowBounds(void) const
874 _Window* pwindow = null;
875 _Control* pControlCore = GetParent();
877 Dimension dateTimeBarSize(0, 0);
878 GET_DIMENSION_CONFIG(DATETIMEBAR::DEFAULT_SIZE, GetOrientation(), dateTimeBarSize);
879 Rectangle parentWindowBounds(0, 0, dateTimeBarSize.width, dateTimeBarSize.height);
883 if (pControlCore == null)
885 SysLog(NID_UI_CTRL,"[E_SYSTEM] Parent window not found.");
887 return parentWindowBounds;
890 // If the parent is a Frame, then return the Form's bounds.
891 pForm = dynamic_cast<_Form*>(pControlCore);
894 parentWindowBounds = pForm->GetBounds();
898 pwindow = dynamic_cast<_Window*>(pControlCore);
902 parentWindowBounds = pwindow->GetBounds();
906 pControlCore = pControlCore->GetParent();
909 return parentWindowBounds;
913 _EditDate::UpdateAccessibilityElement(void)
920 if (likely(!(_AccessibilityManager::IsActivated())))
925 if (__pAccessibilityTitleElement == null)
930 if (__title.IsEmpty() == false)
932 string.Append(__title);
933 string.Append(L", ");
936 yearString.Append(GetYear());
937 dayString.Append(GetDay());
938 String monthString = GetDateTimeBar()->GetMonthValue(GetMonth()).GetPointer();
940 switch (__pEditDatePresenter->GetLocaleDateFormat())
942 case SETTING_DATE_FORMAT_DD_MM_YYYY:
943 string.Append(dayString.GetPointer());
944 string.Append(space.GetPointer());
945 string.Append(monthString.GetPointer());
946 string.Append(space.GetPointer());
947 string.Append(yearString.GetPointer());
949 case SETTING_DATE_FORMAT_MM_DD_YYYY:
950 string.Append(monthString.GetPointer());
951 string.Append(space.GetPointer());
952 string.Append(dayString.GetPointer());
953 string.Append(space.GetPointer());
954 string.Append(yearString.GetPointer());
956 case SETTING_DATE_FORMAT_YYYY_MM_DD:
957 string.Append(yearString.GetPointer());
958 string.Append(space.GetPointer());
959 string.Append(monthString.GetPointer());
960 string.Append(space.GetPointer());
961 string.Append(dayString.GetPointer());
963 case SETTING_DATE_FORMAT_YYYY_DD_MM:
964 string.Append(yearString.GetPointer());
965 string.Append(space.GetPointer());
966 string.Append(dayString.GetPointer());
967 string.Append(space.GetPointer());
968 string.Append(monthString.GetPointer());
974 __pAccessibilityTitleElement->SetLabel(string);
975 __pAccessibilityDayElement->SetLabel(dayString);
976 __pAccessibilityMonthElement->SetLabel(monthString);
977 __pAccessibilityYearElement->SetLabel(yearString);
981 }}} // Tizen::Ui::Controls