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_EditTime.cpp
20 * @brief This is the implementation file for the _EditTime class.
23 #include <FSysSettingInfo.h>
24 #include "FUi_CoordinateSystemUtils.h"
25 #include "FUi_AccessibilityContainer.h"
26 #include "FUi_AccessibilityElement.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUiAnim_VisualElement.h"
29 #include "FUiCtrl_EditTime.h"
30 #include "FUiCtrl_EditTimePresenter.h"
31 #include "FUiCtrl_Form.h"
32 #include "FUiCtrl_Frame.h"
33 #include "FUiCtrl_DateTimeUtils.h"
34 #include "FUiCtrl_DateTimeDefine.h"
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Base::Runtime;
38 using namespace Tizen::Base;
39 using namespace Tizen::System;
41 namespace Tizen { namespace Ui { namespace Controls
44 IMPLEMENT_PROPERTY(_EditTime);
46 _EditTime::_EditTime(void)
47 : __pEditTimePresenter(null)
48 , __pTimeChangeEvent(null)
49 , __pDateTimeBar(null)
50 , __absoluteBounds(FloatRectangle())
51 , __previousSize(0.0f, 0.0f)
53 , __pAccessibilityEditTimeElement(null)
54 , __pAccessibilityHourElement(null)
55 , __pAccessibilityMinuteElement(null)
56 , __pAccessibilityAmPmElement(null)
57 , __isCalledBoundsChanged(false)
58 , __isXmlBoundsExist(false)
62 _EditTime::~_EditTime(void)
64 SettingInfo::RemoveSettingEventListener(*this);
66 delete __pDateTimeBar;
67 __pDateTimeBar = null;
69 delete __pEditTimePresenter;
70 __pEditTimePresenter = null;
72 if (__pTimeChangeEvent != null)
74 delete __pTimeChangeEvent;
75 __pTimeChangeEvent = null;
78 if (__pAccessibilityEditTimeElement)
80 __pAccessibilityEditTimeElement->Activate(false);
81 __pAccessibilityEditTimeElement = null;
83 if (__pAccessibilityHourElement)
85 __pAccessibilityHourElement->Activate(false);
86 __pAccessibilityHourElement = null;
88 if (__pAccessibilityMinuteElement)
90 __pAccessibilityMinuteElement->Activate(false);
91 __pAccessibilityMinuteElement = null;
93 if (__pAccessibilityAmPmElement)
95 __pAccessibilityAmPmElement->Activate(false);
96 __pAccessibilityAmPmElement = null;
101 _EditTime::CreateEditTimeN(const String& title)
103 result r = E_SUCCESS;
105 _AccessibilityContainer* pContainer = null;
107 _EditTime* pEditTime = new (std::nothrow) _EditTime;
108 SysTryReturn(NID_UI_CTRL, pEditTime, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
110 pEditTime->GetVisualElement()->SetSurfaceOpaque(false);
112 pEditTime->__pEditTimePresenter = _EditTimePresenter::CreateInstanceN(*pEditTime, title);
114 SysTryCatch(NID_UI_CTRL, pEditTime->__pEditTimePresenter, , r, "[%s] Propagating.", GetErrorMessage(r));
116 r = pEditTime->CreateDateTimeBar();
117 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
119 pEditTime->__pEditTimePresenter->Initialize();
121 SysTryCatch(NID_UI_CTRL, pEditTime->__pEditTimePresenter, , r, "[%s] Propagating.", GetErrorMessage(r));
123 pEditTime->__pEditTimePresenter->SetCurrentTime();
125 if (title.IsEmpty() != true)
127 pEditTime->__title = title;
130 pContainer = pEditTime->GetAccessibilityContainer();
133 pContainer->Activate(true);
134 pEditTime->CreateAccessibilityElement();
137 pEditTime->AcquireHandle();
138 pEditTime->SetTouchPressThreshold(_TOUCH_PRESS_THRESHOLD_INSENSITIVE);
148 _EditTime::CreateDateTimeBar(void)
150 result r = E_SUCCESS;
152 __pDateTimeBar = _DateTimeBar::CreateDateTimeBarN(*this);
154 SysTryReturn(NID_UI_CTRL, (__pDateTimeBar != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
156 r = __pDateTimeBar->AddActionEventListener(*this);
157 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
159 r = __pDateTimeBar->AddDateTimeChangeEventListener(*this);
160 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
162 r = SettingInfo::AddSettingEventListener(*this);
163 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
165 GET_SHAPE_CONFIG(EDITTIME::WIDTH, GetOrientation(), __previousSize.width);
166 GET_SHAPE_CONFIG(EDITTIME::HEIGHT, GetOrientation(), __previousSize.height);
171 delete __pDateTimeBar;
176 _EditTime::AddTimeChangeEventListener(const _IDateTimeChangeEventListener& listener)
178 if (__pTimeChangeEvent == null)
180 __pTimeChangeEvent = new (std::nothrow) _DateTimeChangeEvent(*this);
181 SysTryReturn(NID_UI_CTRL, (__pTimeChangeEvent != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
182 "[E_OUT_OF_MEMORY] Memory allocation failed.");
185 result r = __pTimeChangeEvent->AddListener(listener);
186 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
192 _EditTime::RemoveTimeChangeEventListener(const _IDateTimeChangeEventListener& listener)
194 result r = E_OBJ_NOT_FOUND;
196 if (__pTimeChangeEvent)
198 r = __pTimeChangeEvent->RemoveListener(listener);
201 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
207 _EditTime::SetTime(const DateTime& time)
209 SetProperty("time", Variant(time));
214 _EditTime::SetPropertyTime(const Variant& time)
216 SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM,
217 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
219 __pEditTimePresenter->SetTime(time.ToDateTime());
221 UpdateAccessibilityElement();
226 _EditTime::GetTime(void) const
228 Variant time = GetProperty("time");
230 return time.ToDateTime();
234 _EditTime::GetPropertyTime(void) const
238 SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM,
239 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
241 time = __pEditTimePresenter->GetTime();
243 return Variant(time);
247 _EditTime::SetHour(int hour)
249 result r = E_SUCCESS;
251 SetProperty("hour", Variant(hour));
259 _EditTime::SetPropertyHour(const Variant& hour)
261 SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM,
262 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
264 result r = E_SUCCESS;
266 r = __pEditTimePresenter->SetHour(hour.ToInt());
267 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
269 UpdateAccessibilityElement();
275 _EditTime::GetHour(void) const
277 Variant hour = GetProperty("hour");
283 _EditTime::GetPropertyHour(void) const
287 SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM,
288 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
290 hour = __pEditTimePresenter->GetHour();
292 return Variant(hour);
296 _EditTime::SetMinute(int minute)
298 result r = E_SUCCESS;
300 SetProperty("minute", Variant(minute));
308 _EditTime::SetPropertyMinute(const Variant& minute)
310 SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM,
311 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
313 result r = E_SUCCESS;
315 r = __pEditTimePresenter->SetMinute(minute.ToInt());
316 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
318 UpdateAccessibilityElement();
324 _EditTime::GetMinute(void) const
326 Variant minute = GetProperty("minute");
328 return minute.ToInt();
332 _EditTime::GetPropertyMinute(void) const
336 SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM,
337 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
339 minute = __pEditTimePresenter->GetMinute();
341 return Variant(minute);
345 _EditTime::SetCurrentTime(void)
347 SysTryReturnVoidResult(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM,
348 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
350 __pEditTimePresenter->SetCurrentTime();
352 UpdateAccessibilityElement();
358 _EditTime::SetTimePickerEnabled(bool enable)
360 SetProperty("timePickerEnabled", Variant(enable));
365 _EditTime::SetPropertyTimePickerEnabled(const Variant& enable)
367 SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM,
368 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
370 __pEditTimePresenter->SetTimePickerEnabled(enable.ToBool());
376 _EditTime::IsTimePickerEnabled(void) const
378 Variant enable = GetProperty("timePickerEnabled");
380 return enable.ToBool();
384 _EditTime::GetPropertyTimePickerEnabled(void) const
388 SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM,
389 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
391 enable = __pEditTimePresenter->IsTimePickerEnabled();
393 return Variant(enable);
397 _EditTime::Set24HourNotationEnabled(bool enable)
399 SysTryReturnVoidResult(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM,
400 "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
402 __pEditTimePresenter->Set24HourNotationEnabled(enable);
407 _EditTime::Is24HourNotationEnabled(void) const
409 SysAssertf((__pEditTimePresenter != null), "The _EditDatePresenter instance is null.");
411 return __pEditTimePresenter->Is24HourNotationEnabled();
415 _EditTime::CalculateDateTimeBarPosition(void)
417 result r = E_SUCCESS;
419 float dateTimeBarHeight = 0.0f;
420 float arrowHeight = 0.0f;
421 float timeHeight = 0.0f;
422 float timeBarMargin = 0.0f;
423 float textHeight = 0.0f;
424 float titleTimeMargin = 0.0f;
425 float bottomPosition = 0.0f;
428 FloatRectangle absoluteBounds;
429 FloatRectangle frameBounds;
430 FloatRectangle parentWindowBounds;
431 FloatRectangle titleBounds;
433 _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
434 SysTryReturn(NID_UI_CTRL, (pFrame != null), E_SYSTEM, E_SYSTEM,
435 "[E_SYSTEM] A system error has occurred. Failed to get frame instance.");
437 frameBounds = pFrame->GetAbsoluteBoundsF();
438 absoluteBounds = GetAbsoluteBoundsF();
439 parentWindowBounds = GetParentWindowBounds();
440 titleBounds = __pEditTimePresenter->GetTitleBounds();
442 GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, GetOrientation(), dateTimeBarHeight);
443 GET_SHAPE_CONFIG(DATETIMEBAR::ARROW_HEIGHT, GetOrientation(), arrowHeight);
444 GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, GetOrientation(), timeHeight);
445 GET_SHAPE_CONFIG(EDITTIME::TIME_BAR_MARGIN, GetOrientation(), timeBarMargin);
446 GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, GetOrientation(), textHeight);
447 GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, GetOrientation(), titleTimeMargin);
449 if (!__title.IsEmpty()) //with title
451 timeY = titleBounds.y + textHeight + titleTimeMargin ;
455 timeY = (absoluteBounds.height - timeHeight) / 2.0f ;
458 bottomPosition = absoluteBounds.y + timeY + timeHeight + timeBarMargin + arrowHeight + dateTimeBarHeight;
460 GetDateTimeBar()->SetParentWindowBounds(parentWindowBounds);
462 if (bottomPosition > frameBounds.y + parentWindowBounds.y + parentWindowBounds.height) //ALIGN_UP
464 r = GetDateTimeBar()->SetPositionAndAlignment(FloatPoint(parentWindowBounds.x, absoluteBounds.y + timeY - timeBarMargin - arrowHeight), DATETIME_BAR_ALIGN_UP);
465 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
469 r = GetDateTimeBar()->SetPositionAndAlignment(FloatPoint(parentWindowBounds.x, absoluteBounds.y + timeY + timeHeight + timeBarMargin + arrowHeight), DATETIME_BAR_ALIGN_DOWN);
470 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
473 __absoluteBounds = absoluteBounds;
479 _EditTime::OnDraw(void)
481 if (GetDateTimeBar() != null)
483 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
485 if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
487 CalculateDateTimeBarPosition();
491 __pEditTimePresenter->Draw();
493 if(unlikely((_AccessibilityManager::IsActivated())))
495 UpdateAccessibilityElement();
502 _EditTime::CreateAccessibilityElement(void)
504 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
505 FloatRectangle hourBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
506 FloatRectangle minuteBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
507 FloatRectangle ampmBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
509 pContainer->AddListener(*this);
510 if (__pAccessibilityEditTimeElement == null)
512 __pAccessibilityEditTimeElement = new _AccessibilityElement(true);
513 __pAccessibilityEditTimeElement->SetBounds(GetClientBoundsF());
514 __pAccessibilityEditTimeElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
515 __pAccessibilityEditTimeElement->SetName(L"EditTimeText");
516 pContainer->AddElement(*__pAccessibilityEditTimeElement);
519 if (__pAccessibilityHourElement == null && __pAccessibilityMinuteElement == null)
521 String hintText(L"Double tap to edit");
523 __pAccessibilityHourElement = new _AccessibilityElement(true);
524 __pAccessibilityHourElement->SetBounds(hourBounds);
525 __pAccessibilityHourElement->SetTrait(ACCESSIBILITY_TRAITS_HOUR);
526 __pAccessibilityHourElement->SetHint(hintText);
527 pContainer->AddElement(*__pAccessibilityHourElement);
529 __pAccessibilityMinuteElement = new _AccessibilityElement(true);
530 __pAccessibilityMinuteElement->SetBounds(minuteBounds);
531 __pAccessibilityMinuteElement->SetTrait(ACCESSIBILITY_TRAITS_MINUTE);
532 __pAccessibilityMinuteElement->SetHint(hintText);
533 pContainer->AddElement(*__pAccessibilityMinuteElement);
535 if (Is24HourNotationEnabled() == false)
537 __pAccessibilityAmPmElement = new _AccessibilityElement(true);
538 __pAccessibilityAmPmElement->SetBounds(ampmBounds);
539 __pAccessibilityAmPmElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON);
540 pContainer->AddElement(*__pAccessibilityAmPmElement);
542 __pAccessibilityHourElement->SetBounds(FloatRectangle(hourBounds.x, ampmBounds.y, hourBounds.width, ampmBounds.height));
543 __pAccessibilityMinuteElement->SetBounds(FloatRectangle(minuteBounds.x, ampmBounds.y, minuteBounds.width, ampmBounds.height));
549 _EditTime::OnBoundsChanged(void)
551 FloatDimension newSize = GetSizeF();
553 if (newSize.width != __previousSize.width || newSize.height != __previousSize.height)
555 __isCalledBoundsChanged = true;
558 __pEditTimePresenter->Initialize();
560 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityEditTimeElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime accessibility element must not be null.");
561 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityHourElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Hour accessibility element must not be null.");
562 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityMinuteElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Minute accessibility element must not be null.");
564 __pAccessibilityEditTimeElement->SetBounds(GetClientBoundsF());
566 FloatRectangle hourBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
567 FloatRectangle minuteBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
568 FloatRectangle ampmBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
570 __pAccessibilityHourElement->SetBounds(hourBounds);
571 __pAccessibilityMinuteElement->SetBounds(minuteBounds);
573 if (__pAccessibilityAmPmElement)
575 __pAccessibilityHourElement->SetBounds(FloatRectangle(hourBounds.x, ampmBounds.y, hourBounds.width, ampmBounds.height));
576 __pAccessibilityMinuteElement->SetBounds(FloatRectangle(minuteBounds.x, ampmBounds.y, minuteBounds.width, ampmBounds.height));
577 __pAccessibilityAmPmElement->SetBounds(ampmBounds);
584 _EditTime::OnChangeLayout(_ControlOrientation orientation)
586 if (!__isCalledBoundsChanged && !__isXmlBoundsExist)
588 FloatRectangle bounds = GetBoundsF();
590 GET_SHAPE_CONFIG(EDITTIME::WIDTH, GetOrientation(), bounds.width);
591 GET_SHAPE_CONFIG(EDITTIME::HEIGHT, GetOrientation(), bounds.height);
593 SetBounds(bounds, false);
596 __pEditTimePresenter->Initialize();
597 __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE);
599 if (GetDateTimeBar() != null)
601 GetDateTimeBar()->SetVisibleState(false);
602 GetDateTimeBar()->Close();
609 _EditTime::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
613 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
614 if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
616 CalculateDateTimeBarPosition();
619 return __pEditTimePresenter->OnTouchPressed(source, touchinfo);
623 _EditTime::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
625 return __pEditTimePresenter->OnTouchReleased(source, touchinfo);
629 _EditTime::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
631 return __pEditTimePresenter->OnTouchCanceled(source, touchinfo);
635 _EditTime::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
637 return __pEditTimePresenter->OnTouchMoved(source, touchinfo);
641 _EditTime::OnTouchMoveHandled(const _Control& control)
643 __pEditTimePresenter->OnTouchMoveHandled(control);
648 _EditTime::FireTimeChangeEvent(_DateTimeChangeStatus status)
650 SysTryReturn(NID_UI_CTRL, (__pTimeChangeEvent != null), E_SYSTEM, E_SYSTEM,
651 "[E_SYSTEM] A system error has occurred. The _DateTimeChangeEvent instance is null.");
653 _DateTimeChangeEventArg* pDateTimeEventArg = new (std::nothrow) _DateTimeChangeEventArg(status);
654 SysTryReturn(NID_UI_CTRL, pDateTimeEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
655 "[E_OUT_OF_MEMORY] Memory allocation failed.");
657 pDateTimeEventArg->SetTime(GetHour(), GetMinute());
659 __pTimeChangeEvent->Fire(*pDateTimeEventArg);
665 _EditTime::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute)
667 __pEditTimePresenter->Animate();
668 __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE);
670 FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
675 _EditTime::OnDateTimeChangeCanceled(const _Control& source)
677 __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE);
679 FireTimeChangeEvent(TIME_INTERNAL_CHANGE_CANCELED);
684 _EditTime::OnActionPerformed(const Ui::_Control& source, int actionId)
686 _DateTimeId boxId = __pEditTimePresenter->GetLastSelectedId();
688 if (boxId == DATETIME_ID_HOUR)
690 bool amEnable = true;
691 amEnable = __pEditTimePresenter->GetAmEnabled();
695 if (amEnable == false && Is24HourNotationEnabled() == false)
697 if (hour < DATETIME_HOUR_MAX_FOR_24NOTATION)
699 hour += DATETIME_HOUR_MAX_FOR_24NOTATION;
702 else if (amEnable == true && Is24HourNotationEnabled() == false)
704 if (hour == DATETIME_HOUR_MAX_FOR_24NOTATION)
706 hour = DATETIME_HOUR_MIN;
711 else if (boxId == DATETIME_ID_MINUTE)
721 _EditTime::GetDateTimeBar(void) const
723 return __pDateTimeBar;
727 _EditTime::OnFontChanged(Font* pFont)
729 __pEditTimePresenter->OnFontChanged(pFont);
735 _EditTime::OnFontInfoRequested(unsigned long& style, float& size)
737 __pEditTimePresenter->OnFontInfoRequested(style, size);
743 _EditTime::OnSettingChanged(String& key)
745 if (key.Equals(L"http://tizen.org/setting/locale.time.format.24hour", false))
747 __pEditTimePresenter->UpdateTimeFormat();
748 __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE);
750 if (GetDateTimeBar() != null)
752 GetDateTimeBar()->SetVisibleState(false);
753 GetDateTimeBar()->Close();
763 _EditTime::GetParentWindowBounds(void) const
766 _Window* pwindow = null;
767 _Control* pControlCore = GetParent();
769 FloatDimension dateTimeBarSize(0.0f, 0.0f);
771 GET_DIMENSION_CONFIG(DATETIMEBAR::DEFAULT_SIZE, GetOrientation(), dateTimeBarSize);
773 FloatRectangle parentWindowBounds(0.0f, 0.0f, dateTimeBarSize.width, dateTimeBarSize.height);
777 if (pControlCore == null)
779 SysLog(NID_UI_CTRL,"[E_SYSTEM] Parent window not found.");
781 return parentWindowBounds;
784 // If the parent is a Frame, then return the Form's bounds.
785 pForm = dynamic_cast<_Form*>(pControlCore);
788 parentWindowBounds = pForm->GetBoundsF();
792 pwindow = dynamic_cast<_Window*>(pControlCore);
796 parentWindowBounds = pwindow->GetBoundsF();
800 pControlCore = pControlCore->GetParent();
803 return parentWindowBounds;
807 _EditTime::SetXmlBoundsExist(bool isXmlBoundsExist)
809 __isXmlBoundsExist = isXmlBoundsExist;
813 _EditTime::UpdateAccessibilityElement(void)
818 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityEditTimeElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime accessibility element must not be null.");
819 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityHourElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Hour accessibility element must not be null.");
820 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityMinuteElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Minute accessibility element must not be null.");
822 if (__title.IsEmpty() == false)
824 string.Append(__title);
825 string.Append(L", ");
829 int hour = GetHour();
830 int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION;
832 if (Is24HourNotationEnabled() == false && (hour > maxHour))
834 hourString.Format(10, L"%02d", hour - DATETIME_HOUR_MAX_FOR_24NOTATION);
838 hourString.Format(10, L"%02d", hour);
841 string.Append(hourString.GetPointer());
843 string.Append(GetMinute());
846 FloatRectangle hourBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
847 FloatRectangle minuteBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
848 FloatRectangle ampmBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
850 if (Is24HourNotationEnabled() == false)
852 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
853 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
855 if (__pAccessibilityAmPmElement == null)
857 __pAccessibilityAmPmElement = new (std::nothrow) _AccessibilityElement(true);
858 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityAmPmElement != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
860 __pAccessibilityAmPmElement->SetBounds(ampmBounds);
861 __pAccessibilityAmPmElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON);
862 pContainer->AddElement(*__pAccessibilityAmPmElement);
864 __pAccessibilityHourElement->SetBounds(FloatRectangle(hourBounds.x, ampmBounds.y, hourBounds.width, ampmBounds.height));
865 __pAccessibilityMinuteElement->SetBounds(FloatRectangle(minuteBounds.x, ampmBounds.y, minuteBounds.width, ampmBounds.height));
869 __pAccessibilityAmPmElement->Activate(true);
872 String hintAmPmText(L"Double tap to change to ");
876 _DateTimeUtils dateTimeUtils;
877 dateTimeUtils.GetAmPm(amString, AM_TYPE);
878 dateTimeUtils.GetAmPm(pmString, PM_TYPE);
880 if (__pEditTimePresenter->GetAmEnabled() == true)
882 __pAccessibilityAmPmElement->SetLabel(amString);
883 hintAmPmText.Append(pmString.GetPointer());
884 string.Append(amString.GetPointer());
888 __pAccessibilityAmPmElement->SetLabel(pmString);
889 hintAmPmText.Append(amString.GetPointer());
890 string.Append(pmString.GetPointer());
893 __pAccessibilityAmPmElement->SetHint(hintAmPmText);
895 else if (__pAccessibilityAmPmElement != null)
897 __pAccessibilityAmPmElement->Activate(false);
900 __pAccessibilityEditTimeElement->SetLabel(string);
902 __pAccessibilityHourElement->SetLabel(hourString);
905 string.Format(10, L"%02d", GetMinute());
906 __pAccessibilityMinuteElement->SetLabel(string);
912 _EditTime::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
918 _EditTime::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
924 _EditTime::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
930 _EditTime::OnAccessibilityReadedElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
937 _EditTime::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
943 _EditTime::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
949 _EditTime::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
955 labelText = element.GetLabel();
957 _DateTimeUtils dateTimeUtils;
958 dateTimeUtils.GetAmPm(amString, AM_TYPE);
959 dateTimeUtils.GetAmPm(pmString, PM_TYPE);
961 if (labelText == amString || labelText == pmString)
963 labelText.Append(L" Selected");
964 _AccessibilityManager::GetInstance()->ReadContent(labelText);
971 _EditTime::OnAccessibilityValueIncreased(const _AccessibilityContainer&, const _AccessibilityElement&)
977 _EditTime::OnAccessibilityValueDecreased(const _AccessibilityContainer&, const _AccessibilityElement&)