2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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_EditDatePresenter.cpp
20 * @brief This is the implementation file for the _EditDatePresenter class.
24 #include <FGrp_TextTextObject.h>
25 #include <FGrp_TextTextSimple.h>
26 #include <FGrp_CanvasImpl.h>
27 #include <FGrp_BitmapImpl.h>
28 #include <FGrp_FontImpl.h>
29 #include "FUi_ResourceManager.h"
30 #include "FUiCtrl_EditDatePresenter.h"
31 #include "FUiCtrl_EditDate.h"
32 #include "FUiCtrl_DateTimeModel.h"
33 #include "FUiCtrl_DateTimeUtils.h"
34 #include "FUiControl.h"
35 #include "FUiAnim_VisualElement.h"
36 #include "FUiAnimVisualElementPropertyAnimation.h"
37 #include "FGrpColor.h"
38 #include "FUi_CoordinateSystemUtils.h"
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Base;
42 using namespace Tizen::Graphics::_Text;
43 using namespace Tizen::Ui::Animations;
46 namespace Tizen { namespace Ui { namespace Controls
48 _EditDatePresenter::_EditDatePresenter(void)
49 : __pEditDateTimeModel(null)
51 , __dayBounds(FloatRectangle())
52 , __monthBounds(FloatRectangle())
53 , __yearBounds(FloatRectangle())
54 , __dayTouchBounds(FloatRectangle())
55 , __monthTouchBounds(FloatRectangle())
56 , __yearTouchBounds(FloatRectangle())
57 , __titleBounds(FloatRectangle())
58 , __pContentBgNormalColorReplacementBitmap(null)
59 , __pContentBgDisabledColorReplacementBitmap(null)
60 , __pContentBgPressedColorReplacementBitmap(null)
61 , __pContentBgHighlightedColorReplacementBitmap(null)
62 , __pContentBgEffectNormalBitmap(null)
63 , __pContentBgEffectPressedBitmap(null)
64 , __pContentBgEffectDisabledBitmap(null)
65 , __datePickerEnabled(true)
66 , __selectedId(DATETIME_ID_NONE)
67 , __lastSelectedId(DATETIME_ID_NONE)
68 , __touchMoveHandled(false)
72 , __elementMargin(0.0f)
73 , __dividerLineHeight(0.0f)
74 , __titleFontSize(0.0f)
75 , __dateFontSize(0.0f)
76 , __pContentProvider(null)
77 , __isAnimating(false)
78 , __isEditDateInitialized(false)
79 , __elementWidth(0.0f)
80 , __focusStatus(FOCUS_NONE)
81 , __isEnterKeyPressed(false)
86 _EditDatePresenter::~_EditDatePresenter(void)
88 __titleObject.RemoveAll();
89 __textObject.RemoveAll();
91 delete __pEditDateTimeModel;
92 __pEditDateTimeModel = null;
94 delete __pContentBgNormalColorReplacementBitmap;
95 __pContentBgNormalColorReplacementBitmap = null;
97 delete __pContentBgDisabledColorReplacementBitmap;
98 __pContentBgDisabledColorReplacementBitmap = null;
100 delete __pContentBgPressedColorReplacementBitmap;
101 __pContentBgPressedColorReplacementBitmap = null;
103 delete __pContentBgHighlightedColorReplacementBitmap;
104 __pContentBgHighlightedColorReplacementBitmap = null;
106 delete __pContentBgEffectNormalBitmap;
107 __pContentBgEffectNormalBitmap = null;
109 delete __pContentBgEffectPressedBitmap;
110 __pContentBgEffectPressedBitmap = null;
112 delete __pContentBgEffectDisabledBitmap;
113 __pContentBgEffectDisabledBitmap = null;
117 _EditDatePresenter::CreateInstanceN(const _EditDate& editDate, const String& title)
119 _EditDatePresenter* pEditDatePresenter = new (std::nothrow) _EditDatePresenter;
120 SysTryReturn(NID_UI_CTRL, pEditDatePresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
122 pEditDatePresenter->__pEditDate = const_cast <_EditDate*>(&editDate);
124 pEditDatePresenter->__pEditDateTimeModel = new (std::nothrow) _DateTimeModel;
125 SysTryCatch(NID_UI_CTRL, pEditDatePresenter->__pEditDateTimeModel, , E_OUT_OF_MEMORY,
126 "[E_OUT_OF_MEMORY] Memory allocation failed.");
127 pEditDatePresenter->SetTitle(title);
129 return pEditDatePresenter;
132 delete pEditDatePresenter;
137 _EditDatePresenter::SetTitle(const String& title)
143 _EditDatePresenter::Initialize(void)
145 result r = E_SUCCESS;
146 float editDateHeight = 0.0f;
147 float dateLeftMargin = 0.0f;
148 float titleLeftMargin = 0.0f;
149 float titledateMargin = 0.0f;
150 float dateHeight = 0.0f;
151 float monthYearMinWidth = 0.0f;
152 float dayElementWidth = 0.0f;
153 float dayElementMinWidth = 0.0f;
154 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
156 GET_SHAPE_CONFIG(EDITDATE::HEIGHT, __pEditDate->GetOrientation(), editDateHeight);
157 GET_SHAPE_CONFIG(EDITDATE::TITLE_TEXT_LEFT_MARGIN, __pEditDate->GetOrientation(), titleLeftMargin);
158 GET_SHAPE_CONFIG(EDITDATE::ITEM_DIVIDER_HEIGHT, __pEditDate->GetOrientation(), __dividerLineHeight);
159 GET_SHAPE_CONFIG(EDITDATE::TEXT_FONT_SIZE, __pEditDate->GetOrientation(), __titleFontSize);
160 GET_SHAPE_CONFIG(EDITDATE::DATE_FONT_SIZE, __pEditDate->GetOrientation(), __dateFontSize);
161 GET_SHAPE_CONFIG(EDITDATE::TITLE_DATE_MARGIN, __pEditDate->GetOrientation(), titledateMargin);
162 GET_SHAPE_CONFIG(EDITDATE::DATE_HEIGHT, __pEditDate->GetOrientation(), dateHeight);
163 GET_SHAPE_CONFIG(EDITDATE::TITLE_HEIGHT, __pEditDate->GetOrientation(), __titleBounds.height);
164 GET_SHAPE_CONFIG(EDITDATE::MONTH_YEAR_ELEMENT_WIDTH, __pEditDate->GetOrientation(), __elementWidth);
165 GET_SHAPE_CONFIG(EDITDATE::DAY_ELEMENT_WIDTH, __pEditDate->GetOrientation(), dayElementWidth);
166 GET_SHAPE_CONFIG(EDITDATE::ELEMENT_MARGIN, __pEditDate->GetOrientation(), __elementMargin);
167 GET_SHAPE_CONFIG(EDITDATE::DATE_TEXT_LEFT_MARGIN, __pEditDate->GetOrientation(), dateLeftMargin);
169 GET_SHAPE_CONFIG(EDITDATE::MONTH_YEAR_ELEMENT_MIN_WIDTH, __pEditDate->GetOrientation(), monthYearMinWidth);
170 GET_SHAPE_CONFIG(EDITDATE::DAY_ELEMENT_MIN_WIDTH, __pEditDate->GetOrientation(), dayElementMinWidth);
172 if (__pEditDate->GetBoundsF().height > editDateHeight)
174 editDateHeight = __pEditDate->GetBoundsF().height;
177 __pFont = __pEditDate->GetFallbackFont();
179 SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
181 if (__title.IsEmpty() == false)
183 __titleBounds.x = titleLeftMargin;
184 __titleBounds.y = (editDateHeight - (__titleBounds.height + titledateMargin + dateHeight)) / 2.0f;
185 __titleBounds.width = __pEditDate->GetBoundsF().width - __titleBounds.x;
187 bounds.y = __titleBounds.y + __titleBounds.height + titledateMargin;
189 if (!__isEditDateInitialized)
191 r = InitializeTitleObject();
192 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
195 __titleObject.SetBounds(__titleBounds);
199 bounds.y = (editDateHeight - dateHeight) / 2.0f;
203 dayElementWidth = GetElementWidth(dayElementMinWidth, dayElementWidth);
204 __elementWidth = GetElementWidth(monthYearMinWidth, __elementWidth);
206 __dayBounds.height = dateHeight;
207 __monthBounds.height = dateHeight;
208 __yearBounds.height = dateHeight;
210 __dayBounds.width = dayElementWidth;
211 __monthBounds.width = __elementWidth;
212 __yearBounds.width = __elementWidth;
214 __dayBounds.x = dateLeftMargin;
215 __monthBounds.x = dateLeftMargin;
216 __yearBounds.x = dateLeftMargin;
218 __dayBounds.y = bounds.y;
219 __monthBounds.y = bounds.y;
220 __yearBounds.y = bounds.y;
222 if (!__isEditDateInitialized)
225 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
227 r = InitializeTextObject();
228 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
231 __isEditDateInitialized = true;
233 CalculateAreaBounds();
239 _EditDatePresenter::InitializeTitleObject(void)
241 result r = E_SUCCESS;
243 Color titleNormalColor;
245 GET_COLOR_CONFIG(EDITDATE::TITLE_TEXT_NORMAL, titleNormalColor);
247 r = __titleObject.Construct();
248 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
250 TextSimple* pSimpleText = null;
252 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
253 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
255 __titleObject.AppendElement(*pSimpleText);
257 __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength());
258 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
259 __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
260 __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
261 __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
262 __titleObject.SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL);
268 _EditDatePresenter::InitializeTextObject(void)
270 result r = E_SUCCESS;
272 r = __textObject.Construct();
273 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
275 TextSimple* pSimpleText = null;
277 pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
278 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
280 __textObject.AppendElement(*pSimpleText);
282 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
283 __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
284 __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
285 __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
291 _EditDatePresenter::GetElementWidth(const float minWidth, const float maxWidth) const
293 FloatRectangle bounds;
294 FloatDimension minSize;
295 bounds = __pEditDate->GetBoundsF();
297 float elementWidth = 0.0f;
298 float editDateWidth = 0.0f;
300 GET_SHAPE_CONFIG(EDITDATE::WIDTH, __pEditDate->GetOrientation(), editDateWidth);
301 GET_DIMENSION_CONFIG(EDITDATE::MIN_SIZE, __pEditDate->GetOrientation(), minSize);
303 if (bounds.width >= editDateWidth)
308 if (bounds.width <= minSize.width)
310 elementWidth = minWidth;
312 else if (bounds.width < editDateWidth && bounds.width > minSize.width)
314 elementWidth = maxWidth -
315 ((maxWidth - minWidth) / (editDateWidth - minSize.width)) * (editDateWidth - bounds.width);
322 _EditDatePresenter::LoadResource(void)
324 result r = E_SUCCESS;
326 Color contentNormalBgColor;
327 Color contentDisabledBgColor;
328 Color contentPressedColor;
329 Color contentHighlightedColor;
331 Bitmap* pTempBitmap = null;
333 GET_COLOR_CONFIG(EDITDATE::CONTENT_BG_NORMAL, contentNormalBgColor);
334 GET_COLOR_CONFIG(EDITDATE::CONTENT_BG_DISABLED, contentDisabledBgColor);
335 GET_COLOR_CONFIG(EDITDATE::CONTENT_BG_PRESSED, contentPressedColor);
336 GET_COLOR_CONFIG(EDITDATE::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
338 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
339 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
341 __pContentBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentNormalBgColor);
342 SysTryCatch(NID_UI_CTRL, (__pContentBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
343 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
348 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
349 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
351 __pContentBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentPressedColor);
352 SysTryCatch(NID_UI_CTRL, (__pContentBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
353 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
358 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
359 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
361 __pContentBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentDisabledBgColor);
362 SysTryCatch(NID_UI_CTRL, (__pContentBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
363 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
368 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
369 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
371 __pContentBgHighlightedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
372 SysTryCatch(NID_UI_CTRL, (__pContentBgHighlightedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
373 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
375 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectNormalBitmap);
376 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
378 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectPressedBitmap);
379 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
381 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectDisabledBitmap);
382 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
394 delete __pContentBgNormalColorReplacementBitmap;
395 __pContentBgNormalColorReplacementBitmap = null;
397 delete __pContentBgPressedColorReplacementBitmap;
398 __pContentBgPressedColorReplacementBitmap = null;
400 delete __pContentBgDisabledColorReplacementBitmap;
401 __pContentBgDisabledColorReplacementBitmap = null;
403 delete __pContentBgHighlightedColorReplacementBitmap;
404 __pContentBgHighlightedColorReplacementBitmap = null;
406 delete __pContentBgEffectNormalBitmap;
407 __pContentBgEffectNormalBitmap = null;
409 delete __pContentBgEffectPressedBitmap;
410 __pContentBgEffectPressedBitmap = null;
412 delete __pContentBgEffectDisabledBitmap;
413 __pContentBgEffectDisabledBitmap = null;
419 _EditDatePresenter::GetDate(void) const
421 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
424 date.SetValue(GetYear(), GetMonth(), GetDay(), DATETIME_HOUR_MIN, DATETIME_MINUTE_MIN);
430 _EditDatePresenter::GetDay(void) const
432 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
434 return __pEditDateTimeModel->GetDay();
438 _EditDatePresenter::GetMonth(void) const
440 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
442 return __pEditDateTimeModel->GetMonth();
446 _EditDatePresenter::GetYear(void) const
448 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
450 return __pEditDateTimeModel->GetYear();
454 _EditDatePresenter::SetDate(const DateTime& date)
456 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
458 __pEditDateTimeModel->SetDateTime(date);
463 _EditDatePresenter::SetCurrentDate(void)
465 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
467 __pEditDateTimeModel->SetCurrentDateTime();
472 _EditDatePresenter::SetYear(int year)
474 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
476 return __pEditDateTimeModel->SetYear(year);
480 _EditDatePresenter::SetMonth(int month)
482 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
484 return __pEditDateTimeModel->SetMonth(month);
488 _EditDatePresenter::SetDay(int day)
490 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
492 return __pEditDateTimeModel->SetDay(day);
496 _EditDatePresenter::SetDatePickerEnabled(bool enable)
498 __datePickerEnabled = enable;
503 _EditDatePresenter::IsDatePickerEnabled(void) const
505 return __datePickerEnabled;
509 _EditDatePresenter::SetMinYear(int minYear)
511 return __pEditDateTimeModel->SetMinYear(minYear);
515 _EditDatePresenter::SetMaxYear(int maxYear)
517 return __pEditDateTimeModel->SetMaxYear(maxYear);
521 _EditDatePresenter::GetMinYear(void) const
526 __pEditDateTimeModel->GetYearRange(minYear, maxYear);
532 _EditDatePresenter::GetMaxYear(void) const
537 __pEditDateTimeModel->GetYearRange(minYear, maxYear);
543 _EditDatePresenter::Draw(void)
545 result r = E_SUCCESS;
551 Canvas* pCanvas = __pEditDate->GetCanvasN();
552 SysAssertf((pCanvas != null), "Failed to get canvas.");
554 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
557 if (__title.IsEmpty() == false)
566 _DateTimeUtils dateTimeUtils;
567 monthString = dateTimeUtils.GetMonthString(GetMonth());
568 yearString.Format(10, L"%04d", GetYear());
569 dayString.Format(10, L"%02d", GetDay());
571 CalculateAreaBounds();
573 r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_DAY), dayString, DATETIME_ID_DAY);
574 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
575 r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_MONTH), monthString, DATETIME_ID_MONTH);
576 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
577 r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_YEAR), yearString, DATETIME_ID_YEAR);
578 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
580 if (__pEditDate->IsFocused())
591 _EditDatePresenter::DrawFocus(void)
593 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
595 Canvas* pCanvas = __pEditDate->GetCanvasN();
596 SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
598 if (__focusStatus == FOCUS_DAY)
600 bounds = GetDateAreaBounds(DATETIME_ID_DAY);
602 else if (__focusStatus == FOCUS_MONTH)
604 bounds = GetDateAreaBounds(DATETIME_ID_MONTH);
606 else if (__focusStatus == FOCUS_YEAR)
608 bounds = GetDateAreaBounds(DATETIME_ID_YEAR);
611 bounds.y = bounds.y - (__adjustFocusHeight / 2.0f);
612 bounds.height = bounds.height + __adjustFocusHeight;
614 result r = E_SUCCESS;
616 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pContentBgHighlightedColorReplacementBitmap))
618 r = pCanvas->DrawNinePatchedBitmap(bounds, *__pContentBgHighlightedColorReplacementBitmap);
619 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
623 r = pCanvas->DrawBitmap(bounds, *__pContentBgHighlightedColorReplacementBitmap);
624 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
637 _EditDatePresenter::UpdateLastSelectedValue(_DateTimeId id, bool isTouchPressed)
640 SetLastSelectedId(id);
641 __lastSelectedValue = "";
642 _DateTimeUtils dateTimeUtils;
644 if (GetLastSelectedId() == DATETIME_ID_YEAR)
646 __lastSelectedValue.Format(10, L"%04d", GetYear());
649 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
652 else if (GetLastSelectedId() == DATETIME_ID_MONTH)
654 __lastSelectedValue = dateTimeUtils.GetMonthString(GetMonth());
657 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
660 else if (GetLastSelectedId() == DATETIME_ID_DAY)
662 __lastSelectedValue.Format(10, L"%02d", GetDay());
665 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
669 __pEditDate->Invalidate();
674 _EditDatePresenter::CalculateAreaBounds(void)
676 result r = E_SUCCESS;
678 _DateTimeUtils dateTimeUtils;
679 int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
681 if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
683 __monthBounds.x = __dayBounds.x + __dayBounds.width + __elementMargin;
684 __yearBounds.x = __monthBounds.x + __monthBounds.width + __elementMargin;
686 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
688 __dayBounds.x = __monthBounds.x + __monthBounds.width + __elementMargin;
689 __yearBounds.x = __dayBounds.x + __dayBounds.width + __elementMargin;
691 else if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
693 __monthBounds.x = __yearBounds.x + __yearBounds.width + __elementMargin;
694 __dayBounds.x = __monthBounds.x + __monthBounds.width + __elementMargin;
696 else if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
698 __dayBounds.x = __yearBounds.x + __yearBounds.width + __elementMargin;
699 __monthBounds.x = __dayBounds.x + __dayBounds.width + __elementMargin;
706 _EditDatePresenter::DrawTitle(Canvas& canvas)
708 if (!__pEditDate->IsEnabled())
710 Color titleDisabledColor;
711 GET_COLOR_CONFIG(EDITDATE::TITLE_TEXT_DISABLED, titleDisabledColor);
712 __titleObject.SetForegroundColor(titleDisabledColor, 0, __titleObject.GetTextLength());
715 (_FontImpl::GetInstance(*__pFont))->SetSize(__titleFontSize);
716 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
717 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
718 __titleObject.Draw(*_CanvasImpl::GetInstance(canvas));
724 _EditDatePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, _DateTimeId boxId)
728 if (!__pEditDate->IsEnabled())
730 GET_COLOR_CONFIG(EDITDATE::TEXT_DISABLED, textColor);
734 GET_COLOR_CONFIG(EDITDATE::TEXT_NORMAL, textColor);
737 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN);
739 if (boxId == GetLastSelectedId() && boxId != DATETIME_ID_NONE)
741 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
742 GET_COLOR_CONFIG(EDITDATE::TEXT_PRESSED, textColor);
745 DrawContentBitmap(canvas, bounds, boxId);
747 FloatRectangle drawAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
748 drawAreaBounds = bounds;
750 TextSimple* pSimpleText = null;
751 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
752 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
754 __textObject.RemoveAll();
756 (_FontImpl::GetInstance(*__pFont))->SetSize(__dateFontSize);
757 __textObject.AppendElement(*pSimpleText);
759 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
760 __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength());
761 __textObject.SetBounds(drawAreaBounds);
762 __textObject.Draw(*_CanvasImpl::GetInstance(canvas));
768 _EditDatePresenter::DrawContentBitmap(Canvas& canvas, const FloatRectangle& bounds, _DateTimeId boxId)
770 result r = E_SUCCESS;
772 bool isCustomBitmap = false;
773 Bitmap* pReplacementBitmap = null;
774 Bitmap* pEffectBitmap = null;
776 if (!__pEditDate->IsEnabled())
778 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_DISABLED);
779 pReplacementBitmap = __pContentBgDisabledColorReplacementBitmap;
780 pEffectBitmap = __pContentBgEffectDisabledBitmap;
782 else if (GetLastSelectedId() != boxId)
784 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_NORMAL);
785 pReplacementBitmap = __pContentBgNormalColorReplacementBitmap;
786 pEffectBitmap = __pContentBgEffectNormalBitmap;
790 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED);
791 pReplacementBitmap = __pContentBgPressedColorReplacementBitmap;
792 pEffectBitmap = __pContentBgEffectPressedBitmap;
795 r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap);
796 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
800 r = DrawResourceBitmap(canvas, bounds, pEffectBitmap);
801 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
808 _EditDatePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
810 result r = E_SUCCESS;
817 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
819 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
820 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
824 r = canvas.DrawBitmap(bounds, *pBitmap);
825 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
832 _EditDatePresenter::GetBoxIdFromPosition(const FloatPoint& point) const
834 _DateTimeId displayBoxId = DATETIME_ID_NONE;
836 if (point.y < __dayBounds.y || point.y > __dayBounds.y + __dayBounds.height)
841 if (__dayBounds.Contains(point) == true)
843 displayBoxId = DATETIME_ID_DAY;
845 else if (__monthBounds.Contains(point) == true)
847 displayBoxId = DATETIME_ID_MONTH;
849 else if (__yearBounds.Contains(point) == true)
851 displayBoxId = DATETIME_ID_YEAR;
858 _EditDatePresenter::GetDateAreaBounds(_DateTimeId id) const
860 if (id == DATETIME_ID_DAY)
864 else if (id == DATETIME_ID_MONTH)
866 return __monthBounds;
868 else if (id == DATETIME_ID_YEAR)
874 return FloatRectangle();
879 _EditDatePresenter::GetTitleBounds(void) const
881 return __titleBounds;
885 _EditDatePresenter::SetLastSelectedId(_DateTimeId boxId)
887 __lastSelectedId = boxId;
892 _EditDatePresenter::GetLastSelectedId(void) const
894 return __lastSelectedId;
898 _EditDatePresenter::OnFontChanged(Font* pFont)
902 if (__pEditDate->GetDateTimeBar() != null)
904 __pEditDate->GetDateTimeBar()->SetFont(*pFont);
911 _EditDatePresenter::OnFontInfoRequested(unsigned long& style, float& size)
913 style = FONT_STYLE_PLAIN;
914 size = __dateFontSize;
920 _EditDatePresenter::SetFocusState(bool isFocused)
922 __isFocused = isFocused;
926 _EditDatePresenter::SetFocusedElement()
928 _DateTimeUtils dateTimeUtils;
929 int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
930 if (__focusStatus == FOCUS_NONE)
932 if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
934 __focusStatus = FOCUS_DAY;
936 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
938 __focusStatus = FOCUS_MONTH;
940 else if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
942 __focusStatus = FOCUS_YEAR;
944 else if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
946 __focusStatus = FOCUS_YEAR;
953 _EditDatePresenter::OnFocusLost(const _Control &source)
955 if (!__isEnterKeyPressed)
957 __focusStatus = FOCUS_NONE;
961 __isEnterKeyPressed = false;
963 __pEditDate->Invalidate();
968 _EditDatePresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
974 _KeyCode keyCode = keyInfo.GetKeyCode();
978 int displayValue = -1;
980 _DateTimeId boxId = DATETIME_ID_NONE;
981 _DateTimeUtils dateTimeUtils;
982 int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
988 if (__focusStatus == FOCUS_DAY)
990 if (localeDateFormat == DATE_FORMAT_DDMMYYYY || localeDateFormat == DATE_FORMAT_YYYYDDMM)
992 __focusStatus = FOCUS_MONTH;
994 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
996 __focusStatus = FOCUS_YEAR;
999 else if (__focusStatus == FOCUS_MONTH)
1001 if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
1003 __focusStatus = FOCUS_YEAR;
1005 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY || localeDateFormat == DATE_FORMAT_YYYYMMDD)
1007 __focusStatus = FOCUS_DAY;
1010 else if (__focusStatus == FOCUS_YEAR)
1012 if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
1014 __focusStatus = FOCUS_MONTH;
1016 else if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
1018 __focusStatus = FOCUS_DAY;
1021 __pEditDate->Invalidate();
1027 if (__focusStatus == FOCUS_DAY)
1029 if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
1031 __focusStatus = FOCUS_YEAR;
1033 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY || localeDateFormat == DATE_FORMAT_YYYYMMDD)
1035 __focusStatus = FOCUS_MONTH;
1038 else if (__focusStatus == FOCUS_MONTH)
1040 if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
1042 __focusStatus = FOCUS_YEAR;
1044 else if (localeDateFormat == DATE_FORMAT_DDMMYYYY || localeDateFormat == DATE_FORMAT_YYYYDDMM)
1046 __focusStatus = FOCUS_DAY;
1049 else if (__focusStatus == FOCUS_YEAR)
1051 if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
1053 __focusStatus = FOCUS_MONTH;
1055 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
1057 __focusStatus = FOCUS_DAY;
1060 __pEditDate->Invalidate();
1066 __isEnterKeyPressed = true;
1067 if (__focusStatus == FOCUS_DAY)
1069 _DateTimeUtils dateTimeUtils;
1070 maxValue = dateTimeUtils.CalculateMaxDay(GetYear(), GetMonth());
1071 minValue = DATETIME_DAY_MIN;
1072 displayValue = GetDay();
1073 boxId = DATETIME_ID_DAY;
1075 if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
1077 __pEditDate->GetDateTimeBar()->RemoveAllItems();
1081 else if (__focusStatus == FOCUS_MONTH)
1083 minValue = DATETIME_MONTH_MIN;
1084 maxValue = DATETIME_MONTH_MAX;
1085 displayValue = GetMonth();
1086 boxId = DATETIME_ID_MONTH;
1088 if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
1090 __pEditDate->GetDateTimeBar()->RemoveAllItems();
1093 else if (__focusStatus == FOCUS_YEAR)
1095 minValue = GetMinYear();
1096 maxValue = GetMaxYear();
1097 displayValue = GetYear();
1098 boxId = DATETIME_ID_YEAR;
1100 if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
1102 __pEditDate->GetDateTimeBar()->RemoveAllItems();
1105 FloatRectangle absoluteBounds = __pEditDate->GetAbsoluteBoundsF();
1107 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1108 bounds = GetDateAreaBounds(boxId);
1109 bounds.x += absoluteBounds.x;
1110 __pEditDate->GetDateTimeBar()->CalculateArrowBounds(bounds);
1111 __pEditDate->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
1112 __pEditDate->GetDateTimeBar()->SetVisibleState(true);
1113 __pEditDate->GetDateTimeBar()->Open();
1115 UpdateLastSelectedValue(boxId, false);
1127 _EditDatePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1129 SysTryReturn(NID_UI_CTRL, IsDatePickerEnabled() == true, true, E_SYSTEM,
1130 "[E_SYSTEM] A system error has occurred. EditDate instance is disabled.");
1132 if (&source != __pEditDate)
1137 __touchMoveHandled = false;
1139 FloatPoint point = touchinfo.GetCurrentPosition();
1141 _DateTimeId boxId = DATETIME_ID_NONE;
1142 boxId = GetBoxIdFromPosition(point);
1144 if (boxId < DATETIME_ID_YEAR || boxId > DATETIME_ID_DAY)
1146 __selectedId = DATETIME_ID_NONE;
1152 int displayValue = -1;
1154 if (boxId == DATETIME_ID_DAY)
1156 if (__pEditDate->GetDateTimeBar() != null)
1158 _DateTimeUtils dateTimeUtils;
1159 maxValue = dateTimeUtils.CalculateMaxDay(GetYear(), GetMonth());
1160 minValue = DATETIME_DAY_MIN;
1161 displayValue = GetDay();
1164 else if (boxId == DATETIME_ID_MONTH)
1166 minValue = DATETIME_MONTH_MIN;
1167 maxValue = DATETIME_MONTH_MAX;
1168 displayValue = GetMonth();
1170 else if (boxId == DATETIME_ID_YEAR)
1172 minValue = GetMinYear();
1173 maxValue = GetMaxYear();
1174 displayValue = GetYear();
1177 if (__pEditDate->GetDateTimeBar() != null)
1179 if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
1181 __pEditDate->GetDateTimeBar()->RemoveAllItems();
1184 result r = __pEditDate->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
1187 __selectedId = DATETIME_ID_NONE;
1192 __selectedId = boxId;
1198 _EditDatePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1200 SysTryReturn(NID_UI_CTRL, IsDatePickerEnabled() == true, true, E_SYSTEM,
1201 "[E_SYSTEM] A system error has occurred. EditDate instance is disabled.");
1203 if (&source != __pEditDate)
1208 FloatPoint point = touchinfo.GetCurrentPosition();
1210 _DateTimeId boxId = DATETIME_ID_NONE;
1211 boxId = GetBoxIdFromPosition(point);
1213 if (boxId == GetLastSelectedId() || boxId != __selectedId || boxId == DATETIME_ID_NONE)
1215 if (__pEditDate->GetDateTimeBar() != null && __pEditDate->GetDateTimeBar()->IsActivated())
1217 __pEditDate->GetDateTimeBar()->SetVisibleState(false);
1218 __pEditDate->GetDateTimeBar()->Close();
1221 __selectedId = DATETIME_ID_NONE;
1222 SetLastSelectedId(__selectedId);
1229 UpdateLastSelectedValue(__selectedId, true);
1231 if ((__pEditDate->GetDateTimeBar() != null) && (GetLastSelectedId() != DATETIME_ID_NONE))
1233 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1234 bounds = GetDateAreaBounds(GetLastSelectedId());
1235 FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1236 absoluteBounds = __pEditDate->GetAbsoluteBoundsF();
1237 bounds.x += absoluteBounds.x;
1239 __pEditDate->GetDateTimeBar()->CalculateArrowBounds(bounds);
1241 if (__pEditDate->GetDateTimeBar()->IsActivated())
1243 __pEditDate->GetDateTimeBar()->RefreshItems();
1247 __pEditDate->GetDateTimeBar()->SetVisibleState(true);
1248 __pEditDate->GetDateTimeBar()->Open();
1252 __selectedId = DATETIME_ID_NONE;
1257 _EditDatePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1259 if (&source != __pEditDate)
1264 __selectedId = DATETIME_ID_NONE;
1270 _EditDatePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1272 if (&source != __pEditDate)
1277 if (__pEditDate->GetDateTimeBar() != null && __pEditDate->GetDateTimeBar()->IsActivated())
1286 _EditDatePresenter::OnTouchMoveHandled(const _Control& control)
1288 __touchMoveHandled = true;
1289 __selectedId = DATETIME_ID_NONE;
1295 _EditDatePresenter::Animate(void)
1297 SysAssertf((__pFont != null), "Font instance must not be null.");
1299 (_FontImpl::GetInstance(*__pFont))->SetSize(__dateFontSize);
1301 result r = E_SUCCESS;
1302 FloatRectangle rect;
1308 _DateTimeUtils dateTimeUtils;
1309 monthString = dateTimeUtils.GetMonthString(GetMonth());
1310 yearString.Format(10, L"%04d", GetYear());
1311 dayString.Format(10, L"%02d", GetDay());
1313 if (GetLastSelectedId() == DATETIME_ID_DAY)
1315 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(dayString) == false), E_SUCCESS, "Day string matched.");
1317 newValue = dayString;
1318 rect = GetDateAreaBounds(DATETIME_ID_DAY);
1320 else if (GetLastSelectedId() == DATETIME_ID_MONTH)
1322 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(monthString) == false), E_SUCCESS, "Month string matched.");
1324 newValue = monthString;
1325 rect = GetDateAreaBounds(DATETIME_ID_MONTH);
1327 else if (GetLastSelectedId() == DATETIME_ID_YEAR)
1329 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(yearString) == false), E_SUCCESS, "Year string matched.");
1331 newValue = yearString;
1332 rect = GetDateAreaBounds(DATETIME_ID_YEAR);
1335 FloatDimension newTextDim;
1336 FloatDimension oldTextDim;
1337 FloatPoint textPoint;
1338 VisualElement* pNewVisualElement = null;
1339 VisualElement* pOldVisualElement = null;
1340 VisualElement* pEditDateElement = null;
1341 VisualElementPropertyAnimation* pNewBoundsAnimation = null;
1342 VisualElementPropertyAnimation* pOldBoundsAnimation = null;
1343 Canvas *pCanvas = null;
1344 Color contentBgColor;
1345 Color textPressedColor;
1347 GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_PRESSED, contentBgColor);
1348 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textPressedColor);
1350 __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim);
1351 __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim);
1353 if (newTextDim.width > oldTextDim.width)
1355 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1359 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1362 SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditDate->GetBoundsF().width), E_SUCCESS, "Rolling animation cann't be played.");
1364 __isAnimating = true;
1366 __pContentProvider = new (std::nothrow) VisualElement();
1367 SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1369 r = __pContentProvider->Construct();
1370 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1372 __pContentProvider->SetShowState(true);
1373 __pContentProvider->SetClipChildrenEnabled(true);
1374 __pContentProvider->SetImplicitAnimationEnabled(false);
1376 pEditDateElement = __pEditDate->GetVisualElement();
1377 r = GetLastResult();
1378 SysTryCatch(NID_UI_CTRL, (pEditDateElement != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1380 pNewVisualElement = new (std::nothrow) VisualElement();
1381 SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1383 r = pNewVisualElement->Construct();
1386 pNewVisualElement->Destroy();
1388 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1390 pOldVisualElement = new (std::nothrow) VisualElement();
1391 if (pOldVisualElement == null)
1393 pNewVisualElement->Destroy();
1395 SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1397 r = pOldVisualElement->Construct();
1400 pNewVisualElement->Destroy();
1401 pOldVisualElement->Destroy();
1403 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1405 pNewVisualElement->SetShowState(true);
1406 pOldVisualElement->SetShowState(true);
1408 if (newTextDim.width > oldTextDim.width)
1410 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1411 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1412 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1413 pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1415 rect.x = static_cast<int>(__pContentProvider->GetBounds().x);
1416 rect.y = static_cast<int>(__pContentProvider->GetBounds().y);
1417 rect.width = static_cast<int>(__pContentProvider->GetBounds().width);
1418 rect.height = static_cast<int>(__pContentProvider->GetBounds().height);
1420 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1421 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1423 pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1427 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1428 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1429 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1430 pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1432 rect.x = static_cast<int>(__pContentProvider->GetBounds().x);
1433 rect.y = static_cast<int>(__pContentProvider->GetBounds().y);
1434 rect.width = static_cast<int>(__pContentProvider->GetBounds().width);
1435 rect.height = static_cast<int>(__pContentProvider->GetBounds().height);
1437 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1438 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1440 pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1444 pCanvas = pEditDateElement->GetCanvasN(rect);
1445 pCanvas->SetBackgroundColor(contentBgColor);
1449 pEditDateElement->AttachChild(*__pContentProvider);
1451 __pContentProvider->AttachChild(*pOldVisualElement);
1452 __pContentProvider->AttachChild(*pNewVisualElement);
1454 pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1455 SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1457 pNewBoundsAnimation->SetDuration(300);
1458 pNewBoundsAnimation->SetPropertyName("bounds.position");
1459 pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.height * 1.0f)));
1460 pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f)));
1461 pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1463 pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1464 SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1466 pOldBoundsAnimation->SetDuration(300);
1467 pOldBoundsAnimation->SetPropertyName("bounds.position");
1468 pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f)));
1469 pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f)));
1470 pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1472 pCanvas = pOldVisualElement->GetCanvasN();
1473 r = GetLastResult();
1474 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1476 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1478 pCanvas->SetForegroundColor(textPressedColor);
1479 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
1480 pCanvas->SetFont(*__pFont);
1481 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), __lastSelectedValue);
1486 pCanvas = pNewVisualElement->GetCanvasN();
1487 r = GetLastResult();
1488 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1490 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1492 pCanvas->SetForegroundColor(textPressedColor);
1493 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
1494 pCanvas->SetFont(*__pFont);
1495 pCanvas->DrawText(FloatPoint(0.0f, 0.0f), newValue);
1500 pOldVisualElement->SetImplicitAnimationEnabled(false);
1501 pOldVisualElement->AddAnimation(*pOldBoundsAnimation);
1503 pNewVisualElement->SetImplicitAnimationEnabled(false);
1504 pNewVisualElement->AddAnimation(*pNewBoundsAnimation);
1506 delete pOldBoundsAnimation;
1507 delete pNewBoundsAnimation;
1512 __isAnimating = false;
1513 __pContentProvider->Destroy();
1515 delete pNewBoundsAnimation;
1516 pNewBoundsAnimation = null;
1518 delete pOldBoundsAnimation;
1519 pOldBoundsAnimation = null;
1528 _EditDatePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally)
1530 result r = E_SUCCESS;
1531 __isAnimating = false;
1533 VisualElement* pEditDateElement = __pEditDate->GetVisualElement();
1534 r = GetLastResult();
1535 SysTryReturnVoidResult(NID_UI_CTRL, (pEditDateElement != null), r, "[%s] Propagating.", GetErrorMessage(r));
1537 pEditDateElement->DetachChild(*__pContentProvider);
1538 __pContentProvider->Destroy();
1544 }}} // Tizen::Ui::Controls