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_EditTimePresenter.cpp
20 * @brief This is the implementation file for the _EditTimePresenter class.
23 #include <FSysSettingInfo.h>
24 #include <FGrp_BitmapImpl.h>
25 #include <FGrp_TextTextObject.h>
26 #include <FGrp_TextTextSimple.h>
27 #include <FGrp_FontImpl.h>
28 #include "FUi_CoordinateSystemUtils.h"
29 #include "FUi_ResourceManager.h"
30 #include "FUiCtrl_EditTimePresenter.h"
31 #include "FUiCtrl_EditTime.h"
32 #include "FUiCtrl_DateTimeModel.h"
33 #include "FUiCtrl_DateTimeUtils.h"
34 #include "FUiAnim_VisualElement.h"
35 #include "FUiAnimVisualElementPropertyAnimation.h"
36 #include "FGrpColor.h"
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Base;
40 using namespace Tizen::Graphics::_Text;
41 using namespace Tizen::Ui::Animations;
42 using namespace Tizen::System;
44 namespace Tizen { namespace Ui { namespace Controls
46 _EditTimePresenter::_EditTimePresenter(const String& title)
47 : __pEditDateTimeModel(null)
49 , __bounds(FloatRectangle())
50 , __titleBounds(FloatRectangle())
51 , __ampmString(String())
52 , __hourString(String())
53 , __minuteString(String())
56 , __is24hoursSet(false)
58 , __timePickerEnabled(true)
59 , __selectedId(DATETIME_ID_NONE)
60 , __lastSelectedId(DATETIME_ID_NONE)
61 , __touchMoveHandled(false)
62 , __pAmPmBgNormalColorReplacementBitmap(null)
63 , __pAmPmBgDisabledColorReplacementBitmap(null)
64 , __pAmPmBgPressedColorReplacementBitmap(null)
65 , __pAmPmBgEffectNomralBitmap(null)
66 , __pAmPmBgEffectPressedBitmap(null)
67 , __pAmPmBgEffectDisabledBitmap(null)
68 , __pColonColorReplacementBitmap(null)
69 , __pColonDisabledColorReplacementBitmap(null)
70 , __pContentProvider(null)
74 , __amPmTextSize(0.0f)
75 , __titleFontSize(0.0f)
76 , __timeFontSize(0.0f)
77 , __isAnimating(false)
78 , __isEditTimeInitialized(false)
82 _EditTimePresenter::~_EditTimePresenter(void)
84 __textObject.RemoveAll();
85 __titleObject.RemoveAll();
87 delete __pEditDateTimeModel;
88 __pEditDateTimeModel = null;
90 delete __pAmPmBgNormalColorReplacementBitmap;
91 __pAmPmBgNormalColorReplacementBitmap = null;
93 delete __pAmPmBgDisabledColorReplacementBitmap;
94 __pAmPmBgDisabledColorReplacementBitmap = null;
96 delete __pAmPmBgPressedColorReplacementBitmap;
97 __pAmPmBgPressedColorReplacementBitmap = null;
99 delete __pAmPmBgEffectNomralBitmap;
100 __pAmPmBgEffectNomralBitmap = null;
102 delete __pAmPmBgEffectPressedBitmap;
103 __pAmPmBgEffectPressedBitmap = null;
105 delete __pAmPmBgEffectDisabledBitmap;
106 __pAmPmBgEffectDisabledBitmap = null;
108 delete __pColonColorReplacementBitmap;
109 __pColonColorReplacementBitmap = null;
111 delete __pColonDisabledColorReplacementBitmap;
112 __pColonDisabledColorReplacementBitmap = null;
116 _EditTimePresenter::CreateInstanceN(const _EditTime& editTime, const String& title)
118 _EditTimePresenter* pEditTimePresenter = new (std::nothrow) _EditTimePresenter(title);
119 SysTryReturn(NID_UI_CTRL, pEditTimePresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
121 pEditTimePresenter->__pEditTime = const_cast <_EditTime*>(&editTime);
123 pEditTimePresenter->__pEditDateTimeModel = new (std::nothrow) _DateTimeModel;
124 SysTryCatch(NID_UI_CTRL, pEditTimePresenter->__pEditDateTimeModel, , E_OUT_OF_MEMORY,
125 "[E_OUT_OF_MEMORY] Memory allocation failed.");
127 return pEditTimePresenter;
130 delete pEditTimePresenter;
135 _EditTimePresenter::GetTime(void) const
138 time.SetValue(DATETIME_YEAR_MIN, DATETIME_MONTH_MIN, DATETIME_DAY_MIN, GetHour(), GetMinute(), 0);
144 _EditTimePresenter::GetHour(void) const
146 return __pEditDateTimeModel->GetHour();
150 _EditTimePresenter::GetMinute(void) const
152 return __pEditDateTimeModel->GetMinute();
156 _EditTimePresenter::SetTime(const DateTime& time)
158 __pEditDateTimeModel->SetDateTime(time);
162 _EditTimePresenter::SetCurrentTime(void)
164 __pEditDateTimeModel->SetCurrentDateTime();
169 _EditTimePresenter::SetHour(int hour)
171 return __pEditDateTimeModel->SetHour(hour);
175 _EditTimePresenter::SetMinute(int minute)
177 return __pEditDateTimeModel->SetMinute(minute);
181 _EditTimePresenter::SetTimePickerEnabled(bool enable)
183 __timePickerEnabled = enable;
188 _EditTimePresenter::IsTimePickerEnabled(void) const
190 return __timePickerEnabled;
194 _EditTimePresenter::Set24HourNotationEnabled(bool enable)
197 __is24hoursSet = true;
202 _EditTimePresenter::Is24HourNotationEnabled(void) const
208 _EditTimePresenter::SetTimeConversion(void)
210 int hour = GetHour();
211 int minute = GetMinute();
213 if (__24hours == false)
215 int max = DATETIME_HOUR_MAX_FOR_24NOTATION;
219 __hourString.Format(10, L"%02d", hour - max);
221 else if (hour == DATETIME_HOUR_MIN)
223 __hourString.Format(10, L"%02d", hour + DATETIME_HOUR_MAX_FOR_24NOTATION);
227 __hourString.Format(10, L"%02d", hour);
230 __minuteString.Format(10, L"%02d", minute);
234 __hourString.Format(10, L"%02d", hour);
235 __minuteString.Format(10, L"%02d", minute);
242 _EditTimePresenter::SetAmEnabled(bool amEnable)
247 GET_STRING_CONFIG(IDS_COM_BODY_AM, textAm);
248 GET_STRING_CONFIG(IDS_COM_POP_PM, textPm);
250 __amEnable = amEnable;
251 int hour = GetHour();
253 if (__amEnable == true)
255 __ampmString = textAm;
256 if (hour >= DATETIME_HOUR_MAX_FOR_24NOTATION)
258 SetHour(hour - DATETIME_HOUR_MAX_FOR_24NOTATION);
263 __ampmString = textPm;
264 if (hour < DATETIME_HOUR_MAX_FOR_24NOTATION)
266 SetHour(hour + DATETIME_HOUR_MAX_FOR_24NOTATION);
274 _EditTimePresenter::GetAmEnabled(void) const
280 _EditTimePresenter::GetDisplayAreaBoundsFromHoursStyle(_DateTimeId displayBoxId) const
282 SysTryReturn(NID_UI_CTRL, displayBoxId >= DATETIME_ID_HOUR && displayBoxId <= DATETIME_ID_AMPM, FloatRectangle(),
283 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] displayBoxId is out of range.");
285 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
288 float colonWidth = 0.0f;
290 float colonMargin = 0.0f;
291 float timeElementWidth = 0.0f;
292 float amPmHeight = 0.0f;
293 float timeHeight = 0.0f;
294 float titleTimeMargin = 0.0f;
295 float leftMargin = 0.0f;
297 GET_SHAPE_CONFIG(EDITTIME::TIME_WIDTH, __pEditTime->GetOrientation(), width);
298 GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), bounds.height);
299 GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonWidth);
300 GET_SHAPE_CONFIG(EDITTIME::TIME_AMPM_MARGIN, __pEditTime->GetOrientation(), margin);
301 GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), leftMargin);
302 GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
303 GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), timeElementWidth);
304 GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), amPmHeight);
305 GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
306 GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
308 if (__pEditTime->GetBoundsF().height > bounds.height)
310 bounds.height = __pEditTime->GetBoundsF().height;
313 if (!__title.IsEmpty())
315 if (displayBoxId == DATETIME_ID_AMPM)
317 bounds.y = __titleBounds.y + __titleBounds.height;
321 bounds.y = __titleBounds.y + __titleBounds.height + titleTimeMargin;
322 bounds.height = timeHeight;
326 if (__pEditTime->GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
331 bounds.x = leftMargin + ((width - (2.0f * timeElementWidth + colonWidth + 2.0f * colonMargin)) / 2.0f);
333 if (displayBoxId == DATETIME_ID_HOUR)
335 bounds.width = timeElementWidth;
337 else if (displayBoxId == DATETIME_ID_MINUTE)
339 bounds.x = bounds.x + timeElementWidth + colonWidth + 2.0f * colonMargin;
340 bounds.width = timeElementWidth;
342 else if (displayBoxId == DATETIME_ID_AMPM)
344 bounds.x = leftMargin + width + margin;
346 if (__title.IsEmpty())
348 bounds.y = bounds.y + (bounds.height - amPmHeight) / 2.0f;
351 GET_SHAPE_CONFIG(EDITTIME::AMPM_WIDTH, __pEditTime->GetOrientation(), bounds.width);
352 bounds.height = amPmHeight;
359 _EditTimePresenter::SetTitleBounds(void)
361 GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), __titleBounds.x);
362 GET_SHAPE_CONFIG(EDITTIME::WIDTH, __pEditTime->GetOrientation(), __titleBounds.width);
363 GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), __titleBounds.height);
369 _EditTimePresenter::GetTitleBounds(void) const
371 return __titleBounds;
375 _EditTimePresenter::LoadResource(void)
377 result r = E_SUCCESS;
379 Color buttonNormalBgColor;
380 Color buttonDisabledBgColor;
381 Color buttonNormalPressedColor;
382 Color colonTextColor;
383 Color colonTextDisabledColor;
384 Bitmap* pTempBitmap = null;
386 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_NORMAL, buttonNormalBgColor);
387 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_PRESSED, buttonNormalPressedColor);
388 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_DISABLED, buttonDisabledBgColor);
389 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, colonTextColor);
390 GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, colonTextDisabledColor);
392 GET_SHAPE_CONFIG(EDITTIME::AMPM_FONT_SIZE, __pEditTime->GetOrientation(), __amPmTextSize);
394 r = GET_BITMAP_CONFIG_N(EDITTIME::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
395 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
397 __pColonColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE),
399 SysTryCatch(NID_UI_CTRL, (__pColonColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
400 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
402 __pColonDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE),
403 colonTextDisabledColor);
404 SysTryCatch(NID_UI_CTRL, (__pColonDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
405 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
410 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
411 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
413 __pAmPmBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalBgColor);
414 SysTryCatch(NID_UI_CTRL, (__pAmPmBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
415 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
420 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
421 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
423 __pAmPmBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonDisabledBgColor);
424 SysTryCatch(NID_UI_CTRL, (__pAmPmBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
425 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
430 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
431 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
433 __pAmPmBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalPressedColor);
434 SysTryCatch(NID_UI_CTRL, (__pAmPmBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
435 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
437 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectNomralBitmap);
438 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
440 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectPressedBitmap);
441 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
443 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectDisabledBitmap);
444 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
456 delete __pAmPmBgNormalColorReplacementBitmap;
457 __pAmPmBgNormalColorReplacementBitmap = null;
459 delete __pAmPmBgPressedColorReplacementBitmap;
460 __pAmPmBgPressedColorReplacementBitmap = null;
462 delete __pAmPmBgEffectNomralBitmap;
463 __pAmPmBgEffectNomralBitmap = null;
465 delete __pAmPmBgEffectPressedBitmap;
466 __pAmPmBgEffectPressedBitmap = null;
468 delete __pColonColorReplacementBitmap;
469 __pColonColorReplacementBitmap = null;
475 _EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
477 result r = E_SUCCESS;
484 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
486 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
487 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
491 r = canvas.DrawBitmap(bounds, *pBitmap);
492 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
499 _EditTimePresenter::InitializeTitleObject(void)
501 result r = E_SUCCESS;
503 Color titleNormalColor;
505 GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_NORMAL, titleNormalColor);
507 r = __titleObject.Construct();
508 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
510 TextSimple* pSimpleText = null;
512 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
513 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
515 __titleObject.AppendElement(*pSimpleText);
517 __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength());
518 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
519 __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
520 __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
521 __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
527 _EditTimePresenter::InitializeTextObject(void)
529 result r = E_SUCCESS;
531 r = __textObject.Construct();
532 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
534 TextSimple* pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
535 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
536 "[E_OUT_OF_MEMORY] Memory allocation failed.");
538 __textObject.AppendElement(*pSimpleText);
540 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
541 __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
542 __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
543 __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
549 _EditTimePresenter::Draw(void)
551 result r = E_SUCCESS;
558 Canvas* pCanvas = __pEditTime->GetCanvasN();
559 SysAssertf((pCanvas != null), "Failed to get canvas.");
561 FloatRectangle colonBounds(0.0f, 0.0f, 0.0f, 0.0f);
563 float colonMargin = 0.0f;
567 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
570 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
571 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
572 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
573 bool isCustomBitmap = false;
574 Bitmap* pReplacementBitmap = null;
575 Bitmap* pEffectBitmap = null;
577 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
578 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
580 if (__24hours == false)
582 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
584 if (!__pEditTime->IsEnabled())
586 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_DISABLED);
587 pReplacementBitmap = __pAmPmBgDisabledColorReplacementBitmap;
588 pEffectBitmap = __pAmPmBgEffectDisabledBitmap;
590 else if (__selectedId != DATETIME_ID_AMPM)
592 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_NORMAL);
593 pReplacementBitmap = __pAmPmBgNormalColorReplacementBitmap;
594 pEffectBitmap = __pAmPmBgEffectNomralBitmap;
598 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_PRESSED);
599 pReplacementBitmap = __pAmPmBgPressedColorReplacementBitmap;
600 pEffectBitmap = __pAmPmBgEffectPressedBitmap;
603 r = DrawResourceBitmap(*pCanvas, ampmBounds, pReplacementBitmap);
604 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
608 r = DrawResourceBitmap(*pCanvas, ampmBounds, pEffectBitmap);
609 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
613 if (GetHour() >= DATETIME_HOUR_MAX_FOR_24NOTATION)
624 GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonBounds.width);
625 GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
626 GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), colonBounds.height);
628 colonBounds.x = hourBounds.x + hourBounds.width + colonMargin;
629 colonBounds.y = hourBounds.y + (hourBounds.height - colonBounds.height) / 2.0f;
631 if (__title.IsEmpty() == false)
633 r = DrawTitle(*pCanvas);
634 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
637 r = DrawText(*pCanvas, hourBounds, __hourString);
638 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
640 r = DrawText(*pCanvas, minuteBounds, __minuteString);
641 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
643 if (__24hours == false)
645 r = DrawText(*pCanvas, ampmBounds, __ampmString, __amPmTextSize);
646 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
649 r = DrawColon(*pCanvas, colonBounds);
650 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
659 _EditTimePresenter::DrawColon(Canvas& canvas, const FloatRectangle& bounds)
661 result r = E_SUCCESS;
663 if (!__pEditTime->IsEnabled())
665 r = DrawResourceBitmap(canvas, bounds, __pColonDisabledColorReplacementBitmap);
669 r = DrawResourceBitmap(canvas, bounds, __pColonColorReplacementBitmap);
674 r = DrawText(canvas, bounds, L":");
675 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
682 _EditTimePresenter::DrawTitle(Canvas& canvas)
684 if (!__pEditTime->IsEnabled())
686 Color titleDisabledColor;
687 GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_DISABLED, titleDisabledColor);
688 __titleObject.SetForegroundColor(titleDisabledColor, 0, __titleObject.GetTextLength());
691 (_FontImpl::GetInstance(*__pFont))->SetSize(__titleFontSize);
692 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
694 __titleObject.Draw(*_CanvasImpl::GetInstance(canvas));
700 _EditTimePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, float textSize)
702 result r = E_SUCCESS;
706 _DateTimeId boxId = DATETIME_ID_NONE;
707 boxId = GetBoxIdFromPosition(FloatPoint(bounds.x + 1.0f, bounds.y));
709 if (!__pEditTime->IsEnabled())
711 if (boxId == DATETIME_ID_AMPM)
713 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_DISABLED, textColor);
717 GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, textColor);
722 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, textColor);
724 if (boxId == DATETIME_ID_AMPM)
726 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_NORMAL, textColor);
729 if (boxId > -1 && boxId == __selectedId)
731 if (boxId == DATETIME_ID_AMPM)
733 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_PRESSED, textColor);
737 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
742 FloatRectangle drawAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
743 drawAreaBounds = bounds;
745 TextSimple* pSimpleText = null;
746 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
747 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
749 __textObject.RemoveAll();
751 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
753 __textObject.AppendElement(*pSimpleText);
755 if (boxId == DATETIME_ID_AMPM)
757 (_FontImpl::GetInstance(*__pFont))->SetSize(textSize);
758 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
762 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
765 __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength());
766 __textObject.SetBounds(drawAreaBounds);
767 __textObject.Draw(*_CanvasImpl::GetInstance(canvas));
773 _EditTimePresenter::GetBoxIdFromPosition(const FloatPoint& point) const
775 _DateTimeId displayBoxId = DATETIME_ID_NONE;
777 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
778 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
779 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
781 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
782 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
784 if (__24hours == false)
786 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
789 if (point.y < hourBounds.y || point.y > hourBounds.y + hourBounds.height)
794 if (hourBounds.Contains(point) == true)
796 displayBoxId = DATETIME_ID_HOUR;
798 else if (minuteBounds.Contains(point) == true)
800 displayBoxId = DATETIME_ID_MINUTE;
802 else if (ampmBounds.Contains(point) == true)
804 displayBoxId = DATETIME_ID_AMPM;
811 _EditTimePresenter::SetLastSelectedId(_DateTimeId boxId)
813 __lastSelectedId = boxId;
818 _EditTimePresenter::GetLastSelectedId(void) const
820 return __lastSelectedId;
824 _EditTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
826 SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
828 if (&source != __pEditTime)
833 __touchMoveHandled = false;
835 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
836 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
837 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
839 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
840 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
842 if (__24hours == false)
844 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
847 FloatPoint point = touchinfo.GetCurrentPosition();
849 _DateTimeId boxId = GetBoxIdFromPosition(point);
853 int displayValue = -1;
855 if (boxId == DATETIME_ID_HOUR)
857 if (__pEditTime->GetDateTimeBar() != null)
859 if (__24hours == false)
863 minValue = DATETIME_HOUR_MIN + 1;
864 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
865 displayValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
867 else if (GetHour() > DATETIME_HOUR_MAX_FOR_24NOTATION)
869 minValue = DATETIME_HOUR_MIN + 1;
870 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
871 displayValue = GetHour() - DATETIME_HOUR_MAX_FOR_24NOTATION;
875 minValue = DATETIME_HOUR_MIN + 1;
876 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
877 displayValue = GetHour();
882 minValue = DATETIME_HOUR_MIN;
883 maxValue = DATETIME_HOUR_MAX;
884 displayValue = GetHour();
887 if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
889 __pEditTime->GetDateTimeBar()->RemoveAllItems();
892 __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
895 __bounds = hourBounds;
897 else if (boxId == DATETIME_ID_MINUTE)
899 if (__pEditTime->GetDateTimeBar() != null)
901 minValue = DATETIME_MINUTE_MIN;
902 maxValue = DATETIME_MINUTE_MAX;
903 displayValue = GetMinute();
905 if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
907 __pEditTime->GetDateTimeBar()->RemoveAllItems();
910 __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
913 __bounds = minuteBounds;
915 else if (boxId == DATETIME_ID_AMPM)
917 __selectedId = boxId;
918 __bounds = ampmBounds;
923 __selectedId = DATETIME_ID_NONE;
927 __selectedId = boxId;
933 _EditTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
935 SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
937 if (&source != __pEditTime)
942 FloatRectangle bounds = __pEditTime->GetBoundsF();
944 FloatPoint startPoint(0.0f, 0.0f);
946 float titleHeight = 0;
947 GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), titleHeight);
949 __bounds = FloatRectangle(0.0f, titleHeight, bounds.width, bounds.height);
951 FloatPoint point = touchinfo.GetCurrentPosition();
953 _DateTimeId boxId = GetBoxIdFromPosition(point);
955 if (boxId != __selectedId || boxId == DATETIME_ID_NONE)
957 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
959 __pEditTime->GetDateTimeBar()->SetVisibleState(false);
960 __pEditTime->GetDateTimeBar()->Close();
965 __selectedId = DATETIME_ID_NONE;
966 SetLastSelectedId(__selectedId);
971 SetLastSelectedId(__selectedId);
973 __lastSelectedValue = "";
974 _DateTimeUtils dateTimeUtils;
976 if (GetLastSelectedId() == DATETIME_ID_HOUR)
978 int hours = GetHour();
980 if (!Is24HourNotationEnabled())
984 if (hours == DATETIME_HOUR_MIN)
986 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
989 __lastSelectedValue.Format(10, L"%02d", hours);
990 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
992 else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
994 __lastSelectedValue.Format(10, L"%02d", GetMinute());
995 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
997 else if (GetLastSelectedId() == DATETIME_ID_AMPM)
999 SetAmEnabled(!GetAmEnabled());
1000 __pEditTime->FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
1001 __pEditTime->UpdateAccessibilityElement();
1002 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1004 __selectedId = DATETIME_ID_NONE;
1006 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1008 __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1009 __pEditTime->GetDateTimeBar()->Close();
1019 if ((__pEditTime->GetDateTimeBar() != null) && (boxId != DATETIME_ID_AMPM) && (GetLastSelectedId() != DATETIME_ID_NONE))
1021 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1022 bounds = GetDisplayAreaBoundsFromHoursStyle(GetLastSelectedId());
1023 FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1024 absoluteBounds = __pEditTime->GetAbsoluteBoundsF();
1025 bounds.x += absoluteBounds.x;
1027 __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds);
1029 if (__pEditTime->GetDateTimeBar()->IsActivated())
1031 __pEditTime->GetDateTimeBar()->RefreshItems();
1035 __pEditTime->GetDateTimeBar()->SetVisibleState(true);
1036 __pEditTime->GetDateTimeBar()->Open();
1040 __selectedId = DATETIME_ID_NONE;
1045 _EditTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1047 if (&source != __pEditTime)
1052 __selectedId = DATETIME_ID_NONE;
1058 _EditTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1060 if (&source != __pEditTime)
1065 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
1067 if (GetBoxIdFromPosition(touchPoint) != __selectedId)
1069 __selectedId = DATETIME_ID_NONE;
1076 _EditTimePresenter::OnTouchMoveHandled(const _Control& control)
1078 __touchMoveHandled = true;
1079 __selectedId = DATETIME_ID_NONE;
1085 _EditTimePresenter::OnFontChanged(Font* pFont)
1089 if (__pEditTime->GetDateTimeBar() != null)
1091 __pEditTime->GetDateTimeBar()->SetFont(*pFont);
1098 _EditTimePresenter::OnFontInfoRequested(unsigned long& style, float& size)
1100 style = FONT_STYLE_PLAIN;
1101 size = __timeFontSize;
1107 _EditTimePresenter::Initialize(void)
1109 result r = E_SUCCESS;
1111 float titleTimeMargin = 0;
1112 float timeHeight = 0;
1113 float editTimeHeight = 0;
1115 GET_SHAPE_CONFIG(EDITTIME::TEXT_FONT_SIZE, __pEditTime->GetOrientation(), __titleFontSize);
1116 GET_SHAPE_CONFIG(EDITTIME::TIME_FONT_SIZE, __pEditTime->GetOrientation(), __timeFontSize);
1117 GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
1118 GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
1119 GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), editTimeHeight);
1121 if (__pEditTime->GetBoundsF().height > editTimeHeight)
1123 editTimeHeight = __pEditTime->GetBoundsF().height;
1126 if (__title.IsEmpty() == false)
1129 if (!__isEditTimeInitialized)
1131 r = InitializeTitleObject();
1132 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1135 __titleBounds.y = (editTimeHeight - (__titleBounds.height + titleTimeMargin + timeHeight)) / 2.0f;
1136 __titleObject.SetBounds(__titleBounds);
1139 __pFont = __pEditTime->GetFallbackFont();
1140 r = GetLastResult();
1141 SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
1143 if (!__isEditTimeInitialized)
1146 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1148 r = InitializeTextObject();
1149 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1152 __isEditTimeInitialized = true;
1159 _EditTimePresenter::UpdateTimeFormat(void)
1161 if (!__is24hoursSet)
1163 String key(L"http://tizen.org/setting/locale.time.format.24hour");
1164 SettingInfo::GetValue(key , __24hours);
1171 _EditTimePresenter::Animate(void)
1173 SysAssertf((__pFont != null), "Font instance must not be null.");
1175 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
1177 result r = E_SUCCESS;
1178 FloatRectangle rect;
1180 String minuteString;
1183 _DateTimeUtils dateTimeUtils;
1184 int hours = GetHour();
1185 if (!Is24HourNotationEnabled())
1189 if (hours == DATETIME_HOUR_MIN)
1191 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1194 hourString.Format(10, L"%02d", hours);
1195 minuteString.Format(10, L"%02d", GetMinute());
1197 if (GetLastSelectedId() == DATETIME_ID_HOUR)
1199 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(hourString) == false), E_SUCCESS, "[E_SUCCESS] Hour string matched.");
1201 newValue = hourString;
1202 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1204 else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1206 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(minuteString) == false), E_SUCCESS, "[E_SUCCESS] Minute string matched.");
1208 newValue = minuteString;
1209 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1212 FloatDimension newTextDim;
1213 FloatDimension oldTextDim;
1214 FloatPoint textPoint;
1215 VisualElement* pNewVisualElement = null;
1216 VisualElement* pOldVisualElement = null;
1217 VisualElement* pEditTimeElement = null;
1218 VisualElementPropertyAnimation* pNewBoundsAnimation = null;
1219 VisualElementPropertyAnimation* pOldBoundsAnimation = null;
1220 Canvas *pCanvas = null;
1222 __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim);
1223 __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim);
1225 if (newTextDim.width > oldTextDim.width)
1227 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1231 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1234 SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditTime->GetBounds().width), E_SUCCESS, "Rolling animation cann't be played.");
1236 __isAnimating = true;
1238 __pContentProvider = new (std::nothrow) VisualElement();
1239 SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1241 r = __pContentProvider->Construct();
1242 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1244 __pContentProvider->SetShowState(true);
1245 __pContentProvider->SetClipChildrenEnabled(true);
1246 __pContentProvider->SetImplicitAnimationEnabled(false);
1248 pEditTimeElement = __pEditTime->GetVisualElement();
1249 r = GetLastResult();
1250 SysTryCatch(NID_UI_CTRL, (pEditTimeElement != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1252 pNewVisualElement = new (std::nothrow) VisualElement();
1253 SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1255 r = pNewVisualElement->Construct();
1258 pNewVisualElement->Destroy();
1260 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1262 pNewVisualElement->SetShowState(true);
1264 pOldVisualElement = new (std::nothrow) VisualElement();
1265 if (pOldVisualElement == null)
1267 pNewVisualElement->Destroy();
1269 SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1271 r = pOldVisualElement->Construct();
1274 pNewVisualElement->Destroy();
1275 pOldVisualElement->Destroy();
1277 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1279 pOldVisualElement->SetShowState(true);
1281 if (newTextDim.width > oldTextDim.width)
1283 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1284 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1285 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1286 pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1288 rect.x = __pContentProvider->GetBounds().x;
1289 rect.y = __pContentProvider->GetBounds().y;
1290 rect.width = __pContentProvider->GetBounds().width;
1291 rect.height = __pContentProvider->GetBounds().height;
1293 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1294 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1296 pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1300 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1301 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1302 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1303 pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1305 rect.x = __pContentProvider->GetBounds().x;
1306 rect.y = __pContentProvider->GetBounds().y;
1307 rect.width = __pContentProvider->GetBounds().width;
1308 rect.height = __pContentProvider->GetBounds().height;
1310 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1311 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1313 pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1316 pCanvas = pEditTimeElement->GetCanvasN(rect);
1317 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1321 pEditTimeElement->AttachChild(*__pContentProvider);
1323 __pContentProvider->AttachChild(*pOldVisualElement);
1324 __pContentProvider->AttachChild(*pNewVisualElement);
1326 pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1327 SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1329 pNewBoundsAnimation->SetDuration(300);
1330 pNewBoundsAnimation->SetPropertyName("bounds.position");
1331 pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.height * 1.0f)));
1332 pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f)));
1333 pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1335 pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1336 SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1338 pOldBoundsAnimation->SetDuration(300);
1339 pOldBoundsAnimation->SetPropertyName("bounds.position");
1340 pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f)));
1341 pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f)));
1342 pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1344 pCanvas = pOldVisualElement->GetCanvasN();
1345 r = GetLastResult();
1346 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1348 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1350 pCanvas->SetFont(*__pFont);
1351 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), __lastSelectedValue);
1356 pCanvas = pNewVisualElement->GetCanvasN();
1357 r = GetLastResult();
1358 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1360 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1362 pCanvas->SetFont(*__pFont);
1363 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), newValue);
1368 pOldVisualElement->SetImplicitAnimationEnabled(false);
1369 pOldVisualElement->AddAnimation(*pOldBoundsAnimation);
1371 pNewVisualElement->SetImplicitAnimationEnabled(false);
1372 pNewVisualElement->AddAnimation(*pNewBoundsAnimation);
1374 delete pOldBoundsAnimation;
1375 delete pNewBoundsAnimation;
1380 __isAnimating = false;
1381 __pContentProvider->Destroy();
1383 delete pNewBoundsAnimation;
1384 pNewBoundsAnimation = null;
1386 delete pOldBoundsAnimation;
1387 pOldBoundsAnimation = null;
1396 _EditTimePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally)
1398 result r = E_SUCCESS;
1399 __isAnimating = false;
1401 VisualElement* pEditTimeElement = __pEditTime->GetVisualElement();
1402 r = GetLastResult();
1403 SysTryReturnVoidResult(NID_UI_CTRL, (pEditTimeElement != null), r, "[%s] Propagating.", GetErrorMessage(r));
1405 pEditTimeElement->DetachChild(*__pContentProvider);
1406 __pContentProvider->Destroy();
1412 }}} // Tizen::Ui::Controls