GUI 3.6 applied in EditDate & EditTime
[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::WIDTH, __pEditTime->GetOrientation(), __titleBounds.width);
432         GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), __titleBounds.height);
433
434         __titleBounds.width = __titleBounds.width - __titleBounds.x;
435         return;
436 }
437
438 FloatRectangle
439 _EditTimePresenter::GetTitleBounds(void) const
440 {
441         return __titleBounds;
442 }
443
444 result
445 _EditTimePresenter::LoadResource(void)
446 {
447         result r = E_SUCCESS;
448
449         Color buttonNormalBgColor;
450         Color buttonDisabledBgColor;
451         Color buttonPressedColor;
452         Color buttonHighlightedColor;
453         Color contentNormalBgColor;
454         Color contentDisabledBgColor;
455         Color contentPressedColor;
456         Color contentHighlightedColor;
457         Color colonTextColor;
458         Color colonTextDisabledColor;
459         Bitmap* pTempBitmap = null;
460
461         GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_NORMAL, buttonNormalBgColor);
462         GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_PRESSED, buttonPressedColor);
463         GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_DISABLED, buttonDisabledBgColor);
464         GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_HIGHLIGHTED, buttonHighlightedColor);
465
466         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_NORMAL, contentNormalBgColor);
467         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_DISABLED, contentDisabledBgColor);
468         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_PRESSED, contentPressedColor);
469         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
470
471         GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, colonTextColor);
472         GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, colonTextDisabledColor);
473
474         GET_SHAPE_CONFIG(EDITTIME::AMPM_FONT_SIZE, __pEditTime->GetOrientation(), __amPmTextSize);
475
476         r = GET_BITMAP_CONFIG_N(EDITTIME::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
477         SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
478
479         __pColonColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA),
480                                                                               colonTextColor);
481         SysTryCatch(NID_UI_CTRL, (__pColonColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
482                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
483
484         __pColonDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA),
485                         colonTextDisabledColor);
486         SysTryCatch(NID_UI_CTRL, (__pColonDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
487                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
488
489         delete pTempBitmap;
490         pTempBitmap = null;
491
492         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
493         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
494
495         __pAmPmBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalBgColor);
496         SysTryCatch(NID_UI_CTRL, (__pAmPmBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
497                                 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
498
499         delete pTempBitmap;
500         pTempBitmap = null;
501
502         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
503         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
504
505         __pAmPmBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonDisabledBgColor);
506         SysTryCatch(NID_UI_CTRL, (__pAmPmBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
507                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
508
509         delete pTempBitmap;
510         pTempBitmap = null;
511
512         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
513         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
514
515         __pAmPmBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonPressedColor);
516         SysTryCatch(NID_UI_CTRL, (__pAmPmBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
517                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
518
519         delete pTempBitmap;
520         pTempBitmap = null;
521
522         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
523         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
524
525         __pAmPmBgHighlightedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonHighlightedColor);
526         SysTryCatch(NID_UI_CTRL, (__pAmPmBgHighlightedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
527                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
528
529         delete pTempBitmap;
530         pTempBitmap = null;
531
532         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
533         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
534
535         __pContentBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentNormalBgColor);
536         SysTryCatch(NID_UI_CTRL, (__pContentBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
537                                 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
538
539         delete pTempBitmap;
540         pTempBitmap = null;
541
542         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
543         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
544
545         __pContentBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentPressedColor);
546         SysTryCatch(NID_UI_CTRL, (__pContentBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
547                                 "[%s] Propagating.", GetErrorMessage(GetLastResult()));
548
549         delete pTempBitmap;
550         pTempBitmap = null;
551
552         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
553         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
554
555         __pContentBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentDisabledBgColor);
556         SysTryCatch(NID_UI_CTRL, (__pContentBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
557                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
558
559         delete pTempBitmap;
560         pTempBitmap = null;
561
562         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
563         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
564
565         __pContentBgHighlightedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
566         SysTryCatch(NID_UI_CTRL, (__pContentBgHighlightedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(),
567                                         "[%s] Propagating.", GetErrorMessage(GetLastResult()));
568
569         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectNomralBitmap);
570         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
571
572         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectPressedBitmap);
573         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
574
575         r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectDisabledBitmap);
576         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
577
578         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectNormalBitmap);
579         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
580
581         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectPressedBitmap);
582         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
583
584         r = GET_BITMAP_CONFIG_N(EDITTIME::CONTENT_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pContentBgEffectDisabledBitmap);
585         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
586
587
588         delete pTempBitmap;
589         pTempBitmap = null;
590
591         return r;
592
593 CATCH:
594         delete pTempBitmap;
595         pTempBitmap = null;
596
597         delete __pAmPmBgNormalColorReplacementBitmap;
598         __pAmPmBgNormalColorReplacementBitmap = null;
599
600         delete __pAmPmBgPressedColorReplacementBitmap;
601         __pAmPmBgPressedColorReplacementBitmap = null;
602
603         delete __pAmPmBgDisabledColorReplacementBitmap;
604         __pAmPmBgDisabledColorReplacementBitmap = null;
605
606         delete __pAmPmBgHighlightedColorReplacementBitmap;
607         __pAmPmBgHighlightedColorReplacementBitmap = null;
608
609         delete __pContentBgNormalColorReplacementBitmap;
610         __pContentBgNormalColorReplacementBitmap = null;
611
612         delete __pContentBgPressedColorReplacementBitmap;
613         __pContentBgPressedColorReplacementBitmap = null;
614
615         delete __pContentBgDisabledColorReplacementBitmap;
616         __pContentBgDisabledColorReplacementBitmap = null;
617
618         delete __pContentBgHighlightedColorReplacementBitmap;
619         __pContentBgHighlightedColorReplacementBitmap = null;
620
621         delete __pAmPmBgEffectNomralBitmap;
622         __pAmPmBgEffectNomralBitmap = null;
623
624         delete __pAmPmBgEffectPressedBitmap;
625         __pAmPmBgEffectPressedBitmap = null;
626
627         delete __pAmPmBgEffectDisabledBitmap;
628         __pAmPmBgEffectDisabledBitmap = null;
629
630         delete __pContentBgEffectNormalBitmap;
631         __pContentBgEffectNormalBitmap = null;
632
633         delete __pContentBgEffectPressedBitmap;
634         __pContentBgEffectPressedBitmap = null;
635
636         delete __pContentBgEffectDisabledBitmap;
637         __pContentBgEffectDisabledBitmap = null;
638
639         delete __pColonColorReplacementBitmap;
640         __pColonColorReplacementBitmap = null;
641
642         delete __pColonDisabledColorReplacementBitmap;
643         __pColonDisabledColorReplacementBitmap = null;
644
645         return r;
646 }
647
648 result
649 _EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
650 {
651         result r = E_SUCCESS;
652
653         if (pBitmap == null)
654         {
655                 return r;
656         }
657
658         if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
659         {
660                 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
661                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
662         }
663         else
664         {
665                 r = canvas.DrawBitmap(bounds, *pBitmap);
666                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
667         }
668
669         return r;
670 }
671
672 float
673 _EditTimePresenter::GetTimeElementWidth(void) const
674 {
675         FloatRectangle bounds;
676         FloatDimension minSize;
677         bounds = __pEditTime->GetBoundsF();
678
679         float timeElementWidth = 0.0f;
680         float timeElementMinWidth = 0.0f;
681         float editTimeWidth = 0.0f;
682
683         GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), timeElementWidth);
684         GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_MIN_WIDTH, __pEditTime->GetOrientation(), timeElementMinWidth);
685         GET_SHAPE_CONFIG(EDITTIME::WIDTH, __pEditTime->GetOrientation(), editTimeWidth);
686
687         GET_DIMENSION_CONFIG(EDITTIME::MIN_SIZE, __pEditTime->GetOrientation(), minSize);
688
689         if (bounds.width >= editTimeWidth)
690         {
691                 return timeElementWidth;
692         }
693
694         if (bounds.width <= minSize.width)
695         {
696                 timeElementWidth = timeElementMinWidth;
697         }
698         else if (bounds.width < editTimeWidth && bounds.width > minSize.width)
699         {
700                 timeElementWidth = timeElementWidth -
701                                 ((timeElementWidth - timeElementMinWidth) / (editTimeWidth - minSize.width)) * (editTimeWidth - bounds.width);
702         }
703
704         return timeElementWidth;
705 }
706
707 result
708 _EditTimePresenter::InitializeTitleObject(void)
709 {
710         result r = E_SUCCESS;
711
712         Color titleNormalColor;
713
714         GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_NORMAL, titleNormalColor);
715
716         r = __titleObject.Construct();
717         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
718
719         TextSimple* pSimpleText = null;
720
721         pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
722         SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
723
724         __titleObject.AppendElement(*pSimpleText);
725
726         __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength());
727         __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength());
728         __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
729         __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
730         __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
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                 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_NORMAL);
921                 pReplacementBitmap = __pContentBgNormalColorReplacementBitmap;
922                 pEffectBitmap = __pContentBgEffectNormalBitmap;
923         }
924         else
925         {
926                 isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED);
927                 pReplacementBitmap = __pContentBgPressedColorReplacementBitmap;
928                 pEffectBitmap = __pContentBgEffectPressedBitmap;
929         }
930
931         r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap);
932         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
933
934         if (!isCustomBitmap)
935         {
936                 r = DrawResourceBitmap(canvas, bounds, pEffectBitmap);
937                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
938         }
939
940         return r;
941 }
942
943 result
944 _EditTimePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, _DateTimeId boxId, float textSize)
945 {
946         result r = E_SUCCESS;
947
948         Color textColor;
949
950         if (!__pEditTime->IsEnabled())
951         {
952                 if (boxId == DATETIME_ID_AMPM)
953                 {
954                         GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_DISABLED, textColor);
955                 }
956                 else
957                 {
958                         GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, textColor);
959                 }
960         }
961         else
962         {
963                 GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, textColor);
964
965                 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated() &&
966                                 (GetLastSelectedId() == boxId))
967                 {
968                         GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
969                 }
970
971                 if (boxId == DATETIME_ID_AMPM)
972                 {
973                         GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_NORMAL, textColor);
974                 }
975
976                 if (boxId > -1 && boxId == __selectedId)
977                 {
978                         if (boxId == DATETIME_ID_AMPM)
979                         {
980                                 GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_PRESSED, textColor);
981                         }
982                         else
983                         {
984                                 GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
985                         }
986                 }
987         }
988
989         if (boxId != DATETIME_ID_AMPM)
990         {
991                 DrawContentBitmap(canvas, bounds, boxId);
992         }
993
994         FloatRectangle drawAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
995         drawAreaBounds = bounds;
996
997         TextSimple* pSimpleText = null;
998         pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
999         SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1000
1001         __textObject.RemoveAll();
1002
1003         (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
1004         (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN);
1005
1006         __textObject.AppendElement(*pSimpleText);
1007
1008         if (boxId == __selectedId && boxId != DATETIME_ID_AMPM)
1009         {
1010                 (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
1011         }
1012
1013         if (boxId == DATETIME_ID_AMPM)
1014         {
1015                 (_FontImpl::GetInstance(*__pFont))->SetSize(textSize);
1016         }
1017
1018         __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
1019
1020         __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength());
1021         __textObject.SetBounds(drawAreaBounds);
1022         __textObject.Draw(*_CanvasImpl::GetInstance(canvas));
1023
1024         return r;
1025 }
1026
1027 _DateTimeId
1028 _EditTimePresenter::GetBoxIdFromPosition(const FloatPoint& point) const
1029 {
1030         _DateTimeId displayBoxId = DATETIME_ID_NONE;
1031
1032         FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
1033         FloatRectangle hoursBounds(0.0f, 0.0f, 0.0f, 0.0f);
1034         FloatRectangle minutesBounds(0.0f, 0.0f, 0.0f, 0.0f);
1035
1036         if (__24hours == false)
1037         {
1038                 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
1039         }
1040
1041         hoursBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1042         minutesBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1043
1044         if (point.y < hoursBounds.y || point.y > hoursBounds.y + hoursBounds.height)
1045         {
1046                 return displayBoxId;
1047         }
1048
1049         if (hoursBounds.Contains(point) == true)
1050         {
1051                 displayBoxId = DATETIME_ID_HOUR;
1052         }
1053         else if (minutesBounds.Contains(point) == true)
1054         {
1055                 displayBoxId = DATETIME_ID_MINUTE;
1056         }
1057         else if (ampmBounds.Contains(point) == true)
1058         {
1059                 displayBoxId = DATETIME_ID_AMPM;
1060         }
1061
1062         return displayBoxId;
1063 }
1064
1065 void
1066 _EditTimePresenter::SetLastSelectedId(_DateTimeId boxId)
1067 {
1068         __lastSelectedId = boxId;
1069         return;
1070 }
1071
1072 _DateTimeId
1073 _EditTimePresenter::GetLastSelectedId(void) const
1074 {
1075         return __lastSelectedId;
1076 }
1077
1078 bool
1079 _EditTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1080 {
1081         SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
1082
1083         if (&source != __pEditTime)
1084         {
1085                 return false;
1086         }
1087
1088         __touchMoveHandled = false;
1089
1090         FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f);
1091         FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1092         FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f);
1093
1094         hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1095         minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1096
1097         if (__24hours == false)
1098         {
1099                 ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
1100         }
1101
1102         FloatPoint point = touchinfo.GetCurrentPosition();
1103
1104         _DateTimeId boxId = GetBoxIdFromPosition(point);
1105
1106         int minValue = -1;
1107         int maxValue = -1;
1108         int displayValue = -1;
1109
1110         if (boxId == DATETIME_ID_HOUR)
1111         {
1112                 if (__pEditTime->GetDateTimeBar() != null)
1113                 {
1114                         if (__24hours == false)
1115                         {
1116                                 if (GetHour() == 0)
1117                                 {
1118                                         minValue = DATETIME_HOUR_MIN + 1;
1119                                         maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1120                                         displayValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1121                                 }
1122                                 else if (GetHour() > DATETIME_HOUR_MAX_FOR_24NOTATION)
1123                                 {
1124                                         minValue = DATETIME_HOUR_MIN + 1;
1125                                         maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1126                                         displayValue = GetHour() - DATETIME_HOUR_MAX_FOR_24NOTATION;
1127                                 }
1128                                 else
1129                                 {
1130                                         minValue = DATETIME_HOUR_MIN + 1;
1131                                         maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
1132                                         displayValue = GetHour();
1133                                 }
1134                         }
1135                         else
1136                         {
1137                                 minValue = DATETIME_HOUR_MIN;
1138                                 maxValue = DATETIME_HOUR_MAX;
1139                                 displayValue = GetHour();
1140                         }
1141
1142                         if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
1143                         {
1144                                 __pEditTime->GetDateTimeBar()->RemoveAllItems();
1145                         }
1146
1147                         __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
1148                 }
1149
1150                 __bounds = hourBounds;
1151         }
1152         else if (boxId == DATETIME_ID_MINUTE)
1153         {
1154                 if (__pEditTime->GetDateTimeBar() != null)
1155                 {
1156                         minValue = DATETIME_MINUTE_MIN;
1157                         maxValue = DATETIME_MINUTE_MAX;
1158                         displayValue = GetMinute();
1159
1160                         if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
1161                         {
1162                                 __pEditTime->GetDateTimeBar()->RemoveAllItems();
1163                         }
1164
1165                         __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
1166                 }
1167
1168                 __bounds = minuteBounds;
1169         }
1170         else if (boxId == DATETIME_ID_AMPM)
1171         {
1172                 __selectedId = boxId;
1173                 __bounds = ampmBounds;
1174                 Draw();
1175         }
1176         else
1177         {
1178                 __selectedId = DATETIME_ID_NONE;
1179                 return false;
1180         }
1181
1182         __selectedId = boxId;
1183
1184         return true;
1185 }
1186
1187 bool
1188 _EditTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1189 {
1190         SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled.");
1191
1192         if (&source != __pEditTime)
1193         {
1194                 return false;
1195         }
1196
1197         FloatRectangle bounds = __pEditTime->GetBoundsF();
1198
1199         FloatPoint startPoint(0.0f, 0.0f);
1200
1201         float titleHeight = 0;
1202         GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), titleHeight);
1203
1204         __bounds = FloatRectangle(0.0f, titleHeight, bounds.width, bounds.height);
1205
1206         FloatPoint point = touchinfo.GetCurrentPosition();
1207
1208         _DateTimeId boxId = GetBoxIdFromPosition(point);
1209
1210         if ((boxId == GetLastSelectedId() && boxId != DATETIME_ID_AMPM) || boxId != __selectedId || boxId == DATETIME_ID_NONE)
1211         {
1212                 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1213                 {
1214                         __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1215                         __pEditTime->GetDateTimeBar()->Close();
1216                 }
1217
1218                 __selectedId = DATETIME_ID_NONE;
1219                 SetLastSelectedId(__selectedId);
1220
1221                 Draw();
1222
1223                 return true;
1224         }
1225
1226         SetLastSelectedId(__selectedId);
1227
1228         __lastSelectedValue = "";
1229         _DateTimeUtils dateTimeUtils;
1230
1231         if (GetLastSelectedId() == DATETIME_ID_HOUR)
1232         {
1233                 int hours = GetHour();
1234
1235                 if (!Is24HourNotationEnabled())
1236                 {
1237                         hours = hours % 12;
1238
1239                         if (hours == DATETIME_HOUR_MIN)
1240                         {
1241                                 hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1242                         }
1243                 }
1244                 __lastSelectedValue.Format(10, L"%02d", hours);
1245                 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1246         }
1247         else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1248         {
1249                 __lastSelectedValue.Format(10, L"%02d", GetMinute());
1250                 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1251         }
1252         else if (GetLastSelectedId() == DATETIME_ID_AMPM)
1253         {
1254                 SetAmEnabled(!GetAmEnabled());
1255                 __pEditTime->FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
1256                 __pEditTime->UpdateAccessibilityElement();
1257                 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
1258
1259                 __selectedId = DATETIME_ID_NONE;
1260
1261                 if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1262                 {
1263                         __pEditTime->GetDateTimeBar()->SetVisibleState(false);
1264                         __pEditTime->GetDateTimeBar()->Close();
1265                 }
1266
1267                 Draw();
1268
1269                 return true;
1270         }
1271
1272         Draw();
1273
1274         if ((__pEditTime->GetDateTimeBar() != null) && (boxId != DATETIME_ID_AMPM) && (GetLastSelectedId() != DATETIME_ID_NONE))
1275         {
1276                 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1277                 bounds = GetDisplayAreaBoundsFromHoursStyle(GetLastSelectedId());
1278                 FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1279                 absoluteBounds = __pEditTime->GetAbsoluteBoundsF();
1280                 bounds.x += absoluteBounds.x;
1281
1282                 __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds);
1283
1284                 if (__pEditTime->GetDateTimeBar()->IsActivated())
1285                 {
1286                         __pEditTime->GetDateTimeBar()->RefreshItems();
1287                 }
1288                 else
1289                 {
1290                         __pEditTime->GetDateTimeBar()->SetVisibleState(true);
1291                         __pEditTime->GetDateTimeBar()->Open();
1292                 }
1293         }
1294
1295         __selectedId = DATETIME_ID_NONE;
1296         return true;
1297 }
1298
1299 bool
1300 _EditTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1301 {
1302         if (&source != __pEditTime)
1303         {
1304                 return false;
1305         }
1306
1307         __selectedId = DATETIME_ID_NONE;
1308
1309         return true;
1310 }
1311
1312 bool
1313 _EditTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1314 {
1315         if (&source != __pEditTime)
1316         {
1317                 return false;
1318         }
1319
1320         if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
1321         {
1322                 return true;
1323         }
1324
1325         return false;
1326 }
1327
1328 void
1329 _EditTimePresenter::OnTouchMoveHandled(const _Control& control)
1330 {
1331         __touchMoveHandled = true;
1332         __selectedId = DATETIME_ID_NONE;
1333
1334         return;
1335 }
1336
1337 void
1338 _EditTimePresenter::OnFontChanged(Font* pFont)
1339 {
1340         __pFont = pFont;
1341
1342         if (__pEditTime->GetDateTimeBar() != null)
1343         {
1344                 __pEditTime->GetDateTimeBar()->SetFont(*pFont);
1345         }
1346
1347         return;
1348 }
1349
1350 void
1351 _EditTimePresenter::OnFontInfoRequested(unsigned long& style, float& size)
1352 {
1353         style = FONT_STYLE_PLAIN;
1354         size = __timeFontSize;
1355
1356         return;
1357 }
1358
1359 result
1360 _EditTimePresenter::Initialize(void)
1361 {
1362         result r = E_SUCCESS;
1363
1364         float titleTimeMargin = 0;
1365         float timeHeight = 0;
1366         float editTimeHeight = 0;
1367
1368         GET_SHAPE_CONFIG(EDITTIME::TEXT_FONT_SIZE, __pEditTime->GetOrientation(), __titleFontSize);
1369         GET_SHAPE_CONFIG(EDITTIME::TIME_FONT_SIZE, __pEditTime->GetOrientation(), __timeFontSize);
1370         GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin);
1371         GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight);
1372         GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), editTimeHeight);
1373
1374         if (__pEditTime->GetBoundsF().height > editTimeHeight)
1375         {
1376                 editTimeHeight = __pEditTime->GetBoundsF().height;
1377         }
1378
1379         if (__title.IsEmpty() == false)
1380         {
1381                 SetTitleBounds();
1382                 if (!__isEditTimeInitialized)
1383                 {
1384                         r = InitializeTitleObject();
1385                         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1386                 }
1387
1388                 __titleBounds.y = (editTimeHeight - (__titleBounds.height + titleTimeMargin + timeHeight)) / 2.0f;
1389                 __titleObject.SetBounds(__titleBounds);
1390         }
1391
1392         __pFont = __pEditTime->GetFallbackFont();
1393         r = GetLastResult();
1394         SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
1395
1396         if (!__isEditTimeInitialized)
1397         {
1398                 r = LoadResource();
1399                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1400
1401                 r = InitializeTextObject();
1402                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1403         }
1404
1405         __isEditTimeInitialized = true;
1406
1407         UpdateTimeFormat();
1408         return r;
1409 }
1410
1411 void
1412 _EditTimePresenter::UpdateTimeFormat(void)
1413 {
1414         if (!__is24hoursSet)
1415         {
1416                 String key(L"http://tizen.org/setting/locale.time.format.24hour");
1417                 SettingInfo::GetValue(key , __24hours);
1418         }
1419
1420         return;
1421 }
1422
1423 void
1424 _EditTimePresenter::Animate(void)
1425 {
1426         SysAssertf((__pFont != null), "Font instance must not be null.");
1427
1428         (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
1429
1430         result r = E_SUCCESS;
1431         FloatRectangle rect;
1432         String hourString;
1433         String minuteString;
1434         String newValue;
1435
1436         _DateTimeUtils dateTimeUtils;
1437         int hours = GetHour();
1438         if (!Is24HourNotationEnabled())
1439         {
1440                 hours = hours % 12;
1441
1442                 if (hours == DATETIME_HOUR_MIN)
1443                 {
1444                         hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
1445                 }
1446         }
1447         hourString.Format(10, L"%02d", hours);
1448         minuteString.Format(10, L"%02d", GetMinute());
1449
1450         if (GetLastSelectedId() == DATETIME_ID_HOUR)
1451         {
1452                 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(hourString) == false), E_SUCCESS, "[E_SUCCESS] Hour string matched.");
1453
1454                 newValue = hourString;
1455                 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
1456         }
1457         else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
1458         {
1459                 SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(minuteString) == false), E_SUCCESS, "[E_SUCCESS] Minute string matched.");
1460
1461                 newValue = minuteString;
1462                 rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
1463         }
1464
1465         FloatDimension newTextDim;
1466         FloatDimension oldTextDim;
1467         FloatPoint textPoint;
1468         VisualElement* pNewVisualElement = null;
1469         VisualElement* pOldVisualElement = null;
1470         VisualElement* pEditTimeElement = null;
1471         VisualElementPropertyAnimation* pNewBoundsAnimation = null;
1472         VisualElementPropertyAnimation* pOldBoundsAnimation = null;
1473         Canvas *pCanvas = null;
1474         Color contentBgColor;
1475         Color textNormalColor;
1476         Color textPressedColor;
1477
1478         GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_PRESSED, contentBgColor);
1479         GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textPressedColor);
1480
1481         __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim);
1482         __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim);
1483
1484         if (newTextDim.width > oldTextDim.width)
1485         {
1486                 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1487         }
1488         else
1489         {
1490                 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1491         }
1492
1493         SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditTime->GetBounds().width), E_SUCCESS, "Rolling animation cann't be played.");
1494
1495         __isAnimating = true;
1496
1497         __pContentProvider = new (std::nothrow) VisualElement();
1498         SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1499
1500         r = __pContentProvider->Construct();
1501         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1502
1503         __pContentProvider->SetShowState(true);
1504         __pContentProvider->SetClipChildrenEnabled(true);
1505         __pContentProvider->SetImplicitAnimationEnabled(false);
1506
1507         pEditTimeElement = __pEditTime->GetVisualElement();
1508         r = GetLastResult();
1509         SysTryCatch(NID_UI_CTRL, (pEditTimeElement != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1510
1511         pNewVisualElement = new (std::nothrow) VisualElement();
1512         SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1513
1514         r = pNewVisualElement->Construct();
1515         if (r != E_SUCCESS)
1516         {
1517                 pNewVisualElement->Destroy();
1518         }
1519         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1520
1521         pNewVisualElement->SetShowState(true);
1522
1523         pOldVisualElement = new (std::nothrow) VisualElement();
1524         if (pOldVisualElement == null)
1525         {
1526                 pNewVisualElement->Destroy();
1527         }
1528         SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1529
1530         r = pOldVisualElement->Construct();
1531         if (r != E_SUCCESS)
1532         {
1533                 pNewVisualElement->Destroy();
1534                 pOldVisualElement->Destroy();
1535         }
1536         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1537
1538         pOldVisualElement->SetShowState(true);
1539
1540         if (newTextDim.width > oldTextDim.width)
1541         {
1542                 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1543                 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1544                 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1545                 pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1546
1547                 rect.x = __pContentProvider->GetBounds().x;
1548                 rect.y = __pContentProvider->GetBounds().y;
1549                 rect.width = __pContentProvider->GetBounds().width;
1550                 rect.height = __pContentProvider->GetBounds().height;
1551
1552                 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1553                 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1554
1555                 pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1556         }
1557         else
1558         {
1559                 textPoint.x = (rect.width - oldTextDim.width) / 2.0f;
1560                 textPoint.y = (rect.height - oldTextDim.height) / 2.0f;
1561                 __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1562                 pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f));
1563
1564                 rect.x = __pContentProvider->GetBounds().x;
1565                 rect.y = __pContentProvider->GetBounds().y;
1566                 rect.width = __pContentProvider->GetBounds().width;
1567                 rect.height = __pContentProvider->GetBounds().height;
1568
1569                 textPoint.x = (rect.width - newTextDim.width) / 2.0f;
1570                 textPoint.y = (rect.height - newTextDim.height) / 2.0f;
1571
1572                 pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f));
1573         }
1574
1575         pCanvas = pEditTimeElement->GetCanvasN(rect);
1576         pCanvas->SetBackgroundColor(contentBgColor);
1577         pCanvas->Clear();
1578         delete pCanvas;
1579
1580         pEditTimeElement->AttachChild(*__pContentProvider);
1581
1582         __pContentProvider->AttachChild(*pOldVisualElement);
1583         __pContentProvider->AttachChild(*pNewVisualElement);
1584
1585         pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1586         SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1587
1588         pNewBoundsAnimation->SetDuration(300);
1589         pNewBoundsAnimation->SetPropertyName("bounds.position");
1590         pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.height * 1.0f)));
1591         pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f)));
1592         pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1593
1594         pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation();
1595         SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1596
1597         pOldBoundsAnimation->SetDuration(300);
1598         pOldBoundsAnimation->SetPropertyName("bounds.position");
1599         pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f)));
1600         pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f)));
1601         pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
1602
1603         pCanvas = pOldVisualElement->GetCanvasN();
1604         r = GetLastResult();
1605         SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1606
1607         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1608         pCanvas->Clear();
1609         pCanvas->SetForegroundColor(textPressedColor);
1610         (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
1611         pCanvas->SetFont(*__pFont);
1612         pCanvas->DrawText(FloatPoint(0.0f, 0.0f), __lastSelectedValue);
1613
1614         delete pCanvas;
1615         pCanvas = null;
1616
1617         pCanvas = pNewVisualElement->GetCanvasN();
1618         r = GetLastResult();
1619         SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
1620
1621         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1622         pCanvas->Clear();
1623         pCanvas->SetForegroundColor(textPressedColor);
1624         (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
1625         pCanvas->SetFont(*__pFont);
1626         pCanvas->DrawText(FloatPoint(0.0f, 0.0f), newValue);
1627
1628         delete pCanvas;
1629         pCanvas = null;
1630
1631         pOldVisualElement->SetImplicitAnimationEnabled(false);
1632         pOldVisualElement->AddAnimation(*pOldBoundsAnimation);
1633
1634         pNewVisualElement->SetImplicitAnimationEnabled(false);
1635         pNewVisualElement->AddAnimation(*pNewBoundsAnimation);
1636
1637         delete pOldBoundsAnimation;
1638         delete pNewBoundsAnimation;
1639
1640         return;
1641
1642 CATCH:
1643         __isAnimating = false;
1644         __pContentProvider->Destroy();
1645
1646         delete pNewBoundsAnimation;
1647         pNewBoundsAnimation = null;
1648
1649         delete pOldBoundsAnimation;
1650         pOldBoundsAnimation = null;
1651
1652         delete pCanvas;
1653         pCanvas = null;
1654
1655         return;
1656 }
1657
1658 void
1659 _EditTimePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally)
1660 {
1661         result r = E_SUCCESS;
1662         __isAnimating = false;
1663
1664         VisualElement* pEditTimeElement = __pEditTime->GetVisualElement();
1665         r = GetLastResult();
1666         SysTryReturnVoidResult(NID_UI_CTRL, (pEditTimeElement != null), r, "[%s] Propagating.", GetErrorMessage(r));
1667
1668         pEditTimeElement->DetachChild(*__pContentProvider);
1669         __pContentProvider->Destroy();
1670
1671         Draw();
1672         return;
1673 }
1674
1675 }}} // Tizen::Ui::Controls