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 _DateTimeUtils dateTimeUtils;
248 dateTimeUtils.GetAmPm(textAm, AM_TYPE);
249 dateTimeUtils.GetAmPm(textPm, PM_TYPE);
251 __amEnable = amEnable;
252 int hour = GetHour();
254 if (__amEnable == true)
256 __ampmString = textAm;
257 if (hour >= DATETIME_HOUR_MAX_FOR_24NOTATION)
259 SetHour(hour - DATETIME_HOUR_MAX_FOR_24NOTATION);
264 __ampmString = textPm;
265 if (hour < DATETIME_HOUR_MAX_FOR_24NOTATION)
267 SetHour(hour + DATETIME_HOUR_MAX_FOR_24NOTATION);
275 _EditTimePresenter::GetAmEnabled(void) const
281 _EditTimePresenter::GetDisplayAreaBoundsFromHoursStyle(_DateTimeId displayBoxId) const
283 SysTryReturn(NID_UI_CTRL, displayBoxId >= DATETIME_ID_HOUR && displayBoxId <= DATETIME_ID_AMPM, FloatRectangle(),
284 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] displayBoxId is out of range.");
286 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
289 float colonWidth = 0.0f;
291 float colonMargin = 0.0f;
292 float timeElementWidth = 0.0f;
293 float amPmHeight = 0.0f;
294 float timeHeight = 0.0f;
295 float titleTimeMargin = 0.0f;
296 float leftMargin = 0.0f;
298 GET_SHAPE_CONFIG(EDITTIME::TIME_WIDTH, __pEditTime->GetOrientation(), width);
299 GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), bounds.height);
300 GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonWidth);
301 GET_SHAPE_CONFIG(EDITTIME::TIME_AMPM_MARGIN, __pEditTime->GetOrientation(), margin);
302 GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), leftMargin);
303 GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
304 GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), timeElementWidth);
305 GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), amPmHeight);
306 GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
307 GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
309 if (__pEditTime->GetBoundsF().height > bounds.height)
311 bounds.height = __pEditTime->GetBoundsF().height;
314 if (!__title.IsEmpty())
316 if (displayBoxId == DATETIME_ID_AMPM)
318 bounds.y = __titleBounds.y + __titleBounds.height;
322 bounds.y = __titleBounds.y + __titleBounds.height + titleTimeMargin;
323 bounds.height = timeHeight;
327 if (__pEditTime->GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
332 bounds.x = leftMargin + ((width - (2.0f * timeElementWidth + colonWidth + 2.0f * colonMargin)) / 2.0f);
334 if (displayBoxId == DATETIME_ID_HOUR)
336 bounds.width = GetTextWidth(displayBoxId);
338 else if (displayBoxId == DATETIME_ID_MINUTE)
340 bounds.width = GetTextWidth(displayBoxId);
341 bounds.x = bounds.x + timeElementWidth + colonWidth + 2.0f * colonMargin + (timeElementWidth - bounds.width) / 2.0f;
344 else if (displayBoxId == DATETIME_ID_AMPM)
346 bounds.x = leftMargin + width + margin;
348 if (__title.IsEmpty())
350 bounds.y = bounds.y + (bounds.height - amPmHeight) / 2.0f;
353 GET_SHAPE_CONFIG(EDITTIME::AMPM_WIDTH, __pEditTime->GetOrientation(), bounds.width);
354 bounds.height = amPmHeight;
361 _EditTimePresenter::GetTextWidth(_DateTimeId boxId) const
363 result r = E_SUCCESS;
365 TextObject dateObject;
369 hourString.Format(10, L"%02d", GetHour());
370 minuteString.Format(10, L"%02d", GetMinute());
372 r = dateObject.Construct();
373 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
375 TextSimple* pSimpleText = null;
377 if (boxId == DATETIME_ID_HOUR)
379 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(hourString.GetPointer())), hourString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
381 else if (boxId == DATETIME_ID_MINUTE)
383 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(minuteString.GetPointer())), minuteString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
386 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), dim.width, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
388 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
390 dateObject.AppendElement(*pSimpleText);
391 dateObject.SetFont(__pFont, 0, dateObject.GetTextLength());
392 dim = dateObject.GetTextExtentF(0, dateObject.GetTextLength());
394 dateObject.RemoveAll();
399 _EditTimePresenter::SetTitleBounds(void)
401 GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), __titleBounds.x);
402 GET_SHAPE_CONFIG(EDITTIME::WIDTH, __pEditTime->GetOrientation(), __titleBounds.width);
403 GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), __titleBounds.height);
409 _EditTimePresenter::GetTitleBounds(void) const
411 return __titleBounds;
415 _EditTimePresenter::LoadResource(void)
417 result r = E_SUCCESS;
419 Color buttonNormalBgColor;
420 Color buttonDisabledBgColor;
421 Color buttonNormalPressedColor;
422 Color colonTextColor;
423 Color colonTextDisabledColor;
424 Bitmap* pTempBitmap = null;
426 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_NORMAL, buttonNormalBgColor);
427 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_PRESSED, buttonNormalPressedColor);
428 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_DISABLED, buttonDisabledBgColor);
429 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, colonTextColor);
430 GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, colonTextDisabledColor);
432 GET_SHAPE_CONFIG(EDITTIME::AMPM_FONT_SIZE, __pEditTime->GetOrientation(), __amPmTextSize);
434 r = GET_BITMAP_CONFIG_N(EDITTIME::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
435 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
437 __pColonColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE),
439 SysTryCatch(NID_UI_CTRL, (__pColonColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
440 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
442 __pColonDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE),
443 colonTextDisabledColor);
444 SysTryCatch(NID_UI_CTRL, (__pColonDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
445 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
450 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
451 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
453 __pAmPmBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalBgColor);
454 SysTryCatch(NID_UI_CTRL, (__pAmPmBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
455 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
460 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
461 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
463 __pAmPmBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonDisabledBgColor);
464 SysTryCatch(NID_UI_CTRL, (__pAmPmBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
465 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
470 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
471 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
473 __pAmPmBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalPressedColor);
474 SysTryCatch(NID_UI_CTRL, (__pAmPmBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
475 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
477 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectNomralBitmap);
478 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
480 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectPressedBitmap);
481 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
483 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectDisabledBitmap);
484 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
496 delete __pAmPmBgNormalColorReplacementBitmap;
497 __pAmPmBgNormalColorReplacementBitmap = null;
499 delete __pAmPmBgPressedColorReplacementBitmap;
500 __pAmPmBgPressedColorReplacementBitmap = null;
502 delete __pAmPmBgEffectNomralBitmap;
503 __pAmPmBgEffectNomralBitmap = null;
505 delete __pAmPmBgEffectPressedBitmap;
506 __pAmPmBgEffectPressedBitmap = null;
508 delete __pColonColorReplacementBitmap;
509 __pColonColorReplacementBitmap = null;
515 _EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
517 result r = E_SUCCESS;
524 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
526 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
527 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
531 r = canvas.DrawBitmap(bounds, *pBitmap);
532 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
539 _EditTimePresenter::InitializeTitleObject(void)
541 result r = E_SUCCESS;
543 Color titleNormalColor;
545 GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_NORMAL, titleNormalColor);
547 r = __titleObject.Construct();
548 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
550 TextSimple* pSimpleText = null;
552 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
553 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
555 __titleObject.AppendElement(*pSimpleText);
557 __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength());
558 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
559 __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
560 __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
561 __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
567 _EditTimePresenter::InitializeTextObject(void)
569 result r = E_SUCCESS;
571 r = __textObject.Construct();
572 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
574 TextSimple* pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
575 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
576 "[E_OUT_OF_MEMORY] Memory allocation failed.");
578 __textObject.AppendElement(*pSimpleText);
580 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
581 __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
582 __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
583 __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
589 _EditTimePresenter::Draw(void)
591 result r = E_SUCCESS;
598 Canvas* pCanvas = __pEditTime->GetCanvasN();
599 SysAssertf((pCanvas != null), "Failed to get canvas.");
601 FloatRectangle colonBounds(0.0f, 0.0f, 0.0f, 0.0f);
603 float colonMargin = 0.0f;
604 float hourMinuteWidth = 0.0f;
608 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
611 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
612 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
613 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
614 bool isCustomBitmap = false;
615 Bitmap* pReplacementBitmap = null;
616 Bitmap* pEffectBitmap = null;
618 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
619 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
621 if (__24hours == false)
623 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
625 if (!__pEditTime->IsEnabled())
627 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_DISABLED);
628 pReplacementBitmap = __pAmPmBgDisabledColorReplacementBitmap;
629 pEffectBitmap = __pAmPmBgEffectDisabledBitmap;
631 else if (__selectedId != DATETIME_ID_AMPM)
633 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_NORMAL);
634 pReplacementBitmap = __pAmPmBgNormalColorReplacementBitmap;
635 pEffectBitmap = __pAmPmBgEffectNomralBitmap;
639 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_PRESSED);
640 pReplacementBitmap = __pAmPmBgPressedColorReplacementBitmap;
641 pEffectBitmap = __pAmPmBgEffectPressedBitmap;
644 r = DrawResourceBitmap(*pCanvas, ampmBounds, pReplacementBitmap);
645 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
649 r = DrawResourceBitmap(*pCanvas, ampmBounds, pEffectBitmap);
650 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
654 if (GetHour() >= DATETIME_HOUR_MAX_FOR_24NOTATION)
665 GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonBounds.width);
666 GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
667 GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), colonBounds.height);
668 GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), hourMinuteWidth);
670 colonBounds.x = hourBounds.x + hourMinuteWidth + colonMargin;
671 colonBounds.y = hourBounds.y + (hourBounds.height - colonBounds.height) / 2.0f;
673 if (__title.IsEmpty() == false)
675 r = DrawTitle(*pCanvas);
676 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
679 r = DrawText(*pCanvas, hourBounds, __hourString);
680 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
682 r = DrawText(*pCanvas, minuteBounds, __minuteString);
683 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
685 if (__24hours == false)
687 r = DrawText(*pCanvas, ampmBounds, __ampmString, __amPmTextSize);
688 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
691 r = DrawColon(*pCanvas, colonBounds);
692 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
701 _EditTimePresenter::DrawColon(Canvas& canvas, const FloatRectangle& bounds)
703 result r = E_SUCCESS;
705 if (!__pEditTime->IsEnabled())
707 r = DrawResourceBitmap(canvas, bounds, __pColonDisabledColorReplacementBitmap);
711 r = DrawResourceBitmap(canvas, bounds, __pColonColorReplacementBitmap);
716 r = DrawText(canvas, bounds, L":");
717 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
724 _EditTimePresenter::DrawTitle(Canvas& canvas)
726 if (!__pEditTime->IsEnabled())
728 Color titleDisabledColor;
729 GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_DISABLED, titleDisabledColor);
730 __titleObject.SetForegroundColor(titleDisabledColor, 0, __titleObject.GetTextLength());
733 (_FontImpl::GetInstance(*__pFont))->SetSize(__titleFontSize);
734 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
736 __titleObject.Draw(*_CanvasImpl::GetInstance(canvas));
742 _EditTimePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, float textSize)
744 result r = E_SUCCESS;
748 _DateTimeId boxId = DATETIME_ID_NONE;
749 boxId = GetBoxIdFromPosition(FloatPoint(bounds.x + 1.0f, bounds.y));
751 if (!__pEditTime->IsEnabled())
753 if (boxId == DATETIME_ID_AMPM)
755 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_DISABLED, textColor);
759 GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, textColor);
764 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, textColor);
766 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated() &&
767 (GetLastSelectedId() == boxId))
769 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
772 if (boxId == DATETIME_ID_AMPM)
774 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_NORMAL, textColor);
777 if (boxId > -1 && boxId == __selectedId)
779 if (boxId == DATETIME_ID_AMPM)
781 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_PRESSED, textColor);
785 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
790 FloatRectangle drawAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
791 drawAreaBounds = bounds;
793 TextSimple* pSimpleText = null;
794 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
795 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
797 __textObject.RemoveAll();
799 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
801 __textObject.AppendElement(*pSimpleText);
803 if (boxId == DATETIME_ID_AMPM)
805 (_FontImpl::GetInstance(*__pFont))->SetSize(textSize);
806 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
810 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
813 __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength());
814 __textObject.SetBounds(drawAreaBounds);
815 __textObject.Draw(*_CanvasImpl::GetInstance(canvas));
821 _EditTimePresenter::GetBoxIdFromPosition(const FloatPoint& point) const
823 _DateTimeId displayBoxId = DATETIME_ID_NONE;
825 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
826 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
827 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
829 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
830 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
832 if (__24hours == false)
834 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
837 if (point.y < hourBounds.y || point.y > hourBounds.y + hourBounds.height)
842 if (hourBounds.Contains(point) == true)
844 displayBoxId = DATETIME_ID_HOUR;
846 else if (minuteBounds.Contains(point) == true)
848 displayBoxId = DATETIME_ID_MINUTE;
850 else if (ampmBounds.Contains(point) == true)
852 displayBoxId = DATETIME_ID_AMPM;
859 _EditTimePresenter::SetLastSelectedId(_DateTimeId boxId)
861 __lastSelectedId = boxId;
866 _EditTimePresenter::GetLastSelectedId(void) const
868 return __lastSelectedId;
872 _EditTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
874 SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
876 if (&source != __pEditTime)
881 __touchMoveHandled = false;
883 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
884 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
885 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
887 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
888 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
890 if (__24hours == false)
892 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
895 FloatPoint point = touchinfo.GetCurrentPosition();
897 _DateTimeId boxId = GetBoxIdFromPosition(point);
901 int displayValue = -1;
903 if (boxId == DATETIME_ID_HOUR)
905 if (__pEditTime->GetDateTimeBar() != null)
907 if (__24hours == false)
911 minValue = DATETIME_HOUR_MIN + 1;
912 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
913 displayValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
915 else if (GetHour() > DATETIME_HOUR_MAX_FOR_24NOTATION)
917 minValue = DATETIME_HOUR_MIN + 1;
918 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
919 displayValue = GetHour() - DATETIME_HOUR_MAX_FOR_24NOTATION;
923 minValue = DATETIME_HOUR_MIN + 1;
924 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
925 displayValue = GetHour();
930 minValue = DATETIME_HOUR_MIN;
931 maxValue = DATETIME_HOUR_MAX;
932 displayValue = GetHour();
935 if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
937 __pEditTime->GetDateTimeBar()->RemoveAllItems();
940 __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
943 __bounds = hourBounds;
945 else if (boxId == DATETIME_ID_MINUTE)
947 if (__pEditTime->GetDateTimeBar() != null)
949 minValue = DATETIME_MINUTE_MIN;
950 maxValue = DATETIME_MINUTE_MAX;
951 displayValue = GetMinute();
953 if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
955 __pEditTime->GetDateTimeBar()->RemoveAllItems();
958 __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
961 __bounds = minuteBounds;
963 else if (boxId == DATETIME_ID_AMPM)
965 __selectedId = boxId;
966 __bounds = ampmBounds;
971 __selectedId = DATETIME_ID_NONE;
975 __selectedId = boxId;
981 _EditTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
983 SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
985 if (&source != __pEditTime)
990 FloatRectangle bounds = __pEditTime->GetBoundsF();
992 FloatPoint startPoint(0.0f, 0.0f);
994 float titleHeight = 0;
995 GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), titleHeight);
997 __bounds = FloatRectangle(0.0f, titleHeight, bounds.width, bounds.height);
999 FloatPoint point = touchinfo.GetCurrentPosition();
1001 _DateTimeId boxId = GetBoxIdFromPosition(point);
1003 if (boxId == GetLastSelectedId() || boxId != __selectedId || boxId == DATETIME_ID_NONE)
1005 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1007 __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1008 __pEditTime->GetDateTimeBar()->Close();
1011 __selectedId = DATETIME_ID_NONE;
1012 SetLastSelectedId(__selectedId);
1019 SetLastSelectedId(__selectedId);
1021 __lastSelectedValue = "";
1022 _DateTimeUtils dateTimeUtils;
1024 if (GetLastSelectedId() == DATETIME_ID_HOUR)
1026 int hours = GetHour();
1028 if (!Is24HourNotationEnabled())
1032 if (hours == DATETIME_HOUR_MIN)
1034 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1037 __lastSelectedValue.Format(10, L"%02d", hours);
1038 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1040 else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1042 __lastSelectedValue.Format(10, L"%02d", GetMinute());
1043 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1045 else if (GetLastSelectedId() == DATETIME_ID_AMPM)
1047 SetAmEnabled(!GetAmEnabled());
1048 __pEditTime->FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
1049 __pEditTime->UpdateAccessibilityElement();
1050 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1052 __selectedId = DATETIME_ID_NONE;
1054 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1056 __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1057 __pEditTime->GetDateTimeBar()->Close();
1067 if ((__pEditTime->GetDateTimeBar() != null) && (boxId != DATETIME_ID_AMPM) && (GetLastSelectedId() != DATETIME_ID_NONE))
1069 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1070 bounds = GetDisplayAreaBoundsFromHoursStyle(GetLastSelectedId());
1071 FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1072 absoluteBounds = __pEditTime->GetAbsoluteBoundsF();
1073 bounds.x += absoluteBounds.x;
1075 __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds);
1077 if (__pEditTime->GetDateTimeBar()->IsActivated())
1079 __pEditTime->GetDateTimeBar()->RefreshItems();
1083 __pEditTime->GetDateTimeBar()->SetVisibleState(true);
1084 __pEditTime->GetDateTimeBar()->Open();
1088 __selectedId = DATETIME_ID_NONE;
1093 _EditTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1095 if (&source != __pEditTime)
1100 __selectedId = DATETIME_ID_NONE;
1106 _EditTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1108 if (&source != __pEditTime)
1113 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1122 _EditTimePresenter::OnTouchMoveHandled(const _Control& control)
1124 __touchMoveHandled = true;
1125 __selectedId = DATETIME_ID_NONE;
1131 _EditTimePresenter::OnFontChanged(Font* pFont)
1135 if (__pEditTime->GetDateTimeBar() != null)
1137 __pEditTime->GetDateTimeBar()->SetFont(*pFont);
1144 _EditTimePresenter::OnFontInfoRequested(unsigned long& style, float& size)
1146 style = FONT_STYLE_PLAIN;
1147 size = __timeFontSize;
1153 _EditTimePresenter::Initialize(void)
1155 result r = E_SUCCESS;
1157 float titleTimeMargin = 0;
1158 float timeHeight = 0;
1159 float editTimeHeight = 0;
1161 GET_SHAPE_CONFIG(EDITTIME::TEXT_FONT_SIZE, __pEditTime->GetOrientation(), __titleFontSize);
1162 GET_SHAPE_CONFIG(EDITTIME::TIME_FONT_SIZE, __pEditTime->GetOrientation(), __timeFontSize);
1163 GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
1164 GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
1165 GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), editTimeHeight);
1167 if (__pEditTime->GetBoundsF().height > editTimeHeight)
1169 editTimeHeight = __pEditTime->GetBoundsF().height;
1172 if (__title.IsEmpty() == false)
1175 if (!__isEditTimeInitialized)
1177 r = InitializeTitleObject();
1178 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1181 __titleBounds.y = (editTimeHeight - (__titleBounds.height + titleTimeMargin + timeHeight)) / 2.0f;
1182 __titleObject.SetBounds(__titleBounds);
1185 __pFont = __pEditTime->GetFallbackFont();
1186 r = GetLastResult();
1187 SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
1189 if (!__isEditTimeInitialized)
1192 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1194 r = InitializeTextObject();
1195 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1198 __isEditTimeInitialized = true;
1205 _EditTimePresenter::UpdateTimeFormat(void)
1207 if (!__is24hoursSet)
1209 String key(L"http://tizen.org/setting/locale.time.format.24hour");
1210 SettingInfo::GetValue(key , __24hours);
1217 _EditTimePresenter::Animate(void)
1219 SysAssertf((__pFont != null), "Font instance must not be null.");
1221 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
1223 result r = E_SUCCESS;
1224 FloatRectangle rect;
1226 String minuteString;
1229 _DateTimeUtils dateTimeUtils;
1230 int hours = GetHour();
1231 if (!Is24HourNotationEnabled())
1235 if (hours == DATETIME_HOUR_MIN)
1237 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1240 hourString.Format(10, L"%02d", hours);
1241 minuteString.Format(10, L"%02d", GetMinute());
1243 if (GetLastSelectedId() == DATETIME_ID_HOUR)
1245 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(hourString) == false), E_SUCCESS, "[E_SUCCESS] Hour string matched.");
1247 newValue = hourString;
1248 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1250 else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1252 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(minuteString) == false), E_SUCCESS, "[E_SUCCESS] Minute string matched.");
1254 newValue = minuteString;
1255 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1258 FloatDimension newTextDim;
1259 FloatDimension oldTextDim;
1260 FloatPoint textPoint;
1261 VisualElement* pNewVisualElement = null;
1262 VisualElement* pOldVisualElement = null;
1263 VisualElement* pEditTimeElement = null;
1264 VisualElementPropertyAnimation* pNewBoundsAnimation = null;
1265 VisualElementPropertyAnimation* pOldBoundsAnimation = null;
1266 Canvas *pCanvas = null;
1268 __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim);
1269 __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim);
1271 if (newTextDim.width > oldTextDim.width)
1273 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1277 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1280 SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditTime->GetBounds().width), E_SUCCESS, "Rolling animation cann't be played.");
1282 __isAnimating = true;
1284 __pContentProvider = new (std::nothrow) VisualElement();
1285 SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1287 r = __pContentProvider->Construct();
1288 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1290 __pContentProvider->SetShowState(true);
1291 __pContentProvider->SetClipChildrenEnabled(true);
1292 __pContentProvider->SetImplicitAnimationEnabled(false);
1294 pEditTimeElement = __pEditTime->GetVisualElement();
1295 r = GetLastResult();
1296 SysTryCatch(NID_UI_CTRL, (pEditTimeElement != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1298 pNewVisualElement = new (std::nothrow) VisualElement();
1299 SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1301 r = pNewVisualElement->Construct();
1304 pNewVisualElement->Destroy();
1306 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1308 pNewVisualElement->SetShowState(true);
1310 pOldVisualElement = new (std::nothrow) VisualElement();
1311 if (pOldVisualElement == null)
1313 pNewVisualElement->Destroy();
1315 SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1317 r = pOldVisualElement->Construct();
1320 pNewVisualElement->Destroy();
1321 pOldVisualElement->Destroy();
1323 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1325 pOldVisualElement->SetShowState(true);
1327 if (newTextDim.width > oldTextDim.width)
1329 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1330 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1331 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1332 pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1334 rect.x = __pContentProvider->GetBounds().x;
1335 rect.y = __pContentProvider->GetBounds().y;
1336 rect.width = __pContentProvider->GetBounds().width;
1337 rect.height = __pContentProvider->GetBounds().height;
1339 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1340 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1342 pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1346 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1347 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1348 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1349 pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1351 rect.x = __pContentProvider->GetBounds().x;
1352 rect.y = __pContentProvider->GetBounds().y;
1353 rect.width = __pContentProvider->GetBounds().width;
1354 rect.height = __pContentProvider->GetBounds().height;
1356 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1357 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1359 pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1362 pCanvas = pEditTimeElement->GetCanvasN(rect);
1363 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1367 pEditTimeElement->AttachChild(*__pContentProvider);
1369 __pContentProvider->AttachChild(*pOldVisualElement);
1370 __pContentProvider->AttachChild(*pNewVisualElement);
1372 pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1373 SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1375 pNewBoundsAnimation->SetDuration(300);
1376 pNewBoundsAnimation->SetPropertyName("bounds.position");
1377 pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.height * 1.0f)));
1378 pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f)));
1379 pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1381 pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1382 SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1384 pOldBoundsAnimation->SetDuration(300);
1385 pOldBoundsAnimation->SetPropertyName("bounds.position");
1386 pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f)));
1387 pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f)));
1388 pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1390 pCanvas = pOldVisualElement->GetCanvasN();
1391 r = GetLastResult();
1392 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1394 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1396 pCanvas->SetFont(*__pFont);
1397 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), __lastSelectedValue);
1402 pCanvas = pNewVisualElement->GetCanvasN();
1403 r = GetLastResult();
1404 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1406 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1408 pCanvas->SetFont(*__pFont);
1409 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), newValue);
1414 pOldVisualElement->SetImplicitAnimationEnabled(false);
1415 pOldVisualElement->AddAnimation(*pOldBoundsAnimation);
1417 pNewVisualElement->SetImplicitAnimationEnabled(false);
1418 pNewVisualElement->AddAnimation(*pNewBoundsAnimation);
1420 delete pOldBoundsAnimation;
1421 delete pNewBoundsAnimation;
1426 __isAnimating = false;
1427 __pContentProvider->Destroy();
1429 delete pNewBoundsAnimation;
1430 pNewBoundsAnimation = null;
1432 delete pOldBoundsAnimation;
1433 pOldBoundsAnimation = null;
1442 _EditTimePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally)
1444 result r = E_SUCCESS;
1445 __isAnimating = false;
1447 VisualElement* pEditTimeElement = __pEditTime->GetVisualElement();
1448 r = GetLastResult();
1449 SysTryReturnVoidResult(NID_UI_CTRL, (pEditTimeElement != null), r, "[%s] Propagating.", GetErrorMessage(r));
1451 pEditTimeElement->DetachChild(*__pContentProvider);
1452 __pContentProvider->Destroy();
1458 }}} // Tizen::Ui::Controls