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 , __hourTouchBounds(FloatRectangle())
52 , __minuteTouchBounds(FloatRectangle())
53 , __ampmString(String())
54 , __hourString(String())
55 , __minuteString(String())
58 , __is24hoursSet(false)
60 , __timePickerEnabled(true)
61 , __selectedId(DATETIME_ID_NONE)
62 , __lastSelectedId(DATETIME_ID_NONE)
63 , __touchMoveHandled(false)
64 , __pAmPmBgNormalColorReplacementBitmap(null)
65 , __pAmPmBgDisabledColorReplacementBitmap(null)
66 , __pAmPmBgPressedColorReplacementBitmap(null)
67 , __pAmPmBgEffectNomralBitmap(null)
68 , __pAmPmBgEffectPressedBitmap(null)
69 , __pAmPmBgEffectDisabledBitmap(null)
70 , __pColonColorReplacementBitmap(null)
71 , __pColonDisabledColorReplacementBitmap(null)
72 , __pContentProvider(null)
76 , __amPmTextSize(0.0f)
77 , __titleFontSize(0.0f)
78 , __timeFontSize(0.0f)
79 , __isAnimating(false)
80 , __isEditTimeInitialized(false)
84 _EditTimePresenter::~_EditTimePresenter(void)
86 __textObject.RemoveAll();
87 __titleObject.RemoveAll();
89 delete __pEditDateTimeModel;
90 __pEditDateTimeModel = null;
92 delete __pAmPmBgNormalColorReplacementBitmap;
93 __pAmPmBgNormalColorReplacementBitmap = null;
95 delete __pAmPmBgDisabledColorReplacementBitmap;
96 __pAmPmBgDisabledColorReplacementBitmap = null;
98 delete __pAmPmBgPressedColorReplacementBitmap;
99 __pAmPmBgPressedColorReplacementBitmap = null;
101 delete __pAmPmBgEffectNomralBitmap;
102 __pAmPmBgEffectNomralBitmap = null;
104 delete __pAmPmBgEffectPressedBitmap;
105 __pAmPmBgEffectPressedBitmap = null;
107 delete __pAmPmBgEffectDisabledBitmap;
108 __pAmPmBgEffectDisabledBitmap = null;
110 delete __pColonColorReplacementBitmap;
111 __pColonColorReplacementBitmap = null;
113 delete __pColonDisabledColorReplacementBitmap;
114 __pColonDisabledColorReplacementBitmap = null;
118 _EditTimePresenter::CreateInstanceN(const _EditTime& editTime, const String& title)
120 _EditTimePresenter* pEditTimePresenter = new (std::nothrow) _EditTimePresenter(title);
121 SysTryReturn(NID_UI_CTRL, pEditTimePresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
123 pEditTimePresenter->__pEditTime = const_cast <_EditTime*>(&editTime);
125 pEditTimePresenter->__pEditDateTimeModel = new (std::nothrow) _DateTimeModel;
126 SysTryCatch(NID_UI_CTRL, pEditTimePresenter->__pEditDateTimeModel, , E_OUT_OF_MEMORY,
127 "[E_OUT_OF_MEMORY] Memory allocation failed.");
129 return pEditTimePresenter;
132 delete pEditTimePresenter;
137 _EditTimePresenter::GetTime(void) const
140 time.SetValue(DATETIME_YEAR_MIN, DATETIME_MONTH_MIN, DATETIME_DAY_MIN, GetHour(), GetMinute(), 0);
146 _EditTimePresenter::GetHour(void) const
148 return __pEditDateTimeModel->GetHour();
152 _EditTimePresenter::GetMinute(void) const
154 return __pEditDateTimeModel->GetMinute();
158 _EditTimePresenter::SetTime(const DateTime& time)
160 __pEditDateTimeModel->SetDateTime(time);
164 _EditTimePresenter::SetCurrentTime(void)
166 __pEditDateTimeModel->SetCurrentDateTime();
171 _EditTimePresenter::SetHour(int hour)
173 return __pEditDateTimeModel->SetHour(hour);
177 _EditTimePresenter::SetMinute(int minute)
179 return __pEditDateTimeModel->SetMinute(minute);
183 _EditTimePresenter::SetTimePickerEnabled(bool enable)
185 __timePickerEnabled = enable;
190 _EditTimePresenter::IsTimePickerEnabled(void) const
192 return __timePickerEnabled;
196 _EditTimePresenter::Set24HourNotationEnabled(bool enable)
199 __is24hoursSet = true;
204 _EditTimePresenter::Is24HourNotationEnabled(void) const
210 _EditTimePresenter::SetTimeConversion(void)
212 int hour = GetHour();
213 int minute = GetMinute();
215 if (__24hours == false)
217 int max = DATETIME_HOUR_MAX_FOR_24NOTATION;
221 __hourString.Format(10, L"%02d", hour - max);
223 else if (hour == DATETIME_HOUR_MIN)
225 __hourString.Format(10, L"%02d", hour + DATETIME_HOUR_MAX_FOR_24NOTATION);
229 __hourString.Format(10, L"%02d", hour);
232 __minuteString.Format(10, L"%02d", minute);
236 __hourString.Format(10, L"%02d", hour);
237 __minuteString.Format(10, L"%02d", minute);
244 _EditTimePresenter::SetAmEnabled(bool amEnable)
249 _DateTimeUtils dateTimeUtils;
250 dateTimeUtils.GetAmPm(textAm, AM_TYPE);
251 dateTimeUtils.GetAmPm(textPm, PM_TYPE);
253 __amEnable = amEnable;
254 int hour = GetHour();
256 if (__amEnable == true)
258 __ampmString = textAm;
259 if (hour >= DATETIME_HOUR_MAX_FOR_24NOTATION)
261 SetHour(hour - DATETIME_HOUR_MAX_FOR_24NOTATION);
266 __ampmString = textPm;
267 if (hour < DATETIME_HOUR_MAX_FOR_24NOTATION)
269 SetHour(hour + DATETIME_HOUR_MAX_FOR_24NOTATION);
277 _EditTimePresenter::GetAmEnabled(void) const
283 _EditTimePresenter::GetDisplayAreaBoundsFromHoursStyle(_DateTimeId displayBoxId) const
285 SysTryReturn(NID_UI_CTRL, displayBoxId >= DATETIME_ID_HOUR && displayBoxId <= DATETIME_ID_AMPM, FloatRectangle(),
286 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] displayBoxId is out of range.");
288 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
291 float colonWidth = 0.0f;
293 float colonMargin = 0.0f;
294 float timeElementWidth = 0.0f;
295 float amPmHeight = 0.0f;
296 float timeHeight = 0.0f;
297 float titleTimeMargin = 0.0f;
298 float leftMargin = 0.0f;
300 GET_SHAPE_CONFIG(EDITTIME::TIME_WIDTH, __pEditTime->GetOrientation(), width);
301 GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), bounds.height);
302 GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonWidth);
303 GET_SHAPE_CONFIG(EDITTIME::TIME_AMPM_MARGIN, __pEditTime->GetOrientation(), margin);
304 GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), leftMargin);
305 GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
306 GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), timeElementWidth);
307 GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), amPmHeight);
308 GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
309 GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
311 if (__pEditTime->GetBoundsF().height > bounds.height)
313 bounds.height = __pEditTime->GetBoundsF().height;
316 if (!__title.IsEmpty())
318 if (displayBoxId == DATETIME_ID_AMPM)
320 bounds.y = __titleBounds.y + __titleBounds.height;
324 bounds.y = __titleBounds.y + __titleBounds.height + titleTimeMargin;
325 bounds.height = timeHeight;
329 if (__pEditTime->GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
334 bounds.x = leftMargin + ((width - (2.0f * timeElementWidth + colonWidth + 2.0f * colonMargin)) / 2.0f);
336 if (displayBoxId == DATETIME_ID_HOUR)
338 bounds.width = timeElementWidth;
340 else if (displayBoxId == DATETIME_ID_MINUTE)
342 bounds.x = bounds.x + timeElementWidth + colonWidth + 2.0f * colonMargin;
343 bounds.width = timeElementWidth;
345 else if (displayBoxId == DATETIME_ID_AMPM)
347 bounds.x = leftMargin + width + margin;
349 if (__title.IsEmpty())
351 bounds.y = bounds.y + (bounds.height - amPmHeight) / 2.0f;
354 GET_SHAPE_CONFIG(EDITTIME::AMPM_WIDTH, __pEditTime->GetOrientation(), bounds.width);
355 bounds.height = amPmHeight;
362 _EditTimePresenter::GetTextWidth(_DateTimeId boxId) const
364 result r = E_SUCCESS;
366 TextObject dateObject;
370 hourString.Format(10, L"%02d", GetHour());
371 minuteString.Format(10, L"%02d", GetMinute());
373 r = dateObject.Construct();
374 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
376 TextSimple* pSimpleText = null;
378 if (boxId == DATETIME_ID_HOUR)
380 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(hourString.GetPointer())), hourString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
382 else if (boxId == DATETIME_ID_MINUTE)
384 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(minuteString.GetPointer())), minuteString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
387 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), dim.width, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
389 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
391 dateObject.AppendElement(*pSimpleText);
392 dateObject.SetFont(__pFont, 0, dateObject.GetTextLength());
393 dim = dateObject.GetTextExtentF(0, dateObject.GetTextLength());
395 dateObject.RemoveAll();
400 _EditTimePresenter::SetTitleBounds(void)
402 GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), __titleBounds.x);
403 GET_SHAPE_CONFIG(EDITTIME::WIDTH, __pEditTime->GetOrientation(), __titleBounds.width);
404 GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), __titleBounds.height);
410 _EditTimePresenter::GetTitleBounds(void) const
412 return __titleBounds;
416 _EditTimePresenter::LoadResource(void)
418 result r = E_SUCCESS;
420 Color buttonNormalBgColor;
421 Color buttonDisabledBgColor;
422 Color buttonNormalPressedColor;
423 Color colonTextColor;
424 Color colonTextDisabledColor;
425 Bitmap* pTempBitmap = null;
427 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_NORMAL, buttonNormalBgColor);
428 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_PRESSED, buttonNormalPressedColor);
429 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_DISABLED, buttonDisabledBgColor);
430 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, colonTextColor);
431 GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, colonTextDisabledColor);
433 GET_SHAPE_CONFIG(EDITTIME::AMPM_FONT_SIZE, __pEditTime->GetOrientation(), __amPmTextSize);
435 r = GET_BITMAP_CONFIG_N(EDITTIME::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
436 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
438 __pColonColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE),
440 SysTryCatch(NID_UI_CTRL, (__pColonColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
441 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
443 __pColonDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE),
444 colonTextDisabledColor);
445 SysTryCatch(NID_UI_CTRL, (__pColonDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
446 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
451 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
452 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
454 __pAmPmBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalBgColor);
455 SysTryCatch(NID_UI_CTRL, (__pAmPmBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
456 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
461 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
462 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
464 __pAmPmBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonDisabledBgColor);
465 SysTryCatch(NID_UI_CTRL, (__pAmPmBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
466 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
471 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
472 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
474 __pAmPmBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalPressedColor);
475 SysTryCatch(NID_UI_CTRL, (__pAmPmBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
476 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
478 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectNomralBitmap);
479 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
481 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectPressedBitmap);
482 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
484 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectDisabledBitmap);
485 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
497 delete __pAmPmBgNormalColorReplacementBitmap;
498 __pAmPmBgNormalColorReplacementBitmap = null;
500 delete __pAmPmBgPressedColorReplacementBitmap;
501 __pAmPmBgPressedColorReplacementBitmap = null;
503 delete __pAmPmBgEffectNomralBitmap;
504 __pAmPmBgEffectNomralBitmap = null;
506 delete __pAmPmBgEffectPressedBitmap;
507 __pAmPmBgEffectPressedBitmap = null;
509 delete __pColonColorReplacementBitmap;
510 __pColonColorReplacementBitmap = null;
516 _EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
518 result r = E_SUCCESS;
525 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
527 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
528 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
532 r = canvas.DrawBitmap(bounds, *pBitmap);
533 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
540 _EditTimePresenter::CalculateTouchAreaBounds(const FloatRectangle hourBounds, const FloatRectangle minuteBounds)
542 __hourTouchBounds.width = GetTextWidth(DATETIME_ID_HOUR);
543 __hourTouchBounds.x = hourBounds.x + (hourBounds.width - __hourTouchBounds.width) / 2.0f;
544 __hourTouchBounds.y = hourBounds.y;
545 __hourTouchBounds.height = hourBounds.height;
547 __minuteTouchBounds.width = GetTextWidth(DATETIME_ID_MINUTE);
548 __minuteTouchBounds.x = minuteBounds.x + (minuteBounds.width - __minuteTouchBounds.width) / 2.0f;
549 __minuteTouchBounds.y = minuteBounds.y;
550 __minuteTouchBounds.height = minuteBounds.height;
556 _EditTimePresenter::InitializeTitleObject(void)
558 result r = E_SUCCESS;
560 Color titleNormalColor;
562 GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_NORMAL, titleNormalColor);
564 r = __titleObject.Construct();
565 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
567 TextSimple* pSimpleText = null;
569 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
570 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
572 __titleObject.AppendElement(*pSimpleText);
574 __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength());
575 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
576 __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
577 __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
578 __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
584 _EditTimePresenter::InitializeTextObject(void)
586 result r = E_SUCCESS;
588 r = __textObject.Construct();
589 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
591 TextSimple* pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
592 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
593 "[E_OUT_OF_MEMORY] Memory allocation failed.");
595 __textObject.AppendElement(*pSimpleText);
597 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
598 __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
599 __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
600 __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
606 _EditTimePresenter::Draw(void)
608 result r = E_SUCCESS;
615 Canvas* pCanvas = __pEditTime->GetCanvasN();
616 SysAssertf((pCanvas != null), "Failed to get canvas.");
618 FloatRectangle colonBounds(0.0f, 0.0f, 0.0f, 0.0f);
620 float colonMargin = 0.0f;
624 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
627 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
628 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
629 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
630 bool isCustomBitmap = false;
631 Bitmap* pReplacementBitmap = null;
632 Bitmap* pEffectBitmap = null;
634 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
635 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
637 if (__24hours == false)
639 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
641 if (!__pEditTime->IsEnabled())
643 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_DISABLED);
644 pReplacementBitmap = __pAmPmBgDisabledColorReplacementBitmap;
645 pEffectBitmap = __pAmPmBgEffectDisabledBitmap;
647 else if (__selectedId != DATETIME_ID_AMPM)
649 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_NORMAL);
650 pReplacementBitmap = __pAmPmBgNormalColorReplacementBitmap;
651 pEffectBitmap = __pAmPmBgEffectNomralBitmap;
655 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_PRESSED);
656 pReplacementBitmap = __pAmPmBgPressedColorReplacementBitmap;
657 pEffectBitmap = __pAmPmBgEffectPressedBitmap;
660 r = DrawResourceBitmap(*pCanvas, ampmBounds, pReplacementBitmap);
661 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
665 r = DrawResourceBitmap(*pCanvas, ampmBounds, pEffectBitmap);
666 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
670 if (GetHour() >= DATETIME_HOUR_MAX_FOR_24NOTATION)
681 GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonBounds.width);
682 GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
683 GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), colonBounds.height);
685 colonBounds.x = hourBounds.x + hourBounds.width + colonMargin;
686 colonBounds.y = hourBounds.y + (hourBounds.height - colonBounds.height) / 2.0f;
688 if (__title.IsEmpty() == false)
690 r = DrawTitle(*pCanvas);
691 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
694 r = DrawText(*pCanvas, hourBounds, __hourString, DATETIME_ID_HOUR);
695 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
697 r = DrawText(*pCanvas, minuteBounds, __minuteString, DATETIME_ID_MINUTE);
698 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
700 if (__24hours == false)
702 r = DrawText(*pCanvas, ampmBounds, __ampmString, DATETIME_ID_AMPM, __amPmTextSize);
703 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
706 r = DrawColon(*pCanvas, colonBounds);
707 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
709 CalculateTouchAreaBounds(hourBounds, minuteBounds);
717 _EditTimePresenter::DrawColon(Canvas& canvas, const FloatRectangle& bounds)
719 result r = E_SUCCESS;
721 if (!__pEditTime->IsEnabled())
723 r = DrawResourceBitmap(canvas, bounds, __pColonDisabledColorReplacementBitmap);
727 r = DrawResourceBitmap(canvas, bounds, __pColonColorReplacementBitmap);
734 _EditTimePresenter::DrawTitle(Canvas& canvas)
736 if (!__pEditTime->IsEnabled())
738 Color titleDisabledColor;
739 GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_DISABLED, titleDisabledColor);
740 __titleObject.SetForegroundColor(titleDisabledColor, 0, __titleObject.GetTextLength());
743 (_FontImpl::GetInstance(*__pFont))->SetSize(__titleFontSize);
744 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
746 __titleObject.Draw(*_CanvasImpl::GetInstance(canvas));
752 _EditTimePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, _DateTimeId boxId, float textSize)
754 result r = E_SUCCESS;
758 if (!__pEditTime->IsEnabled())
760 if (boxId == DATETIME_ID_AMPM)
762 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_DISABLED, textColor);
766 GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, textColor);
771 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, textColor);
773 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated() &&
774 (GetLastSelectedId() == boxId))
776 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
779 if (boxId == DATETIME_ID_AMPM)
781 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_NORMAL, textColor);
784 if (boxId > -1 && boxId == __selectedId)
786 if (boxId == DATETIME_ID_AMPM)
788 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_PRESSED, textColor);
792 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
797 FloatRectangle drawAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
798 drawAreaBounds = bounds;
800 TextSimple* pSimpleText = null;
801 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
802 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
804 __textObject.RemoveAll();
806 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
808 __textObject.AppendElement(*pSimpleText);
810 if (boxId == DATETIME_ID_AMPM)
812 (_FontImpl::GetInstance(*__pFont))->SetSize(textSize);
813 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
817 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
820 __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength());
821 __textObject.SetBounds(drawAreaBounds);
822 __textObject.Draw(*_CanvasImpl::GetInstance(canvas));
828 _EditTimePresenter::GetBoxIdFromPosition(const FloatPoint& point) const
830 _DateTimeId displayBoxId = DATETIME_ID_NONE;
832 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
834 if (__24hours == false)
836 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
839 if (point.y < __hourTouchBounds.y || point.y > __hourTouchBounds.y + __hourTouchBounds.height)
844 if (__hourTouchBounds.Contains(point) == true)
846 displayBoxId = DATETIME_ID_HOUR;
848 else if (__minuteTouchBounds.Contains(point) == true)
850 displayBoxId = DATETIME_ID_MINUTE;
852 else if (ampmBounds.Contains(point) == true)
854 displayBoxId = DATETIME_ID_AMPM;
861 _EditTimePresenter::SetLastSelectedId(_DateTimeId boxId)
863 __lastSelectedId = boxId;
868 _EditTimePresenter::GetLastSelectedId(void) const
870 return __lastSelectedId;
874 _EditTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
876 SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
878 if (&source != __pEditTime)
883 __touchMoveHandled = false;
885 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
886 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
887 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
889 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
890 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
892 if (__24hours == false)
894 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
897 FloatPoint point = touchinfo.GetCurrentPosition();
899 _DateTimeId boxId = GetBoxIdFromPosition(point);
903 int displayValue = -1;
905 if (boxId == DATETIME_ID_HOUR)
907 if (__pEditTime->GetDateTimeBar() != null)
909 if (__24hours == false)
913 minValue = DATETIME_HOUR_MIN + 1;
914 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
915 displayValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
917 else if (GetHour() > DATETIME_HOUR_MAX_FOR_24NOTATION)
919 minValue = DATETIME_HOUR_MIN + 1;
920 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
921 displayValue = GetHour() - DATETIME_HOUR_MAX_FOR_24NOTATION;
925 minValue = DATETIME_HOUR_MIN + 1;
926 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
927 displayValue = GetHour();
932 minValue = DATETIME_HOUR_MIN;
933 maxValue = DATETIME_HOUR_MAX;
934 displayValue = GetHour();
937 if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
939 __pEditTime->GetDateTimeBar()->RemoveAllItems();
942 __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
945 __bounds = hourBounds;
947 else if (boxId == DATETIME_ID_MINUTE)
949 if (__pEditTime->GetDateTimeBar() != null)
951 minValue = DATETIME_MINUTE_MIN;
952 maxValue = DATETIME_MINUTE_MAX;
953 displayValue = GetMinute();
955 if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
957 __pEditTime->GetDateTimeBar()->RemoveAllItems();
960 __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
963 __bounds = minuteBounds;
965 else if (boxId == DATETIME_ID_AMPM)
967 __selectedId = boxId;
968 __bounds = ampmBounds;
973 __selectedId = DATETIME_ID_NONE;
977 __selectedId = boxId;
983 _EditTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
985 SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
987 if (&source != __pEditTime)
992 FloatRectangle bounds = __pEditTime->GetBoundsF();
994 FloatPoint startPoint(0.0f, 0.0f);
996 float titleHeight = 0;
997 GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), titleHeight);
999 __bounds = FloatRectangle(0.0f, titleHeight, bounds.width, bounds.height);
1001 FloatPoint point = touchinfo.GetCurrentPosition();
1003 _DateTimeId boxId = GetBoxIdFromPosition(point);
1005 if ((boxId == GetLastSelectedId() && boxId != DATETIME_ID_AMPM) || boxId != __selectedId || boxId == DATETIME_ID_NONE)
1007 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1009 __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1010 __pEditTime->GetDateTimeBar()->Close();
1013 __selectedId = DATETIME_ID_NONE;
1014 SetLastSelectedId(__selectedId);
1021 SetLastSelectedId(__selectedId);
1023 __lastSelectedValue = "";
1024 _DateTimeUtils dateTimeUtils;
1026 if (GetLastSelectedId() == DATETIME_ID_HOUR)
1028 int hours = GetHour();
1030 if (!Is24HourNotationEnabled())
1034 if (hours == DATETIME_HOUR_MIN)
1036 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1039 __lastSelectedValue.Format(10, L"%02d", hours);
1040 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1042 else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1044 __lastSelectedValue.Format(10, L"%02d", GetMinute());
1045 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1047 else if (GetLastSelectedId() == DATETIME_ID_AMPM)
1049 SetAmEnabled(!GetAmEnabled());
1050 __pEditTime->FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
1051 __pEditTime->UpdateAccessibilityElement();
1052 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1054 __selectedId = DATETIME_ID_NONE;
1056 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1058 __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1059 __pEditTime->GetDateTimeBar()->Close();
1069 if ((__pEditTime->GetDateTimeBar() != null) && (boxId != DATETIME_ID_AMPM) && (GetLastSelectedId() != DATETIME_ID_NONE))
1071 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1072 bounds = GetDisplayAreaBoundsFromHoursStyle(GetLastSelectedId());
1073 FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1074 absoluteBounds = __pEditTime->GetAbsoluteBoundsF();
1075 bounds.x += absoluteBounds.x;
1077 __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds);
1079 if (__pEditTime->GetDateTimeBar()->IsActivated())
1081 __pEditTime->GetDateTimeBar()->RefreshItems();
1085 __pEditTime->GetDateTimeBar()->SetVisibleState(true);
1086 __pEditTime->GetDateTimeBar()->Open();
1090 __selectedId = DATETIME_ID_NONE;
1095 _EditTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1097 if (&source != __pEditTime)
1102 __selectedId = DATETIME_ID_NONE;
1108 _EditTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1110 if (&source != __pEditTime)
1115 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1124 _EditTimePresenter::OnTouchMoveHandled(const _Control& control)
1126 __touchMoveHandled = true;
1127 __selectedId = DATETIME_ID_NONE;
1133 _EditTimePresenter::OnFontChanged(Font* pFont)
1137 if (__pEditTime->GetDateTimeBar() != null)
1139 __pEditTime->GetDateTimeBar()->SetFont(*pFont);
1146 _EditTimePresenter::OnFontInfoRequested(unsigned long& style, float& size)
1148 style = FONT_STYLE_PLAIN;
1149 size = __timeFontSize;
1155 _EditTimePresenter::Initialize(void)
1157 result r = E_SUCCESS;
1159 float titleTimeMargin = 0;
1160 float timeHeight = 0;
1161 float editTimeHeight = 0;
1163 GET_SHAPE_CONFIG(EDITTIME::TEXT_FONT_SIZE, __pEditTime->GetOrientation(), __titleFontSize);
1164 GET_SHAPE_CONFIG(EDITTIME::TIME_FONT_SIZE, __pEditTime->GetOrientation(), __timeFontSize);
1165 GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
1166 GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
1167 GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), editTimeHeight);
1169 if (__pEditTime->GetBoundsF().height > editTimeHeight)
1171 editTimeHeight = __pEditTime->GetBoundsF().height;
1174 if (__title.IsEmpty() == false)
1177 if (!__isEditTimeInitialized)
1179 r = InitializeTitleObject();
1180 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1183 __titleBounds.y = (editTimeHeight - (__titleBounds.height + titleTimeMargin + timeHeight)) / 2.0f;
1184 __titleObject.SetBounds(__titleBounds);
1187 __pFont = __pEditTime->GetFallbackFont();
1188 r = GetLastResult();
1189 SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
1191 if (!__isEditTimeInitialized)
1194 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1196 r = InitializeTextObject();
1197 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1200 __isEditTimeInitialized = true;
1207 _EditTimePresenter::UpdateTimeFormat(void)
1209 if (!__is24hoursSet)
1211 String key(L"http://tizen.org/setting/locale.time.format.24hour");
1212 SettingInfo::GetValue(key , __24hours);
1219 _EditTimePresenter::Animate(void)
1221 SysAssertf((__pFont != null), "Font instance must not be null.");
1223 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
1225 result r = E_SUCCESS;
1226 FloatRectangle rect;
1228 String minuteString;
1231 _DateTimeUtils dateTimeUtils;
1232 int hours = GetHour();
1233 if (!Is24HourNotationEnabled())
1237 if (hours == DATETIME_HOUR_MIN)
1239 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1242 hourString.Format(10, L"%02d", hours);
1243 minuteString.Format(10, L"%02d", GetMinute());
1245 if (GetLastSelectedId() == DATETIME_ID_HOUR)
1247 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(hourString) == false), E_SUCCESS, "[E_SUCCESS] Hour string matched.");
1249 newValue = hourString;
1250 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1252 else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1254 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(minuteString) == false), E_SUCCESS, "[E_SUCCESS] Minute string matched.");
1256 newValue = minuteString;
1257 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1260 FloatDimension newTextDim;
1261 FloatDimension oldTextDim;
1262 FloatPoint textPoint;
1263 VisualElement* pNewVisualElement = null;
1264 VisualElement* pOldVisualElement = null;
1265 VisualElement* pEditTimeElement = null;
1266 VisualElementPropertyAnimation* pNewBoundsAnimation = null;
1267 VisualElementPropertyAnimation* pOldBoundsAnimation = null;
1268 Canvas *pCanvas = null;
1270 __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim);
1271 __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim);
1273 if (newTextDim.width > oldTextDim.width)
1275 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1279 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1282 SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditTime->GetBounds().width), E_SUCCESS, "Rolling animation cann't be played.");
1284 __isAnimating = true;
1286 __pContentProvider = new (std::nothrow) VisualElement();
1287 SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1289 r = __pContentProvider->Construct();
1290 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1292 __pContentProvider->SetShowState(true);
1293 __pContentProvider->SetClipChildrenEnabled(true);
1294 __pContentProvider->SetImplicitAnimationEnabled(false);
1296 pEditTimeElement = __pEditTime->GetVisualElement();
1297 r = GetLastResult();
1298 SysTryCatch(NID_UI_CTRL, (pEditTimeElement != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1300 pNewVisualElement = new (std::nothrow) VisualElement();
1301 SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1303 r = pNewVisualElement->Construct();
1306 pNewVisualElement->Destroy();
1308 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1310 pNewVisualElement->SetShowState(true);
1312 pOldVisualElement = new (std::nothrow) VisualElement();
1313 if (pOldVisualElement == null)
1315 pNewVisualElement->Destroy();
1317 SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1319 r = pOldVisualElement->Construct();
1322 pNewVisualElement->Destroy();
1323 pOldVisualElement->Destroy();
1325 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1327 pOldVisualElement->SetShowState(true);
1329 if (newTextDim.width > oldTextDim.width)
1331 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1332 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1333 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1334 pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1336 rect.x = __pContentProvider->GetBounds().x;
1337 rect.y = __pContentProvider->GetBounds().y;
1338 rect.width = __pContentProvider->GetBounds().width;
1339 rect.height = __pContentProvider->GetBounds().height;
1341 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1342 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1344 pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1348 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1349 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1350 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1351 pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1353 rect.x = __pContentProvider->GetBounds().x;
1354 rect.y = __pContentProvider->GetBounds().y;
1355 rect.width = __pContentProvider->GetBounds().width;
1356 rect.height = __pContentProvider->GetBounds().height;
1358 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1359 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1361 pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1364 pCanvas = pEditTimeElement->GetCanvasN(rect);
1365 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1369 pEditTimeElement->AttachChild(*__pContentProvider);
1371 __pContentProvider->AttachChild(*pOldVisualElement);
1372 __pContentProvider->AttachChild(*pNewVisualElement);
1374 pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1375 SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1377 pNewBoundsAnimation->SetDuration(300);
1378 pNewBoundsAnimation->SetPropertyName("bounds.position");
1379 pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.height * 1.0f)));
1380 pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f)));
1381 pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1383 pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1384 SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1386 pOldBoundsAnimation->SetDuration(300);
1387 pOldBoundsAnimation->SetPropertyName("bounds.position");
1388 pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f)));
1389 pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f)));
1390 pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1392 pCanvas = pOldVisualElement->GetCanvasN();
1393 r = GetLastResult();
1394 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1396 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1398 pCanvas->SetFont(*__pFont);
1399 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), __lastSelectedValue);
1404 pCanvas = pNewVisualElement->GetCanvasN();
1405 r = GetLastResult();
1406 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1408 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1410 pCanvas->SetFont(*__pFont);
1411 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), newValue);
1416 pOldVisualElement->SetImplicitAnimationEnabled(false);
1417 pOldVisualElement->AddAnimation(*pOldBoundsAnimation);
1419 pNewVisualElement->SetImplicitAnimationEnabled(false);
1420 pNewVisualElement->AddAnimation(*pNewBoundsAnimation);
1422 delete pOldBoundsAnimation;
1423 delete pNewBoundsAnimation;
1428 __isAnimating = false;
1429 __pContentProvider->Destroy();
1431 delete pNewBoundsAnimation;
1432 pNewBoundsAnimation = null;
1434 delete pOldBoundsAnimation;
1435 pOldBoundsAnimation = null;
1444 _EditTimePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally)
1446 result r = E_SUCCESS;
1447 __isAnimating = false;
1449 VisualElement* pEditTimeElement = __pEditTime->GetVisualElement();
1450 r = GetLastResult();
1451 SysTryReturnVoidResult(NID_UI_CTRL, (pEditTimeElement != null), r, "[%s] Propagating.", GetErrorMessage(r));
1453 pEditTimeElement->DetachChild(*__pContentProvider);
1454 __pContentProvider->Destroy();
1460 }}} // Tizen::Ui::Controls