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 , __focusId(DATETIME_ID_NONE)
69 , __touchMoveHandled(false)
73 , __elementMargin(0.0f)
74 , __dividerLineHeight(0.0f)
75 , __titleFontSize(0.0f)
76 , __dateFontSize(0.0f)
77 , __pContentProvider(null)
78 , __isAnimating(false)
79 , __isEditDateInitialized(false)
80 , __elementWidth(0.0f)
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;
115 if (__pContentProvider)
117 __pContentProvider->Destroy();
118 __pContentProvider = null;
123 _EditDatePresenter::CreateInstanceN(const _EditDate& editDate, const String& title)
125 _EditDatePresenter* pEditDatePresenter = new (std::nothrow) _EditDatePresenter;
126 SysTryReturn(NID_UI_CTRL, pEditDatePresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
128 pEditDatePresenter->__pEditDate = const_cast <_EditDate*>(&editDate);
130 pEditDatePresenter->__pEditDateTimeModel = new (std::nothrow) _DateTimeModel;
131 SysTryCatch(NID_UI_CTRL, pEditDatePresenter->__pEditDateTimeModel, , E_OUT_OF_MEMORY,
132 "[E_OUT_OF_MEMORY] Memory allocation failed.");
133 pEditDatePresenter->SetTitle(title);
135 return pEditDatePresenter;
138 delete pEditDatePresenter;
143 _EditDatePresenter::SetTitle(const String& title)
149 _EditDatePresenter::Initialize(void)
151 result r = E_SUCCESS;
152 float editDateHeight = 0.0f;
153 float dateLeftMargin = 0.0f;
154 float titleLeftMargin = 0.0f;
155 float titledateMargin = 0.0f;
156 float dateHeight = 0.0f;
157 float monthYearMinWidth = 0.0f;
158 float dayElementWidth = 0.0f;
159 float dayElementMinWidth = 0.0f;
160 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
162 GET_SHAPE_CONFIG(EDITDATE::HEIGHT, __pEditDate->GetOrientation(), editDateHeight);
163 GET_SHAPE_CONFIG(EDITDATE::TITLE_TEXT_LEFT_MARGIN, __pEditDate->GetOrientation(), titleLeftMargin);
164 GET_SHAPE_CONFIG(EDITDATE::ITEM_DIVIDER_HEIGHT, __pEditDate->GetOrientation(), __dividerLineHeight);
165 GET_SHAPE_CONFIG(EDITDATE::TEXT_FONT_SIZE, __pEditDate->GetOrientation(), __titleFontSize);
166 GET_SHAPE_CONFIG(EDITDATE::DATE_FONT_SIZE, __pEditDate->GetOrientation(), __dateFontSize);
167 GET_SHAPE_CONFIG(EDITDATE::TITLE_DATE_MARGIN, __pEditDate->GetOrientation(), titledateMargin);
168 GET_SHAPE_CONFIG(EDITDATE::DATE_HEIGHT, __pEditDate->GetOrientation(), dateHeight);
169 GET_SHAPE_CONFIG(EDITDATE::TITLE_HEIGHT, __pEditDate->GetOrientation(), __titleBounds.height);
170 GET_SHAPE_CONFIG(EDITDATE::MONTH_YEAR_ELEMENT_WIDTH, __pEditDate->GetOrientation(), __elementWidth);
171 GET_SHAPE_CONFIG(EDITDATE::DAY_ELEMENT_WIDTH, __pEditDate->GetOrientation(), dayElementWidth);
172 GET_SHAPE_CONFIG(EDITDATE::ELEMENT_MARGIN, __pEditDate->GetOrientation(), __elementMargin);
173 GET_SHAPE_CONFIG(EDITDATE::DATE_TEXT_LEFT_MARGIN, __pEditDate->GetOrientation(), dateLeftMargin);
175 GET_SHAPE_CONFIG(EDITDATE::MONTH_YEAR_ELEMENT_MIN_WIDTH, __pEditDate->GetOrientation(), monthYearMinWidth);
176 GET_SHAPE_CONFIG(EDITDATE::DAY_ELEMENT_MIN_WIDTH, __pEditDate->GetOrientation(), dayElementMinWidth);
178 if (__pEditDate->GetBoundsF().height > editDateHeight)
180 editDateHeight = __pEditDate->GetBoundsF().height;
183 __pFont = __pEditDate->GetFallbackFont();
185 SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
187 if (__title.IsEmpty() == false)
189 __titleBounds.x = titleLeftMargin;
190 __titleBounds.y = (editDateHeight - (__titleBounds.height + titledateMargin + dateHeight)) / 2.0f;
191 __titleBounds.width = __pEditDate->GetBoundsF().width - __titleBounds.x;
193 bounds.y = __titleBounds.y + __titleBounds.height + titledateMargin;
195 if (!__isEditDateInitialized)
197 r = InitializeTitleObject();
198 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
201 __titleObject.SetBounds(__titleBounds);
205 bounds.y = (editDateHeight - dateHeight) / 2.0f;
209 dayElementWidth = GetElementWidth(dayElementMinWidth, dayElementWidth);
210 __elementWidth = GetElementWidth(monthYearMinWidth, __elementWidth);
212 __dayBounds.height = dateHeight;
213 __monthBounds.height = dateHeight;
214 __yearBounds.height = dateHeight;
216 __dayBounds.width = dayElementWidth;
217 __monthBounds.width = __elementWidth;
218 __yearBounds.width = __elementWidth;
220 __dayBounds.x = dateLeftMargin;
221 __monthBounds.x = dateLeftMargin;
222 __yearBounds.x = dateLeftMargin;
224 __dayBounds.y = bounds.y;
225 __monthBounds.y = bounds.y;
226 __yearBounds.y = bounds.y;
228 if (!__isEditDateInitialized)
231 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
233 r = InitializeTextObject();
234 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
237 __isEditDateInitialized = true;
239 CalculateAreaBounds();
245 _EditDatePresenter::InitializeTitleObject(void)
247 result r = E_SUCCESS;
249 Color titleNormalColor;
251 GET_COLOR_CONFIG(EDITDATE::TITLE_TEXT_NORMAL, titleNormalColor);
253 r = __titleObject.Construct();
254 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
256 TextSimple* pSimpleText = null;
258 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
259 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
261 __titleObject.AppendElement(*pSimpleText);
263 __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength());
264 __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
265 __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
266 __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
267 __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
268 __titleObject.SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL);
274 _EditDatePresenter::InitializeTextObject(void)
276 result r = E_SUCCESS;
278 r = __textObject.Construct();
279 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
281 TextSimple* pSimpleText = null;
283 pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
284 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
286 __textObject.AppendElement(*pSimpleText);
288 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
289 __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
290 __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
291 __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
297 _EditDatePresenter::GetElementWidth(const float minWidth, const float maxWidth) const
299 FloatRectangle bounds;
300 FloatDimension minSize;
301 bounds = __pEditDate->GetBoundsF();
303 float elementWidth = 0.0f;
304 float editDateWidth = 0.0f;
306 GET_SHAPE_CONFIG(EDITDATE::WIDTH, __pEditDate->GetOrientation(), editDateWidth);
307 GET_DIMENSION_CONFIG(EDITDATE::MIN_SIZE, __pEditDate->GetOrientation(), minSize);
309 if (bounds.width >= editDateWidth)
314 if (bounds.width <= minSize.width)
316 elementWidth = minWidth;
318 else if (bounds.width < editDateWidth && bounds.width > minSize.width)
320 elementWidth = maxWidth -
321 ((maxWidth - minWidth) / (editDateWidth - minSize.width)) * (editDateWidth - bounds.width);
328 _EditDatePresenter::LoadResource(void)
330 result r = E_SUCCESS;
332 Color contentNormalBgColor;
333 Color contentDisabledBgColor;
334 Color contentPressedColor;
335 Color contentHighlightedColor;
337 Bitmap* pTempBitmap = null;
339 GET_COLOR_CONFIG(EDITDATE::CONTENT_BG_NORMAL, contentNormalBgColor);
340 GET_COLOR_CONFIG(EDITDATE::CONTENT_BG_DISABLED, contentDisabledBgColor);
341 GET_COLOR_CONFIG(EDITDATE::CONTENT_BG_PRESSED, contentPressedColor);
342 GET_COLOR_CONFIG(EDITDATE::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
344 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
345 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
347 __pContentBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentNormalBgColor);
348 SysTryCatch(NID_UI_CTRL, (__pContentBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
349 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
354 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
355 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
357 __pContentBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentPressedColor);
358 SysTryCatch(NID_UI_CTRL, (__pContentBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
359 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
364 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
365 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
367 __pContentBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentDisabledBgColor);
368 SysTryCatch(NID_UI_CTRL, (__pContentBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
369 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
374 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
375 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
377 __pContentBgHighlightedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
378 SysTryCatch(NID_UI_CTRL, (__pContentBgHighlightedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
379 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
381 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectNormalBitmap);
382 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
384 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectPressedBitmap);
385 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
387 r = GET_BITMAP_CONFIG_N(EDITDATE::CONTENT_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectDisabledBitmap);
388 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
400 delete __pContentBgNormalColorReplacementBitmap;
401 __pContentBgNormalColorReplacementBitmap = null;
403 delete __pContentBgPressedColorReplacementBitmap;
404 __pContentBgPressedColorReplacementBitmap = null;
406 delete __pContentBgDisabledColorReplacementBitmap;
407 __pContentBgDisabledColorReplacementBitmap = null;
409 delete __pContentBgHighlightedColorReplacementBitmap;
410 __pContentBgHighlightedColorReplacementBitmap = null;
412 delete __pContentBgEffectNormalBitmap;
413 __pContentBgEffectNormalBitmap = null;
415 delete __pContentBgEffectPressedBitmap;
416 __pContentBgEffectPressedBitmap = null;
418 delete __pContentBgEffectDisabledBitmap;
419 __pContentBgEffectDisabledBitmap = null;
425 _EditDatePresenter::GetDate(void) const
427 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
430 date.SetValue(GetYear(), GetMonth(), GetDay(), DATETIME_HOUR_MIN, DATETIME_MINUTE_MIN);
436 _EditDatePresenter::GetDay(void) const
438 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
440 return __pEditDateTimeModel->GetDay();
444 _EditDatePresenter::GetMonth(void) const
446 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
448 return __pEditDateTimeModel->GetMonth();
452 _EditDatePresenter::GetYear(void) const
454 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
456 return __pEditDateTimeModel->GetYear();
460 _EditDatePresenter::SetDate(const DateTime& date)
462 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
464 __pEditDateTimeModel->SetDateTime(date);
469 _EditDatePresenter::SetCurrentDate(void)
471 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
473 __pEditDateTimeModel->SetCurrentDateTime();
478 _EditDatePresenter::SetYear(int year)
480 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
482 return __pEditDateTimeModel->SetYear(year);
486 _EditDatePresenter::SetMonth(int month)
488 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
490 return __pEditDateTimeModel->SetMonth(month);
494 _EditDatePresenter::SetDay(int day)
496 SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null.");
498 return __pEditDateTimeModel->SetDay(day);
502 _EditDatePresenter::SetDatePickerEnabled(bool enable)
504 __datePickerEnabled = enable;
509 _EditDatePresenter::IsDatePickerEnabled(void) const
511 return __datePickerEnabled;
515 _EditDatePresenter::SetMinYear(int minYear)
517 return __pEditDateTimeModel->SetMinYear(minYear);
521 _EditDatePresenter::SetMaxYear(int maxYear)
523 return __pEditDateTimeModel->SetMaxYear(maxYear);
527 _EditDatePresenter::GetMinYear(void) const
532 __pEditDateTimeModel->GetYearRange(minYear, maxYear);
538 _EditDatePresenter::GetMaxYear(void) const
543 __pEditDateTimeModel->GetYearRange(minYear, maxYear);
549 _EditDatePresenter::Draw(void)
551 result r = E_SUCCESS;
557 Canvas* pCanvas = __pEditDate->GetCanvasN();
559 SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating. Failed to get canvas.", GetErrorMessage(r));
561 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
564 if (__title.IsEmpty() == false)
573 _DateTimeUtils dateTimeUtils;
574 monthString = dateTimeUtils.GetMonthString(GetMonth());
575 yearString.Format(10, L"%04d", GetYear());
576 dayString.Format(10, L"%02d", GetDay());
578 CalculateAreaBounds();
580 r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_DAY), dayString, DATETIME_ID_DAY);
581 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
582 r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_MONTH), monthString, DATETIME_ID_MONTH);
583 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
584 r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_YEAR), yearString, DATETIME_ID_YEAR);
585 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
594 _EditDatePresenter::DrawFocus(void)
596 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
598 Canvas* pCanvas = __pEditDate->GetCanvasN();
599 SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
601 if (__focusId == DATETIME_ID_DAY)
603 bounds = GetDateAreaBounds(DATETIME_ID_DAY);
605 else if (__focusId == DATETIME_ID_MONTH)
607 bounds = GetDateAreaBounds(DATETIME_ID_MONTH);
609 else if (__focusId == DATETIME_ID_YEAR)
611 bounds = GetDateAreaBounds(DATETIME_ID_YEAR);
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, __pEditDate);
652 else if (GetLastSelectedId() == DATETIME_ID_MONTH)
654 __lastSelectedValue = dateTimeUtils.GetMonthString(GetMonth());
657 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pEditDate);
660 else if (GetLastSelectedId() == DATETIME_ID_DAY)
662 __lastSelectedValue.Format(10, L"%02d", GetDay());
665 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pEditDate);
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)
727 float contentTextMargin;
729 GET_SHAPE_CONFIG(EDITDATE::CONTENT_TEXT_MARGIN, __pEditDate->GetOrientation(), contentTextMargin);
731 if (!__pEditDate->IsEnabled())
733 GET_COLOR_CONFIG(EDITDATE::TEXT_DISABLED, textColor);
737 GET_COLOR_CONFIG(EDITDATE::TEXT_NORMAL, textColor);
740 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN);
742 if (boxId == GetLastSelectedId() && boxId != DATETIME_ID_NONE)
744 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
745 GET_COLOR_CONFIG(EDITDATE::TEXT_PRESSED, textColor);
748 DrawContentBitmap(canvas, bounds, boxId);
750 FloatRectangle drawAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
751 drawAreaBounds.x = bounds.x + contentTextMargin;
752 drawAreaBounds.y = bounds.y + contentTextMargin;
753 drawAreaBounds.width = bounds.width - (contentTextMargin * 2.0f);
754 drawAreaBounds.height = bounds.height - (contentTextMargin * 2.0f);
756 TextSimple* pSimpleText = null;
757 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
758 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
760 __textObject.RemoveAll();
761 if (__isFocused && __focusId == boxId)
763 GET_COLOR_CONFIG(EDITDATE::TEXT_HIGHLIGHTED, textColor);
767 (_FontImpl::GetInstance(*__pFont))->SetSize(__dateFontSize);
768 __textObject.AppendElement(*pSimpleText);
770 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
771 __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength());
772 __textObject.SetBounds(drawAreaBounds);
773 __textObject.Draw(*_CanvasImpl::GetInstance(canvas));
779 _EditDatePresenter::DrawContentBitmap(Canvas& canvas, const FloatRectangle& bounds, _DateTimeId boxId)
781 result r = E_SUCCESS;
783 bool isCustomBitmap = false;
784 Bitmap* pReplacementBitmap = null;
785 Bitmap* pEffectBitmap = null;
787 if (!__pEditDate->IsEnabled())
789 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_DISABLED);
790 pReplacementBitmap = __pContentBgDisabledColorReplacementBitmap;
791 pEffectBitmap = __pContentBgEffectDisabledBitmap;
793 else if (GetLastSelectedId() != boxId)
795 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_NORMAL);
796 pReplacementBitmap = __pContentBgNormalColorReplacementBitmap;
797 pEffectBitmap = __pContentBgEffectNormalBitmap;
801 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED);
802 pReplacementBitmap = __pContentBgPressedColorReplacementBitmap;
803 pEffectBitmap = __pContentBgEffectPressedBitmap;
806 r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap);
807 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
811 r = DrawResourceBitmap(canvas, bounds, pEffectBitmap);
812 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
819 _EditDatePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
821 result r = E_SUCCESS;
828 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
830 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
831 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
835 r = canvas.DrawBitmap(bounds, *pBitmap);
836 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
843 _EditDatePresenter::GetBoxIdFromPosition(const FloatPoint& point) const
845 _DateTimeId displayBoxId = DATETIME_ID_NONE;
847 if (point.y < __dayBounds.y || point.y > __dayBounds.y + __dayBounds.height)
852 if (__dayBounds.Contains(point) == true)
854 displayBoxId = DATETIME_ID_DAY;
856 else if (__monthBounds.Contains(point) == true)
858 displayBoxId = DATETIME_ID_MONTH;
860 else if (__yearBounds.Contains(point) == true)
862 displayBoxId = DATETIME_ID_YEAR;
869 _EditDatePresenter::GetDateAreaBounds(_DateTimeId id) const
871 if (id == DATETIME_ID_DAY)
875 else if (id == DATETIME_ID_MONTH)
877 return __monthBounds;
879 else if (id == DATETIME_ID_YEAR)
885 return FloatRectangle();
890 _EditDatePresenter::GetTitleBounds(void) const
892 return __titleBounds;
896 _EditDatePresenter::SetLastSelectedId(_DateTimeId boxId)
898 __lastSelectedId = boxId;
903 _EditDatePresenter::GetLastSelectedId(void) const
905 return __lastSelectedId;
909 _EditDatePresenter::OnFontChanged(Font* pFont)
913 if (__pEditDate->GetDateTimeBar() != null)
915 __pEditDate->GetDateTimeBar()->SetFont(*pFont);
922 _EditDatePresenter::OnFontInfoRequested(unsigned long& style, float& size)
924 style = FONT_STYLE_PLAIN;
925 size = __dateFontSize;
931 _EditDatePresenter::SetFocusState(bool isFocused)
933 __isFocused = isFocused;
937 _EditDatePresenter::SetFocusedElement(void)
939 _DateTimeUtils dateTimeUtils;
940 if (__isEnterKeyPressed)
942 __isEnterKeyPressed = false;
945 int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
946 if (__focusId == DATETIME_ID_NONE)
948 if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
950 __focusId = DATETIME_ID_DAY;
952 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
954 __focusId = DATETIME_ID_MONTH;
956 else if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
958 __focusId = DATETIME_ID_YEAR;
960 else if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
962 __focusId = DATETIME_ID_YEAR;
969 _EditDatePresenter::OnFocusLost(const _Control &source)
971 if (!__isEnterKeyPressed)
973 __focusId = DATETIME_ID_NONE;
976 __pEditDate->Invalidate();
981 _EditDatePresenter::OnFocusModeStateChanged(void)
984 __focusId = DATETIME_ID_NONE;
985 __pEditDate->Invalidate();
990 _EditDatePresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
996 _KeyCode keyCode = keyInfo.GetKeyCode();
1000 int displayValue = -1;
1002 _DateTimeId boxId = DATETIME_ID_NONE;
1003 _DateTimeUtils dateTimeUtils;
1004 int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
1010 if (__focusId == DATETIME_ID_DAY)
1012 if (localeDateFormat == DATE_FORMAT_DDMMYYYY || localeDateFormat == DATE_FORMAT_YYYYDDMM)
1014 __focusId = DATETIME_ID_MONTH;
1016 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
1018 __focusId = DATETIME_ID_YEAR;
1025 else if (__focusId == DATETIME_ID_MONTH)
1027 if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
1029 __focusId = DATETIME_ID_YEAR;
1031 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY || localeDateFormat == DATE_FORMAT_YYYYMMDD)
1033 __focusId = DATETIME_ID_DAY;
1040 else if (__focusId == DATETIME_ID_YEAR)
1042 if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
1044 __focusId = DATETIME_ID_MONTH;
1046 else if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
1048 __focusId = DATETIME_ID_DAY;
1055 __pEditDate->Invalidate();
1061 if (__focusId == DATETIME_ID_DAY)
1063 if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
1065 __focusId = DATETIME_ID_YEAR;
1067 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY || localeDateFormat == DATE_FORMAT_YYYYMMDD)
1069 __focusId = DATETIME_ID_MONTH;
1076 else if (__focusId == DATETIME_ID_MONTH)
1078 if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
1080 __focusId = DATETIME_ID_YEAR;
1082 else if (localeDateFormat == DATE_FORMAT_DDMMYYYY || localeDateFormat == DATE_FORMAT_YYYYDDMM)
1084 __focusId = DATETIME_ID_DAY;
1091 else if (__focusId == DATETIME_ID_YEAR)
1093 if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
1095 __focusId = DATETIME_ID_MONTH;
1097 else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
1099 __focusId = DATETIME_ID_DAY;
1106 __pEditDate->Invalidate();
1112 __isEnterKeyPressed = true;
1113 if (__focusId == DATETIME_ID_DAY)
1115 _DateTimeUtils dateTimeUtils;
1116 maxValue = dateTimeUtils.CalculateMaxDay(GetYear(), GetMonth());
1117 minValue = DATETIME_DAY_MIN;
1118 displayValue = GetDay();
1119 boxId = DATETIME_ID_DAY;
1121 if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
1123 __pEditDate->GetDateTimeBar()->RemoveAllItems();
1127 else if (__focusId == DATETIME_ID_MONTH)
1129 minValue = DATETIME_MONTH_MIN;
1130 maxValue = DATETIME_MONTH_MAX;
1131 displayValue = GetMonth();
1132 boxId = DATETIME_ID_MONTH;
1134 if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
1136 __pEditDate->GetDateTimeBar()->RemoveAllItems();
1139 else if (__focusId == DATETIME_ID_YEAR)
1141 minValue = GetMinYear();
1142 maxValue = GetMaxYear();
1143 displayValue = GetYear();
1144 boxId = DATETIME_ID_YEAR;
1146 if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
1148 __pEditDate->GetDateTimeBar()->RemoveAllItems();
1151 FloatRectangle absoluteBounds = __pEditDate->GetAbsoluteBoundsF();
1153 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1154 bounds = GetDateAreaBounds(boxId);
1155 bounds.x += absoluteBounds.x;
1156 __pEditDate->GetDateTimeBar()->CalculateArrowBounds(bounds);
1157 __pEditDate->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
1158 __pEditDate->GetDateTimeBar()->SetVisibleState(true);
1159 __pEditDate->GetDateTimeBar()->Open();
1161 UpdateLastSelectedValue(boxId, false);
1173 _EditDatePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1175 SysTryReturn(NID_UI_CTRL, IsDatePickerEnabled() == true, true, E_SYSTEM,
1176 "[E_SYSTEM] A system error has occurred. EditDate instance is disabled.");
1178 if (&source != __pEditDate)
1183 __touchMoveHandled = false;
1185 FloatPoint point = touchinfo.GetCurrentPosition();
1187 _DateTimeId boxId = DATETIME_ID_NONE;
1188 boxId = GetBoxIdFromPosition(point);
1190 if (boxId < DATETIME_ID_YEAR || boxId > DATETIME_ID_DAY)
1192 __selectedId = DATETIME_ID_NONE;
1198 int displayValue = -1;
1200 if (boxId == DATETIME_ID_DAY)
1202 if (__pEditDate->GetDateTimeBar() != null)
1204 _DateTimeUtils dateTimeUtils;
1205 maxValue = dateTimeUtils.CalculateMaxDay(GetYear(), GetMonth());
1206 minValue = DATETIME_DAY_MIN;
1207 displayValue = GetDay();
1210 else if (boxId == DATETIME_ID_MONTH)
1212 minValue = DATETIME_MONTH_MIN;
1213 maxValue = DATETIME_MONTH_MAX;
1214 displayValue = GetMonth();
1216 else if (boxId == DATETIME_ID_YEAR)
1218 minValue = GetMinYear();
1219 maxValue = GetMaxYear();
1220 displayValue = GetYear();
1223 if (__pEditDate->GetDateTimeBar() != null)
1225 if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
1227 __pEditDate->GetDateTimeBar()->RemoveAllItems();
1230 result r = __pEditDate->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
1233 __selectedId = DATETIME_ID_NONE;
1238 __selectedId = boxId;
1244 _EditDatePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1246 SysTryReturn(NID_UI_CTRL, IsDatePickerEnabled() == true, true, E_SYSTEM,
1247 "[E_SYSTEM] A system error has occurred. EditDate instance is disabled.");
1249 if (&source != __pEditDate)
1254 FloatPoint point = touchinfo.GetCurrentPosition();
1256 _DateTimeId boxId = DATETIME_ID_NONE;
1257 boxId = GetBoxIdFromPosition(point);
1259 if (boxId == GetLastSelectedId() || boxId != __selectedId || boxId == DATETIME_ID_NONE)
1261 if (__pEditDate->GetDateTimeBar() != null && __pEditDate->GetDateTimeBar()->IsActivated())
1263 __pEditDate->GetDateTimeBar()->CloseDateTimeBar();
1266 __selectedId = DATETIME_ID_NONE;
1267 SetLastSelectedId(__selectedId);
1274 UpdateLastSelectedValue(__selectedId, true);
1276 if ((__pEditDate->GetDateTimeBar() != null) && (GetLastSelectedId() != DATETIME_ID_NONE))
1278 __pEditDate->SetFocused(true);
1280 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1281 bounds = GetDateAreaBounds(GetLastSelectedId());
1282 FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1283 absoluteBounds = __pEditDate->GetAbsoluteBoundsF();
1284 bounds.x += absoluteBounds.x;
1286 __pEditDate->GetDateTimeBar()->CalculateArrowBounds(bounds);
1288 if (__pEditDate->GetDateTimeBar()->IsActivated())
1290 __pEditDate->GetDateTimeBar()->RefreshItems();
1294 __pEditDate->GetDateTimeBar()->SetVisibleState(true);
1295 __pEditDate->GetDateTimeBar()->Open();
1299 __selectedId = DATETIME_ID_NONE;
1304 _EditDatePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1306 if (&source != __pEditDate)
1311 __selectedId = DATETIME_ID_NONE;
1317 _EditDatePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1319 if (&source != __pEditDate)
1324 if (__pEditDate->GetDateTimeBar() != null && __pEditDate->GetDateTimeBar()->IsActivated())
1333 _EditDatePresenter::OnTouchMoveHandled(const _Control& control)
1335 __touchMoveHandled = true;
1336 __selectedId = DATETIME_ID_NONE;
1342 _EditDatePresenter::Animate(void)
1344 SysTryReturnVoidResult(NID_UI_CTRL, !__isAnimating, E_SUCCESS, "Rolling animation is in progress.");
1345 SysAssertf((__pFont != null), "Font instance must not be null.");
1347 result r = E_SUCCESS;
1348 FloatRectangle rect;
1353 FloatPoint textPoint;
1354 TextSimple* pOldSimpleText = null;
1355 TextSimple* pNewSimpleText = null;
1357 _DateTimeUtils dateTimeUtils;
1358 monthString = dateTimeUtils.GetMonthString(GetMonth());
1359 yearString.Format(10, L"%04d", GetYear());
1360 dayString.Format(10, L"%02d", GetDay());
1362 if (GetLastSelectedId() == DATETIME_ID_DAY)
1364 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(dayString) == false), E_SUCCESS, "Day string matched.");
1366 newValue = dayString;
1367 rect = GetDateAreaBounds(DATETIME_ID_DAY);
1369 else if (GetLastSelectedId() == DATETIME_ID_MONTH)
1371 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(monthString) == false), E_SUCCESS, "Month string matched.");
1373 newValue = monthString;
1374 rect = GetDateAreaBounds(DATETIME_ID_MONTH);
1376 else if (GetLastSelectedId() == DATETIME_ID_YEAR)
1378 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(yearString) == false), E_SUCCESS, "Year string matched.");
1380 newValue = yearString;
1381 rect = GetDateAreaBounds(DATETIME_ID_YEAR);
1384 FloatDimension newTextDim;
1385 FloatDimension oldTextDim;
1386 VisualElement* pNewVisualElement = null;
1387 VisualElement* pOldVisualElement = null;
1388 VisualElement* pEditDateElement = null;
1389 VisualElementPropertyAnimation* pNewBoundsAnimation = null;
1390 VisualElementPropertyAnimation* pOldBoundsAnimation = null;
1391 Canvas *pCanvas = null;
1392 Color contentBgColor;
1393 Color textPressedColor;
1394 float contentTextMargin;
1396 GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_PRESSED, contentBgColor);
1397 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textPressedColor);
1398 GET_SHAPE_CONFIG(EDITDATE::CONTENT_TEXT_MARGIN, __pEditDate->GetOrientation(), contentTextMargin);
1400 __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim);
1401 __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim);
1403 if (newTextDim.width > oldTextDim.width)
1405 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1409 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1412 SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditDate->GetBoundsF().width), E_SUCCESS, "Rolling animation can't be played.");
1414 __isAnimating = true;
1416 __pContentProvider = new (std::nothrow) VisualElement();
1417 SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1419 r = __pContentProvider->Construct();
1420 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1422 __pContentProvider->SetShowState(true);
1423 __pContentProvider->SetClipChildrenEnabled(true);
1424 __pContentProvider->SetImplicitAnimationEnabled(false);
1426 pEditDateElement = __pEditDate->GetVisualElement();
1427 r = GetLastResult();
1428 SysTryCatch(NID_UI_CTRL, (pEditDateElement != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1430 pNewVisualElement = new (std::nothrow) VisualElement();
1431 SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1433 r = pNewVisualElement->Construct();
1436 pNewVisualElement->Destroy();
1437 pNewVisualElement = null;
1439 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1441 pOldVisualElement = new (std::nothrow) VisualElement();
1442 if (pOldVisualElement == null)
1444 pNewVisualElement->Destroy();
1445 pNewVisualElement = null;
1447 SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1449 r = pOldVisualElement->Construct();
1452 pNewVisualElement->Destroy();
1453 pOldVisualElement->Destroy();
1454 pNewVisualElement = null;
1455 pOldVisualElement = null;
1457 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1459 pNewVisualElement->SetShowState(true);
1460 pOldVisualElement->SetShowState(true);
1462 __pContentProvider->SetBounds(FloatRectangle((rect.x + contentTextMargin), (rect.y + contentTextMargin), (rect.width - (contentTextMargin * 2.0f)), (rect.height - (contentTextMargin * 2.0f))));
1464 pNewVisualElement->SetBounds(FloatRectangle(0, 0, __pContentProvider->GetBounds().width, __pContentProvider->GetBounds().height));
1465 pOldVisualElement->SetBounds(FloatRectangle(0, 0, __pContentProvider->GetBounds().width, __pContentProvider->GetBounds().height));
1467 pCanvas = pEditDateElement->GetCanvasN(__pContentProvider->GetBounds());
1468 pCanvas->SetBackgroundColor(contentBgColor);
1473 pEditDateElement->AttachChild(*__pContentProvider);
1474 __pContentProvider->AttachChild(*pOldVisualElement);
1475 __pContentProvider->AttachChild(*pNewVisualElement);
1477 pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1478 SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1480 pNewBoundsAnimation->SetDuration(300);
1481 pNewBoundsAnimation->SetPropertyName("bounds.position");
1482 pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x, oldTextDim.height)));
1483 pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x, 0.0f)));
1484 pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1486 pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1487 SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1489 pOldBoundsAnimation->SetDuration(300);
1490 pOldBoundsAnimation->SetPropertyName("bounds.position");
1491 pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x, 0.0f)));
1492 pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x, oldTextDim.height * -1.0f)));
1493 pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1495 pOldSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__lastSelectedValue.GetPointer())), __lastSelectedValue.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1496 SysTryCatch(NID_UI_CTRL, (pOldSimpleText != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1498 pCanvas = pOldVisualElement->GetCanvasN();
1499 r = GetLastResult();
1500 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1502 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1504 pCanvas->SetForegroundColor(textPressedColor);
1506 (_FontImpl::GetInstance(*__pFont))->SetSize(__dateFontSize);
1507 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN);
1508 __textObject.RemoveAll();
1509 __textObject.AppendElement(*pOldSimpleText);
1511 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
1512 __textObject.SetForegroundColor(textPressedColor, 0, __textObject.GetTextLength());
1513 __textObject.SetBounds(FloatRectangle(0, 0, pCanvas->GetBounds().width, pCanvas->GetBounds().height));
1514 __textObject.Draw(*_CanvasImpl::GetInstance(*pCanvas));
1519 pNewSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(newValue.GetPointer())), newValue.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1520 SysTryCatch(NID_UI_CTRL, (pNewSimpleText != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1522 pCanvas = pNewVisualElement->GetCanvasN();
1523 r = GetLastResult();
1524 SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1526 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1528 pCanvas->SetForegroundColor(textPressedColor);
1530 (_FontImpl::GetInstance(*__pFont))->SetSize(__dateFontSize);
1531 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN);
1532 __textObject.RemoveAll();
1533 __textObject.AppendElement(*pNewSimpleText);
1535 __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
1536 __textObject.SetForegroundColor(textPressedColor, 0, __textObject.GetTextLength());
1537 __textObject.SetBounds(FloatRectangle(0, 0, pCanvas->GetBounds().width, pCanvas->GetBounds().height));
1538 __textObject.Draw(*_CanvasImpl::GetInstance(*pCanvas));
1543 pOldVisualElement->SetImplicitAnimationEnabled(false);
1544 pOldVisualElement->AddAnimation(*pOldBoundsAnimation);
1546 pNewVisualElement->SetImplicitAnimationEnabled(false);
1547 pNewVisualElement->AddAnimation(*pNewBoundsAnimation);
1549 delete pOldBoundsAnimation;
1550 delete pNewBoundsAnimation;
1555 __isAnimating = false;
1556 __pContentProvider->Destroy();
1557 __pContentProvider = null;
1559 delete pNewBoundsAnimation;
1560 pNewBoundsAnimation = null;
1562 delete pOldBoundsAnimation;
1563 pOldBoundsAnimation = null;
1565 delete pOldSimpleText;
1566 pOldSimpleText = null;
1568 delete pNewSimpleText;
1569 pNewSimpleText = null;
1575 _EditDatePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally)
1577 result r = E_SUCCESS;
1578 __isAnimating = false;
1580 VisualElement* pEditDateElement = __pEditDate->GetVisualElement();
1581 r = GetLastResult();
1582 SysTryReturnVoidResult(NID_UI_CTRL, (pEditDateElement != null), r, "[%s] Propagating.", GetErrorMessage(r));
1584 //__pContentProvider will be destroyed in destructor when OnFormBackRequested() callback is received
1585 if (__pContentProvider)
1587 pEditDateElement->DetachChild(*__pContentProvider);
1588 __pContentProvider->Destroy();
1589 __pContentProvider = null;
1596 }}} // Tizen::Ui::Controls