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::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
305 GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), timeElementWidth);
306 GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), amPmHeight);
307 GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
308 GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
310 leftMargin = GetLeftMargin();
312 if (__pEditTime->GetBoundsF().height > bounds.height)
314 bounds.height = __pEditTime->GetBoundsF().height;
317 if (!__title.IsEmpty())
319 if (displayBoxId == DATETIME_ID_AMPM)
321 bounds.y = __titleBounds.y + __titleBounds.height;
325 bounds.y = __titleBounds.y + __titleBounds.height + titleTimeMargin;
326 bounds.height = timeHeight;
330 if (__pEditTime->GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
335 bounds.x = leftMargin + ((width - (2.0f * timeElementWidth + colonWidth + 2.0f * colonMargin)) / 2.0f);
337 if (displayBoxId == DATETIME_ID_HOUR)
339 bounds.width = timeElementWidth;
341 else if (displayBoxId == DATETIME_ID_MINUTE)
343 bounds.x = bounds.x + timeElementWidth + colonWidth + 2.0f * colonMargin;
344 bounds.width = timeElementWidth;
346 else if (displayBoxId == DATETIME_ID_AMPM)
348 bounds.x = leftMargin + width + margin;
350 if (__title.IsEmpty())
352 bounds.y = bounds.y + (bounds.height - amPmHeight) / 2.0f;
355 GET_SHAPE_CONFIG(EDITTIME::AMPM_WIDTH, __pEditTime->GetOrientation(), bounds.width);
356 bounds.height = amPmHeight;
363 _EditTimePresenter::GetTextWidth(_DateTimeId boxId) const
365 result r = E_SUCCESS;
367 TextObject dateObject;
371 hourString.Format(10, L"%02d", GetHour());
372 minuteString.Format(10, L"%02d", GetMinute());
374 r = dateObject.Construct();
375 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
377 TextSimple* pSimpleText = null;
379 if (boxId == DATETIME_ID_HOUR)
381 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(hourString.GetPointer())), hourString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
383 else if (boxId == DATETIME_ID_MINUTE)
385 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(minuteString.GetPointer())), minuteString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
388 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), dim.width, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
390 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
392 dateObject.AppendElement(*pSimpleText);
393 dateObject.SetFont(__pFont, 0, dateObject.GetTextLength());
394 dim = dateObject.GetTextExtentF(0, dateObject.GetTextLength());
396 dateObject.RemoveAll();
401 _EditTimePresenter::SetTitleBounds(void)
403 if (__pEditTime->GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
405 GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), __titleBounds.x);
409 __titleBounds.x = GetLeftMargin();
411 GET_SHAPE_CONFIG(EDITTIME::WIDTH, __pEditTime->GetOrientation(), __titleBounds.width);
412 GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), __titleBounds.height);
418 _EditTimePresenter::GetTitleBounds(void) const
420 return __titleBounds;
424 _EditTimePresenter::LoadResource(void)
426 result r = E_SUCCESS;
428 Color buttonNormalBgColor;
429 Color buttonDisabledBgColor;
430 Color buttonNormalPressedColor;
431 Color colonTextColor;
432 Color colonTextDisabledColor;
433 Bitmap* pTempBitmap = null;
435 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_NORMAL, buttonNormalBgColor);
436 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_PRESSED, buttonNormalPressedColor);
437 GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_DISABLED, buttonDisabledBgColor);
438 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, colonTextColor);
439 GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, colonTextDisabledColor);
441 GET_SHAPE_CONFIG(EDITTIME::AMPM_FONT_SIZE, __pEditTime->GetOrientation(), __amPmTextSize);
443 r = GET_BITMAP_CONFIG_N(EDITTIME::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
444 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
446 __pColonColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE),
448 SysTryCatch(NID_UI_CTRL, (__pColonColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
449 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
451 __pColonDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE),
452 colonTextDisabledColor);
453 SysTryCatch(NID_UI_CTRL, (__pColonDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
454 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
459 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
460 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
462 __pAmPmBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalBgColor);
463 SysTryCatch(NID_UI_CTRL, (__pAmPmBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
464 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
469 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
470 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
472 __pAmPmBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonDisabledBgColor);
473 SysTryCatch(NID_UI_CTRL, (__pAmPmBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
474 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
479 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
480 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
482 __pAmPmBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalPressedColor);
483 SysTryCatch(NID_UI_CTRL, (__pAmPmBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
484 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
486 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectNomralBitmap);
487 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
489 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectPressedBitmap);
490 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
492 r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectDisabledBitmap);
493 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
505 delete __pAmPmBgNormalColorReplacementBitmap;
506 __pAmPmBgNormalColorReplacementBitmap = null;
508 delete __pAmPmBgPressedColorReplacementBitmap;
509 __pAmPmBgPressedColorReplacementBitmap = null;
511 delete __pAmPmBgEffectNomralBitmap;
512 __pAmPmBgEffectNomralBitmap = null;
514 delete __pAmPmBgEffectPressedBitmap;
515 __pAmPmBgEffectPressedBitmap = null;
517 delete __pColonColorReplacementBitmap;
518 __pColonColorReplacementBitmap = null;
524 _EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
526 result r = E_SUCCESS;
533 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
535 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
536 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
540 r = canvas.DrawBitmap(bounds, *pBitmap);
541 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
548 _EditTimePresenter::CalculateTouchAreaBounds(const FloatRectangle hourBounds, const FloatRectangle minuteBounds)
550 __hourTouchBounds.width = GetTextWidth(DATETIME_ID_HOUR);
551 __hourTouchBounds.x = hourBounds.x + (hourBounds.width - __hourTouchBounds.width) / 2.0f;
552 __hourTouchBounds.y = hourBounds.y;
553 __hourTouchBounds.height = hourBounds.height;
555 __minuteTouchBounds.width = GetTextWidth(DATETIME_ID_MINUTE);
556 __minuteTouchBounds.x = minuteBounds.x + (minuteBounds.width - __minuteTouchBounds.width) / 2.0f;
557 __minuteTouchBounds.y = minuteBounds.y;
558 __minuteTouchBounds.height = minuteBounds.height;
564 _EditTimePresenter::GetLeftMargin(void) const
566 FloatRectangle bounds;
567 FloatDimension minSize;
568 bounds = __pEditTime->GetBoundsF();
570 float leftMargin = 0.0f;
571 float leftMinMargin = 0.0f;
574 GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), leftMargin);
575 GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MIN_MARGIN, __pEditTime->GetOrientation(), leftMinMargin);
576 GET_SHAPE_CONFIG(EDITTIME::WIDTH, __pEditTime->GetOrientation(), width);
578 GET_DIMENSION_CONFIG(EDITTIME::MIN_SIZE, __pEditTime->GetOrientation(), minSize);
580 if (bounds.width >= width)
585 if (bounds.width <= minSize.width)
587 leftMargin = leftMinMargin;
589 else if (bounds.width < width && bounds.width > minSize.width)
591 leftMargin = leftMargin - ((leftMargin - leftMinMargin) / (width - minSize.width)) * (width - bounds.width);
598 _EditTimePresenter::InitializeTitleObject(void)
600 result r = E_SUCCESS;
602 Color titleNormalColor;
604 GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_NORMAL, titleNormalColor);
606 r = __titleObject.Construct();
607 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
609 TextSimple* pSimpleText = null;
611 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
612 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
614 __titleObject.AppendElement(*pSimpleText);
616 __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength());
617 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
618 __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
619 __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
620 __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
626 _EditTimePresenter::InitializeTextObject(void)
628 result r = E_SUCCESS;
630 r = __textObject.Construct();
631 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
633 TextSimple* pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
634 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
635 "[E_OUT_OF_MEMORY] Memory allocation failed.");
637 __textObject.AppendElement(*pSimpleText);
639 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
640 __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
641 __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
642 __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
648 _EditTimePresenter::Draw(void)
650 result r = E_SUCCESS;
657 Canvas* pCanvas = __pEditTime->GetCanvasN();
658 SysAssertf((pCanvas != null), "Failed to get canvas.");
660 FloatRectangle colonBounds(0.0f, 0.0f, 0.0f, 0.0f);
662 float colonMargin = 0.0f;
666 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
669 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
670 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
671 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
672 bool isCustomBitmap = false;
673 Bitmap* pReplacementBitmap = null;
674 Bitmap* pEffectBitmap = null;
676 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
677 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
679 if (__24hours == false)
681 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
683 if (!__pEditTime->IsEnabled())
685 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_DISABLED);
686 pReplacementBitmap = __pAmPmBgDisabledColorReplacementBitmap;
687 pEffectBitmap = __pAmPmBgEffectDisabledBitmap;
689 else if (__selectedId != DATETIME_ID_AMPM)
691 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_NORMAL);
692 pReplacementBitmap = __pAmPmBgNormalColorReplacementBitmap;
693 pEffectBitmap = __pAmPmBgEffectNomralBitmap;
697 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_PRESSED);
698 pReplacementBitmap = __pAmPmBgPressedColorReplacementBitmap;
699 pEffectBitmap = __pAmPmBgEffectPressedBitmap;
703 if (GetHour() >= DATETIME_HOUR_MAX_FOR_24NOTATION)
714 GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonBounds.width);
715 GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
716 GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), colonBounds.height);
718 colonBounds.x = hourBounds.x + hourBounds.width + colonMargin;
719 colonBounds.y = hourBounds.y + (hourBounds.height - colonBounds.height) / 2.0f;
721 if (__title.IsEmpty() == false)
723 r = DrawTitle(*pCanvas);
724 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
727 r = DrawText(*pCanvas, hourBounds, __hourString, DATETIME_ID_HOUR);
728 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
730 r = DrawText(*pCanvas, minuteBounds, __minuteString, DATETIME_ID_MINUTE);
731 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
733 r = DrawColon(*pCanvas, colonBounds);
734 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
736 CalculateTouchAreaBounds(hourBounds, minuteBounds);
738 if (__24hours == false)
740 r = DrawResourceBitmap(*pCanvas, ampmBounds, pReplacementBitmap);
741 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
745 r = DrawResourceBitmap(*pCanvas, ampmBounds, pEffectBitmap);
746 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
749 r = DrawText(*pCanvas, ampmBounds, __ampmString, DATETIME_ID_AMPM, __amPmTextSize);
750 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
760 _EditTimePresenter::DrawColon(Canvas& canvas, const FloatRectangle& bounds)
762 result r = E_SUCCESS;
764 if (!__pEditTime->IsEnabled())
766 r = DrawResourceBitmap(canvas, bounds, __pColonDisabledColorReplacementBitmap);
770 r = DrawResourceBitmap(canvas, bounds, __pColonColorReplacementBitmap);
777 _EditTimePresenter::DrawTitle(Canvas& canvas)
779 if (!__pEditTime->IsEnabled())
781 Color titleDisabledColor;
782 GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_DISABLED, titleDisabledColor);
783 __titleObject.SetForegroundColor(titleDisabledColor, 0, __titleObject.GetTextLength());
786 (_FontImpl::GetInstance(*__pFont))->SetSize(__titleFontSize);
787 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
789 __titleObject.Draw(*_CanvasImpl::GetInstance(canvas));
795 _EditTimePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, _DateTimeId boxId, float textSize)
797 result r = E_SUCCESS;
801 if (!__pEditTime->IsEnabled())
803 if (boxId == DATETIME_ID_AMPM)
805 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_DISABLED, textColor);
809 GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, textColor);
814 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, textColor);
816 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated() &&
817 (GetLastSelectedId() == boxId))
819 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
822 if (boxId == DATETIME_ID_AMPM)
824 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_NORMAL, textColor);
827 if (boxId > -1 && boxId == __selectedId)
829 if (boxId == DATETIME_ID_AMPM)
831 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_PRESSED, textColor);
835 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
840 FloatRectangle drawAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
841 drawAreaBounds = bounds;
843 TextSimple* pSimpleText = null;
844 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
845 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
847 __textObject.RemoveAll();
849 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
851 __textObject.AppendElement(*pSimpleText);
853 if (boxId == DATETIME_ID_AMPM)
855 (_FontImpl::GetInstance(*__pFont))->SetSize(textSize);
856 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
860 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
863 __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength());
864 __textObject.SetBounds(drawAreaBounds);
865 __textObject.Draw(*_CanvasImpl::GetInstance(canvas));
871 _EditTimePresenter::GetBoxIdFromPosition(const FloatPoint& point) const
873 _DateTimeId displayBoxId = DATETIME_ID_NONE;
875 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
877 if (__24hours == false)
879 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
882 if (point.y < __hourTouchBounds.y || point.y > __hourTouchBounds.y + __hourTouchBounds.height)
887 if (__hourTouchBounds.Contains(point) == true)
889 displayBoxId = DATETIME_ID_HOUR;
891 else if (__minuteTouchBounds.Contains(point) == true)
893 displayBoxId = DATETIME_ID_MINUTE;
895 else if (ampmBounds.Contains(point) == true)
897 displayBoxId = DATETIME_ID_AMPM;
904 _EditTimePresenter::SetLastSelectedId(_DateTimeId boxId)
906 __lastSelectedId = boxId;
911 _EditTimePresenter::GetLastSelectedId(void) const
913 return __lastSelectedId;
917 _EditTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
919 SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
921 if (&source != __pEditTime)
926 __touchMoveHandled = false;
928 FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
929 FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
930 FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
932 hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
933 minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
935 if (__24hours == false)
937 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
940 FloatPoint point = touchinfo.GetCurrentPosition();
942 _DateTimeId boxId = GetBoxIdFromPosition(point);
946 int displayValue = -1;
948 if (boxId == DATETIME_ID_HOUR)
950 if (__pEditTime->GetDateTimeBar() != null)
952 if (__24hours == false)
956 minValue = DATETIME_HOUR_MIN + 1;
957 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
958 displayValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
960 else if (GetHour() > DATETIME_HOUR_MAX_FOR_24NOTATION)
962 minValue = DATETIME_HOUR_MIN + 1;
963 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
964 displayValue = GetHour() - DATETIME_HOUR_MAX_FOR_24NOTATION;
968 minValue = DATETIME_HOUR_MIN + 1;
969 maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
970 displayValue = GetHour();
975 minValue = DATETIME_HOUR_MIN;
976 maxValue = DATETIME_HOUR_MAX;
977 displayValue = GetHour();
980 if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
982 __pEditTime->GetDateTimeBar()->RemoveAllItems();
985 __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
988 __bounds = hourBounds;
990 else if (boxId == DATETIME_ID_MINUTE)
992 if (__pEditTime->GetDateTimeBar() != null)
994 minValue = DATETIME_MINUTE_MIN;
995 maxValue = DATETIME_MINUTE_MAX;
996 displayValue = GetMinute();
998 if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
1000 __pEditTime->GetDateTimeBar()->RemoveAllItems();
1003 __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
1006 __bounds = minuteBounds;
1008 else if (boxId == DATETIME_ID_AMPM)
1010 __selectedId = boxId;
1011 __bounds = ampmBounds;
1016 __selectedId = DATETIME_ID_NONE;
1020 __selectedId = boxId;
1026 _EditTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1028 SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
1030 if (&source != __pEditTime)
1035 FloatRectangle bounds = __pEditTime->GetBoundsF();
1037 FloatPoint startPoint(0.0f, 0.0f);
1039 float titleHeight = 0;
1040 GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), titleHeight);
1042 __bounds = FloatRectangle(0.0f, titleHeight, bounds.width, bounds.height);
1044 FloatPoint point = touchinfo.GetCurrentPosition();
1046 _DateTimeId boxId = GetBoxIdFromPosition(point);
1048 if ((boxId == GetLastSelectedId() && boxId != DATETIME_ID_AMPM) || boxId != __selectedId || boxId == DATETIME_ID_NONE)
1050 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1052 __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1053 __pEditTime->GetDateTimeBar()->Close();
1056 __selectedId = DATETIME_ID_NONE;
1057 SetLastSelectedId(__selectedId);
1064 SetLastSelectedId(__selectedId);
1066 __lastSelectedValue = "";
1067 _DateTimeUtils dateTimeUtils;
1069 if (GetLastSelectedId() == DATETIME_ID_HOUR)
1071 int hours = GetHour();
1073 if (!Is24HourNotationEnabled())
1077 if (hours == DATETIME_HOUR_MIN)
1079 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1082 __lastSelectedValue.Format(10, L"%02d", hours);
1083 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1085 else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1087 __lastSelectedValue.Format(10, L"%02d", GetMinute());
1088 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1090 else if (GetLastSelectedId() == DATETIME_ID_AMPM)
1092 SetAmEnabled(!GetAmEnabled());
1093 __pEditTime->FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
1094 __pEditTime->UpdateAccessibilityElement();
1095 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1097 __selectedId = DATETIME_ID_NONE;
1099 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1101 __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1102 __pEditTime->GetDateTimeBar()->Close();
1112 if ((__pEditTime->GetDateTimeBar() != null) && (boxId != DATETIME_ID_AMPM) && (GetLastSelectedId() != DATETIME_ID_NONE))
1114 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1115 bounds = GetDisplayAreaBoundsFromHoursStyle(GetLastSelectedId());
1116 FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1117 absoluteBounds = __pEditTime->GetAbsoluteBoundsF();
1118 bounds.x += absoluteBounds.x;
1120 __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds);
1122 if (__pEditTime->GetDateTimeBar()->IsActivated())
1124 __pEditTime->GetDateTimeBar()->RefreshItems();
1128 __pEditTime->GetDateTimeBar()->SetVisibleState(true);
1129 __pEditTime->GetDateTimeBar()->Open();
1133 __selectedId = DATETIME_ID_NONE;
1138 _EditTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1140 if (&source != __pEditTime)
1145 __selectedId = DATETIME_ID_NONE;
1151 _EditTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1153 if (&source != __pEditTime)
1158 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1167 _EditTimePresenter::OnTouchMoveHandled(const _Control& control)
1169 __touchMoveHandled = true;
1170 __selectedId = DATETIME_ID_NONE;
1176 _EditTimePresenter::OnFontChanged(Font* pFont)
1180 if (__pEditTime->GetDateTimeBar() != null)
1182 __pEditTime->GetDateTimeBar()->SetFont(*pFont);
1189 _EditTimePresenter::OnFontInfoRequested(unsigned long& style, float& size)
1191 style = FONT_STYLE_PLAIN;
1192 size = __timeFontSize;
1198 _EditTimePresenter::Initialize(void)
1200 result r = E_SUCCESS;
1202 float titleTimeMargin = 0;
1203 float timeHeight = 0;
1204 float editTimeHeight = 0;
1206 GET_SHAPE_CONFIG(EDITTIME::TEXT_FONT_SIZE, __pEditTime->GetOrientation(), __titleFontSize);
1207 GET_SHAPE_CONFIG(EDITTIME::TIME_FONT_SIZE, __pEditTime->GetOrientation(), __timeFontSize);
1208 GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
1209 GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
1210 GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), editTimeHeight);
1212 if (__pEditTime->GetBoundsF().height > editTimeHeight)
1214 editTimeHeight = __pEditTime->GetBoundsF().height;
1217 if (__title.IsEmpty() == false)
1220 if (!__isEditTimeInitialized)
1222 r = InitializeTitleObject();
1223 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1226 __titleBounds.y = (editTimeHeight - (__titleBounds.height + titleTimeMargin + timeHeight)) / 2.0f;
1227 __titleObject.SetBounds(__titleBounds);
1230 __pFont = __pEditTime->GetFallbackFont();
1231 r = GetLastResult();
1232 SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
1234 if (!__isEditTimeInitialized)
1237 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1239 r = InitializeTextObject();
1240 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1243 __isEditTimeInitialized = true;
1250 _EditTimePresenter::UpdateTimeFormat(void)
1252 if (!__is24hoursSet)
1254 String key(L"http://tizen.org/setting/locale.time.format.24hour");
1255 SettingInfo::GetValue(key , __24hours);
1262 _EditTimePresenter::Animate(void)
1264 SysAssertf((__pFont != null), "Font instance must not be null.");
1266 (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
1268 result r = E_SUCCESS;
1269 FloatRectangle rect;
1271 String minuteString;
1274 _DateTimeUtils dateTimeUtils;
1275 int hours = GetHour();
1276 if (!Is24HourNotationEnabled())
1280 if (hours == DATETIME_HOUR_MIN)
1282 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1285 hourString.Format(10, L"%02d", hours);
1286 minuteString.Format(10, L"%02d", GetMinute());
1288 if (GetLastSelectedId() == DATETIME_ID_HOUR)
1290 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(hourString) == false), E_SUCCESS, "[E_SUCCESS] Hour string matched.");
1292 newValue = hourString;
1293 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1295 else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1297 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(minuteString) == false), E_SUCCESS, "[E_SUCCESS] Minute string matched.");
1299 newValue = minuteString;
1300 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1303 FloatDimension newTextDim;
1304 FloatDimension oldTextDim;
1305 FloatPoint textPoint;
1306 VisualElement* pNewVisualElement = null;
1307 VisualElement* pOldVisualElement = null;
1308 VisualElement* pEditTimeElement = null;
1309 VisualElementPropertyAnimation* pNewBoundsAnimation = null;
1310 VisualElementPropertyAnimation* pOldBoundsAnimation = null;
1311 Canvas *pCanvas = null;
1313 __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim);
1314 __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim);
1316 if (newTextDim.width > oldTextDim.width)
1318 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1322 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1325 SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditTime->GetBounds().width), E_SUCCESS, "Rolling animation cann't be played.");
1327 __isAnimating = true;
1329 __pContentProvider = new (std::nothrow) VisualElement();
1330 SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1332 r = __pContentProvider->Construct();
1333 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1335 __pContentProvider->SetShowState(true);
1336 __pContentProvider->SetClipChildrenEnabled(true);
1337 __pContentProvider->SetImplicitAnimationEnabled(false);
1339 pEditTimeElement = __pEditTime->GetVisualElement();
1340 r = GetLastResult();
1341 SysTryCatch(NID_UI_CTRL, (pEditTimeElement != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1343 pNewVisualElement = new (std::nothrow) VisualElement();
1344 SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1346 r = pNewVisualElement->Construct();
1349 pNewVisualElement->Destroy();
1351 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1353 pNewVisualElement->SetShowState(true);
1355 pOldVisualElement = new (std::nothrow) VisualElement();
1356 if (pOldVisualElement == null)
1358 pNewVisualElement->Destroy();
1360 SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1362 r = pOldVisualElement->Construct();
1365 pNewVisualElement->Destroy();
1366 pOldVisualElement->Destroy();
1368 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1370 pOldVisualElement->SetShowState(true);
1372 if (newTextDim.width > oldTextDim.width)
1374 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1375 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1376 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1377 pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1379 rect.x = __pContentProvider->GetBounds().x;
1380 rect.y = __pContentProvider->GetBounds().y;
1381 rect.width = __pContentProvider->GetBounds().width;
1382 rect.height = __pContentProvider->GetBounds().height;
1384 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1385 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1387 pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1391 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1392 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1393 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1394 pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1396 rect.x = __pContentProvider->GetBounds().x;
1397 rect.y = __pContentProvider->GetBounds().y;
1398 rect.width = __pContentProvider->GetBounds().width;
1399 rect.height = __pContentProvider->GetBounds().height;
1401 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1402 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1404 pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1407 pCanvas = pEditTimeElement->GetCanvasN(rect);
1408 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1412 pEditTimeElement->AttachChild(*__pContentProvider);
1414 __pContentProvider->AttachChild(*pOldVisualElement);
1415 __pContentProvider->AttachChild(*pNewVisualElement);
1417 pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1418 SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1420 pNewBoundsAnimation->SetDuration(300);
1421 pNewBoundsAnimation->SetPropertyName("bounds.position");
1422 pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.height * 1.0f)));
1423 pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f)));
1424 pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1426 pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1427 SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1429 pOldBoundsAnimation->SetDuration(300);
1430 pOldBoundsAnimation->SetPropertyName("bounds.position");
1431 pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f)));
1432 pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f)));
1433 pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1435 pCanvas = pOldVisualElement->GetCanvasN();
1436 r = GetLastResult();
1437 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1439 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1441 pCanvas->SetFont(*__pFont);
1442 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), __lastSelectedValue);
1447 pCanvas = pNewVisualElement->GetCanvasN();
1448 r = GetLastResult();
1449 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1451 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1453 pCanvas->SetFont(*__pFont);
1454 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), newValue);
1459 pOldVisualElement->SetImplicitAnimationEnabled(false);
1460 pOldVisualElement->AddAnimation(*pOldBoundsAnimation);
1462 pNewVisualElement->SetImplicitAnimationEnabled(false);
1463 pNewVisualElement->AddAnimation(*pNewBoundsAnimation);
1465 delete pOldBoundsAnimation;
1466 delete pNewBoundsAnimation;
1471 __isAnimating = false;
1472 __pContentProvider->Destroy();
1474 delete pNewBoundsAnimation;
1475 pNewBoundsAnimation = null;
1477 delete pOldBoundsAnimation;
1478 pOldBoundsAnimation = null;
1487 _EditTimePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally)
1489 result r = E_SUCCESS;
1490 __isAnimating = false;
1492 VisualElement* pEditTimeElement = __pEditTime->GetVisualElement();
1493 r = GetLastResult();
1494 SysTryReturnVoidResult(NID_UI_CTRL, (pEditTimeElement != null), r, "[%s] Propagating.", GetErrorMessage(r));
1496 pEditTimeElement->DetachChild(*__pContentProvider);
1497 __pContentProvider->Destroy();
1503 }}} // Tizen::Ui::Controls