Merge "Revert "fix AppControl launch for multi-windows like WebControl"" into tizen_2.1
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_EditTimePresenter.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17
18 /**
19  * @file                FUiCtrl_EditTimePresenter.cpp
20  * @brief               This is the implementation file for the _EditTimePresenter class.
21  */
22
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"
37
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;
43
44 namespace Tizen { namespace Ui { namespace Controls
45 {
46 _EditTimePresenter::_EditTimePresenter(const String& title)
47         : __pEditDateTimeModel(null)
48         , __pEditTime(null)
49         , __bounds(FloatRectangle())
50         , __titleBounds(FloatRectangle())
51         , __ampmString(String())
52         , __hourString(String())
53         , __minuteString(String())
54         , __title(title)
55         , __24hours(false)
56         , __is24hoursSet(false)
57         , __amEnable(true)
58         , __timePickerEnabled(true)
59         , __selectedId(DATETIME_ID_NONE)
60         , __lastSelectedId(DATETIME_ID_NONE)
61         , __touchMoveHandled(false)
62         , __pAmPmBgNormalColorReplacementBitmap(null)
63         , __pAmPmBgDisabledColorReplacementBitmap(null)
64         , __pAmPmBgPressedColorReplacementBitmap(null)
65         , __pAmPmBgHighlightedColorReplacementBitmap(null)
66         , __pAmPmBgEffectNomralBitmap(null)
67         , __pAmPmBgEffectPressedBitmap(null)
68         , __pAmPmBgEffectDisabledBitmap(null)
69         , __pColonColorReplacementBitmap(null)
70         , __pColonDisabledColorReplacementBitmap(null)
71         , __pContentBgNormalColorReplacementBitmap(null)
72         , __pContentBgDisabledColorReplacementBitmap(null)
73         , __pContentBgPressedColorReplacementBitmap(null)
74         , __pContentBgHighlightedColorReplacementBitmap(null)
75         , __pContentBgEffectNormalBitmap(null)
76         , __pContentBgEffectPressedBitmap(null)
77         , __pContentBgEffectDisabledBitmap(null)
78         , __pContentProvider(null)
79         , __textObject()
80         , __pFont(null)
81         , __titleObject()
82         , __amPmTextSize(0.0f)
83         , __titleFontSize(0.0f)
84         , __timeFontSize(0.0f)
85         , __isAnimating(false)
86         , __isEditTimeInitialized(false)
87 {
88 }
89
90 _EditTimePresenter::~_EditTimePresenter(void)
91 {
92         __textObject.RemoveAll();
93         __titleObject.RemoveAll();
94
95         delete __pEditDateTimeModel;
96         __pEditDateTimeModel = null;
97
98         delete __pAmPmBgNormalColorReplacementBitmap;
99         __pAmPmBgNormalColorReplacementBitmap = null;
100
101         delete __pAmPmBgDisabledColorReplacementBitmap;
102         __pAmPmBgDisabledColorReplacementBitmap = null;
103
104         delete __pAmPmBgPressedColorReplacementBitmap;
105         __pAmPmBgPressedColorReplacementBitmap = null;
106
107         delete __pAmPmBgHighlightedColorReplacementBitmap;
108         __pAmPmBgHighlightedColorReplacementBitmap = null;
109
110         delete __pAmPmBgEffectNomralBitmap;
111         __pAmPmBgEffectNomralBitmap = null;
112
113         delete __pAmPmBgEffectPressedBitmap;
114         __pAmPmBgEffectPressedBitmap = null;
115
116         delete __pAmPmBgEffectDisabledBitmap;
117         __pAmPmBgEffectDisabledBitmap = null;
118
119         delete __pColonColorReplacementBitmap;
120         __pColonColorReplacementBitmap = null;
121
122         delete __pColonDisabledColorReplacementBitmap;
123         __pColonDisabledColorReplacementBitmap = null;
124
125         delete __pContentBgNormalColorReplacementBitmap;
126         __pContentBgNormalColorReplacementBitmap = null;
127
128         delete __pContentBgDisabledColorReplacementBitmap;
129         __pContentBgDisabledColorReplacementBitmap = null;
130
131         delete __pContentBgPressedColorReplacementBitmap;
132         __pContentBgPressedColorReplacementBitmap = null;
133
134         delete __pContentBgHighlightedColorReplacementBitmap;
135         __pContentBgHighlightedColorReplacementBitmap = null;
136
137         delete __pContentBgEffectNormalBitmap;
138         __pContentBgEffectNormalBitmap = null;
139
140         delete __pContentBgEffectPressedBitmap;
141         __pContentBgEffectPressedBitmap = null;
142
143         delete __pContentBgEffectDisabledBitmap;
144         __pContentBgEffectDisabledBitmap = null;
145 }
146
147 _EditTimePresenter*
148 _EditTimePresenter::CreateInstanceN(const _EditTime& editTime, const String& title)
149 {
150         _EditTimePresenter* pEditTimePresenter = new (std::nothrow) _EditTimePresenter(title);
151         SysTryReturn(NID_UI_CTRL, pEditTimePresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
152
153         pEditTimePresenter->__pEditTime = const_cast <_EditTime*>(&editTime);
154
155         pEditTimePresenter->__pEditDateTimeModel = new (std::nothrow) _DateTimeModel;
156         SysTryCatch(NID_UI_CTRL, pEditTimePresenter->__pEditDateTimeModel, , E_OUT_OF_MEMORY,
157                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
158
159         return pEditTimePresenter;
160
161 CATCH:
162         delete pEditTimePresenter;
163         return null;
164 }
165
166 DateTime
167 _EditTimePresenter::GetTime(void) const
168 {
169         DateTime time;
170         time.SetValue(DATETIME_YEAR_MIN, DATETIME_MONTH_MIN, DATETIME_DAY_MIN, GetHour(), GetMinute(), 0);
171
172         return time;
173 }
174
175 int
176 _EditTimePresenter::GetHour(void) const
177 {
178         return __pEditDateTimeModel->GetHour();
179 }
180
181 int
182 _EditTimePresenter::GetMinute(void) const
183 {
184         return __pEditDateTimeModel->GetMinute();
185 }
186
187 void
188 _EditTimePresenter::SetTime(const DateTime& time)
189 {
190         __pEditDateTimeModel->SetDateTime(time);
191 }
192
193 void
194 _EditTimePresenter::SetCurrentTime(void)
195 {
196         __pEditDateTimeModel->SetCurrentDateTime();
197         return;
198 }
199
200 result
201 _EditTimePresenter::SetHour(int hour)
202 {
203         return __pEditDateTimeModel->SetHour(hour);
204 }
205
206 result
207 _EditTimePresenter::SetMinute(int minute)
208 {
209         return __pEditDateTimeModel->SetMinute(minute);
210 }
211
212 void
213 _EditTimePresenter::SetTimePickerEnabled(bool enable)
214 {
215         __timePickerEnabled = enable;
216         return;
217 }
218
219 bool
220 _EditTimePresenter::IsTimePickerEnabled(void) const
221 {
222         return __timePickerEnabled;
223 }
224
225 void
226 _EditTimePresenter::Set24HourNotationEnabled(bool enable)
227 {
228         __24hours = enable;
229         __is24hoursSet = true;
230         return;
231 }
232
233 bool
234 _EditTimePresenter::Is24HourNotationEnabled(void) const
235 {
236         return __24hours;
237 }
238
239 void
240 _EditTimePresenter::SetTimeConversion(void)
241 {
242         int hour = GetHour();
243         int minute = GetMinute();
244
245         if (__24hours == false)
246         {
247                 int max = DATETIME_HOUR_MAX_FOR_24NOTATION;
248
249                 if (hour > max)
250                 {
251                         __hourString.Format(10, L"%02d", hour - max);
252                 }
253                 else if (hour == DATETIME_HOUR_MIN)
254                 {
255                         __hourString.Format(10, L"%02d", hour + DATETIME_HOUR_MAX_FOR_24NOTATION);
256                 }
257                 else
258                 {
259                         __hourString.Format(10, L"%02d", hour);
260                 }
261
262                 __minuteString.Format(10, L"%02d", minute);
263         }
264         else
265         {
266                 __hourString.Format(10, L"%02d", hour);
267                 __minuteString.Format(10, L"%02d", minute);
268         }
269
270         return;
271 }
272
273 void
274 _EditTimePresenter::SetAmEnabled(bool amEnable)
275 {
276         String textAm;
277         String textPm;
278
279         _DateTimeUtils dateTimeUtils;
280         dateTimeUtils.GetAmPm(textAm, AM_TYPE);
281         dateTimeUtils.GetAmPm(textPm, PM_TYPE);
282
283         __amEnable = amEnable;
284         int hour = GetHour();
285
286         if (__amEnable == true)
287         {
288                 __ampmString = textAm;
289                 if (hour >= DATETIME_HOUR_MAX_FOR_24NOTATION)
290                 {
291                         SetHour(hour - DATETIME_HOUR_MAX_FOR_24NOTATION);
292                 }
293         }
294         else
295         {
296                 __ampmString = textPm;
297                 if (hour < DATETIME_HOUR_MAX_FOR_24NOTATION)
298                 {
299                         SetHour(hour + DATETIME_HOUR_MAX_FOR_24NOTATION);
300                 }
301         }
302
303         return;
304 }
305
306 bool
307 _EditTimePresenter::GetAmEnabled(void) const
308 {
309         return __amEnable;
310 }
311
312 FloatRectangle
313 _EditTimePresenter::GetDisplayAreaBoundsFromHoursStyle(_DateTimeId displayBoxId) const
314 {
315         SysTryReturn(NID_UI_CTRL, displayBoxId >= DATETIME_ID_HOUR && displayBoxId <= DATETIME_ID_AMPM, FloatRectangle(),
316                         E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] displayBoxId is out of range.");
317
318         FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
319
320         float editTimeHeight = 0.0f;
321         float colonWidth = 0.0f;
322         float timeAmPmMargin = 0.0f;
323         float colonMargin = 0.0f;
324         float timeElementWidth = 0.0f;
325         float amPmHeight = 0.0f;
326         float timeHeight = 0.0f;
327         float titleTimeMargin = 0.0f;
328         float leftMargin = 0.0f;
329
330         GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), editTimeHeight);
331         GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonWidth);
332         GET_SHAPE_CONFIG(EDITTIME::TIME_AMPM_MARGIN, __pEditTime->GetOrientation(), timeAmPmMargin);
333         GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
334         GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), amPmHeight);
335         GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
336         GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
337
338         GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), leftMargin);
339
340         if (__pEditTime->GetBoundsF().height > bounds.height)
341         {
342                 editTimeHeight = __pEditTime->GetBoundsF().height;
343         }
344
345         bounds.y = (editTimeHeight - timeHeight) / 2.0f;
346
347         if (!__title.IsEmpty())
348         {
349                 if (displayBoxId == DATETIME_ID_AMPM)
350                 {
351                         bounds.y = __titleBounds.y + __titleBounds.height;
352                 }
353                 else
354                 {
355                         bounds.y = __titleBounds.y + __titleBounds.height + titleTimeMargin;
356                 }
357         }
358
359         bounds.x = leftMargin;
360         bounds.height = timeHeight;
361
362         timeElementWidth = GetTimeElementWidth();
363
364         if (displayBoxId == DATETIME_ID_HOUR)
365         {
366                 bounds.width = timeElementWidth;
367         }
368         else if (displayBoxId == DATETIME_ID_MINUTE)
369         {
370                 bounds.x = bounds.x + timeElementWidth + colonWidth + (2.0f * colonMargin);
371                 bounds.width = timeElementWidth;
372         }
373         else if (displayBoxId == DATETIME_ID_AMPM)
374         {
375                 bounds.x = leftMargin + (2.0f * timeElementWidth) + colonWidth + (2.0f * colonMargin) + timeAmPmMargin;
376
377                 if (__title.IsEmpty())
378                 {
379                         bounds.y = (editTimeHeight - amPmHeight) / 2.0f;
380                 }
381
382                 GET_SHAPE_CONFIG(EDITTIME::AMPM_WIDTH, __pEditTime->GetOrientation(), bounds.width);
383                 bounds.height = amPmHeight;
384         }
385
386         return bounds;
387 }
388
389 float
390 _EditTimePresenter::GetTextWidth(_DateTimeId boxId) const
391 {
392         result r = E_SUCCESS;
393         FloatDimension dim;
394         TextObject dateObject;
395         String hourString;
396         String minuteString;
397
398         hourString.Format(10, L"%02d", GetHour());
399         minuteString.Format(10, L"%02d", GetMinute());
400
401         r = dateObject.Construct();
402         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
403
404         TextSimple* pSimpleText = null;
405
406         if (boxId == DATETIME_ID_HOUR)
407         {
408                 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(hourString.GetPointer())), hourString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
409         }
410         else if (boxId == DATETIME_ID_MINUTE)
411         {
412                 pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(minuteString.GetPointer())), minuteString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
413         }
414
415         SysTryReturn(NID_UI_CTRL, (pSimpleText != null), dim.width, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
416
417         (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
418
419         dateObject.AppendElement(*pSimpleText);
420         dateObject.SetFont(__pFont, 0, dateObject.GetTextLength());
421         dim = dateObject.GetTextExtentF(0, dateObject.GetTextLength());
422
423         dateObject.RemoveAll();
424         return dim.width;
425 }
426
427 void
428 _EditTimePresenter::SetTitleBounds(void)
429 {
430         GET_SHAPE_CONFIG(EDITTIME::TITLE_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), __titleBounds.x);
431         GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), __titleBounds.height);
432
433         __titleBounds.width = __pEditTime->GetBoundsF().width - __titleBounds.x;
434         return;
435 }
436
437 FloatRectangle
438 _EditTimePresenter::GetTitleBounds(void) const
439 {
440         return __titleBounds;
441 }
442
443 result
444 _EditTimePresenter::LoadResource(void)
445 {
446         result r = E_SUCCESS;
447
448         Color buttonNormalBgColor;
449         Color buttonDisabledBgColor;
450         Color buttonPressedColor;
451         Color buttonHighlightedColor;
452         Color contentNormalBgColor;
453         Color contentDisabledBgColor;
454         Color contentPressedColor;
455         Color contentHighlightedColor;
456         Color colonTextColor;
457         Color colonTextDisabledColor;
458         Bitmap* pTempBitmap = null;
459
460         GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_NORMAL, buttonNormalBgColor);
461         GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_PRESSED, buttonPressedColor);
462         GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_DISABLED, buttonDisabledBgColor);
463         GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_HIGHLIGHTED, buttonHighlightedColor);
464
465         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_NORMAL, contentNormalBgColor);
466         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_DISABLED, contentDisabledBgColor);
467         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_PRESSED, contentPressedColor);
468         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
469
470         GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, colonTextColor);
471         GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, colonTextDisabledColor);
472
473         GET_SHAPE_CONFIG(EDITTIME::AMPM_FONT_SIZE, __pEditTime->GetOrientation(), __amPmTextSize);
474
475         r = GET_BITMAP_CONFIG_N(EDITTIME::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
476         SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
477
478         __pColonColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA),
479                                                                               colonTextColor);
480         SysTryCatch(NID_UI_CTRL, (__pColonColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
481                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
482
483         __pColonDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA),
484                         colonTextDisabledColor);
485         SysTryCatch(NID_UI_CTRL, (__pColonDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
486                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
487
488         delete pTempBitmap;
489         pTempBitmap = null;
490
491         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
492         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
493
494         __pAmPmBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalBgColor);
495         SysTryCatch(NID_UI_CTRL, (__pAmPmBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
496                                 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
497
498         delete pTempBitmap;
499         pTempBitmap = null;
500
501         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
502         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
503
504         __pAmPmBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonDisabledBgColor);
505         SysTryCatch(NID_UI_CTRL, (__pAmPmBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
506                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
507
508         delete pTempBitmap;
509         pTempBitmap = null;
510
511         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
512         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
513
514         __pAmPmBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonPressedColor);
515         SysTryCatch(NID_UI_CTRL, (__pAmPmBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
516                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
517
518         delete pTempBitmap;
519         pTempBitmap = null;
520
521         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
522         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
523
524         __pAmPmBgHighlightedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonHighlightedColor);
525         SysTryCatch(NID_UI_CTRL, (__pAmPmBgHighlightedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
526                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
527
528         delete pTempBitmap;
529         pTempBitmap = null;
530
531         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
532         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
533
534         __pContentBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentNormalBgColor);
535         SysTryCatch(NID_UI_CTRL, (__pContentBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
536                                 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
537
538         delete pTempBitmap;
539         pTempBitmap = null;
540
541         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
542         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
543
544         __pContentBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentPressedColor);
545         SysTryCatch(NID_UI_CTRL, (__pContentBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
546                                 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
547
548         delete pTempBitmap;
549         pTempBitmap = null;
550
551         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
552         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
553
554         __pContentBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentDisabledBgColor);
555         SysTryCatch(NID_UI_CTRL, (__pContentBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
556                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
557
558         delete pTempBitmap;
559         pTempBitmap = null;
560
561         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
562         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
563
564         __pContentBgHighlightedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
565         SysTryCatch(NID_UI_CTRL, (__pContentBgHighlightedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
566                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
567
568         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectNomralBitmap);
569         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
570
571         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectPressedBitmap);
572         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
573
574         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectDisabledBitmap);
575         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
576
577         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectNormalBitmap);
578         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
579
580         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectPressedBitmap);
581         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
582
583         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectDisabledBitmap);
584         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
585
586
587         delete pTempBitmap;
588         pTempBitmap = null;
589
590         return r;
591
592 CATCH:
593         delete pTempBitmap;
594         pTempBitmap = null;
595
596         delete __pAmPmBgNormalColorReplacementBitmap;
597         __pAmPmBgNormalColorReplacementBitmap = null;
598
599         delete __pAmPmBgPressedColorReplacementBitmap;
600         __pAmPmBgPressedColorReplacementBitmap = null;
601
602         delete __pAmPmBgDisabledColorReplacementBitmap;
603         __pAmPmBgDisabledColorReplacementBitmap = null;
604
605         delete __pAmPmBgHighlightedColorReplacementBitmap;
606         __pAmPmBgHighlightedColorReplacementBitmap = null;
607
608         delete __pContentBgNormalColorReplacementBitmap;
609         __pContentBgNormalColorReplacementBitmap = null;
610
611         delete __pContentBgPressedColorReplacementBitmap;
612         __pContentBgPressedColorReplacementBitmap = null;
613
614         delete __pContentBgDisabledColorReplacementBitmap;
615         __pContentBgDisabledColorReplacementBitmap = null;
616
617         delete __pContentBgHighlightedColorReplacementBitmap;
618         __pContentBgHighlightedColorReplacementBitmap = null;
619
620         delete __pAmPmBgEffectNomralBitmap;
621         __pAmPmBgEffectNomralBitmap = null;
622
623         delete __pAmPmBgEffectPressedBitmap;
624         __pAmPmBgEffectPressedBitmap = null;
625
626         delete __pAmPmBgEffectDisabledBitmap;
627         __pAmPmBgEffectDisabledBitmap = null;
628
629         delete __pContentBgEffectNormalBitmap;
630         __pContentBgEffectNormalBitmap = null;
631
632         delete __pContentBgEffectPressedBitmap;
633         __pContentBgEffectPressedBitmap = null;
634
635         delete __pContentBgEffectDisabledBitmap;
636         __pContentBgEffectDisabledBitmap = null;
637
638         delete __pColonColorReplacementBitmap;
639         __pColonColorReplacementBitmap = null;
640
641         delete __pColonDisabledColorReplacementBitmap;
642         __pColonDisabledColorReplacementBitmap = null;
643
644         return r;
645 }
646
647 result
648 _EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
649 {
650         result r = E_SUCCESS;
651
652         if (pBitmap == null)
653         {
654                 return r;
655         }
656
657         if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
658         {
659                 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
660                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
661         }
662         else
663         {
664                 r = canvas.DrawBitmap(bounds, *pBitmap);
665                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
666         }
667
668         return r;
669 }
670
671 float
672 _EditTimePresenter::GetTimeElementWidth(void) const
673 {
674         FloatRectangle bounds;
675         FloatDimension minSize;
676         bounds = __pEditTime->GetBoundsF();
677
678         float timeElementWidth = 0.0f;
679         float timeElementMinWidth = 0.0f;
680         float editTimeWidth = 0.0f;
681
682         GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), timeElementWidth);
683         GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_MIN_WIDTH, __pEditTime->GetOrientation(), timeElementMinWidth);
684         GET_SHAPE_CONFIG(EDITTIME::WIDTH, __pEditTime->GetOrientation(), editTimeWidth);
685
686         GET_DIMENSION_CONFIG(EDITTIME::MIN_SIZE, __pEditTime->GetOrientation(), minSize);
687
688         if (bounds.width >= editTimeWidth)
689         {
690                 return timeElementWidth;
691         }
692
693         if (bounds.width <= minSize.width)
694         {
695                 timeElementWidth = timeElementMinWidth;
696         }
697         else if (bounds.width < editTimeWidth && bounds.width > minSize.width)
698         {
699                 timeElementWidth = timeElementWidth -
700                                 ((timeElementWidth - timeElementMinWidth) / (editTimeWidth - minSize.width)) * (editTimeWidth - bounds.width);
701         }
702
703         return timeElementWidth;
704 }
705
706 result
707 _EditTimePresenter::InitializeTitleObject(void)
708 {
709         result r = E_SUCCESS;
710
711         Color titleNormalColor;
712
713         GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_NORMAL, titleNormalColor);
714
715         r = __titleObject.Construct();
716         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
717
718         TextSimple* pSimpleText = null;
719
720         pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
721         SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
722
723         __titleObject.AppendElement(*pSimpleText);
724
725         __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength());
726         __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
727         __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
728         __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
729         __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
730         __titleObject.SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL);
731
732         return r;
733 }
734
735 result
736 _EditTimePresenter::InitializeTextObject(void)
737 {
738         result r = E_SUCCESS;
739
740         r = __textObject.Construct();
741         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
742
743         TextSimple* pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
744         SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
745                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
746
747         __textObject.AppendElement(*pSimpleText);
748
749         __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
750         __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
751         __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
752         __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
753
754         return r;
755 }
756
757 result
758 _EditTimePresenter::Draw(void)
759 {
760         result r = E_SUCCESS;
761
762         if (__isAnimating)
763         {
764                 return E_SUCCESS;
765         }
766
767         Canvas* pCanvas = __pEditTime->GetCanvasN();
768         SysAssertf((pCanvas != null), "Failed to get canvas.");
769
770         FloatRectangle colonBounds(0.0f, 0.0f, 0.0f, 0.0f);
771
772         float colonMargin = 0.0f;
773
774         Dimension textArea;
775
776         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
777         pCanvas->Clear();
778
779         FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
780         FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
781         FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
782         bool isCustomBitmap = false;
783         Bitmap* pReplacementBitmap = null;
784         Bitmap* pEffectBitmap = null;
785
786         hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
787         minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
788
789         if (__24hours == false)
790         {
791                 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
792
793                 if (!__pEditTime->IsEnabled())
794                 {
795                         isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_DISABLED);
796                         pReplacementBitmap = __pAmPmBgDisabledColorReplacementBitmap;
797                         pEffectBitmap = __pAmPmBgEffectDisabledBitmap;
798                 }
799                 else if (__selectedId != DATETIME_ID_AMPM)
800                 {
801                         isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_NORMAL);
802                         pReplacementBitmap = __pAmPmBgNormalColorReplacementBitmap;
803                         pEffectBitmap = __pAmPmBgEffectNomralBitmap;
804                 }
805                 else
806                 {
807                         isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::BUTTON_BG_PRESSED);
808                         pReplacementBitmap = __pAmPmBgPressedColorReplacementBitmap;
809                         pEffectBitmap = __pAmPmBgEffectPressedBitmap;
810                 }
811         }
812
813         if (GetHour() >= DATETIME_HOUR_MAX_FOR_24NOTATION)
814         {
815                 SetAmEnabled(false);
816         }
817         else
818         {
819                 SetAmEnabled(true);
820         }
821
822         SetTimeConversion();
823
824         GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonBounds.width);
825         GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
826         GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), colonBounds.height);
827
828         colonBounds.x = hourBounds.x + hourBounds.width + colonMargin;
829         colonBounds.y = hourBounds.y + (hourBounds.height - colonBounds.height) / 2.0f;
830
831         if (__title.IsEmpty() == false)
832         {
833                 r = DrawTitle(*pCanvas);
834                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
835         }
836
837         r = DrawText(*pCanvas, hourBounds, __hourString, DATETIME_ID_HOUR);
838         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
839
840         r = DrawText(*pCanvas, minuteBounds, __minuteString, DATETIME_ID_MINUTE);
841         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
842
843         r = DrawColon(*pCanvas, colonBounds);
844         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
845
846         if (__24hours == false)
847         {
848                 r = DrawResourceBitmap(*pCanvas, ampmBounds, pReplacementBitmap);
849                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
850
851                 if (!isCustomBitmap)
852                 {
853                         r = DrawResourceBitmap(*pCanvas, ampmBounds, pEffectBitmap);
854                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
855                 }
856
857                 r = DrawText(*pCanvas, ampmBounds, __ampmString, DATETIME_ID_AMPM, __amPmTextSize);
858                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
859         }
860
861 CATCH:
862         delete pCanvas;
863
864         return r;
865 }
866
867 result
868 _EditTimePresenter::DrawColon(Canvas& canvas, const FloatRectangle& bounds)
869 {
870         result r = E_SUCCESS;
871
872         if (!__pEditTime->IsEnabled())
873         {
874                 r = DrawResourceBitmap(canvas, bounds, __pColonDisabledColorReplacementBitmap);
875         }
876         else
877         {
878                 r = DrawResourceBitmap(canvas, bounds, __pColonColorReplacementBitmap);
879         }
880
881         return r;
882 }
883
884 result
885 _EditTimePresenter::DrawTitle(Canvas& canvas)
886 {
887         if (!__pEditTime->IsEnabled())
888         {
889                 Color titleDisabledColor;
890                 GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_DISABLED, titleDisabledColor);
891                 __titleObject.SetForegroundColor(titleDisabledColor, 0, __titleObject.GetTextLength());
892         }
893
894         (_FontImpl::GetInstance(*__pFont))->SetSize(__titleFontSize);
895         (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
896         __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
897
898         __titleObject.Draw(*_CanvasImpl::GetInstance(canvas));
899
900         return E_SUCCESS;
901 }
902
903 result
904 _EditTimePresenter::DrawContentBitmap(Canvas& canvas, const FloatRectangle& bounds, _DateTimeId boxId)
905 {
906         result r = E_SUCCESS;
907
908         bool isCustomBitmap = false;
909         Bitmap* pReplacementBitmap = null;
910         Bitmap* pEffectBitmap = null;
911
912         if (!__pEditTime->IsEnabled())
913         {
914                 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_DISABLED);
915                 pReplacementBitmap = __pContentBgDisabledColorReplacementBitmap;
916                 pEffectBitmap = __pContentBgEffectDisabledBitmap;
917         }
918         else if (__selectedId != boxId)
919         {
920                 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated() &&
921                                 (GetLastSelectedId() == boxId))
922                 {
923                         isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED);
924                         pReplacementBitmap = __pContentBgPressedColorReplacementBitmap;
925                         pEffectBitmap = __pContentBgEffectPressedBitmap;
926                 }
927                 else
928                 {
929                         isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_NORMAL);
930                         pReplacementBitmap = __pContentBgNormalColorReplacementBitmap;
931                         pEffectBitmap = __pContentBgEffectNormalBitmap;
932                 }
933         }
934         else
935         {
936                 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED);
937                 pReplacementBitmap = __pContentBgPressedColorReplacementBitmap;
938                 pEffectBitmap = __pContentBgEffectPressedBitmap;
939         }
940
941         r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap);
942         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
943
944         if (!isCustomBitmap)
945         {
946                 r = DrawResourceBitmap(canvas, bounds, pEffectBitmap);
947                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
948         }
949
950         return r;
951 }
952
953 result
954 _EditTimePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, _DateTimeId boxId, float textSize)
955 {
956         result r = E_SUCCESS;
957
958         Color textColor;
959         (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN);
960
961         if (!__pEditTime->IsEnabled())
962         {
963                 if (boxId == DATETIME_ID_AMPM)
964                 {
965                         GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_DISABLED, textColor);
966                 }
967                 else
968                 {
969                         GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, textColor);
970                 }
971         }
972         else
973         {
974                 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, textColor);
975
976                 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated() &&
977                                 (GetLastSelectedId() == boxId))
978                 {
979                         GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
980                         (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
981                 }
982
983                 if (boxId == DATETIME_ID_AMPM)
984                 {
985                         GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_NORMAL, textColor);
986                 }
987
988                 if (boxId > -1 && boxId == __selectedId)
989                 {
990                         if (boxId == DATETIME_ID_AMPM)
991                         {
992                                 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_PRESSED, textColor);
993                         }
994                         else
995                         {
996                                 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
997                                 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
998                         }
999                 }
1000         }
1001
1002         if (boxId != DATETIME_ID_AMPM)
1003         {
1004                 DrawContentBitmap(canvas, bounds, boxId);
1005         }
1006
1007         FloatRectangle drawAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
1008         drawAreaBounds = bounds;
1009
1010         TextSimple* pSimpleText = null;
1011         pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1012         SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1013
1014         __textObject.RemoveAll();
1015
1016         (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
1017         __textObject.AppendElement(*pSimpleText);
1018
1019         if (boxId == DATETIME_ID_AMPM)
1020         {
1021                 (_FontImpl::GetInstance(*__pFont))->SetSize(textSize);
1022         }
1023
1024         __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
1025
1026         __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength());
1027         __textObject.SetBounds(drawAreaBounds);
1028         __textObject.Draw(*_CanvasImpl::GetInstance(canvas));
1029
1030         return r;
1031 }
1032
1033 _DateTimeId
1034 _EditTimePresenter::GetBoxIdFromPosition(const FloatPoint& point) const
1035 {
1036         _DateTimeId displayBoxId = DATETIME_ID_NONE;
1037
1038         FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
1039         FloatRectangle hoursBounds(0.0f, 0.0f, 0.0f, 0.0f);
1040         FloatRectangle minutesBounds(0.0f, 0.0f, 0.0f, 0.0f);
1041
1042         if (__24hours == false)
1043         {
1044                 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
1045         }
1046
1047         hoursBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1048         minutesBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1049
1050         if (point.y < hoursBounds.y || point.y > hoursBounds.y + hoursBounds.height)
1051         {
1052                 return displayBoxId;
1053         }
1054
1055         if (hoursBounds.Contains(point) == true)
1056         {
1057                 displayBoxId = DATETIME_ID_HOUR;
1058         }
1059         else if (minutesBounds.Contains(point) == true)
1060         {
1061                 displayBoxId = DATETIME_ID_MINUTE;
1062         }
1063         else if (ampmBounds.Contains(point) == true)
1064         {
1065                 displayBoxId = DATETIME_ID_AMPM;
1066         }
1067
1068         return displayBoxId;
1069 }
1070
1071 void
1072 _EditTimePresenter::SetLastSelectedId(_DateTimeId boxId)
1073 {
1074         __lastSelectedId = boxId;
1075         return;
1076 }
1077
1078 _DateTimeId
1079 _EditTimePresenter::GetLastSelectedId(void) const
1080 {
1081         return __lastSelectedId;
1082 }
1083
1084 bool
1085 _EditTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1086 {
1087         SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
1088
1089         if (&source != __pEditTime)
1090         {
1091                 return false;
1092         }
1093
1094         __touchMoveHandled = false;
1095
1096         FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
1097         FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1098         FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
1099
1100         hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1101         minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1102
1103         if (__24hours == false)
1104         {
1105                 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
1106         }
1107
1108         FloatPoint point = touchinfo.GetCurrentPosition();
1109
1110         _DateTimeId boxId = GetBoxIdFromPosition(point);
1111
1112         int minValue = -1;
1113         int maxValue = -1;
1114         int displayValue = -1;
1115
1116         if (boxId == DATETIME_ID_HOUR)
1117         {
1118                 if (__pEditTime->GetDateTimeBar() != null)
1119                 {
1120                         if (__24hours == false)
1121                         {
1122                                 if (GetHour() == 0)
1123                                 {
1124                                         minValue = DATETIME_HOUR_MIN + 1;
1125                                         maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1126                                         displayValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1127                                 }
1128                                 else if (GetHour() > DATETIME_HOUR_MAX_FOR_24NOTATION)
1129                                 {
1130                                         minValue = DATETIME_HOUR_MIN + 1;
1131                                         maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1132                                         displayValue = GetHour() - DATETIME_HOUR_MAX_FOR_24NOTATION;
1133                                 }
1134                                 else
1135                                 {
1136                                         minValue = DATETIME_HOUR_MIN + 1;
1137                                         maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1138                                         displayValue = GetHour();
1139                                 }
1140                         }
1141                         else
1142                         {
1143                                 minValue = DATETIME_HOUR_MIN;
1144                                 maxValue = DATETIME_HOUR_MAX;
1145                                 displayValue = GetHour();
1146                         }
1147
1148                         if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
1149                         {
1150                                 __pEditTime->GetDateTimeBar()->RemoveAllItems();
1151                         }
1152
1153                         __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
1154                 }
1155
1156                 __bounds = hourBounds;
1157         }
1158         else if (boxId == DATETIME_ID_MINUTE)
1159         {
1160                 if (__pEditTime->GetDateTimeBar() != null)
1161                 {
1162                         minValue = DATETIME_MINUTE_MIN;
1163                         maxValue = DATETIME_MINUTE_MAX;
1164                         displayValue = GetMinute();
1165
1166                         if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
1167                         {
1168                                 __pEditTime->GetDateTimeBar()->RemoveAllItems();
1169                         }
1170
1171                         __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
1172                 }
1173
1174                 __bounds = minuteBounds;
1175         }
1176         else if (boxId == DATETIME_ID_AMPM)
1177         {
1178                 __selectedId = boxId;
1179                 __bounds = ampmBounds;
1180                 Draw();
1181         }
1182         else
1183         {
1184                 __selectedId = DATETIME_ID_NONE;
1185                 return false;
1186         }
1187
1188         __selectedId = boxId;
1189
1190         return true;
1191 }
1192
1193 bool
1194 _EditTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1195 {
1196         SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
1197
1198         if (&source != __pEditTime)
1199         {
1200                 return false;
1201         }
1202
1203         FloatRectangle bounds = __pEditTime->GetBoundsF();
1204
1205         FloatPoint startPoint(0.0f, 0.0f);
1206
1207         float titleHeight = 0;
1208         GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), titleHeight);
1209
1210         __bounds = FloatRectangle(0.0f, titleHeight, bounds.width, bounds.height);
1211
1212         FloatPoint point = touchinfo.GetCurrentPosition();
1213
1214         _DateTimeId boxId = GetBoxIdFromPosition(point);
1215
1216         if ((boxId == GetLastSelectedId() && boxId != DATETIME_ID_AMPM) || boxId != __selectedId || boxId == DATETIME_ID_NONE)
1217         {
1218                 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1219                 {
1220                         __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1221                         __pEditTime->GetDateTimeBar()->Close();
1222                 }
1223
1224                 __selectedId = DATETIME_ID_NONE;
1225                 SetLastSelectedId(__selectedId);
1226
1227                 Draw();
1228
1229                 return true;
1230         }
1231
1232         SetLastSelectedId(__selectedId);
1233
1234         __lastSelectedValue = "";
1235         _DateTimeUtils dateTimeUtils;
1236
1237         if (GetLastSelectedId() == DATETIME_ID_HOUR)
1238         {
1239                 int hours = GetHour();
1240
1241                 if (!Is24HourNotationEnabled())
1242                 {
1243                         hours = hours % 12;
1244
1245                         if (hours == DATETIME_HOUR_MIN)
1246                         {
1247                                 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1248                         }
1249                 }
1250                 __lastSelectedValue.Format(10, L"%02d", hours);
1251                 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1252         }
1253         else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1254         {
1255                 __lastSelectedValue.Format(10, L"%02d", GetMinute());
1256                 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1257         }
1258         else if (GetLastSelectedId() == DATETIME_ID_AMPM)
1259         {
1260                 SetAmEnabled(!GetAmEnabled());
1261                 __pEditTime->FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
1262                 __pEditTime->UpdateAccessibilityElement();
1263                 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1264
1265                 __selectedId = DATETIME_ID_NONE;
1266
1267                 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1268                 {
1269                         __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1270                         __pEditTime->GetDateTimeBar()->Close();
1271                 }
1272
1273                 Draw();
1274
1275                 return true;
1276         }
1277
1278         Draw();
1279
1280         if ((__pEditTime->GetDateTimeBar() != null) && (boxId != DATETIME_ID_AMPM) && (GetLastSelectedId() != DATETIME_ID_NONE))
1281         {
1282                 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1283                 bounds = GetDisplayAreaBoundsFromHoursStyle(GetLastSelectedId());
1284                 FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1285                 absoluteBounds = __pEditTime->GetAbsoluteBoundsF();
1286                 bounds.x += absoluteBounds.x;
1287
1288                 __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds);
1289
1290                 if (__pEditTime->GetDateTimeBar()->IsActivated())
1291                 {
1292                         __pEditTime->GetDateTimeBar()->RefreshItems();
1293                 }
1294                 else
1295                 {
1296                         __pEditTime->GetDateTimeBar()->SetVisibleState(true);
1297                         __pEditTime->GetDateTimeBar()->Open();
1298                 }
1299         }
1300
1301         __selectedId = DATETIME_ID_NONE;
1302         return true;
1303 }
1304
1305 bool
1306 _EditTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1307 {
1308         if (&source != __pEditTime)
1309         {
1310                 return false;
1311         }
1312
1313         __selectedId = DATETIME_ID_NONE;
1314
1315         return true;
1316 }
1317
1318 bool
1319 _EditTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1320 {
1321         if (&source != __pEditTime)
1322         {
1323                 return false;
1324         }
1325
1326         if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1327         {
1328                 return true;
1329         }
1330
1331         return false;
1332 }
1333
1334 void
1335 _EditTimePresenter::OnTouchMoveHandled(const _Control& control)
1336 {
1337         __touchMoveHandled = true;
1338         __selectedId = DATETIME_ID_NONE;
1339
1340         return;
1341 }
1342
1343 void
1344 _EditTimePresenter::OnFontChanged(Font* pFont)
1345 {
1346         __pFont = pFont;
1347
1348         if (__pEditTime->GetDateTimeBar() != null)
1349         {
1350                 __pEditTime->GetDateTimeBar()->SetFont(*pFont);
1351         }
1352
1353         return;
1354 }
1355
1356 void
1357 _EditTimePresenter::OnFontInfoRequested(unsigned long& style, float& size)
1358 {
1359         style = FONT_STYLE_PLAIN;
1360         size = __timeFontSize;
1361
1362         return;
1363 }
1364
1365 result
1366 _EditTimePresenter::Initialize(void)
1367 {
1368         result r = E_SUCCESS;
1369
1370         float titleTimeMargin = 0;
1371         float timeHeight = 0;
1372         float editTimeHeight = 0;
1373
1374         GET_SHAPE_CONFIG(EDITTIME::TEXT_FONT_SIZE, __pEditTime->GetOrientation(), __titleFontSize);
1375         GET_SHAPE_CONFIG(EDITTIME::TIME_FONT_SIZE, __pEditTime->GetOrientation(), __timeFontSize);
1376         GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
1377         GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
1378         GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), editTimeHeight);
1379
1380         if (__pEditTime->GetBoundsF().height > editTimeHeight)
1381         {
1382                 editTimeHeight = __pEditTime->GetBoundsF().height;
1383         }
1384
1385         if (__title.IsEmpty() == false)
1386         {
1387                 SetTitleBounds();
1388                 if (!__isEditTimeInitialized)
1389                 {
1390                         r = InitializeTitleObject();
1391                         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1392                 }
1393
1394                 __titleBounds.y = (editTimeHeight - (__titleBounds.height + titleTimeMargin + timeHeight)) / 2.0f;
1395                 __titleObject.SetBounds(__titleBounds);
1396         }
1397
1398         __pFont = __pEditTime->GetFallbackFont();
1399         r = GetLastResult();
1400         SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
1401
1402         if (!__isEditTimeInitialized)
1403         {
1404                 r = LoadResource();
1405                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1406
1407                 r = InitializeTextObject();
1408                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1409         }
1410
1411         __isEditTimeInitialized = true;
1412
1413         UpdateTimeFormat();
1414         return r;
1415 }
1416
1417 void
1418 _EditTimePresenter::UpdateTimeFormat(void)
1419 {
1420         if (!__is24hoursSet)
1421         {
1422                 String key(L"http://tizen.org/setting/locale.time.format.24hour");
1423                 SettingInfo::GetValue(key , __24hours);
1424         }
1425
1426         return;
1427 }
1428
1429 void
1430 _EditTimePresenter::Animate(void)
1431 {
1432         SysAssertf((__pFont != null), "Font instance must not be null.");
1433
1434         (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
1435
1436         result r = E_SUCCESS;
1437         FloatRectangle rect;
1438         String hourString;
1439         String minuteString;
1440         String newValue;
1441
1442         _DateTimeUtils dateTimeUtils;
1443         int hours = GetHour();
1444         if (!Is24HourNotationEnabled())
1445         {
1446                 hours = hours % 12;
1447
1448                 if (hours == DATETIME_HOUR_MIN)
1449                 {
1450                         hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1451                 }
1452         }
1453         hourString.Format(10, L"%02d", hours);
1454         minuteString.Format(10, L"%02d", GetMinute());
1455
1456         if (GetLastSelectedId() == DATETIME_ID_HOUR)
1457         {
1458                 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(hourString) == false), E_SUCCESS, "[E_SUCCESS] Hour string matched.");
1459
1460                 newValue = hourString;
1461                 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1462         }
1463         else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1464         {
1465                 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(minuteString) == false), E_SUCCESS, "[E_SUCCESS] Minute string matched.");
1466
1467                 newValue = minuteString;
1468                 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1469         }
1470
1471         FloatDimension newTextDim;
1472         FloatDimension oldTextDim;
1473         FloatPoint textPoint;
1474         VisualElement* pNewVisualElement = null;
1475         VisualElement* pOldVisualElement = null;
1476         VisualElement* pEditTimeElement = null;
1477         VisualElementPropertyAnimation* pNewBoundsAnimation = null;
1478         VisualElementPropertyAnimation* pOldBoundsAnimation = null;
1479         Canvas *pCanvas = null;
1480         Color contentBgColor;
1481         Color textNormalColor;
1482         Color textPressedColor;
1483
1484         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_PRESSED, contentBgColor);
1485         GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textPressedColor);
1486
1487         __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim);
1488         __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim);
1489
1490         if (newTextDim.width > oldTextDim.width)
1491         {
1492                 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1493         }
1494         else
1495         {
1496                 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1497         }
1498
1499         SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditTime->GetBounds().width), E_SUCCESS, "Rolling animation cann't be played.");
1500
1501         __isAnimating = true;
1502
1503         __pContentProvider = new (std::nothrow) VisualElement();
1504         SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1505
1506         r = __pContentProvider->Construct();
1507         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1508
1509         __pContentProvider->SetShowState(true);
1510         __pContentProvider->SetClipChildrenEnabled(true);
1511         __pContentProvider->SetImplicitAnimationEnabled(false);
1512
1513         pEditTimeElement = __pEditTime->GetVisualElement();
1514         r = GetLastResult();
1515         SysTryCatch(NID_UI_CTRL, (pEditTimeElement != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1516
1517         pNewVisualElement = new (std::nothrow) VisualElement();
1518         SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1519
1520         r = pNewVisualElement->Construct();
1521         if (r != E_SUCCESS)
1522         {
1523                 pNewVisualElement->Destroy();
1524         }
1525         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1526
1527         pNewVisualElement->SetShowState(true);
1528
1529         pOldVisualElement = new (std::nothrow) VisualElement();
1530         if (pOldVisualElement == null)
1531         {
1532                 pNewVisualElement->Destroy();
1533         }
1534         SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1535
1536         r = pOldVisualElement->Construct();
1537         if (r != E_SUCCESS)
1538         {
1539                 pNewVisualElement->Destroy();
1540                 pOldVisualElement->Destroy();
1541         }
1542         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1543
1544         pOldVisualElement->SetShowState(true);
1545
1546         if (newTextDim.width > oldTextDim.width)
1547         {
1548                 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1549                 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1550                 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1551                 pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1552
1553                 rect.x = __pContentProvider->GetBounds().x;
1554                 rect.y = __pContentProvider->GetBounds().y;
1555                 rect.width = __pContentProvider->GetBounds().width;
1556                 rect.height = __pContentProvider->GetBounds().height;
1557
1558                 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1559                 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1560
1561                 pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1562         }
1563         else
1564         {
1565                 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1566                 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1567                 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1568                 pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1569
1570                 rect.x = __pContentProvider->GetBounds().x;
1571                 rect.y = __pContentProvider->GetBounds().y;
1572                 rect.width = __pContentProvider->GetBounds().width;
1573                 rect.height = __pContentProvider->GetBounds().height;
1574
1575                 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1576                 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1577
1578                 pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1579         }
1580
1581         pCanvas = pEditTimeElement->GetCanvasN(rect);
1582         pCanvas->SetBackgroundColor(contentBgColor);
1583         pCanvas->Clear();
1584         delete pCanvas;
1585
1586         pEditTimeElement->AttachChild(*__pContentProvider);
1587
1588         __pContentProvider->AttachChild(*pOldVisualElement);
1589         __pContentProvider->AttachChild(*pNewVisualElement);
1590
1591         pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1592         SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1593
1594         pNewBoundsAnimation->SetDuration(300);
1595         pNewBoundsAnimation->SetPropertyName("bounds.position");
1596         pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.height * 1.0f)));
1597         pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f)));
1598         pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1599
1600         pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1601         SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1602
1603         pOldBoundsAnimation->SetDuration(300);
1604         pOldBoundsAnimation->SetPropertyName("bounds.position");
1605         pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f)));
1606         pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f)));
1607         pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1608
1609         pCanvas = pOldVisualElement->GetCanvasN();
1610         r = GetLastResult();
1611         SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1612
1613         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1614         pCanvas->Clear();
1615         pCanvas->SetForegroundColor(textPressedColor);
1616         (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
1617         pCanvas->SetFont(*__pFont);
1618         pCanvas->DrawText(FloatPoint(0.0f, 0.0f), __lastSelectedValue);
1619
1620         delete pCanvas;
1621         pCanvas = null;
1622
1623         pCanvas = pNewVisualElement->GetCanvasN();
1624         r = GetLastResult();
1625         SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1626
1627         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1628         pCanvas->Clear();
1629         pCanvas->SetForegroundColor(textPressedColor);
1630         (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
1631         pCanvas->SetFont(*__pFont);
1632         pCanvas->DrawText(FloatPoint(0.0f, 0.0f), newValue);
1633
1634         delete pCanvas;
1635         pCanvas = null;
1636
1637         pOldVisualElement->SetImplicitAnimationEnabled(false);
1638         pOldVisualElement->AddAnimation(*pOldBoundsAnimation);
1639
1640         pNewVisualElement->SetImplicitAnimationEnabled(false);
1641         pNewVisualElement->AddAnimation(*pNewBoundsAnimation);
1642
1643         delete pOldBoundsAnimation;
1644         delete pNewBoundsAnimation;
1645
1646         return;
1647
1648 CATCH:
1649         __isAnimating = false;
1650         __pContentProvider->Destroy();
1651
1652         delete pNewBoundsAnimation;
1653         pNewBoundsAnimation = null;
1654
1655         delete pOldBoundsAnimation;
1656         pOldBoundsAnimation = null;
1657
1658         delete pCanvas;
1659         pCanvas = null;
1660
1661         return;
1662 }
1663
1664 void
1665 _EditTimePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally)
1666 {
1667         result r = E_SUCCESS;
1668         __isAnimating = false;
1669
1670         VisualElement* pEditTimeElement = __pEditTime->GetVisualElement();
1671         r = GetLastResult();
1672         SysTryReturnVoidResult(NID_UI_CTRL, (pEditTimeElement != null), r, "[%s] Propagating.", GetErrorMessage(r));
1673
1674         pEditTimeElement->DetachChild(*__pContentProvider);
1675         __pContentProvider->Destroy();
1676
1677         Draw();
1678         return;
1679 }
1680
1681 }}} // Tizen::Ui::Controls