Merge "Add GetOrientationStatus for the Ime Orientation" into tizen_2.1
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_EditTime.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 /**
19  * @file                FUiCtrl_EditTime.cpp
20  * @brief               This is the implementation file for the _EditTime class.
21  */
22
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"
35
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Base::Runtime;
38 using namespace Tizen::Base;
39 using namespace Tizen::System;
40
41 namespace Tizen { namespace Ui { namespace Controls
42 {
43
44 IMPLEMENT_PROPERTY(_EditTime);
45
46 _EditTime::_EditTime(void)
47         : __pEditTimePresenter(null)
48         , __pTimeChangeEvent(null)
49         , __pDateTimeBar(null)
50         , __absoluteBounds(FloatRectangle())
51         , __title()
52         , __pAccessibilityEditTimeElement(null)
53         , __pAccessibilityHourElement(null)
54         , __pAccessibilityMinuteElement(null)
55         , __pAccessibilityAmPmElement(null)
56 {
57 }
58
59 _EditTime::~_EditTime(void)
60 {
61         SettingInfo::RemoveSettingEventListener(*this);
62
63         delete __pDateTimeBar;
64         __pDateTimeBar = null;
65
66         delete __pEditTimePresenter;
67         __pEditTimePresenter = null;
68
69         if (__pTimeChangeEvent != null)
70         {
71                 delete __pTimeChangeEvent;
72                 __pTimeChangeEvent = null;
73         }
74
75         if (__pAccessibilityEditTimeElement)
76         {
77                 __pAccessibilityEditTimeElement->Activate(false);
78                 __pAccessibilityEditTimeElement = null;
79         }
80         if (__pAccessibilityHourElement)
81         {
82                 __pAccessibilityHourElement->Activate(false);
83                 __pAccessibilityHourElement = null;
84         }
85         if (__pAccessibilityMinuteElement)
86         {
87                 __pAccessibilityMinuteElement->Activate(false);
88                 __pAccessibilityMinuteElement = null;
89         }
90         if (__pAccessibilityAmPmElement)
91         {
92                 __pAccessibilityAmPmElement->Activate(false);
93                 __pAccessibilityAmPmElement = null;
94         }
95 }
96
97 _EditTime*
98 _EditTime::CreateEditTimeN(const String& title)
99 {
100         result r = E_SUCCESS;
101
102         _AccessibilityContainer* pContainer = null;
103
104         _EditTime* pEditTime = new (std::nothrow) _EditTime;
105         SysTryReturn(NID_UI_CTRL, pEditTime, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
106
107         pEditTime->GetVisualElement()->SetSurfaceOpaque(false);
108
109         pEditTime->__pEditTimePresenter = _EditTimePresenter::CreateInstanceN(*pEditTime, title);
110         r = GetLastResult();
111         SysTryCatch(NID_UI_CTRL, pEditTime->__pEditTimePresenter, , r, "[%s] Propagating.", GetErrorMessage(r));
112
113         r = pEditTime->CreateDateTimeBar();
114         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
115
116         pEditTime->__pEditTimePresenter->Initialize();
117         r = GetLastResult();
118         SysTryCatch(NID_UI_CTRL, pEditTime->__pEditTimePresenter, , r, "[%s] Propagating.", GetErrorMessage(r));
119
120         pEditTime->__pEditTimePresenter->SetCurrentTime();
121
122         if (title.IsEmpty() != true)
123         {
124                 pEditTime->__title = title;
125         }
126
127         pContainer = pEditTime->GetAccessibilityContainer();
128         if (pContainer)
129         {
130                 pContainer->Activate(true);
131                 pEditTime->CreateAccessibilityElement();
132         }
133
134         pEditTime->AcquireHandle();
135
136         return pEditTime;
137
138 CATCH:
139         delete pEditTime;
140         return null;
141 }
142
143 result
144 _EditTime::CreateDateTimeBar(void)
145 {
146         result r = E_SUCCESS;
147
148         __pDateTimeBar = _DateTimeBar::CreateDateTimeBarN(*this);
149         r = GetLastResult();
150         SysTryReturn(NID_UI_CTRL, (__pDateTimeBar != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
151
152         r = __pDateTimeBar->AddActionEventListener(*this);
153         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
154
155         r = __pDateTimeBar->AddDateTimeChangeEventListener(*this);
156         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
157
158         r =  SettingInfo::AddSettingEventListener(*this);
159         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
160
161         return r;
162
163 CATCH:
164         delete __pDateTimeBar;
165         return r;
166 }
167
168 result
169 _EditTime::AddTimeChangeEventListener(const _IDateTimeChangeEventListener& listener)
170 {
171         if (__pTimeChangeEvent == null)
172         {
173                 __pTimeChangeEvent = new (std::nothrow) _DateTimeChangeEvent(*this);
174                 SysTryReturn(NID_UI_CTRL, (__pTimeChangeEvent != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
175                                 "[E_OUT_OF_MEMORY] Memory allocation failed.");
176         }
177
178         result r = __pTimeChangeEvent->AddListener(listener);
179         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
180
181         return E_SUCCESS;
182 }
183
184 result
185 _EditTime::RemoveTimeChangeEventListener(const _IDateTimeChangeEventListener& listener)
186 {
187         result r = E_OBJ_NOT_FOUND;
188
189         if (__pTimeChangeEvent)
190         {
191                 r = __pTimeChangeEvent->RemoveListener(listener);
192         }
193
194         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
195
196         return E_SUCCESS;
197 }
198
199 void
200 _EditTime::SetTime(const DateTime& time)
201 {
202         SetProperty("time", Variant(time));
203         return;
204 }
205
206 result
207 _EditTime::SetPropertyTime(const Variant& time)
208 {
209         SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM,
210                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
211
212         __pEditTimePresenter->SetTime(time.ToDateTime());
213
214         UpdateAccessibilityElement();
215         return E_SUCCESS;
216 }
217
218 DateTime
219 _EditTime::GetTime(void) const
220 {
221         Variant time = GetProperty("time");
222
223         return time.ToDateTime();
224 }
225
226 Variant
227 _EditTime::GetPropertyTime(void) const
228 {
229         DateTime time;
230
231         SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM,
232                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
233
234         time = __pEditTimePresenter->GetTime();
235
236         return Variant(time);
237 }
238
239 result
240 _EditTime::SetHour(int hour)
241 {
242         result r = E_SUCCESS;
243
244         SetProperty("hour", Variant(hour));
245
246         r = GetLastResult();
247
248         return r;
249 }
250
251 result
252 _EditTime::SetPropertyHour(const Variant& hour)
253 {
254         SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM,
255                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
256
257         result r = E_SUCCESS;
258
259         r = __pEditTimePresenter->SetHour(hour.ToInt());
260         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
261
262         UpdateAccessibilityElement();
263
264         return r;
265 }
266
267 int
268 _EditTime::GetHour(void) const
269 {
270         Variant hour = GetProperty("hour");
271
272         return hour.ToInt();
273 }
274
275 Variant
276 _EditTime::GetPropertyHour(void) const
277 {
278         int hour = -1;
279
280         SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM,
281                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
282
283         hour = __pEditTimePresenter->GetHour();
284
285         return Variant(hour);
286 }
287
288 result
289 _EditTime::SetMinute(int minute)
290 {
291         result r = E_SUCCESS;
292
293         SetProperty("minute", Variant(minute));
294
295         r = GetLastResult();
296
297         return r;
298 }
299
300 result
301 _EditTime::SetPropertyMinute(const Variant& minute)
302 {
303         SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM,
304                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
305
306         result r = E_SUCCESS;
307
308         r = __pEditTimePresenter->SetMinute(minute.ToInt());
309         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
310
311         UpdateAccessibilityElement();
312
313         return r;
314 }
315
316 int
317 _EditTime::GetMinute(void) const
318 {
319         Variant minute = GetProperty("minute");
320
321         return minute.ToInt();
322 }
323
324 Variant
325 _EditTime::GetPropertyMinute(void) const
326 {
327         int minute = -1;
328
329         SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM,
330                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
331
332         minute = __pEditTimePresenter->GetMinute();
333
334         return Variant(minute);
335 }
336
337 void
338 _EditTime::SetCurrentTime(void)
339 {
340         SysTryReturnVoidResult(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM,
341                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
342
343         __pEditTimePresenter->SetCurrentTime();
344
345         UpdateAccessibilityElement();
346
347         return;
348 }
349
350 void
351 _EditTime::SetTimePickerEnabled(bool enable)
352 {
353         SetProperty("timePickerEnabled", Variant(enable));
354         return;
355 }
356
357 result
358 _EditTime::SetPropertyTimePickerEnabled(const Variant& enable)
359 {
360         SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM,
361                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
362
363         __pEditTimePresenter->SetTimePickerEnabled(enable.ToBool());
364
365         return E_SUCCESS;
366 }
367
368 bool
369 _EditTime::IsTimePickerEnabled(void) const
370 {
371         Variant enable = GetProperty("timePickerEnabled");
372
373         return enable.ToBool();
374 }
375
376 Variant
377 _EditTime::GetPropertyTimePickerEnabled(void) const
378 {
379         bool enable = false;
380
381         SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM,
382                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
383
384         enable = __pEditTimePresenter->IsTimePickerEnabled();
385
386         return Variant(enable);
387 }
388
389 void
390 _EditTime::Set24HourNotationEnabled(bool enable)
391 {
392         SysTryReturnVoidResult(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM,
393                         "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null.");
394
395         __pEditTimePresenter->Set24HourNotationEnabled(enable);
396         return;
397 }
398
399 bool
400 _EditTime::Is24HourNotationEnabled(void) const
401 {
402         SysAssertf((__pEditTimePresenter != null), "The _EditDatePresenter instance is null.");
403
404         return __pEditTimePresenter->Is24HourNotationEnabled();
405 }
406
407 result
408 _EditTime::CalculateDateTimeBarPosition(void)
409 {
410         result r = E_SUCCESS;
411
412         float dateTimeBarHeight = 0.0f;
413         float arrowHeight = 0.0f;
414         float timeHeight = 0.0f;
415         float timeBarMargin = 0.0f;
416         float textHeight = 0.0f;
417         float titleTimeMargin = 0.0f;
418         float bottomPosition = 0.0f;
419         float timeY = 0.0f;
420
421         FloatRectangle absoluteBounds;
422         FloatRectangle frameBounds;
423         FloatRectangle parentWindowBounds;
424         FloatRectangle titleBounds;
425
426         _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
427         SysTryReturn(NID_UI_CTRL, (pFrame != null), E_SYSTEM, E_SYSTEM,
428                         "[E_SYSTEM] A system error has occurred. Failed to get frame instance.");
429
430         frameBounds = pFrame->GetAbsoluteBoundsF();
431         absoluteBounds = GetAbsoluteBoundsF();
432         parentWindowBounds = GetParentWindowBounds();
433         titleBounds = __pEditTimePresenter->GetTitleBounds();
434
435         GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, GetOrientation(), dateTimeBarHeight);
436         GET_SHAPE_CONFIG(DATETIMEBAR::ARROW_HEIGHT, GetOrientation(), arrowHeight);
437         GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, GetOrientation(), timeHeight);
438         GET_SHAPE_CONFIG(EDITTIME::TIME_BAR_MARGIN, GetOrientation(), timeBarMargin);
439         GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, GetOrientation(), textHeight);
440         GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, GetOrientation(), titleTimeMargin);
441
442         if (!__title.IsEmpty()) //with title
443         {
444                 timeY = titleBounds.y + textHeight + titleTimeMargin ;
445         }
446         else //without title
447         {
448                 timeY = (absoluteBounds.height - timeHeight) / 2.0f ;
449         }
450
451         bottomPosition = absoluteBounds.y + timeY + timeHeight + timeBarMargin + arrowHeight + dateTimeBarHeight;
452
453         GetDateTimeBar()->SetParentWindowBounds(parentWindowBounds);
454
455         if (bottomPosition > frameBounds.y + parentWindowBounds.y + parentWindowBounds.height) //ALIGN_UP
456         {
457                 r = GetDateTimeBar()->SetPositionAndAlignment(FloatPoint(parentWindowBounds.x, absoluteBounds.y + timeY - timeBarMargin - arrowHeight), DATETIME_BAR_ALIGN_UP);
458                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
459         }
460         else    //ALIGN_DOWN
461         {
462                 r = GetDateTimeBar()->SetPositionAndAlignment(FloatPoint(parentWindowBounds.x, absoluteBounds.y + timeY + timeHeight + timeBarMargin + arrowHeight), DATETIME_BAR_ALIGN_DOWN);
463                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
464         }
465
466         __absoluteBounds = absoluteBounds;
467
468         return r;
469 }
470
471 void
472 _EditTime::OnDraw(void)
473 {
474         if (GetDateTimeBar() != null && GetDateTimeBar()->IsActivated())
475         {
476                 CalculateDateTimeBarPosition();
477         }
478
479         __pEditTimePresenter->Draw();
480
481         UpdateAccessibilityElement();
482         return;
483 }
484
485 void
486 _EditTime::CreateAccessibilityElement(void)
487 {
488         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
489         FloatRectangle hourBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
490         FloatRectangle minuteBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
491         FloatRectangle ampmBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
492
493         pContainer->AddListener(*this);
494         if (__pAccessibilityEditTimeElement == null)
495         {
496                 __pAccessibilityEditTimeElement = new _AccessibilityElement(true);
497                 __pAccessibilityEditTimeElement->SetBounds(GetClientBounds());
498                 __pAccessibilityEditTimeElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
499                 __pAccessibilityEditTimeElement->SetName(L"EditTimeText");
500                 pContainer->AddElement(*__pAccessibilityEditTimeElement);
501         }
502
503         if (__pAccessibilityHourElement == null && __pAccessibilityMinuteElement == null)
504         {
505                 String hintText(L"Double tap to edit");
506
507                 __pAccessibilityHourElement = new _AccessibilityElement(true);
508                 __pAccessibilityHourElement->SetBounds(hourBounds);
509                 __pAccessibilityHourElement->SetTrait(ACCESSIBILITY_TRAITS_HOUR);
510                 __pAccessibilityHourElement->SetHint(hintText);
511                 pContainer->AddElement(*__pAccessibilityHourElement);
512
513                 __pAccessibilityMinuteElement = new _AccessibilityElement(true);
514                 __pAccessibilityMinuteElement->SetBounds(minuteBounds);
515                 __pAccessibilityMinuteElement->SetTrait(ACCESSIBILITY_TRAITS_MINUTE);
516                 __pAccessibilityMinuteElement->SetHint(hintText);
517                 pContainer->AddElement(*__pAccessibilityMinuteElement);
518
519                 if (Is24HourNotationEnabled() == false)
520                 {
521                         __pAccessibilityAmPmElement = new _AccessibilityElement(true);
522                         __pAccessibilityAmPmElement->SetBounds(ampmBounds);
523                         __pAccessibilityAmPmElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON);
524                         pContainer->AddElement(*__pAccessibilityAmPmElement);
525                 }
526         }
527 }
528
529 void
530 _EditTime::OnBoundsChanged(void)
531 {
532         __pEditTimePresenter->Initialize();
533
534         if (__pAccessibilityEditTimeElement)
535         {
536                 __pAccessibilityEditTimeElement->SetBounds(__pEditTimePresenter->GetTitleBounds());
537         }
538         if (__pAccessibilityHourElement)
539         {
540                 __pAccessibilityHourElement->SetBounds(__pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR));
541         }
542         if (__pAccessibilityMinuteElement)
543         {
544                 __pAccessibilityMinuteElement->SetBounds(__pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE));
545         }
546         if (__pAccessibilityAmPmElement)
547         {
548                 __pAccessibilityAmPmElement->SetBounds(__pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM));
549         }
550
551         return;
552 }
553
554 void
555 _EditTime::OnChangeLayout(_ControlOrientation orientation)
556 {
557         FloatDimension dim;
558
559         GET_SHAPE_CONFIG(EDITTIME::WIDTH, GetOrientation(), dim.width);
560         GET_SHAPE_CONFIG(EDITTIME::HEIGHT, GetOrientation(), dim.height);
561
562         SetSize(dim);
563
564         __pEditTimePresenter->Initialize();
565         __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE);
566
567         if (GetDateTimeBar() != null)
568         {
569                 GetDateTimeBar()->SetVisibleState(false);
570                 GetDateTimeBar()->Close();
571         }
572
573         return;
574 }
575
576 bool
577 _EditTime::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
578 {
579         SetFocused(true);
580
581         return __pEditTimePresenter->OnTouchPressed(source, touchinfo);
582 }
583
584 bool
585 _EditTime::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
586 {
587         FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
588
589         if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
590         {
591                 CalculateDateTimeBarPosition();
592         }
593
594         return __pEditTimePresenter->OnTouchReleased(source, touchinfo);
595 }
596
597 bool
598 _EditTime::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
599 {
600         return __pEditTimePresenter->OnTouchCanceled(source, touchinfo);
601 }
602
603 bool
604 _EditTime::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
605 {
606         return __pEditTimePresenter->OnTouchMoved(source, touchinfo);
607 }
608
609 void
610 _EditTime::OnTouchMoveHandled(const _Control& control)
611 {
612         __pEditTimePresenter->OnTouchMoveHandled(control);
613         return;
614 }
615
616 result
617 _EditTime::FireTimeChangeEvent(_DateTimeChangeStatus status)
618 {
619         SysTryReturn(NID_UI_CTRL, (__pTimeChangeEvent != null), E_SYSTEM, E_SYSTEM,
620                         "[E_SYSTEM] A system error has occurred. The _DateTimeChangeEvent instance is null.");
621
622         _DateTimeChangeEventArg* pDateTimeEventArg = new (std::nothrow) _DateTimeChangeEventArg(status);
623         SysTryReturn(NID_UI_CTRL, pDateTimeEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
624                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
625
626         pDateTimeEventArg->SetTime(GetHour(), GetMinute());
627
628         __pTimeChangeEvent->Fire(*pDateTimeEventArg);
629
630         return E_SUCCESS;
631 }
632
633 void
634 _EditTime::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute)
635 {
636         __pEditTimePresenter->Animate();
637         __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE);
638         Invalidate();
639         FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
640         return;
641 }
642
643 void
644 _EditTime::OnDateTimeChangeCanceled(const _Control& source)
645 {
646         __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE);
647         Invalidate();
648         FireTimeChangeEvent(TIME_INTERNAL_CHANGE_CANCELED);
649         return;
650 }
651
652 void
653 _EditTime::OnActionPerformed(const Ui::_Control& source, int actionId)
654 {
655         _DateTimeId boxId = __pEditTimePresenter->GetLastSelectedId();
656
657         if (boxId == DATETIME_ID_HOUR)
658         {
659                 bool amEnable = true;
660                 amEnable = __pEditTimePresenter->GetAmEnabled();
661
662                 int hour = 0;
663                 hour = actionId;
664                 if (amEnable == false && Is24HourNotationEnabled() == false)
665                 {
666                         if (hour < DATETIME_HOUR_MAX_FOR_24NOTATION)
667                         {
668                                 hour += DATETIME_HOUR_MAX_FOR_24NOTATION;
669                         }
670                 }
671                 else if (amEnable == true && Is24HourNotationEnabled() == false)
672                 {
673                         if (hour == DATETIME_HOUR_MAX_FOR_24NOTATION)
674                         {
675                                 hour = DATETIME_HOUR_MIN;
676                         }
677                 }
678                 SetHour(hour);
679         }
680         else if (boxId == DATETIME_ID_MINUTE)
681         {
682                 SetMinute(actionId);
683         }
684
685         Invalidate();
686         return;
687 }
688
689 _DateTimeBar*
690 _EditTime::GetDateTimeBar(void) const
691 {
692         return __pDateTimeBar;
693 }
694
695 void
696 _EditTime::OnFontChanged(Font* pFont)
697 {
698         __pEditTimePresenter->OnFontChanged(pFont);
699
700         return;
701 }
702
703 void
704 _EditTime::OnFontInfoRequested(unsigned long& style, float& size)
705 {
706         __pEditTimePresenter->OnFontInfoRequested(style, size);
707
708         return;
709 }
710
711 void
712 _EditTime::OnSettingChanged(String& key)
713 {
714         if (key.Equals(L"http://tizen.org/setting/locale.time.format.24hour", false))
715         {
716                 __pEditTimePresenter->UpdateTimeFormat();
717                 Invalidate();
718         }
719
720         return;
721 }
722
723 FloatRectangle
724 _EditTime::GetParentWindowBounds(void) const
725 {
726         _Form* pForm = null;
727         _Window* pwindow = null;
728         _Control* pControlCore = GetParent();
729
730         FloatDimension dateTimeBarSize(0.0f, 0.0f);
731
732         GET_DIMENSION_CONFIG(DATETIMEBAR::DEFAULT_SIZE, GetOrientation(), dateTimeBarSize);
733
734         FloatRectangle parentWindowBounds(0.0f, 0.0f, dateTimeBarSize.width, dateTimeBarSize.height);
735
736         while (true)
737         {
738                 if (pControlCore == null)
739                 {
740                         SysLog(NID_UI_CTRL,"[E_SYSTEM] Parent window not found.");
741
742                         return parentWindowBounds;
743                 }
744
745                 // If the parent is a Frame, then return the Form's bounds.
746                 pForm = dynamic_cast<_Form*>(pControlCore);
747                 if (pForm != null)
748                 {
749                         parentWindowBounds = pForm->GetBoundsF();
750                         break;
751                 }
752
753                 pwindow = dynamic_cast<_Window*>(pControlCore);
754
755                 if (pwindow != null)
756                 {
757                         parentWindowBounds = pwindow->GetBoundsF();
758                         break;
759                 }
760
761                 pControlCore = pControlCore->GetParent();
762         }
763
764         return parentWindowBounds;
765 }
766
767 void
768 _EditTime::UpdateAccessibilityElement(void)
769 {
770         String string;
771
772         if (likely(!(_AccessibilityManager::IsActivated())))
773         {
774                 return;
775         }
776
777         if (__pAccessibilityEditTimeElement == null && __pAccessibilityHourElement == null
778                         && __pAccessibilityMinuteElement == null && __pAccessibilityAmPmElement == null)
779         {
780                 return;
781         }
782
783         if (__title.IsEmpty() == false)
784         {
785                 string.Append(__title);
786                 string.Append(L", ");
787         }
788
789         String hourString;
790         int hour =  GetHour();
791         int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION;
792
793         if (Is24HourNotationEnabled() == false && (hour > maxHour))
794         {
795                 hourString.Format(10, L"%02d", hour - DATETIME_HOUR_MAX_FOR_24NOTATION);
796         }
797         else
798         {
799                 hourString.Format(10, L"%02d", hour);
800         }
801
802         string.Append(hourString.GetPointer());
803         string.Append(L":");
804         string.Append(GetMinute());
805         string.Append(L" ");
806
807         if (Is24HourNotationEnabled() == false)
808         {
809                 String hintAmPmText(L"Double tap to change to ");
810
811                 String amString;
812                 String pmString;
813                 _DateTimeUtils dateTimeUtils;
814                 dateTimeUtils.GetAmPm(amString, AM_TYPE);
815                 dateTimeUtils.GetAmPm(pmString, PM_TYPE);
816
817                 if (__pEditTimePresenter->GetAmEnabled() == true)
818                 {
819                         __pAccessibilityAmPmElement->SetLabel(amString);
820                         hintAmPmText.Append(pmString.GetPointer());
821                         string.Append(amString.GetPointer());
822                 }
823                 else
824                 {
825                         __pAccessibilityAmPmElement->SetLabel(pmString);
826                         hintAmPmText.Append(amString.GetPointer());
827                         string.Append(pmString.GetPointer());
828                 }
829
830                 __pAccessibilityAmPmElement->SetHint(hintAmPmText);
831         }
832
833         __pAccessibilityEditTimeElement->SetLabel(string);
834
835         __pAccessibilityHourElement->SetLabel(hourString);
836
837         string.Clear();
838         string.Format(10, L"%02d", GetMinute());
839         __pAccessibilityMinuteElement->SetLabel(string);
840
841         return;
842 }
843
844 bool
845 _EditTime::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
846 {
847         return false;
848 }
849
850 bool
851 _EditTime::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
852 {
853         return false;
854 }
855
856 bool
857 _EditTime::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
858 {
859         return false;
860 }
861
862 bool
863 _EditTime::OnAccessibilityReadedElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
864 {
865         return false;
866 }
867
868
869 bool
870 _EditTime::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
871 {
872         return false;
873 }
874
875 bool
876 _EditTime::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
877 {
878         return false;
879 }
880
881 bool
882 _EditTime::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
883 {
884         String amString;
885         String pmString;
886         String labelText;
887
888         labelText = element.GetLabel();
889
890         _DateTimeUtils dateTimeUtils;
891         dateTimeUtils.GetAmPm(amString, AM_TYPE);
892         dateTimeUtils.GetAmPm(pmString, PM_TYPE);
893
894         if (labelText == amString || labelText == pmString)
895         {
896                 labelText.Append(L" Selected");
897                 _AccessibilityManager::GetInstance()->ReadContent(labelText);
898         }
899
900         return true;
901 }
902
903 bool
904 _EditTime::OnAccessibilityValueIncreased(const _AccessibilityContainer&, const _AccessibilityElement&)
905 {
906         return false;
907 }
908
909 bool
910 _EditTime::OnAccessibilityValueDecreased(const _AccessibilityContainer&, const _AccessibilityElement&)
911 {
912         return false;
913 }
914
915 }}} // Controls