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_EditDate.cpp
20 * @brief This is the implementation file for the _EditDate class.
24 #include <FSysSettingInfo.h>
25 #include "FUi_AccessibilityContainer.h"
26 #include "FUi_AccessibilityElement.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUiAnim_VisualElement.h"
29 #include "FUiCtrl_EditDate.h"
30 #include "FUiCtrl_EditDatePresenter.h"
31 #include "FUiCtrl_Form.h"
32 #include "FUiCtrl_Frame.h"
33 #include "FUiCtrl_DateTimeUtils.h"
34 #include "FUi_CoordinateSystemUtils.h"
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Runtime;
39 using namespace Tizen::Ui;
40 using namespace Tizen::System;
42 namespace Tizen { namespace Ui { namespace Controls
45 IMPLEMENT_PROPERTY(_EditDate);
47 _EditDate::_EditDate(void)
48 : __pEditDatePresenter(null)
49 , __pDateChangeEvent(null)
50 , __pDateTimeBar(null)
51 , __absoluteBounds(FloatRectangle())
53 , __pAccessibilityEditDateElement(null)
54 , __pAccessibilityYearElement(null)
55 , __pAccessibilityMonthElement(null)
56 , __pAccessibilityDayElement(null)
60 _EditDate::~_EditDate(void)
62 SettingInfo::RemoveSettingEventListener(*this);
64 delete __pDateTimeBar;
65 __pDateTimeBar = null;
67 delete __pEditDatePresenter;
68 __pEditDatePresenter = null;
70 if (__pDateChangeEvent != null)
72 delete __pDateChangeEvent;
73 __pDateChangeEvent = null;
76 if (__pAccessibilityEditDateElement)
78 __pAccessibilityEditDateElement->Activate(false);
79 __pAccessibilityEditDateElement = null;
81 if (__pAccessibilityYearElement)
83 __pAccessibilityYearElement->Activate(false);
84 __pAccessibilityYearElement = null;
86 if (__pAccessibilityMonthElement)
88 __pAccessibilityMonthElement->Activate(false);
89 __pAccessibilityMonthElement = null;
91 if (__pAccessibilityDayElement)
93 __pAccessibilityDayElement->Activate(false);
94 __pAccessibilityDayElement = null;
99 _EditDate::CreateEditDateN(const String& title)
101 result r = E_SUCCESS;
103 _AccessibilityContainer* pContainer = null;
105 _EditDate* pEditDate = new (std::nothrow) _EditDate;
106 SysTryReturn(NID_UI_CTRL, pEditDate, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
108 pEditDate->GetVisualElement()->SetSurfaceOpaque(false);
110 pEditDate->__pEditDatePresenter = _EditDatePresenter::CreateInstanceN(*pEditDate, title);
112 r = pEditDate->CreateDateTimeBar();
113 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
115 pEditDate->__pEditDatePresenter->Initialize();
117 SysTryCatch(NID_UI_CTRL, pEditDate->__pEditDatePresenter, , r, "[%s] Propagating.", GetErrorMessage(r));
119 pEditDate->__pEditDatePresenter->SetCurrentDate();
121 if (title.IsEmpty() != true)
123 pEditDate->__title = title;
126 pContainer = pEditDate->GetAccessibilityContainer();
130 pContainer->Activate(true);
131 pEditDate->CreateAccessibilityElement();
134 pEditDate->AcquireHandle();
144 _EditDate::CreateDateTimeBar(void)
146 result r = E_SUCCESS;
148 __pDateTimeBar = _DateTimeBar::CreateDateTimeBarN(*this);
150 SysTryReturn(NID_UI_CTRL, (__pDateTimeBar != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
152 r = __pDateTimeBar->AddActionEventListener(*this);
153 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
155 r = __pDateTimeBar->AddDateTimeChangeEventListener(*this);
156 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
158 r = SettingInfo::AddSettingEventListener(*this);
159 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
164 delete __pDateTimeBar;
169 _EditDate::AddDateChangeEventListener(const _IDateTimeChangeEventListener& listener)
171 if (__pDateChangeEvent == null)
173 __pDateChangeEvent = new (std::nothrow) _DateTimeChangeEvent(*this);
174 SysTryReturn(NID_UI_CTRL, (__pDateChangeEvent != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
175 "[E_OUT_OF_MEMORY] Memory allocation failed.");
178 result r = __pDateChangeEvent->AddListener(listener);
179 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
185 _EditDate::RemoveDateChangeEventListener(const _IDateTimeChangeEventListener& listener)
187 result r = E_OBJ_NOT_FOUND;
189 if (__pDateChangeEvent)
191 r = __pDateChangeEvent->RemoveListener(listener);
194 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
200 _EditDate::SetDate(const DateTime& date)
202 SetProperty("date", Variant(date));
207 _EditDate::SetPropertyDate(const Variant& date)
209 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
210 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
212 __pEditDatePresenter->SetDate(date.ToDateTime());
214 UpdateAccessibilityElement();
219 _EditDate::GetDate(void) const
221 Variant date = GetProperty("date");
223 return date.ToDateTime();
227 _EditDate::GetPropertyDate(void) const
231 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
232 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
234 date = __pEditDatePresenter->GetDate();
236 return Variant(date);
240 _EditDate::SetDay(int day)
242 result r = E_SUCCESS;
244 SetProperty("day", Variant(day));
252 _EditDate::SetPropertyDay(const Variant& day)
254 result r = E_SUCCESS;
256 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
257 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
259 r = __pEditDatePresenter->SetDay(day.ToInt());
263 UpdateAccessibilityElement();
270 _EditDate::GetDay(void) const
272 Variant day = GetProperty("day");
278 _EditDate::GetPropertyDay(void) const
282 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
283 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
285 day = __pEditDatePresenter->GetDay();
291 _EditDate::SetMonth(int month)
293 result r = E_SUCCESS;
295 SetProperty("month", Variant(month));
303 _EditDate::SetPropertyMonth(const Variant& month)
305 result r = E_SUCCESS;
307 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
308 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
313 _DateTimeUtils dateTimeUtils;
315 maxValue = dateTimeUtils.CalculateMaxDay(GetYear(), month.ToInt());
316 day = __pEditDatePresenter->GetDay();
320 __pEditDatePresenter->SetDay(maxValue);
323 r = __pEditDatePresenter->SetMonth(month.ToInt());
327 UpdateAccessibilityElement();
334 _EditDate::GetMonth(void) const
336 Variant month = GetProperty("month");
338 return month.ToInt();
342 _EditDate::GetPropertyMonth(void) const
346 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
347 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
349 month = __pEditDatePresenter->GetMonth();
351 return Variant(month);
355 _EditDate::SetYear(int year)
357 result r = E_SUCCESS;
359 SetProperty("year", Variant(year));
367 _EditDate::SetPropertyYear(const Variant& year)
369 result r = E_SUCCESS;
371 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
372 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
377 _DateTimeUtils dateTimeUtils;
379 maxValue = dateTimeUtils.CalculateMaxDay(year.ToInt(), GetMonth());
380 day = __pEditDatePresenter->GetDay();
384 __pEditDatePresenter->SetDay(maxValue);
387 r = __pEditDatePresenter->SetYear(year.ToInt());
391 UpdateAccessibilityElement();
398 _EditDate::GetYear(void) const
400 Variant year = GetProperty("year");
406 _EditDate::GetPropertyYear(void) const
410 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
411 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
413 year = __pEditDatePresenter->GetYear();
415 return Variant(year);
419 _EditDate::SetCurrentDate(void)
421 SysTryReturnVoidResult(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM,
422 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
424 __pEditDatePresenter->SetCurrentDate();
426 UpdateAccessibilityElement();
432 _EditDate::SetDatePickerEnabled(bool enable)
434 SetProperty("datePickerEnabled", Variant(enable));
439 _EditDate::SetPropertyDatePickerEnabled(const Variant& enable)
441 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
442 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
444 __pEditDatePresenter->SetDatePickerEnabled(enable.ToBool());
450 _EditDate::IsDatePickerEnabled(void) const
452 Variant enable = GetProperty("datePickerEnabled");
454 return enable.ToBool();
458 _EditDate::GetPropertyDatePickerEnabled(void) const
462 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
463 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
465 enable = __pEditDatePresenter->IsDatePickerEnabled();
467 return Variant(enable);
471 _EditDate::SetYearRange(int minYear, int maxYear)
473 result r = E_SUCCESS;
475 SysTryReturn(NID_UI_CTRL, (maxYear >= DATETIME_YEAR_MIN && maxYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, E_INVALID_ARG,
476 "[E_INVALID_ARG] maxYear(%d) must be greater than or equal to %d and less than or equal to %d.",
477 maxYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX);
479 SysTryReturn(NID_UI_CTRL, (minYear >= DATETIME_YEAR_MIN && minYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, E_INVALID_ARG,
480 "[E_INVALID_ARG] minYear(%d) must be greater than or equal to %d and less than or equal to %d.",
481 minYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX);
483 SysTryReturn(NID_UI_CTRL, (maxYear >= minYear), E_INVALID_ARG, E_INVALID_ARG,
484 "[E_INVALID_ARG] maxYear(%d) must be greater than or equal to minYear(%d).", maxYear, minYear);
486 Variant oldMinYear = GetPropertyMinYearRange();
488 r = SetPropertyMinYearRange(Variant(minYear));
489 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
491 r = SetPropertyMaxYearRange(Variant(maxYear));
495 SetPropertyMinYearRange(oldMinYear);
502 _EditDate::SetMinYearRange(int minYear)
504 result r = E_SUCCESS;
506 r = SetProperty("minYearRange", Variant(minYear));
512 _EditDate::SetMaxYearRange(int maxYear)
514 result r = E_SUCCESS;
516 r = SetProperty("maxYearRange", Variant(maxYear));
522 _EditDate::SetPropertyMinYearRange(const Variant& minYear)
524 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
525 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
527 return __pEditDatePresenter->SetMinYear(minYear.ToInt());
531 _EditDate::SetPropertyMaxYearRange(const Variant& maxYear)
533 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM,
534 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
536 return __pEditDatePresenter->SetMaxYear(maxYear.ToInt());
540 _EditDate::GetYearRange(int& minYear, int& maxYear) const
542 result r = E_SUCCESS;
544 minYear = GetMinYearRange();
545 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
546 maxYear = GetMaxYearRange();
547 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
553 _EditDate::GetMinYearRange(void) const
555 Variant minYear = GetProperty("minYearRange");
557 return minYear.ToInt();
561 _EditDate::GetMaxYearRange(void) const
563 Variant maxYear = GetProperty("maxYearRange");
565 return maxYear.ToInt();
569 _EditDate::GetPropertyMinYearRange(void) const
571 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
572 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
576 minYear = __pEditDatePresenter->GetMinYear();
578 return Variant(minYear);
582 _EditDate::GetPropertyMaxYearRange(void) const
584 SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM,
585 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
589 maxYear = __pEditDatePresenter->GetMaxYear();
591 return Variant(maxYear);
595 _EditDate::CalculateDateTimeBarPosition(void)
597 result r = E_SUCCESS;
599 float dateTimeBarHeight = 0.0f;
600 float arrowHeight = 0.0f;
601 float dateHeight = 0.0f;
602 float dateBarMargin = 0.0f;
603 float textHeight = 0.0f;
604 float titleDateMargin = 0.0f;
605 float bottomPosition = 0.0f;
608 FloatRectangle absoluteBounds;
609 FloatRectangle frameBounds;
610 FloatRectangle parentWindowBounds;
611 FloatRectangle titleBounds;
613 _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
614 SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, E_SYSTEM,
615 "[E_SYSTEM] A system error has occurred. Failed to get frame instance.");
617 absoluteBounds = GetAbsoluteBoundsF();
618 frameBounds = pFrame->GetAbsoluteBoundsF();
619 parentWindowBounds = GetParentWindowBounds();
620 titleBounds = __pEditDatePresenter->GetTitleBounds();
622 GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, GetOrientation(), dateTimeBarHeight);
623 GET_SHAPE_CONFIG(DATETIMEBAR::ARROW_HEIGHT, GetOrientation(), arrowHeight);
624 GET_SHAPE_CONFIG(EDITDATE::DATE_HEIGHT, GetOrientation(), dateHeight);
625 GET_SHAPE_CONFIG(EDITDATE::DATE_BAR_MARGIN, GetOrientation(), dateBarMargin);
626 GET_SHAPE_CONFIG(EDITDATE::TITLE_HEIGHT, GetOrientation(), textHeight);
627 GET_SHAPE_CONFIG(EDITDATE::TITLE_DATE_MARGIN, GetOrientation(), titleDateMargin);
629 if (!__title.IsEmpty()) //with title
631 dateY = titleBounds.y + textHeight + titleDateMargin ;
635 dateY = (absoluteBounds.height - dateHeight) / 2.0f ;
638 bottomPosition = absoluteBounds.y + dateY + dateHeight + dateBarMargin + arrowHeight + dateTimeBarHeight;
640 GetDateTimeBar()->SetParentWindowBounds(parentWindowBounds);
642 if (bottomPosition > frameBounds.y + parentWindowBounds.y + parentWindowBounds.height)
644 r = GetDateTimeBar()->SetPositionAndAlignment(FloatPoint(parentWindowBounds.x, absoluteBounds.y + dateY - dateBarMargin - arrowHeight), DATETIME_BAR_ALIGN_UP);
645 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
649 r = GetDateTimeBar()->SetPositionAndAlignment(FloatPoint(parentWindowBounds.x, absoluteBounds.y + dateY + dateHeight + dateBarMargin + arrowHeight), DATETIME_BAR_ALIGN_DOWN);
650 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
653 __absoluteBounds = absoluteBounds;
659 _EditDate::OnDraw(void)
661 if (GetDateTimeBar() != null && GetDateTimeBar()->IsActivated())
663 CalculateDateTimeBarPosition();
666 __pEditDatePresenter->Draw();
671 _EditDate::CreateAccessibilityElement(void)
673 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
675 FloatRectangle dayBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_DAY);
676 FloatRectangle monthBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_MONTH);
677 FloatRectangle yearBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_YEAR);
679 if (__pAccessibilityEditDateElement == null)
681 __pAccessibilityEditDateElement = new _AccessibilityElement(true);
682 __pAccessibilityEditDateElement->SetBounds(GetClientBounds());
683 __pAccessibilityEditDateElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
684 __pAccessibilityEditDateElement->SetName("EditDateText");
685 pContainer->AddElement(*__pAccessibilityEditDateElement);
688 if (__pAccessibilityYearElement == null && __pAccessibilityMonthElement == null && __pAccessibilityDayElement == null)
690 String hintText(L"Double tap to edit");
692 __pAccessibilityYearElement = new _AccessibilityElement(true);
693 __pAccessibilityYearElement->SetBounds(yearBounds);
694 __pAccessibilityYearElement->SetTrait(ACCESSIBILITY_TRAITS_YEAR);
695 __pAccessibilityYearElement->SetHint(hintText);
697 __pAccessibilityMonthElement = new _AccessibilityElement(true);
698 __pAccessibilityMonthElement->SetBounds(monthBounds);
699 __pAccessibilityMonthElement->SetTrait(ACCESSIBILITY_TRAITS_MONTH);
700 __pAccessibilityMonthElement->SetHint(hintText);
702 __pAccessibilityDayElement = new _AccessibilityElement(true);
703 __pAccessibilityDayElement->SetBounds(dayBounds);
704 __pAccessibilityDayElement->SetTrait(ACCESSIBILITY_TRAITS_DAY);
705 __pAccessibilityDayElement->SetHint(hintText);
707 switch (__pEditDatePresenter->GetLocaleDateFormat())
709 case SETTING_DATE_FORMAT_DD_MM_YYYY:
710 pContainer->AddElement(*__pAccessibilityDayElement);
711 pContainer->AddElement(*__pAccessibilityMonthElement);
712 pContainer->AddElement(*__pAccessibilityYearElement);
714 case SETTING_DATE_FORMAT_MM_DD_YYYY:
715 pContainer->AddElement(*__pAccessibilityMonthElement);
716 pContainer->AddElement(*__pAccessibilityDayElement);
717 pContainer->AddElement(*__pAccessibilityYearElement);
719 case SETTING_DATE_FORMAT_YYYY_MM_DD:
720 pContainer->AddElement(*__pAccessibilityYearElement);
721 pContainer->AddElement(*__pAccessibilityMonthElement);
722 pContainer->AddElement(*__pAccessibilityDayElement);
724 case SETTING_DATE_FORMAT_YYYY_DD_MM:
725 pContainer->AddElement(*__pAccessibilityYearElement);
726 pContainer->AddElement(*__pAccessibilityDayElement);
727 pContainer->AddElement(*__pAccessibilityMonthElement);
732 UpdateAccessibilityElement();
737 _EditDate::OnBoundsChanged(void)
739 __pEditDatePresenter->Initialize();
741 if (__pAccessibilityEditDateElement)
743 __pAccessibilityEditDateElement->SetBounds(__pEditDatePresenter->GetTitleBounds());
745 if (__pAccessibilityYearElement)
747 __pAccessibilityYearElement->SetBounds(__pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_YEAR));
749 if (__pAccessibilityMonthElement)
751 __pAccessibilityMonthElement->SetBounds(__pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_MONTH));
753 if (__pAccessibilityDayElement)
755 __pAccessibilityDayElement->SetBounds(__pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_DAY));
762 _EditDate::OnChangeLayout(_ControlOrientation orientation)
766 GET_SHAPE_CONFIG(EDITDATE::WIDTH, GetOrientation(), dim.width);
767 GET_SHAPE_CONFIG(EDITDATE::HEIGHT, GetOrientation(), dim.height);
771 __pEditDatePresenter->Initialize();
772 __pEditDatePresenter->SetLastSelectedId(DATETIME_ID_NONE);
774 if (GetDateTimeBar() != null)
776 GetDateTimeBar()->SetVisibleState(false);
777 GetDateTimeBar()->Close();
784 _EditDate::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
788 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
790 if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
792 CalculateDateTimeBarPosition();
795 return __pEditDatePresenter->OnTouchPressed(source, touchinfo);
799 _EditDate::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
801 return __pEditDatePresenter->OnTouchReleased(source, touchinfo);
805 _EditDate::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
807 return __pEditDatePresenter->OnTouchCanceled(source, touchinfo);
811 _EditDate::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
813 return __pEditDatePresenter->OnTouchMoved(source, touchinfo);
817 _EditDate::OnTouchMoveHandled(const _Control& control)
819 __pEditDatePresenter->OnTouchMoveHandled(control);
824 _EditDate::FireDateChangeEvent(_DateTimeChangeStatus status)
826 SysTryReturn(NID_UI_CTRL, (__pDateChangeEvent != null), E_INVALID_STATE, E_INVALID_STATE,
827 "[E_INVALID_STATE] The _DateChangeEvent instance is null.");
829 _DateTimeChangeEventArg* pDateTimeEventArg = new (std::nothrow) _DateTimeChangeEventArg(status);
830 SysTryReturn(NID_UI_CTRL, pDateTimeEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
832 pDateTimeEventArg->SetDate(GetYear(), GetMonth(), GetDay());
834 __pDateChangeEvent->Fire(*pDateTimeEventArg);
840 _EditDate::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute)
842 __pEditDatePresenter->Animate();
843 __pEditDatePresenter->SetLastSelectedId(DATETIME_ID_NONE);
845 FireDateChangeEvent(DATE_INTERNAL_CHANGE_SAVED);
850 _EditDate::OnDateTimeChangeCanceled(const _Control& source)
852 __pEditDatePresenter->SetLastSelectedId(DATETIME_ID_NONE);
854 FireDateChangeEvent(DATE_INTERNAL_CHANGE_CANCELED);
859 _EditDate::OnActionPerformed(const Ui::_Control& source, int actionId)
861 _DateTimeId boxId = __pEditDatePresenter->GetLastSelectedId();
863 if (boxId == DATETIME_ID_YEAR)
866 AdjustDay(actionId, GetMonth());
868 else if (boxId == DATETIME_ID_MONTH)
871 AdjustDay(GetYear(), actionId);
873 else if (boxId == DATETIME_ID_DAY)
884 _EditDate::AdjustDay(int year, int month)
886 _DateTimeUtils dateTimeUtils;
887 int maxValue = dateTimeUtils.CalculateMaxDay(year, month);
889 if (GetDay() > maxValue)
898 _EditDate::GetDateTimeBar(void) const
900 return __pDateTimeBar;
904 _EditDate::OnFontChanged(Font* pFont)
906 __pEditDatePresenter->OnFontChanged(pFont);
912 _EditDate::OnFontInfoRequested(unsigned long& style, float& size)
914 __pEditDatePresenter->OnFontInfoRequested(style, size);
920 _EditDate::OnSettingChanged(String& key)
922 if (key.Equals(L"http://tizen.org/setting/locale.date.format", false))
931 _EditDate::GetParentWindowBounds(void) const
934 _Window* pwindow = null;
935 _Control* pControlCore = GetParent();
937 FloatDimension dateTimeBarSize(0.0f, 0.0f);
938 GET_DIMENSION_CONFIG(DATETIMEBAR::DEFAULT_SIZE, GetOrientation(), dateTimeBarSize);
939 FloatRectangle parentWindowBounds(0.0f, 0.0f, dateTimeBarSize.width, dateTimeBarSize.height);
943 if (pControlCore == null)
945 SysLog(NID_UI_CTRL,"[E_SYSTEM] Parent window not found.");
947 return parentWindowBounds;
950 // If the parent is a Frame, then return the Form's bounds.
951 pForm = dynamic_cast<_Form*>(pControlCore);
954 parentWindowBounds = pForm->GetBoundsF();
958 pwindow = dynamic_cast<_Window*>(pControlCore);
962 parentWindowBounds = pwindow->GetBoundsF();
966 pControlCore = pControlCore->GetParent();
969 return parentWindowBounds;
973 _EditDate::UpdateAccessibilityElement(void)
980 if (likely(!(_AccessibilityManager::IsActivated())))
985 if (__pAccessibilityEditDateElement == null)
990 if (__title.IsEmpty() == false)
992 string.Append(__title);
993 string.Append(L", ");
996 yearString.Append(GetYear());
997 dayString.Append(GetDay());
998 String monthString = GetDateTimeBar()->GetMonthValue(GetMonth()).GetPointer();
1000 switch (__pEditDatePresenter->GetLocaleDateFormat())
1002 case SETTING_DATE_FORMAT_DD_MM_YYYY:
1003 string.Append(dayString.GetPointer());
1004 string.Append(space.GetPointer());
1005 string.Append(monthString.GetPointer());
1006 string.Append(space.GetPointer());
1007 string.Append(yearString.GetPointer());
1009 case SETTING_DATE_FORMAT_MM_DD_YYYY:
1010 string.Append(monthString.GetPointer());
1011 string.Append(space.GetPointer());
1012 string.Append(dayString.GetPointer());
1013 string.Append(space.GetPointer());
1014 string.Append(yearString.GetPointer());
1016 case SETTING_DATE_FORMAT_YYYY_MM_DD:
1017 string.Append(yearString.GetPointer());
1018 string.Append(space.GetPointer());
1019 string.Append(monthString.GetPointer());
1020 string.Append(space.GetPointer());
1021 string.Append(dayString.GetPointer());
1023 case SETTING_DATE_FORMAT_YYYY_DD_MM:
1024 string.Append(yearString.GetPointer());
1025 string.Append(space.GetPointer());
1026 string.Append(dayString.GetPointer());
1027 string.Append(space.GetPointer());
1028 string.Append(monthString.GetPointer());
1034 __pAccessibilityEditDateElement->SetLabel(string);
1035 __pAccessibilityDayElement->SetLabel(dayString);
1036 __pAccessibilityMonthElement->SetLabel(monthString);
1037 __pAccessibilityYearElement->SetLabel(yearString);
1041 }}} // Tizen::Ui::Controls