Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_TabPresenter.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_TabPresenter.cpp
20  * @brief               This is the implementation file for the _TabPresenter class.
21  */
22
23 #include <FBaseErrorDefine.h>
24 #include <FBaseRtITimerEventListener.h>
25 #include <FBaseRtTimer.h>
26 #include <FGrpFont.h>
27 #include <FBaseSys.h>
28 #include <FBaseSysLog.h>
29 #include <FUiAnimVisualElementPropertyAnimation.h>
30 #include <FGrp_FontImpl.h>
31 #include <FGrp_TextTextObject.h>
32 #include <FGrp_BitmapImpl.h>
33 #include <FGrp_TextTextSimple.h>
34 #include "FUi_AccessibilityElement.h"
35 #include "FUi_IAccessibilityListener.h"
36 #include "FUi_AccessibilityContainer.h"
37 #include "FUiAnim_VisualElement.h"
38 #include "FUi_UiTouchEvent.h"
39 #include "FUi_ResourceManager.h"
40 #include "FUiCtrl_TabPresenter.h"
41 #include "FUi_CoordinateSystemUtils.h"
42
43 using namespace Tizen::Base;
44 using namespace Tizen::Graphics;
45 using namespace Tizen::Graphics::_Text;
46 using namespace Tizen::Base::Runtime;
47 using namespace Tizen::Ui::Animations;
48
49 namespace Tizen { namespace Ui { namespace Controls {
50
51 struct ReorderAnimationInfo{
52
53         float xPosition;
54         int index;
55         float totalDistance;
56         float move;
57         int reorderValue;
58 };
59
60 struct TimerInfo{
61
62         int index;
63         Timer* pReorderTimer;
64 };
65
66 _TabPresenter::_TabPresenter(void)
67         : __pTab(null)
68         , __pTabModel(null)
69         , __pFont(null)
70         , __pTextObject(null)
71         , __isRecalculateNeeded(false)
72         , __isEditMode(false)
73         , __editItemIndex(-1)
74         //, __pVerticalLineBitmap(null)
75         , __pHorizontalLineBitmap(null)
76 //      , __pFrontScrollingEffectBitmap(null)
77 //      , __pRearScrollingEffectBitmap(null)
78 //      , __pScrollingEffectBitmap(null)
79         , __pFocusBitmap(null)
80 //      , __pScrollingEffectVe(null)
81         , __pFlickAnimationTimer(null)
82         , __pScrollAnimationTimer(null)
83         , __flickAnimation()
84         , __showItemCount(0)
85         , __width(0.0f)
86         , __height(0.0f)
87         , __moveDistance(0.0f)
88         , __isFlickEnabled(false)
89         , __itemMaxCount(0)
90         , __itemWidth(0.0f)
91         , __itemHeight(0.0f)
92         , __rearIndex(0)
93         , __isRightScrollable(false)
94         , __isLeftScrollable(false)
95         , __isDirectionRight(true)
96         , __isTimerCanceled(false)
97         , __flickMove(0.0f)
98         , __flickDistance(0.0f)
99         , __flickFlag(0)
100         , __reorderDist(0.0f)
101         , __firstItemIndex(0)
102         , __lastItemIndex(0)
103 //      , __isScrollEffectEnded(false)
104 //      , __isScrollEffectStarted(false)
105         , __timerCount(0)
106         , __isTouchMove(false)
107 //      , __scrollFlag(0)
108         , __tabMinimumSize(0.0f)
109         , __fontChangeItemCount(0)
110
111 {
112         __currentTouchPosition = FloatPoint(0.0f, 0.0f);
113         __dividerLine = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
114         __selectedLine = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
115
116         for (int i = 0; i < (_TIMER_COUNT); i++)
117         {
118                 __pTimerInfo[i] = null;
119         }
120
121         for (int i = 0; i < _TAB_ITEM_MAXCOUNT; i++)
122         {
123                 __pAnimInfo[i] = null;
124         }
125 }
126
127
128 _TabPresenter::~_TabPresenter(void)
129 {
130         if (__pTabModel)
131         {
132                 delete __pTabModel;
133                 __pTabModel = null;
134         }
135
136         if (__pTextObject)
137         {
138                 delete __pTextObject;
139                 __pTextObject = null;
140         }
141
142         //if (__pVerticalLineBitmap)
143         //{
144         //      delete __pVerticalLineBitmap;
145         //      __pVerticalLineBitmap = null;
146         //}
147
148         if (__pHorizontalLineBitmap)
149         {
150                 delete __pHorizontalLineBitmap;
151                 __pHorizontalLineBitmap = null;
152         }
153
154         if (__pFlickAnimationTimer)
155         {
156                 delete __pFlickAnimationTimer;
157                 __pFlickAnimationTimer = null;
158         }
159
160         for (int i = 0; i < (_TIMER_COUNT); i++)
161         {
162                 if (__pTimerInfo[i])
163                 {
164                         if (__pTimerInfo[i]->pReorderTimer)
165                         {
166                                 delete __pTimerInfo[i]->pReorderTimer;
167                                 __pTimerInfo[i]->pReorderTimer = null;
168                         }
169                         delete __pTimerInfo[i];
170                         __pTimerInfo[i] = null;
171                 }
172         }
173
174         for (int i = 0; i < _TAB_ITEM_MAXCOUNT; i++)
175         {
176                 if (__pAnimInfo[i])
177                 {
178                         delete __pAnimInfo[i];
179                         __pAnimInfo[i] = null;
180                 }
181         }
182
183         if (__pScrollAnimationTimer)
184         {
185                 delete __pScrollAnimationTimer;
186                 __pScrollAnimationTimer = null;
187         }
188
189 //      if (__pFrontScrollingEffectBitmap)
190 //      {
191 //              delete __pFrontScrollingEffectBitmap;
192 //              __pFrontScrollingEffectBitmap = null;
193 //      }
194
195 //      if (__pRearScrollingEffectBitmap)
196 //      {
197 //              delete __pRearScrollingEffectBitmap;
198 //              __pRearScrollingEffectBitmap = null;
199 //      }
200 //
201 //      if (__pScrollingEffectBitmap)
202 //      {
203 //              __pScrollingEffectBitmap = null;
204 //      }
205
206         if(__pFocusBitmap)
207         {
208                 delete __pFocusBitmap;
209                 __pFocusBitmap = null;
210         }
211
212 //      if (__pScrollingEffectVe)
213 //      {
214 //              __pScrollingEffectVe->RemoveAllAnimations();
215 //              __pScrollingEffectVe->Destroy();
216 //              __pScrollingEffectVe = null;
217 //      }
218 }
219
220 result
221 _TabPresenter::Construct(const _Tab& tab)
222 {
223         result r = E_SUCCESS;
224
225         __pTab = const_cast<_Tab*>(&tab);
226
227         __pFont = __pTab->GetFallbackFont();
228         SysTryReturn(NID_UI_CTRL, __pFont, E_SYSTEM , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to retrive Font.");
229
230         _TabModel* pModel = new (std::nothrow) _TabModel;
231         SysTryReturn(NID_UI_CTRL, pModel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
232
233         r = SetModel(*pModel);
234         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to set _TabModel instance.");
235
236         r = pModel->Construct();
237         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct _TabModel instance.");
238
239         __pTextObject = new (std::nothrow) TextObject;
240         SysTryCatch(NID_UI_CTRL, __pTextObject, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
241
242         __pTextObject->Construct();
243         __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
244         __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
245
246         r = LoadBitmap();
247         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate bitmap.");
248
249         GET_FIXED_VALUE_CONFIG(TAB::ITEM_MAX_COUNT, __pTab->GetOrientation(), __itemMaxCount);
250         GET_SHAPE_CONFIG(TAB::SCREEN_WIDTH, __pTab->GetOrientation(), __width);
251         GET_SHAPE_CONFIG(TAB::SCREEN_HEIGHT, __pTab->GetOrientation(), __height);
252
253         GET_FIXED_VALUE_CONFIG(TAB::DIVIDER_WIDTH, __pTab->GetOrientation(), __dividerLine.width);
254         GET_SHAPE_CONFIG(TAB::DIVIDER_HEIGHT, __pTab->GetOrientation(), __dividerLine.height);
255
256         GET_SHAPE_CONFIG(TAB::TAB_MINIMUM_SIZE, __pTab->GetOrientation(), __tabMinimumSize);
257
258         GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), __selectedLine.height);
259         GET_FIXED_VALUE_CONFIG(TAB::FONT_CHANGE_ITEM_COUNT, __pTab->GetOrientation(), __fontChangeItemCount);
260
261         __flickAnimation.SetSizeInformation(_CoordinateSystemUtils::ConvertToInteger(__width), _CoordinateSystemUtils::ConvertToInteger(__height), DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL);
262         __flickAnimation.SetSensitivity(FLICK_ANIMATION_FPS_TAB, FLICK_ANIMATION_SENSITIVITY_TAB);
263         __flickAnimation.SetDirection(FD_HORIZONTAL);
264
265         for (int i = 0; i < _TIMER_COUNT; i++)
266         {
267                 __pTimerInfo[i] = new (std::nothrow) TimerInfo();
268                 SysTryCatch(NID_UI_CTRL, __pTimerInfo[i], , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
269
270                 __pTimerInfo[i]->index = -1;
271                 __pTimerInfo[i]->pReorderTimer = null;
272         }
273
274         return r;
275
276 CATCH:
277         delete pModel;
278         pModel = null;
279
280         delete __pTextObject;
281         __pTextObject = null;
282
283         return r;
284 }
285
286 result
287 _TabPresenter::LoadBitmap(void)
288 {
289         result r = E_SUCCESS;
290         Tizen::Graphics::Bitmap* pBitmap = null;
291         Tizen::Graphics::Bitmap* pFocusBitmap = null;
292         Color focusBgColor(0x00000000);
293         Color itemSelectedColor(0x00000000);
294
295         r = GET_BITMAP_CONFIG_N(TAB::ITEM_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap);
296         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate horizontal line bitmap.");
297
298         GET_COLOR_CONFIG(TAB::ITEM_SELECTED, itemSelectedColor);
299
300         if (pBitmap)
301         {
302                 __pHorizontalLineBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pBitmap), Color::GetColor(COLOR_ID_MAGENTA), itemSelectedColor);
303                 SysTryLog(NID_UI_CTRL, (__pHorizontalLineBitmap != null), "Failed to locate focus item line bitmap.");
304         }
305
306 //      r = GET_BITMAP_CONFIG_N(TAB::TAB_BOUNCE_EFFECT_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, __pFrontScrollingEffectBitmap);
307 //      SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate overscrolling left bitmap.");
308
309 //      r = GET_BITMAP_CONFIG_N(TAB::TAB_BOUNCE_EFFECT_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, __pRearScrollingEffectBitmap);
310 //      SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate overscrolling right bitmap.");
311
312         r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pFocusBitmap);
313         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate focus bitmap.");
314
315         GET_COLOR_CONFIG(TAB::ITEM_BG_HIGHLIGHTED, focusBgColor);
316
317         if (pFocusBitmap)
318         {
319                 __pFocusBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pFocusBitmap), Color::GetColor(COLOR_ID_MAGENTA), focusBgColor);
320                 SysTryLog(NID_UI_CTRL, (__pFocusBitmap != null), "Failed to locate focus item line bitmap.");
321         }
322
323         delete pBitmap;
324         delete pFocusBitmap;
325         return r;
326 }
327
328 void
329 _TabPresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
330 {
331         result r = E_SUCCESS;
332
333         if (pBitmap == null)
334         {
335                 return;
336         }
337
338         if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
339         {
340                 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
341                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
342         }
343         else
344         {
345                 r = canvas.DrawBitmap(bounds, *pBitmap);
346                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
347         }
348
349         return;
350 }
351
352 result
353 _TabPresenter::SetModel(const _TabModel& tabModel)
354 {
355         __pTabModel = const_cast<_TabModel*>(&tabModel);
356
357         return E_SUCCESS;
358 }
359
360 void
361 _TabPresenter::SetSelectedItemIndex(int index)
362 {
363         int selectedIndex = GetSelectedItemIndex();
364
365         SetItemStatus(selectedIndex, _TABITEM_STATUS_NORMAL);
366         __pTabModel->SetSelectedItemIndex(index);
367         SetItemStatus(index, _TABITEM_STATUS_SELECTED);
368
369         return;
370 }
371
372 int
373 _TabPresenter::GetSelectedItemIndex(void) const
374 {
375         return __pTabModel->GetSelectedItemIndex();
376 }
377
378 void
379 _TabPresenter::SetPressedItemIndex(int index)
380 {
381         __pTabModel->SetPressedItemIndex(index);
382         return;
383 }
384
385 int
386 _TabPresenter::GetPressedItemIndex(void) const
387 {
388         return __pTabModel->GetPressedItemIndex();
389 }
390
391 void
392 _TabPresenter::SetFirstDrawnItemIndex(int index)
393 {
394         __pTabModel->SetFirstDrawnItemIndex(index);
395         return;
396 }
397
398 int
399 _TabPresenter::GetFirstDrawnItemIndex(void) const
400 {
401
402         return __pTabModel->GetFirstDrawnItemIndex();
403 }
404
405 void
406 _TabPresenter::SetEditModeEnabled(bool isEnabled)
407 {
408
409         return __pTabModel->SetEditModeEnabled(isEnabled);
410 }
411
412 bool
413 _TabPresenter::IsEditModeEnabled(void) const
414 {
415         return __pTabModel->IsEditModeEnabled();
416 }
417
418 int
419 _TabPresenter::GetItemCount(void) const
420 {
421
422         return __pTab->GetItemCount();
423 }
424
425 _TabItem*
426 _TabPresenter::GetItemAt(int index)
427 {
428         return __pTab->GetItemAt(index);
429 }
430
431 result
432 _TabPresenter::SetItemStatus(int index, _TabItemStatus status)
433 {
434         _TabItem *pItem = GetItemAt(index);
435         SysTryReturn(NID_UI_CTRL, pItem, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
436
437         pItem->SetUpdateState(true);
438         pItem->SetStatus(status);
439
440         return E_SUCCESS;
441 }
442
443 _TabItemStatus
444 _TabPresenter::GetItemStatus(int index) const
445 {
446
447         _TabItem *pItem = __pTab->GetItemAt(index);
448
449         if (pItem == null)
450         {
451                 return _TABITEM_STATUS_NORMAL;
452         }
453
454         return pItem->GetStatus();
455 }
456
457 int
458 _TabPresenter::GetItemIndexFromPosition(const FloatPoint& point) const
459 {
460
461         FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
462
463         int itemIndex = GetFirstDrawnItemIndex();
464
465         if ((point.x < 0.0f) || (point.x > __pTab->GetBoundsF().width)
466                         || (point.y < 0.0f) || (point.y > __pTab->GetBoundsF().height))
467         {
468                 return -1;
469         }
470
471         _TabItem* pItem = __pTab->GetItemAt(itemIndex);
472         if (pItem == null)
473         {
474                 return -1;
475         }
476
477         while (pItem != null)
478         {
479                 itemBounds = pItem->GetItemBounds();
480
481                 if ((point.x > itemBounds.x) && (point.x < itemBounds.x + itemBounds.width)
482                                 && (point.y > itemBounds.y) && (point.y < itemBounds.y + itemBounds.height))
483                 {
484                         return itemIndex;
485                 }
486
487                 itemIndex++;
488                 pItem = __pTab->GetItemAt(itemIndex);
489                 if (pItem == null)
490                 {
491                         break;
492                 }
493         }
494
495         return -1;
496 }
497
498 void
499 _TabPresenter::Draw(void)
500 {
501         ClearLastResult();
502
503         SysTryReturnVoidResult(NID_UI_CTRL, __pTab, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Tab instance is null.");
504         GET_COLOR_CONFIG(TAB::ITEM_BG_NORMAL, backgroundColor);
505
506         if (__isRecalculateNeeded)
507         {
508                 __isRecalculateNeeded = false;
509                 CalculateItemBounds();
510         }
511         else if (__isFlickEnabled )
512         {
513                 DrawHorizontal();
514         }
515
516         Canvas* pCanvas = __pTab->GetCanvasN();
517         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
518
519         pCanvas->SetBackgroundColor(backgroundColor);
520         pCanvas->Clear();
521
522         if (__pTab->GetStyle() == _TAB_STYLE_TEXT)
523         {
524                 DrawTextItem(pCanvas);
525         }
526         else if (__pTab->GetStyle() == _TAB_STYLE_ICON)
527         {
528                 DrawIconItem(pCanvas);
529         }
530         else    // _TAB_STYLE_ICON_TEXT
531         {
532                 DrawItem(pCanvas);
533         }
534
535         if (__pTab->GetCurrentHighlightedItemIndex() > -1 && __pTab->IsInFocusMode() == true && GetItemCount() > 0)
536         {
537                 DrawResourceBitmap(*pCanvas, GetItemAt(__pTab->GetCurrentHighlightedItemIndex())->GetItemBounds(), __pFocusBitmap);
538         }
539
540         __pTab->UpdateAccessibilityElement();
541
542         delete pCanvas;
543         return;
544 }
545
546 void
547 _TabPresenter::SetRecalculateItemBounds(bool isRecalculationRequired)
548 {
549         __isRecalculateNeeded = isRecalculationRequired;
550         return;
551 }
552
553 void
554 _TabPresenter::DrawTextItem(Canvas* pCanvas)
555 {
556         ClearLastResult();
557         TextSimple* pSimpleText = null;
558         Rectangle bounds = __pTab->GetBounds();
559
560         _TabItem* pDrawItem = null;
561         String itemText(L"");
562         FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
563
564         const int itemCount = GetItemCount();
565
566         _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
567
568         bool isMultiline = false;
569
570         float topMargin = 0.0f;
571         float bottomMargin = 0.0f;
572         float leftMargin = 0.0f;
573         float rightMargin = 0.0f;
574         float lineHeight = 0.0f;
575         float selectedLineHeight = 0.0f;
576         GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMargin);
577         GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
578         GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin);
579         GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin);
580         GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
581         GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
582
583         SetFirstLoadedItemIndex();
584         SetLastLoadedItemIndex();
585
586         int startIndex = __firstLoadedItemIndex - 1;
587         int endIndex = __lastLoadedItemIndex + 1;
588         if (__firstLoadedItemIndex == 0)
589         {
590                 startIndex = __firstLoadedItemIndex;
591         }
592
593         if (__lastLoadedItemIndex == (GetItemCount() - 1))
594         {
595                 endIndex = __lastLoadedItemIndex;
596         }
597
598         for (int i = startIndex; i <= endIndex; i++)
599         {
600                 if (i == __editItemIndex)
601                 {
602                         continue;
603                 }
604                 pDrawItem = GetItemAt(i);
605
606                 SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
607
608                 SetFirstDrawnItemIndex(0);
609
610                 itemDrawRect = pDrawItem->GetItemBounds();
611                 __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
612                 __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
613
614                 itemStatus = pDrawItem->GetStatus();
615
616                 if (!__pTab->IsEnabled())
617                 {
618                         itemStatus = _TABITEM_STATUS_DISABLED;
619                 }
620
621
622                 if (itemStatus == _TABITEM_STATUS_SELECTED)
623                 {
624                         DrawSelectedItemBackground(pCanvas, itemDrawRect);
625                         __selectedLine.width = __itemWidth;
626                         __selectedLine.x = itemDrawRect.x;
627                 }
628                 else if (itemStatus == _TABITEM_STATUS_PRESSED)
629                 {
630                         DrawPressedItemBackground(pCanvas, itemDrawRect);
631                 }
632                 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
633                 {
634                         DrawHighlightedItemBackground(pCanvas, itemDrawRect);
635                 }
636                 else
637                 {
638                         DrawItemBackground(pCanvas, itemDrawRect);
639                 }
640
641                 itemText = pDrawItem->GetText();
642
643                 __pTextObject->RemoveAll();
644                 pSimpleText = new (std::nothrow)TextSimple(const_cast <mchar*>(itemText.GetPointer()), itemText.GetLength());
645                 SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
646
647                 __pTextObject->AppendElement(*pSimpleText);
648                 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
649                 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
650
651                 itemDrawRect.x = itemDrawRect.x + leftMargin;
652                 itemDrawRect.y = itemDrawRect.y + topMargin;
653                 itemDrawRect.width = itemDrawRect.width - leftMargin - rightMargin;
654                 itemDrawRect.height = itemDrawRect.height - topMargin - bottomMargin;
655
656                 __pTextObject->SetBounds(itemDrawRect);
657                 __pTextObject->Compose();
658
659                 const int textRowCount = __pTextObject->GetTotalLineCount();
660
661                 isMultiline = false;
662
663                 if (textRowCount >= 2)
664                 {
665                         isMultiline = true;
666                 }
667
668                 float fontSize = 0.0f;
669
670                 if (__showItemCount < __fontChangeItemCount)
671                 {
672                         if (isMultiline == false)
673                         {
674                                 GET_SHAPE_CONFIG(TAB::FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
675                         }
676                         else
677                         {
678                                 GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
679                         }
680                 }
681                 else if (__showItemCount == __fontChangeItemCount)
682                 {
683                         if (isMultiline == false)
684                         {
685                                 GET_SHAPE_CONFIG(TAB::FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
686                         }
687                         else
688                         {
689                                 GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
690                         }
691                 }
692                 else
693                 {
694                         if (isMultiline == false)
695                         {
696                                 GET_SHAPE_CONFIG(TAB::FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
697                         }
698                         else
699                         {
700                                 GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
701                         }
702                 }
703
704                 (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize);
705
706                 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
707
708                 if (itemStatus == _TABITEM_STATUS_SELECTED)
709                 {
710                         __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength());
711                         __selectedLine.y = lineHeight - selectedLineHeight;
712
713                         DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
714
715                 }
716                 else if (itemStatus == _TABITEM_STATUS_PRESSED)
717                 {
718                         __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength());
719                 }
720                 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
721                 {
722                         __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength());
723                 }
724                 else if (itemStatus == _TABITEM_STATUS_DISABLED)
725                 {
726                         __pTextObject->SetForegroundColor(__pTab->GetDisabledTextColor(), 0, __pTextObject->GetTextLength());
727                 }
728                 else
729                 {
730                         __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength());
731                 }
732
733                 __pTextObject->SetBounds(itemDrawRect);
734                 __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
735                 if (i < (itemCount - 1))
736                 {
737                         DrawItemDivider(*pCanvas, __dividerLine);
738                 }
739
740                 DrawBadgeIcon(pDrawItem, pCanvas);
741
742         }
743
744         if (__isEditMode)
745         {
746                 DrawEditTextItem(pCanvas);
747         }
748
749         return;
750 }
751
752 void
753 _TabPresenter::DrawEditTextItem(Canvas* pCanvas)
754 {
755         ClearLastResult();
756
757         TextSimple* pSimpleText = null;
758         Rectangle bounds = __pTab->GetBounds();
759
760         _TabItem* pDrawItem = null;
761         String itemText(L"");
762         FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
763
764         _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
765
766         bool isMultiline = false;
767
768         float topMargin = 0.0f;
769         float bottomMargin = 0.0f;
770         float leftMargin = 0.0f;
771         float rightMargin = 0.0f;
772         float lineHeight = 0.0f;
773         float selectedLineHeight = 0.0f;
774         GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMargin);
775         GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
776         GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin);
777         GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin);
778         GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
779         GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
780
781         pDrawItem = GetItemAt(__editItemIndex);
782         SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
783
784         itemDrawRect = pDrawItem->GetItemBounds();
785         __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
786         __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
787
788         itemStatus = pDrawItem->GetStatus();
789
790         if (itemStatus == _TABITEM_STATUS_SELECTED)
791         {
792                 DrawSelectedItemBackground(pCanvas, itemDrawRect);
793                 __selectedLine.width = __itemWidth;
794                 __selectedLine.x = itemDrawRect.x;
795         }
796         else if (itemStatus == _TABITEM_STATUS_PRESSED)
797         {
798                 DrawPressedItemBackground(pCanvas, itemDrawRect);
799         }
800         else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
801         {
802                 DrawHighlightedItemBackground(pCanvas, itemDrawRect);
803         }
804         else
805         {
806                 DrawItemBackground(pCanvas, itemDrawRect);
807         }
808
809         itemText = pDrawItem->GetText();
810
811         __pTextObject->RemoveAll();
812         pSimpleText = new (std::nothrow)TextSimple(const_cast <mchar*>(itemText.GetPointer()), itemText.GetLength());
813         SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
814
815         __pTextObject->AppendElement(*pSimpleText);
816         __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
817         __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
818
819         itemDrawRect.x = itemDrawRect.x + leftMargin;
820         itemDrawRect.y = itemDrawRect.y + topMargin;
821         itemDrawRect.width = itemDrawRect.width - leftMargin - rightMargin;
822         itemDrawRect.height = itemDrawRect.height - topMargin - bottomMargin;
823
824         __pTextObject->SetBounds(itemDrawRect);
825         __pTextObject->Compose();
826
827         const int textRowCount = __pTextObject->GetTotalLineCount();
828
829         isMultiline = false;
830
831         if (textRowCount >= 2)
832         {
833                 isMultiline = true;
834         }
835
836         float fontSize = 0.0f;
837
838         if (__showItemCount < __fontChangeItemCount)
839         {
840                 if (isMultiline == false)
841                 {
842                         GET_SHAPE_CONFIG(TAB::FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
843                 }
844                 else
845                 {
846                         GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
847                 }
848         }
849         else if (__showItemCount == __fontChangeItemCount)
850         {
851                 if (isMultiline == false)
852                 {
853                         GET_SHAPE_CONFIG(TAB::FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
854                 }
855                 else
856                 {
857                         GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
858                 }
859         }
860         else
861         {
862                 if (isMultiline == false)
863                 {
864                         GET_SHAPE_CONFIG(TAB::FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
865                 }
866                 else
867                 {
868                         GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
869                 }
870         }
871
872         (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize);
873
874         __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
875
876         if (itemStatus == _TABITEM_STATUS_SELECTED)
877         {
878                 __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength());
879                 __selectedLine.y = lineHeight - selectedLineHeight;
880
881                 DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
882
883         }
884         else if (itemStatus == _TABITEM_STATUS_PRESSED)
885         {
886                 __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength());
887         }
888         else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
889         {
890                 __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength());
891         }
892         else if (itemStatus == _TABITEM_STATUS_DISABLED)
893         {
894                 __pTextObject->SetForegroundColor(__pTab->GetDisabledTextColor(), 0, __pTextObject->GetTextLength());
895         }
896         else
897         {
898                 __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength());
899         }
900
901         __pTextObject->SetBounds(itemDrawRect);
902         __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
903
904         DrawBadgeIcon(pDrawItem, pCanvas);
905
906         return;
907 }
908
909 void
910 _TabPresenter::DrawItemBackground(Canvas* pCanvas, FloatRectangle& itemRect)
911 {
912         Bitmap* pBackgroundBitmap = __pTab->GetBackgroundBitmap();
913         Bitmap* pDisabledBackgroundBitmap = __pTab->GetDisabledBackgroundBitmap();
914
915         if ((!__pTab->IsEnabled()) && (pDisabledBackgroundBitmap != null))
916         {
917                 DrawResourceBitmap(*pCanvas, itemRect, pDisabledBackgroundBitmap);
918                 return;
919         }
920
921         DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap);
922
923         return;
924 }
925
926 void
927 _TabPresenter::DrawPressedItemBackground(Canvas* pCanvas, FloatRectangle& itemRect)
928 {
929         Bitmap* pBackgroundBitmap = __pTab->GetPressedItemBackgroundBitmap();
930         Bitmap* pBackgroundEffectBitmap = __pTab->GetPressedItemBackgroundEffectBitmap();
931
932         DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap);
933
934         DrawResourceBitmap(*pCanvas, itemRect, pBackgroundEffectBitmap);
935
936         return;
937 }
938
939 void
940 _TabPresenter::DrawHighlightedItemBackground(Canvas* pCanvas, FloatRectangle& itemRect)
941 {
942         Bitmap* pBackgroundBitmap = __pTab->GetHighlightedItemBackgroundBitmap();
943
944         DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap);
945
946         return;
947 }
948
949 void
950 _TabPresenter::DrawSelectedItemBackground(Canvas* pCanvas, FloatRectangle& itemRect)
951 {
952         Bitmap* pBackgroundBitmap = __pTab->GetSelectedItemBackgroundBitmap();
953
954         DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap);
955
956         return;
957 }
958
959 void
960 _TabPresenter::DrawIconItem(Canvas* pCanvas)
961 {
962         ClearLastResult();
963         Rectangle bounds = __pTab->GetBounds();
964
965         _TabItem* pDrawItem = null;
966         String itemText(L"");
967         FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
968         const int itemCount = GetItemCount();
969
970         SetFirstLoadedItemIndex();
971         SetLastLoadedItemIndex();
972
973         _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
974
975         float iconWidth = 0.0f;
976         float iconHeight = 0.0f;
977         float bottomMargin = 0.0f;
978         float lineHeight = 0.0f;
979         float selectedLineHeight = 0.0f;
980
981         GET_SHAPE_CONFIG(TAB::ICON_WIDTH, __pTab->GetOrientation(), iconWidth);
982         GET_SHAPE_CONFIG(TAB::ICON_HEIGHT, __pTab->GetOrientation(), iconHeight);
983         GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
984         GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
985         GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
986
987         int startIndex = __firstLoadedItemIndex - 1;
988         int endIndex = __lastLoadedItemIndex + 1;
989         if (__firstLoadedItemIndex == 0)
990         {
991                 startIndex = __firstLoadedItemIndex;
992         }
993
994         if (__lastLoadedItemIndex == (GetItemCount() - 1))
995         {
996                 endIndex = __lastLoadedItemIndex;
997         }
998
999         for (int i = startIndex; i <= endIndex; i++)
1000         {
1001                 if (i == __editItemIndex)
1002                 {
1003                         continue;
1004                 }
1005
1006                 pDrawItem = GetItemAt(i);
1007                 SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1008
1009                 SetFirstDrawnItemIndex(0);
1010
1011                 itemDrawRect = pDrawItem->GetItemBounds();
1012                 __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
1013                 __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
1014
1015                 itemStatus = pDrawItem->GetStatus();
1016
1017                 if (!__pTab->IsEnabled())
1018                 {
1019                         itemStatus = _TABITEM_STATUS_DISABLED;
1020                 }
1021
1022                 if (itemStatus == _TABITEM_STATUS_SELECTED)
1023                 {
1024                         DrawSelectedItemBackground(pCanvas, itemDrawRect);
1025                         __selectedLine.width = __itemWidth;
1026                         __selectedLine.x = itemDrawRect.x;
1027                         __selectedLine.y = lineHeight - selectedLineHeight;
1028
1029                         DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
1030
1031                 }
1032                 else if (itemStatus == _TABITEM_STATUS_PRESSED)
1033                 {
1034                         DrawPressedItemBackground(pCanvas, itemDrawRect);
1035                 }
1036                 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1037                 {
1038                         DrawHighlightedItemBackground(pCanvas, itemDrawRect);
1039                 }
1040                 else
1041                 {
1042                         DrawItemBackground(pCanvas, itemDrawRect);
1043                 }
1044
1045                 itemDrawRect.x = itemDrawRect.x + ((itemDrawRect.width - iconWidth) / 2.0f);
1046                 itemDrawRect.y = itemDrawRect.y + ((itemDrawRect.height - iconHeight) / 2.0f);
1047                 itemDrawRect.width = iconWidth;
1048                 itemDrawRect.height = iconHeight;
1049
1050                 Bitmap* pIconBitmap = pDrawItem->GetIcon();
1051
1052                 DrawResourceBitmap(*pCanvas, itemDrawRect, pIconBitmap);
1053
1054                 if (i < itemCount - 1)
1055                 {
1056                         DrawItemDivider(*pCanvas, __dividerLine);
1057                 }
1058
1059                 DrawBadgeIcon(pDrawItem, pCanvas);
1060         }
1061
1062         if (__isEditMode)
1063         {
1064                 DrawEditIconItem(pCanvas);
1065         }
1066
1067         return;
1068 }
1069
1070 void
1071 _TabPresenter::DrawEditIconItem(Canvas* pCanvas)
1072 {
1073         ClearLastResult();
1074
1075         Rectangle bounds = __pTab->GetBounds();
1076
1077         _TabItem* pDrawItem = null;
1078         String itemText(L"");
1079         FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
1080
1081         _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
1082
1083         float iconWidth = 0.0f;
1084         float iconHeight = 0.0f;
1085         float bottomMargin = 0.0f;
1086         float lineHeight = 0.0f;
1087         float selectedLineHeight = 0.0f;
1088
1089         GET_SHAPE_CONFIG(TAB::ICON_WIDTH, __pTab->GetOrientation(), iconWidth);
1090         GET_SHAPE_CONFIG(TAB::ICON_HEIGHT, __pTab->GetOrientation(), iconHeight);
1091         GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
1092         GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
1093         GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
1094
1095         pDrawItem = GetItemAt(__editItemIndex);
1096         SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1097
1098         itemDrawRect = pDrawItem->GetItemBounds();
1099         __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
1100         __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
1101
1102         itemStatus = pDrawItem->GetStatus();
1103
1104         if (itemStatus == _TABITEM_STATUS_SELECTED)
1105         {
1106                 DrawSelectedItemBackground(pCanvas, itemDrawRect);
1107                 __selectedLine.width = __itemWidth;
1108                 __selectedLine.x = itemDrawRect.x;
1109                 __selectedLine.y = lineHeight - selectedLineHeight;
1110
1111                 DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
1112         }
1113         else if (itemStatus == _TABITEM_STATUS_PRESSED)
1114         {
1115                 DrawPressedItemBackground(pCanvas, itemDrawRect);
1116         }
1117         else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1118         {
1119                 DrawHighlightedItemBackground(pCanvas, itemDrawRect);
1120         }
1121         else
1122         {
1123                 DrawItemBackground(pCanvas, itemDrawRect);
1124         }
1125
1126         itemDrawRect.x = itemDrawRect.x + ((itemDrawRect.width - iconWidth) / 2.0f);
1127         itemDrawRect.y = itemDrawRect.y + ((itemDrawRect.height - iconHeight) / 2.0f);
1128         itemDrawRect.width = iconWidth;
1129         itemDrawRect.height = iconHeight;
1130
1131         Bitmap* pIconBitmap = pDrawItem->GetIcon();
1132
1133         DrawResourceBitmap(*pCanvas, itemDrawRect, pIconBitmap);
1134
1135         DrawBadgeIcon(pDrawItem, pCanvas);
1136
1137         return;
1138
1139 }
1140
1141 void
1142 _TabPresenter::DrawItem(Canvas* pCanvas)
1143 {
1144         ClearLastResult();
1145
1146         Rectangle bounds = __pTab->GetBounds();
1147
1148         TextSimple* pSimpleText = null;
1149         _TabItem* pDrawItem = null;
1150         Rectangle buttonBounds(0, 0, 0, 0);
1151         String itemText(L"");
1152         FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
1153         FloatRectangle itemDrawIconRect(0.0f, 0.0f, 0.0f, 0.0f);
1154         FloatRectangle itemDrawTextRect(0.0f, 0.0f, 0.0f, 0.0f);
1155         const int itemCount = GetItemCount();
1156
1157         SetFirstLoadedItemIndex();
1158         SetLastLoadedItemIndex();
1159
1160         _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
1161
1162         bool isMultiline = false;
1163         int textLength = 0;
1164         float topMargin = 0.0f;
1165         float bottomMargin = 0.0f;
1166         float leftMargin = 0.0f;
1167         float rightMargin = 0.0f;
1168         float topMarginTextOnly = 0.0f;
1169         float bottomMarginTextOnly = 0.0f;
1170         float iconWidth = 0.0f;
1171         float iconHeight = 0.0f;
1172         float iconGap = 0.0f;
1173         float lineHeight = 0.0f;
1174         float selectedLineHeight = 0.0f;
1175
1176         GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMarginTextOnly);
1177         GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMarginTextOnly);
1178         GET_SHAPE_CONFIG(TAB::ICON_TEXT_TOP_MARGIN, __pTab->GetOrientation(), topMargin);
1179         GET_SHAPE_CONFIG(TAB::ICON_TEXT_BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
1180         GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin);
1181         GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin);
1182         GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_WIDTH, __pTab->GetOrientation(), iconWidth);
1183         GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_HEIGHT, __pTab->GetOrientation(), iconHeight);
1184         GET_FIXED_VALUE_CONFIG(TAB::ICON_TEXT_GAP, __pTab->GetOrientation(), iconGap);
1185         GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
1186         GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
1187
1188         int startIndex = __firstLoadedItemIndex - 1;
1189         int endIndex = __lastLoadedItemIndex + 1;
1190         if (__firstLoadedItemIndex == 0)
1191         {
1192                 startIndex = __firstLoadedItemIndex;
1193         }
1194
1195         if (__lastLoadedItemIndex == (GetItemCount() - 1))
1196         {
1197                 endIndex = __lastLoadedItemIndex;
1198         }
1199
1200         for (int i = startIndex; i <= endIndex; i++)
1201         {
1202                 if (i == __editItemIndex)
1203                 {
1204                         continue;
1205                 }
1206
1207                 pDrawItem = GetItemAt(i);
1208                 SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1209
1210                 SetFirstDrawnItemIndex(0);
1211
1212                 itemDrawRect = pDrawItem->GetItemBounds();
1213                 __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
1214                 __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
1215
1216                 itemStatus = pDrawItem->GetStatus();
1217
1218                 if (!__pTab->IsEnabled())
1219                 {
1220                         itemStatus = _TABITEM_STATUS_DISABLED;
1221                 }
1222
1223                 if (itemStatus == _TABITEM_STATUS_SELECTED)
1224                 {
1225                         DrawSelectedItemBackground(pCanvas, itemDrawRect);
1226                         __selectedLine.width = __itemWidth;
1227                         __selectedLine.x = itemDrawRect.x;
1228                 }
1229                 else if (itemStatus == _TABITEM_STATUS_PRESSED)
1230                 {
1231                         DrawPressedItemBackground(pCanvas, itemDrawRect);
1232                 }
1233                 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1234                 {
1235                         DrawHighlightedItemBackground(pCanvas, itemDrawRect);
1236                 }
1237                 else
1238                 {
1239                         DrawItemBackground(pCanvas, itemDrawRect);
1240                 }
1241
1242
1243                 itemText = pDrawItem->GetText();
1244
1245                 __pTextObject->RemoveAll();
1246                 pSimpleText = new (std::nothrow)TextSimple(const_cast <mchar*>(itemText.GetPointer()), itemText.GetLength());
1247                 SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1248
1249                 __pTextObject->AppendElement(*pSimpleText);
1250
1251                 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1252                 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1253                 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1254                 textLength = __pTextObject->GetTextLength();
1255
1256                 if ((pDrawItem->GetIcon()) == null)
1257                 {
1258                         topMargin = topMarginTextOnly;
1259                         bottomMargin = bottomMarginTextOnly;
1260                 }
1261                 FloatDimension textDim(0.0f, 0.0f);
1262
1263                 float fontSize = 0.0f;
1264
1265                 if (__showItemCount < __fontChangeItemCount)
1266                 {
1267                         if (isMultiline == false)
1268                         {
1269                                 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
1270                         }
1271                         else
1272                         {
1273                                 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1274                         }
1275                 }
1276                 else if (__showItemCount == __fontChangeItemCount)
1277                 {
1278                         if (isMultiline == false)
1279                         {
1280                                 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1281                         }
1282                         else
1283                         {
1284                                 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1285                         }
1286                 }
1287                 else
1288                 {
1289                         if (isMultiline == false)
1290                         {
1291                                 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
1292                         }
1293                         else
1294                         {
1295                                 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
1296                         }
1297                 }
1298
1299                 (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize);
1300
1301                 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
1302
1303                 __pFont->GetTextExtent(itemText, itemText.GetLength(), textDim);
1304
1305                 itemDrawTextRect = itemDrawRect;
1306                 itemDrawTextRect.x = itemDrawRect.x + leftMargin;
1307                 isMultiline = false;
1308                 if (textDim.width > (__itemWidth / 2.0f))
1309                 {
1310                         isMultiline = true;
1311                         textDim.width = (__itemWidth / 2.0f);
1312                         textDim.height = textDim.height * 2.0f;
1313                 }
1314                 itemDrawTextRect.width = textDim.width;
1315                 itemDrawTextRect.x = itemDrawRect.x + leftMargin;
1316                 itemDrawTextRect.x = itemDrawTextRect.x + ((itemDrawRect.width - leftMargin - rightMargin) - (iconWidth + iconGap + itemDrawTextRect.width)) / 2.0f;
1317                 itemDrawTextRect.height = textDim.height;
1318                 itemDrawIconRect = itemDrawTextRect;
1319                 itemDrawTextRect.x = itemDrawIconRect.x + iconWidth + iconGap;
1320
1321                 if ((pDrawItem->GetIcon()) != null)
1322                 {
1323                         itemDrawIconRect.height = itemDrawRect.height - topMargin - bottomMargin;
1324                         itemDrawIconRect.y = itemDrawIconRect.y + topMargin + (itemDrawIconRect.height - iconHeight) / 2.0f;
1325
1326                         itemDrawIconRect.width = iconWidth;
1327                         itemDrawIconRect.height = iconHeight;
1328                         Bitmap* pIconBitmap = pDrawItem->GetIcon();
1329
1330                         DrawResourceBitmap(*pCanvas, itemDrawIconRect, pIconBitmap);
1331
1332                 }
1333                 else
1334                 {
1335                         itemDrawTextRect.x = itemDrawRect.x + leftMargin + (itemDrawRect.width - leftMargin - rightMargin - itemDrawTextRect.width) / 2.0f;
1336                 }
1337
1338
1339                 if (isMultiline == false)
1340                 {
1341                         itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height) / 2.0f;
1342                 }
1343                 else
1344                 {
1345                         itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height) / 2.0f;
1346                 }
1347                 __pTextObject->SetBounds(itemDrawTextRect);
1348                 __pTextObject->Compose();
1349                 if (itemStatus == _TABITEM_STATUS_SELECTED)
1350                 {
1351                         __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength());
1352                         __selectedLine.y = lineHeight - selectedLineHeight;
1353
1354                         DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
1355
1356                 }
1357                 else if (itemStatus == _TABITEM_STATUS_PRESSED)
1358                 {
1359                         __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength());
1360                 }
1361                 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1362                 {
1363                         __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength());
1364                 }
1365                 else if (itemStatus == _TABITEM_STATUS_DISABLED)
1366                 {
1367                         __pTextObject->SetForegroundColor(__pTab->GetDisabledTextColor(), 0, __pTextObject->GetTextLength());
1368                 }
1369                 else
1370                 {
1371                         __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength());
1372                 }
1373
1374                 __pTextObject->SetBounds(itemDrawTextRect);
1375
1376                 __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1377
1378                 if (i < itemCount - 1)
1379                 {
1380                         DrawItemDivider(*pCanvas, __dividerLine);
1381                 }
1382                 DrawBadgeIcon(pDrawItem, pCanvas);
1383         }
1384
1385         if (__isEditMode)
1386         {
1387                 DrawEditIconTextItem(pCanvas);
1388         }
1389         return;
1390 }
1391
1392 void
1393 _TabPresenter::DrawEditIconTextItem(Canvas* pCanvas)
1394 {
1395         ClearLastResult();
1396
1397         Rectangle bounds = __pTab->GetBounds();
1398
1399         TextSimple* pSimpleText = null;
1400         _TabItem* pDrawItem = null;
1401         Rectangle buttonBounds(0, 0, 0, 0);
1402         String itemText(L"");
1403         FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
1404         FloatRectangle itemDrawIconRect(0.0f, 0.0f, 0.0f, 0.0f);
1405         FloatRectangle itemDrawTextRect(0.0f, 0.0f, 0.0f, 0.0f);
1406
1407         _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
1408
1409         bool isMultiline = false;
1410
1411         int textLength = 0;
1412         float topMargin = 0.0f;
1413         float bottomMargin = 0.0f;
1414         float leftMargin = 0.0f;
1415         float rightMargin = 0.0f;
1416         float topMarginTextOnly = 0.0f;
1417         float bottomMarginTextOnly = 0.0f;
1418         float iconWidth = 0.0f;
1419         float iconHeight = 0.0f;
1420         float iconGap = 0.0f;
1421         float lineHeight = 0.0f;
1422         float selectedLineHeight = 0.0f;
1423
1424         GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMarginTextOnly);
1425         GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMarginTextOnly);
1426         GET_SHAPE_CONFIG(TAB::ICON_TEXT_TOP_MARGIN, __pTab->GetOrientation(), topMargin);
1427         GET_SHAPE_CONFIG(TAB::ICON_TEXT_BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
1428         GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin);
1429         GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin);
1430         GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_WIDTH, __pTab->GetOrientation(), iconWidth);
1431         GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_HEIGHT, __pTab->GetOrientation(), iconHeight);
1432         GET_FIXED_VALUE_CONFIG(TAB::ICON_TEXT_GAP, __pTab->GetOrientation(), iconGap);
1433         GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
1434         GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
1435
1436         pDrawItem = GetItemAt(__editItemIndex);
1437         SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1438
1439         SetFirstDrawnItemIndex(0);
1440
1441         itemDrawRect = pDrawItem->GetItemBounds();
1442         __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
1443         __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
1444
1445         itemStatus = pDrawItem->GetStatus();
1446
1447         if (itemStatus == _TABITEM_STATUS_SELECTED)
1448         {
1449                 DrawSelectedItemBackground(pCanvas, itemDrawRect);
1450                 __selectedLine.width = __itemWidth;
1451                 __selectedLine.x = itemDrawRect.x;
1452         }
1453         else if (itemStatus == _TABITEM_STATUS_PRESSED)
1454         {
1455                 DrawPressedItemBackground(pCanvas, itemDrawRect);
1456         }
1457         else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1458         {
1459                 DrawHighlightedItemBackground(pCanvas, itemDrawRect);
1460         }
1461         else
1462         {
1463                 DrawItemBackground(pCanvas, itemDrawRect);
1464         }
1465
1466         itemText = pDrawItem->GetText();
1467
1468         __pTextObject->RemoveAll();
1469         pSimpleText = new (std::nothrow)TextSimple(const_cast <mchar*>(itemText.GetPointer()), itemText.GetLength());
1470         SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1471
1472         __pTextObject->AppendElement(*pSimpleText);
1473
1474         __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1475         __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1476         __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1477         textLength = __pTextObject->GetTextLength();
1478
1479         if ((pDrawItem->GetIcon()) == null)
1480         {
1481                 topMargin = topMarginTextOnly;
1482                 bottomMargin = bottomMarginTextOnly;
1483         }
1484
1485         FloatDimension textDim(0.0f, 0.0f);
1486
1487
1488         float fontSize = 0.0f;
1489
1490         if (__showItemCount < __fontChangeItemCount)
1491         {
1492                 if (isMultiline == false)
1493                 {
1494                         GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
1495                 }
1496                 else
1497                 {
1498                         GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1499                 }
1500         }
1501         else if (__showItemCount == __fontChangeItemCount)
1502         {
1503                 if (isMultiline == false)
1504                 {
1505                         GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1506                 }
1507                 else
1508                 {
1509                         GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1510                 }
1511         }
1512         else
1513         {
1514                 if (isMultiline == false)
1515                 {
1516                         GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
1517                 }
1518                 else
1519                 {
1520                         GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
1521                 }
1522         }
1523
1524         (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize);
1525
1526         __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
1527
1528         __pFont->GetTextExtent(itemText, itemText.GetLength(), textDim);
1529
1530         itemDrawTextRect = itemDrawRect;
1531         itemDrawTextRect.x = itemDrawRect.x + leftMargin;
1532         isMultiline = false;
1533
1534         if (textDim.width > (__itemWidth / 2.0f))
1535         {
1536                 isMultiline = true;
1537                 textDim.width = (__itemWidth / 2.0f);
1538                 textDim.height = textDim.height * 2.0f;
1539         }
1540
1541         itemDrawTextRect.width = textDim.width;
1542         itemDrawTextRect.x = itemDrawRect.x + leftMargin;
1543         itemDrawTextRect.x = itemDrawTextRect.x + ((itemDrawRect.width - leftMargin - rightMargin) - (iconWidth + iconGap + itemDrawTextRect.width)) / 2.0f;
1544         itemDrawTextRect.height = textDim.height;
1545         itemDrawIconRect = itemDrawTextRect;
1546         itemDrawTextRect.x = itemDrawIconRect.x + iconWidth + iconGap;
1547
1548         if ((pDrawItem->GetIcon()) != null)
1549         {
1550                 itemDrawIconRect.height = itemDrawRect.height - topMargin - bottomMargin;
1551                 itemDrawIconRect.y = itemDrawIconRect.y + topMargin + (itemDrawIconRect.height - iconHeight) / 2.0f;
1552
1553                 itemDrawIconRect.width = iconWidth;
1554                 itemDrawIconRect.height = iconHeight;
1555                 Bitmap* pIconBitmap = pDrawItem->GetIcon();
1556
1557                 DrawResourceBitmap(*pCanvas, itemDrawIconRect, pIconBitmap);
1558         }
1559         else
1560         {
1561                 itemDrawTextRect.x = itemDrawRect.x + leftMargin + (itemDrawRect.width - leftMargin - rightMargin - itemDrawTextRect.width) / 2.0f;
1562         }
1563
1564
1565         if (isMultiline == false)
1566         {
1567                 itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height) / 2.0f;
1568         }
1569         else
1570         {
1571                 itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height) / 2.0f;
1572         }
1573
1574         __pTextObject->SetBounds(itemDrawTextRect);
1575         __pTextObject->Compose();
1576         if (itemStatus == _TABITEM_STATUS_SELECTED)
1577         {
1578                 __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength());
1579                 __selectedLine.y = lineHeight - selectedLineHeight;
1580
1581                 DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
1582         }
1583         else if (itemStatus == _TABITEM_STATUS_PRESSED)
1584         {
1585                 __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength());
1586         }
1587         else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1588         {
1589                 __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength());
1590         }
1591         else if (itemStatus == _TABITEM_STATUS_DISABLED)
1592         {
1593                 __pTextObject->SetForegroundColor(__pTab->GetDisabledTextColor(), 0, __pTextObject->GetTextLength());
1594         }
1595         else
1596         {
1597                 __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength());
1598         }
1599
1600         __pTextObject->SetBounds(itemDrawTextRect);
1601
1602         __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1603
1604         DrawBadgeIcon(pDrawItem, pCanvas);
1605
1606         return;
1607 }
1608
1609 void
1610 _TabPresenter::SetEditItemBounds(const FloatPoint& point)
1611 {
1612         _TabItem *pTabItem = null;
1613         FloatRectangle editRect(0.0f, 0.0f, 0.0f, 0.0f);
1614         pTabItem = GetItemAt(__editItemIndex);
1615         SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1616
1617         editRect = pTabItem->GetItemBounds();
1618
1619         editRect.x = point.x - (__itemWidth / 2.0f);
1620         pTabItem->SetItemBounds(editRect);
1621
1622         return;
1623 }
1624
1625 void
1626 _TabPresenter::DrawItemDivider(Canvas& canvas, FloatRectangle& lineRect)
1627 {
1628         Color dividerLeftHalfColor;
1629         Color dividerRightHalfColor;
1630
1631         float halfLineWidth = 0.0f;
1632
1633         GET_COLOR_CONFIG(TAB::DIVIDER_LEFT_HALF, dividerLeftHalfColor);
1634         GET_COLOR_CONFIG(TAB::DIVIDER_RIGHT_HALF, dividerRightHalfColor);
1635
1636         result r = E_SUCCESS;
1637         halfLineWidth = lineRect.width / 2.0f;
1638
1639         canvas.SetForegroundColor(dividerLeftHalfColor);
1640         canvas.SetLineWidth(halfLineWidth);
1641
1642         r = canvas.DrawLine(FloatPoint(lineRect.x, lineRect.y), FloatPoint(lineRect.x, lineRect.y + lineRect.height));
1643         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1644
1645         canvas.SetForegroundColor(dividerRightHalfColor);
1646         canvas.SetLineWidth(halfLineWidth);
1647
1648         r = canvas.DrawLine(FloatPoint(lineRect.x + halfLineWidth, lineRect.y), FloatPoint(lineRect.x + halfLineWidth, lineRect.y + lineRect.height));
1649         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1650
1651         return;
1652 }
1653
1654 void
1655 _TabPresenter::DrawHorizontal()
1656 {
1657         ClearLastResult();
1658
1659         int itemCount = GetItemCount();
1660         int boundItemIndex = 0;
1661         if (__moveDistance == 0.0f)
1662         {
1663                 return;
1664         }
1665         if (itemCount == 0)
1666         {
1667                 SysLog(NID_UI_CTRL, "itemCount is 0.");
1668                 return;
1669         }
1670
1671         //Bound beyond which the item shouldnt move when flicked
1672         boundItemIndex = itemCount - __itemMaxCount;
1673
1674         _TabItem* pItem = null;
1675         pItem = GetItemAt(boundItemIndex);
1676         SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1677
1678         FloatRectangle bounds = pItem->GetItemBounds();
1679         FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
1680         if ((bounds.x + __moveDistance) < 0.0f)
1681         {
1682                 __moveDistance = -bounds.x;
1683                 ResetFlickAnimationTimer();
1684         }
1685
1686         pItem = GetItemAt(0);
1687         SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1688
1689         bounds = pItem->GetItemBounds();
1690
1691         if ((bounds.x + __moveDistance) > 0.0f)
1692         {
1693                 CalculateItemBounds();
1694                 ResetFlickAnimationTimer();
1695                 return;
1696         }
1697
1698         for (int i = 0; i < itemCount; i++)
1699         {
1700                 pItem = GetItemAt(i);
1701                 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1702
1703                 itemBounds = pItem->GetItemBounds();
1704
1705                 itemBounds.x = itemBounds.x + __moveDistance;
1706                 pItem->SetItemBounds(itemBounds);
1707         }
1708         return;
1709 }
1710
1711 result
1712 _TabPresenter::ShiftToFocusedItem(int itemIndex, _FocusDirectionMove direction)
1713 {
1714         if (direction == _FOCUS_DIRECTION_MOVE_LEFT && itemIndex == __firstLoadedItemIndex - 1)         //left key pressed
1715         {
1716                 SetItemFit(__firstLoadedItemIndex - 1);
1717         }
1718         if (direction == _FOCUS_DIRECTION_MOVE_RIGHT && itemIndex == __lastLoadedItemIndex + 1)         //right key pressed
1719         {
1720                 SetItemFit(__firstLoadedItemIndex + 1);
1721         }
1722         if(itemIndex == 0)              //when touched
1723         {
1724                 SetItemFit(0);
1725         }
1726         __pTab->Invalidate();
1727
1728         return E_SUCCESS;
1729 }
1730
1731 void
1732 _TabPresenter::DrawBadgeIcon(_TabItem* pDrawItem, Canvas* pCanvas)
1733 {
1734         Bitmap* pBadgeIcon = null;
1735         float badgeMargin = 0.0f;
1736         GET_SHAPE_CONFIG(TAB::BADGE_ICON_MARGIN, __pTab->GetOrientation(), badgeMargin);
1737
1738         pBadgeIcon = pDrawItem->GetBadgeIcon();
1739
1740         if (pBadgeIcon != null)
1741         {
1742                 FloatRectangle badgeRect = pDrawItem->GetItemBounds();
1743
1744                 badgeRect.x = (badgeRect.x + badgeRect.width) - pBadgeIcon->GetWidthF() - badgeMargin;
1745                 badgeRect.y = badgeMargin;
1746                 badgeRect.width = pBadgeIcon->GetWidthF();
1747                 badgeRect.height = pBadgeIcon->GetHeightF();
1748
1749                 DrawResourceBitmap(*pCanvas, badgeRect, pBadgeIcon);
1750
1751                 pBadgeIcon = null;
1752         }
1753         return;
1754 }
1755
1756 void
1757 _TabPresenter::CalculateItemBounds(void)
1758 {
1759         ClearLastResult();
1760
1761         GET_SHAPE_CONFIG(TAB::SCREEN_WIDTH, __pTab->GetOrientation(), __width);
1762         GET_SHAPE_CONFIG(TAB::SCREEN_HEIGHT, __pTab->GetOrientation(), __height);
1763
1764         const int itemCount = GetItemCount();
1765
1766         if (itemCount == 0)
1767         {
1768                 return;
1769         }
1770
1771         CalculateTabBounds(true);
1772
1773         FloatRectangle bounds = __pTab->GetBoundsF();
1774
1775         _TabItem* pItem = null;
1776         FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
1777
1778         if (__itemMaxCount > itemCount)
1779         {
1780                 __showItemCount = itemCount;
1781         }
1782         else
1783         {
1784                 __showItemCount = __itemMaxCount;
1785         }
1786
1787         itemBounds.width = bounds.width / __showItemCount;
1788         itemBounds.height = bounds.height;
1789         __itemWidth = itemBounds.width;
1790         __itemHeight = bounds.height;
1791
1792
1793         for (int i = 0; i < itemCount; i++)
1794         {
1795                 pItem = GetItemAt(i);
1796                 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1797
1798                 __pAnimInfo[i]->xPosition = itemBounds.x;
1799                 __pAnimInfo[i]->totalDistance = __itemWidth;
1800                 pItem->SetItemBounds(itemBounds);
1801                 itemBounds.x = itemBounds.x + itemBounds.width;
1802         }
1803         return;
1804 }
1805
1806 void
1807 _TabPresenter::CalculateTabBounds(bool isReset)
1808 {
1809         FloatRectangle bounds = __pTab->GetBoundsF();
1810
1811         bool isMovable = __pTab->IsMovable();
1812         bool isResizable = __pTab->IsResizable();
1813
1814         float lineHeight = 0.0f;
1815         float tabLeftMargin = 0.0f;
1816         float tabRightMargin = 0.0f;
1817         GET_SHAPE_CONFIG(TAB::LEFT_MARGIN, __pTab->GetOrientation(), tabLeftMargin);
1818         GET_SHAPE_CONFIG(TAB::RIGHT_MARGIN, __pTab->GetOrientation(), tabRightMargin);
1819         GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
1820
1821         __lastItemIndex = (__pTab->GetItemCount() - 1);
1822
1823         bounds.height = lineHeight;
1824
1825         for (int i = 0; i < (__pTab->GetItemCount()); i++)
1826         {
1827                 if (__pAnimInfo[i] == null)
1828                 {
1829                         __pAnimInfo[i] = new (std::nothrow) ReorderAnimationInfo();
1830                         SysTryReturnVoidResult(NID_UI_CTRL, __pAnimInfo[i], E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1831
1832                         __pAnimInfo[i]->totalDistance = 0.0f;
1833                         __pAnimInfo[i]->move = 0.0f;
1834                         __pAnimInfo[i]->reorderValue = 0;
1835                 }
1836         }
1837
1838         __pTab->SetMovable(true);
1839         __pTab->SetResizable(true);
1840
1841         __pTab->SetBounds(bounds);
1842
1843         __pTab->SetMovable(isMovable);
1844         __pTab->SetResizable(isResizable);
1845
1846         return;
1847
1848 }
1849
1850 bool
1851 _TabPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1852 {
1853         if (GetItemCount() == 0)
1854         {
1855                 return true;
1856         }
1857         __currentTouchPosition = touchinfo.GetCurrentPosition();
1858         SetFirstLoadedItemIndex();
1859         SetLastLoadedItemIndex();
1860         ResetScrollAnimationTimer();
1861         SetRecalculateItemBounds(false);
1862         ResetFlickAnimationTimer();
1863
1864         const int index = GetItemIndexFromPosition(__currentTouchPosition);
1865         if (index == -1)
1866         {
1867                 return false;
1868         }
1869
1870         if (GetItemStatus(index) != _TABITEM_STATUS_SELECTED)
1871         {
1872                 SetItemStatus(index, _TABITEM_STATUS_PRESSED);
1873                 SetPressedItemIndex(index);
1874         }
1875
1876         __pTab->Invalidate();
1877
1878         return true;
1879 }
1880
1881 bool
1882 _TabPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1883 {
1884         if (GetItemCount() == 0)
1885         {
1886                 return true;
1887         }
1888
1889 //      __scrollFlag = 0;
1890         Rectangle itemBounds(0, 0, 0, 0);
1891         _TabItem* pItem = null;
1892
1893         ResetReorderTimer();
1894         ResetScrollAnimationTimer();
1895         int index = GetItemIndexFromPosition(touchinfo.GetCurrentPosition());
1896
1897 //      if (__pScrollingEffectVe)
1898 //      {
1899 //              __pScrollingEffectVe->RemoveAllAnimations();
1900 //              __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe);
1901 //              __pScrollingEffectVe->Destroy();
1902 //              __pScrollingEffectVe = null;
1903 //              __isScrollEffectEnded = false;
1904 //              __isScrollEffectStarted = false;
1905 //      }
1906
1907         int pressedIndex = GetPressedItemIndex();
1908         __isRightScrollable = false;
1909
1910         if (index == -1 && !__isFlickEnabled)
1911         {
1912                 SetFirstLoadedItemIndex();
1913                 if (GetItemStatus(pressedIndex) == _TABITEM_STATUS_PRESSED)
1914                 {
1915                         SetItemStatus(pressedIndex, _TABITEM_STATUS_NORMAL);
1916                 }
1917                 CalculateItemBounds();
1918
1919                 __moveDistance = -(GetItemAt(__firstLoadedItemIndex)->GetItemBounds().x);
1920                 DrawHorizontal();
1921                 __pTab->Invalidate();
1922
1923                 __rearIndex = 0;
1924                 __isEditMode =  false;
1925                 return false;
1926         }
1927         if (__isEditMode && __editItemIndex == __rearIndex)
1928         {
1929                 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1930                 if (__editItemIndex > 0)
1931                 {
1932                         pItem = GetItemAt((__editItemIndex - 1));
1933                         SysTryReturn(NID_UI_CTRL, pItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1934
1935                         bounds = pItem->GetItemBounds();
1936                         bounds.x = bounds.x + __itemWidth;
1937                         GetItemAt(__editItemIndex)->SetItemBounds(bounds);
1938                 }
1939                 else
1940                 {
1941                         CalculateItemBounds();
1942                 }
1943         }
1944
1945         // Edit Mode - Item Insert
1946         if (__isEditMode && (__editItemIndex != __rearIndex))
1947         {
1948                 index = __rearIndex;
1949                 int selectedIndex = GetSelectedItemIndex();
1950                 SetItemStatus(selectedIndex, _TABITEM_STATUS_NORMAL);
1951
1952                 if (__isDirectionRight)
1953                 {
1954                         index = index + 1;
1955                 }
1956
1957                 __pTab->ChangeItemAt(__editItemIndex, (index));
1958                 if (__editItemIndex < index)
1959                 {
1960                         SetItemStatus((index-1), _TABITEM_STATUS_SELECTED);
1961                         SetSelectedItemIndex((index-1));
1962                 }
1963                 else if (__editItemIndex > index)
1964                 {
1965                         SetItemStatus(index, _TABITEM_STATUS_SELECTED);
1966                         SetSelectedItemIndex(index);
1967                 }
1968
1969                 SetFirstLoadedItemIndex();
1970                 SetLastLoadedItemIndex();
1971
1972
1973                 CalculateItemBounds();
1974                 __moveDistance = -(__firstLoadedItemIndex * __itemWidth);
1975                 DrawHorizontal();
1976         }
1977         else
1978         {
1979                 // Pressed -> Selected or Normal
1980                 if (GetItemStatus(index) == _TABITEM_STATUS_PRESSED && !__isFlickEnabled && !__isTouchMove)
1981                 {
1982                         PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pTab);
1983                         int selectedIndex = GetSelectedItemIndex();
1984                         SetItemStatus(selectedIndex, _TABITEM_STATUS_NORMAL);
1985
1986                         SetItemStatus(index, _TABITEM_STATUS_SELECTED);
1987                         SetSelectedItemIndex(index);
1988                 }
1989                 else
1990                 {
1991                         int pressedIndex = GetPressedItemIndex();
1992                         if (GetItemStatus(pressedIndex) == _TABITEM_STATUS_PRESSED)
1993                         {
1994                                 SetItemStatus(pressedIndex, _TABITEM_STATUS_NORMAL);
1995                         }
1996                 }
1997
1998                 SetItemFitToLeft();
1999         }
2000
2001         __pTab->Invalidate();
2002         __isTouchMove = false;
2003         __isEditMode = false;
2004         __editItemIndex = -1;
2005         __rearIndex = -1;
2006
2007         if (__firstItemIndex > 0)
2008         {
2009                 __firstItemIndex--;
2010         }
2011
2012         if (__lastItemIndex < (__pTab->GetItemCount() - 1))
2013         {
2014                 __lastItemIndex++;
2015         }
2016
2017         return true;
2018 }
2019
2020 bool
2021 _TabPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
2022 {
2023         if (GetItemCount() == 0)
2024         {
2025                 return true;
2026         }
2027
2028         _TabItem *pTabItem = null;
2029         _TabItem *pNextItem = null;
2030         _TabItem *pPrevItem = null;
2031         FloatPoint movedPosition = touchinfo.GetCurrentPosition();
2032
2033         int index = GetNextItemIndexFromPosition(movedPosition, __editItemIndex);
2034         SetFirstLoadedItemIndex();
2035         SetLastLoadedItemIndex();
2036
2037         //Remove the Pressed Bitmap during Touch Move
2038         int i = GetPressedItemIndex();
2039         if (!__isEditMode)
2040         {
2041                 if (GetItemStatus(i) == _TABITEM_STATUS_PRESSED)
2042                 {
2043                         SetItemStatus(i, _TABITEM_STATUS_NORMAL);
2044                         Draw();
2045                 }
2046         }
2047
2048         float distance;
2049         distance = movedPosition.x - __currentTouchPosition.x;
2050         __currentTouchPosition.x = movedPosition.x;
2051
2052 //      if (!__isEditMode && distance > 0.0f) //Move right i.e Bounce at leftEnd
2053 //      {
2054 //              __isTouchMove = true;
2055 //              if (!__isDirectionRight)
2056 //              {
2057 //                      if (__pScrollingEffectVe)
2058 //                      {
2059 //                              __pScrollingEffectVe->RemoveAllAnimations();
2060 //                              __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe);
2061 //                              __pScrollingEffectVe->Destroy();
2062 //                              __pScrollingEffectVe = null;
2063 //                      }
2064 //
2065 //                      __isScrollEffectEnded = false;
2066 //                      __isScrollEffectStarted = false;
2067 //              }
2068 //
2069 //              __isDirectionRight = true;
2070 //              SetFirstLoadedItemIndex();
2071 //              if ( GetItemAt(0)->GetItemBounds().x >= 0.0f)
2072 //              {
2073 //                      if (!__isScrollEffectStarted)
2074 //                      {
2075 //                              __pScrollingEffectBitmap = __pFrontScrollingEffectBitmap;
2076 //                              SetOpacityVisualElement(0.0f);
2077 //                              StartScrollingEffect();
2078 //                      }
2079 //
2080 //                      __isScrollEffectStarted = true;
2081 //              }
2082 //
2083 //              __moveDistance = distance;
2084 //              DrawHorizontal();
2085 //              Draw();
2086 //              __moveDistance = 0.0f;
2087 //
2088 //              return true;
2089 //      }
2090 //
2091 //      if (!__isEditMode && distance < 0.0f)//Move left i.e Bounce at RightEnd
2092 //      {
2093 //              __isTouchMove = true;
2094 //              if (__isDirectionRight)
2095 //              {
2096 //                      if (__pScrollingEffectVe)
2097 //                      {
2098 //                              __pScrollingEffectVe->RemoveAllAnimations();
2099 //                              __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe);
2100 //                              __pScrollingEffectVe->Destroy();
2101 //                              __pScrollingEffectVe = null;
2102 //                      }
2103 //
2104 //                      __isScrollEffectEnded = false;
2105 //                      __isScrollEffectStarted = false;
2106 //              }
2107 //
2108 //              __isDirectionRight = false;
2109 //              SetLastLoadedItemIndex();
2110 //
2111 //              if ( __lastLoadedItemIndex == (GetItemCount() - 1) && ((GetItemAt(__lastLoadedItemIndex)->GetItemBounds().x + __itemWidth) <= (__width)))
2112 //              {
2113 //                      if (!__isScrollEffectStarted)
2114 //                      {
2115 //                              int index = (GetItemCount() - 1);
2116 //                              float xPosition = (GetItemAt(index)->GetItemBounds().x + (__itemWidth / 2.0f));
2117 //                              __pScrollingEffectBitmap = __pRearScrollingEffectBitmap;
2118 //                              SetOpacityVisualElement(xPosition);
2119 //                              StartScrollingEffect();
2120 //                      }
2121 //
2122 //                      __isScrollEffectStarted = true;
2123 //              }
2124 //
2125 //              __moveDistance = distance;
2126 //              DrawHorizontal();
2127 //              Draw();
2128 //              __moveDistance = 0.0f;
2129 //
2130 //              return true;
2131 //      }
2132
2133         if (!__isEditMode)
2134         {
2135                 return false;
2136         }
2137
2138         if (distance > 0.0f)
2139         {
2140                 if (!__isDirectionRight)
2141                 {
2142                         __isTimerCanceled = true;
2143                         __isRightScrollable = false;
2144                         __isLeftScrollable = false;
2145                         ResetReorderTimer();
2146                 }
2147
2148                 __isDirectionRight = true;
2149         }
2150         else
2151         {
2152                 if (__isDirectionRight)
2153                 {
2154                         __isTimerCanceled = true;
2155                         __isLeftScrollable = false;
2156                         __isRightScrollable = false;
2157                         ResetReorderTimer();
2158                 }
2159
2160                 __isDirectionRight = false;
2161         }
2162
2163         pTabItem = GetItemAt(__editItemIndex);
2164         SysTryReturn(NID_UI_CTRL, pTabItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2165
2166         FloatRectangle bounds = pTabItem->GetItemBounds();
2167         if (index != -1)
2168         {
2169                 if (__isDirectionRight)
2170                 {
2171                         pNextItem = GetItemAt(index);
2172                         SysTryReturn(NID_UI_CTRL, pNextItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2173
2174                         FloatRectangle boundsNext = pNextItem->GetItemBounds();
2175                         if ((bounds.x + (__itemWidth / 2.0f)) > (boundsNext.x) && ((bounds.x + __itemWidth) < (boundsNext.x + boundsNext.width)))
2176                         {
2177                                 __pTimerInfo[__timerCount]->index = index;
2178                                 StartReorderTimer(__timerCount);
2179                                 __timerCount++;
2180                                 if (__timerCount >= (__itemMaxCount - 1))
2181                                 {
2182                                         __timerCount = 0;
2183                                 }
2184
2185                                 __isTimerCanceled = false;
2186                                 __rearIndex = index;
2187                         }
2188                 }
2189                 else
2190                 {
2191                         pPrevItem = GetItemAt(index);
2192                         SysTryReturn(NID_UI_CTRL, pPrevItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2193
2194                         FloatRectangle boundsPrev = pPrevItem->GetItemBounds();
2195                         if ((bounds.x + (__itemWidth / 2.0f)) > (boundsPrev.x + (__itemWidth / 2.0f)) && ((bounds.x + (__itemWidth / 2.0f)) < (boundsPrev.x + boundsPrev.width)))
2196                         {
2197                                 __pTimerInfo[__timerCount]->index = index;
2198                                 StartReorderTimer(__timerCount);
2199                                 __timerCount++;
2200                                 if (__timerCount >= (__itemMaxCount - 1))
2201                                 {
2202                                         __timerCount = 0;
2203                                 }
2204
2205                                 __isTimerCanceled = false;
2206                                 __rearIndex = index;
2207
2208                         }
2209                 }
2210         }
2211         else //Scroll the entire tab when item moves beyond boundary
2212         {
2213                 if ((bounds.x + __itemWidth) > (__width - (__itemWidth / 2.0f)))
2214                 {
2215                         if (__isDirectionRight)
2216                         {
2217                                 _TabItem *pLastItem = GetItemAt(__lastItemIndex);
2218                                 SysTryReturn(NID_UI_CTRL, pLastItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2219
2220                                 if ((pLastItem->GetItemBounds().x + pLastItem->GetItemBounds().width) > __width)
2221                                 {
2222                                         __isRightScrollable = true;
2223                                         StartScrollAnimationTimer();
2224                                 }
2225                         }
2226                 }
2227
2228                 if (bounds.x < 0.0f)
2229                 {
2230                         if (!__isDirectionRight)
2231                         {
2232                                 if (GetItemAt(__firstItemIndex)->GetItemBounds().x < __itemWidth)
2233                                 {
2234                                         __isLeftScrollable = true;
2235                                         StartScrollAnimationTimer();
2236                                 }
2237                         }
2238                 }
2239         }
2240
2241         SetEditItemBounds(movedPosition);
2242         __pTab->Invalidate();
2243
2244         return true;
2245 }
2246
2247 void
2248 _TabPresenter::ShiftItems(void)
2249 {
2250         int itemCount = GetItemCount();
2251         float fitDistance = 0.0f;
2252         _TabItem* pTabItem = null;
2253         FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
2254
2255         pTabItem = GetItemAt(0);
2256         SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2257
2258         bounds = pTabItem->GetItemBounds();
2259
2260         for (int i = 0; i < itemCount; i++)
2261         {
2262                 if (i == __editItemIndex)
2263                 {
2264                         continue;
2265                 }
2266
2267                 if (__isRightScrollable)
2268                 {
2269                         if (i == __rearIndex + 1)
2270                         {
2271                                 fitDistance = -(2.0f * __itemWidth);
2272
2273                         }
2274                         else
2275                         {
2276                                 fitDistance = -__itemWidth;
2277                         }
2278                 }
2279                 else
2280                 {
2281                         if (i == __rearIndex - 1)
2282                         {
2283                                 fitDistance = (2.0f * __itemWidth);
2284
2285                         }
2286                         else
2287                         {
2288                                 fitDistance = __itemWidth;
2289                         }
2290                 }
2291
2292                 pTabItem =  GetItemAt(i);
2293                 SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2294
2295                 bounds = pTabItem->GetItemBounds();
2296                 bounds.x = bounds.x + fitDistance;
2297                 if ( i == __firstItemIndex && ( bounds.x ) >= (2.0f * __itemWidth))
2298                 {
2299                         return;
2300                 }
2301
2302                 pTabItem->SetItemBounds(bounds);
2303
2304         }
2305
2306         if (__isRightScrollable)
2307         {
2308                 __rearIndex++;
2309         }
2310
2311         if (__isLeftScrollable)
2312         {
2313                 __rearIndex--;
2314         }
2315
2316         Draw();
2317         return;
2318 }
2319
2320 bool
2321 _TabPresenter::OnLongPressGestureDetected(void)
2322 {
2323         if (!__pTabModel->IsEditModeEnabled())
2324         {
2325                 return true;
2326         }
2327
2328         const int index = GetItemIndexFromPosition(__currentTouchPosition);
2329
2330         if (index == -1)
2331         {
2332                 return false;
2333         }
2334
2335         if (GetItemStatus(index) == _TABITEM_STATUS_PRESSED && GetSelectedItemIndex() != index)
2336         {
2337                 SetItemStatus(index, _TABITEM_STATUS_NORMAL);
2338         }
2339
2340         __isEditMode = true;
2341         __editItemIndex = index;
2342
2343         if (__editItemIndex == __firstItemIndex)
2344         {
2345                 __firstItemIndex = __firstItemIndex + 1;
2346         }
2347
2348         if (__editItemIndex == __lastItemIndex)
2349         {
2350                 __lastItemIndex = __lastItemIndex - 1;
2351         }
2352
2353         __rearIndex = index;
2354         __pTab->Invalidate();
2355
2356         return true;
2357 }
2358
2359 bool
2360 _TabPresenter::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
2361 {
2362         if (GetItemCount() == 0)
2363         {
2364                 return true;
2365         }
2366
2367         if (__isEditMode)
2368         {
2369                 return true;
2370         }
2371
2372         if (gesture.GetDirection() != _FLICK_DIRECTION_RIGHT && gesture.GetDirection() != _FLICK_DIRECTION_LEFT)
2373         {
2374                 return false;
2375         }
2376
2377         float distanceX = 0.0f;
2378         float distanceY = 0.0f;
2379         float xPosition = 0.0f;
2380         int itemsBeyondScreen = 0;
2381
2382         gesture.GetDistance(distanceX, distanceY);
2383         SetFirstLoadedItemIndex();
2384         SetLastLoadedItemIndex();
2385         int itemCount = GetItemCount();
2386
2387         if (distanceX < 0.0f)  //left
2388         {
2389                 itemsBeyondScreen = (itemCount - 1) - __lastLoadedItemIndex;
2390                 xPosition = GetItemAt(__lastLoadedItemIndex)->GetItemBounds().x;
2391                 if (xPosition < (3.0f * __itemWidth))
2392                 {
2393                         __flickDistance = xPosition - (4.0f * __itemWidth);
2394                 }
2395         }
2396         else //Right
2397         {
2398                 itemsBeyondScreen = __firstLoadedItemIndex;
2399                 xPosition = GetItemAt(__firstLoadedItemIndex)->GetItemBounds().x;
2400                 if (xPosition < 0.0f)
2401                 {
2402                         __flickDistance = -xPosition;
2403                 }
2404
2405         }
2406
2407         if (itemsBeyondScreen >= (__itemMaxCount - 1))
2408         {
2409                 __flickDistance = (3.0f * __itemWidth);
2410         }
2411         else
2412         {
2413                 __flickDistance = (itemsBeyondScreen * __itemWidth);
2414         }
2415
2416         if (distanceX < 0) //Left flick
2417         {
2418                 __flickMove = 0.006f;
2419                 __flickFlag = 0;
2420         }
2421         else if (distanceX > 0) //Right flick
2422         {
2423                 __flickMove = 0.006f;
2424                 __flickDistance = -(__flickDistance);
2425                 __flickFlag = 0;
2426         }
2427         else
2428         {
2429                 __flickMove = 0.0f;
2430                 __flickDistance = 0.0f;
2431                 __flickFlag = 0;
2432                 __moveDistance = 0.0f;
2433         }
2434
2435         __isFlickEnabled = true;
2436
2437         StartFlickAnimationTimer();
2438
2439         return true;
2440 }
2441
2442 void
2443 _TabPresenter::StartFlickAnimation(void)
2444 {
2445         float distance = CalculateProgress(__flickMove);
2446         __moveDistance = -(__flickDistance * distance);
2447         __flickDistance = (__flickDistance + __moveDistance);
2448         __flickMove = __flickMove + 0.006f;
2449         __flickFlag++;
2450
2451         if (__flickFlag <= FLICK_ANIMATION_COUNT)
2452         {
2453                 StartFlickAnimationTimer();
2454         }
2455         else
2456         {
2457                 ResetFlickAnimationTimer();
2458                 SetItemFitToLeft();
2459         }
2460
2461         Draw();
2462         return;
2463 }
2464
2465 result
2466 _TabPresenter::StartFlickAnimationTimer(void)
2467 {
2468         result r = E_SUCCESS;
2469
2470         if (__pFlickAnimationTimer == null)
2471         {
2472                 __pFlickAnimationTimer = new (std::nothrow) Timer;
2473                 SysTryReturn(NID_UI_CTRL, (__pFlickAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2474
2475                 r = __pFlickAnimationTimer->Construct(*this);
2476                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2477         }
2478         else
2479         {
2480                 __pFlickAnimationTimer->Cancel();
2481         }
2482
2483         r = __pFlickAnimationTimer->Start(FLICK_ANIMATION_TIMER_PERIOD);
2484         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2485
2486         return r;
2487
2488 CATCH:
2489         ResetFlickAnimationTimer();
2490         return r;
2491 }
2492
2493 result
2494 _TabPresenter::StartScrollAnimationTimer(void)
2495 {
2496         result r = E_SUCCESS;
2497         ResetReorderTimer();
2498         if (__pScrollAnimationTimer == null)
2499         {
2500                 __pScrollAnimationTimer = new (std::nothrow) Timer;
2501                 SysTryReturn(NID_UI_CTRL, (__pScrollAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2502
2503                 r = __pScrollAnimationTimer->Construct(*this);
2504                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2505         }
2506         else
2507         {
2508                 __pScrollAnimationTimer->Cancel();
2509         }
2510
2511         r = __pScrollAnimationTimer->Start(SCROLL_ANIMATION_TIMER_PERIOD);
2512         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2513
2514         return r;
2515
2516 CATCH:
2517         ResetScrollAnimationTimer();
2518         return r;
2519 }
2520
2521 result
2522 _TabPresenter::ResetScrollAnimationTimer(void)
2523 {
2524         if (__pScrollAnimationTimer)
2525         {
2526                 delete __pScrollAnimationTimer;
2527                 __pScrollAnimationTimer = null;
2528         }
2529         return E_SUCCESS;
2530 }
2531
2532 result
2533 _TabPresenter::ResetFlickAnimationTimer(void)
2534 {
2535         if (__pFlickAnimationTimer)
2536         {
2537                 delete __pFlickAnimationTimer;
2538                 __pFlickAnimationTimer = null;
2539         }
2540
2541         __isFlickEnabled = false;
2542         __moveDistance = 0.0f;
2543         return E_SUCCESS;
2544 }
2545
2546 void
2547 _TabPresenter::SetItemFit(int index)
2548 {
2549         Point pt = Point(0, 0);
2550         int itemCount = GetItemCount();
2551         float fitDistance = 0.0f;
2552         _TabItem* pTabItem = null;
2553         FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
2554
2555         pTabItem = GetItemAt(index);
2556         SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2557
2558         bounds = pTabItem->GetItemBounds();
2559         fitDistance = -bounds.x;
2560
2561         for (int i = 0; i < itemCount; i++)
2562         {
2563                 pTabItem = GetItemAt(i);
2564                 SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2565
2566                 bounds = pTabItem->GetItemBounds();
2567                 bounds.x = bounds.x + fitDistance;
2568                 pTabItem->SetItemBounds(bounds);
2569         }
2570
2571         return;
2572 }
2573
2574 void
2575 _TabPresenter::SetItemFitToLeft(void)
2576 {
2577         SetItemFit(__firstLoadedItemIndex);
2578         return;
2579 }
2580
2581 void
2582 _TabPresenter::SetItemFitToRight(void)
2583 {
2584         SetItemFit(__lastLoadedItemIndex);
2585         return;
2586 }
2587
2588 void
2589 _TabPresenter::OnTimerExpired(Timer& timer)
2590 {
2591         if (&timer == __pFlickAnimationTimer)
2592         {
2593                 StartFlickAnimation();
2594         }
2595
2596         for (int i = 0; i < _TIMER_COUNT; i++)
2597         {
2598                 if (!__isTimerCanceled)
2599                 {
2600                         if (&timer == __pTimerInfo[i]->pReorderTimer)
2601                         {
2602                                 StartReorderAnimation(__pTimerInfo[i]->index, i);
2603                         }
2604                 }
2605         }
2606
2607         if (&timer == __pScrollAnimationTimer)
2608         {
2609                 _TabItem* pLastItem = GetItemAt(__lastItemIndex);
2610                 SysTryReturnVoidResult(NID_UI_CTRL, pLastItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2611
2612                 if ((GetItemAt(__firstItemIndex)->GetItemBounds().x >= __itemWidth))
2613                 {
2614                         __isRightScrollable = false;
2615                         __isLeftScrollable = false;
2616                 }
2617
2618                 if ((pLastItem->GetItemBounds().x + pLastItem->GetItemBounds().width) <= __width && __isDirectionRight)
2619                 {
2620                         __isRightScrollable = false;
2621                         __isLeftScrollable = false;
2622                 }
2623
2624                 if (__isRightScrollable || __isLeftScrollable)
2625                 {
2626                         if ((__rearIndex - 1) == __editItemIndex && !__isDirectionRight)
2627                         {
2628                                 if (__isLeftScrollable)
2629                                 {
2630                                         __rearIndex--;
2631                                 }
2632                         }
2633
2634                         if ((__rearIndex + 1) == __editItemIndex && __isDirectionRight)
2635                         {
2636                                 if (__isRightScrollable)
2637                                 {
2638                                         __rearIndex++;
2639                                 }
2640                         }
2641
2642                         ShiftItems();
2643                         StartScrollAnimationTimer();
2644                 }
2645                 else
2646                 {
2647                         ResetScrollAnimationTimer();
2648                 }
2649         }
2650         return;
2651 }
2652
2653 float
2654 _TabPresenter::CalculateProgress(float timeProgress) const
2655 {
2656         const float segments[3][3] = {{0.0f, 0.01f, 0.45f}, {0.45f, 0.80f, 0.908f}, {0.908f, 0.9999f, 1.0f}};
2657         float loc_5 = timeProgress / 1;
2658         int loc_6 = 3;  //Length of the segments array
2659         int loc_9 = (int)floor(loc_6 * loc_5);
2660         if (loc_9 >= loc_6)
2661         {
2662                 loc_9 = loc_6 - 1;
2663         }
2664         float loc_7 = (loc_5 - loc_9 * (1.0 / loc_6)) * loc_6;
2665         float loc_8[3];
2666         for (int i = 0; i < 3; i++)
2667         {
2668                  loc_8[i] = segments[loc_9][i];
2669         }
2670         float ret = 0 + 1 * (loc_8[0] + loc_7 * (2 * (1 - loc_7) * (loc_8[1] - loc_8[0]) + loc_7 * (loc_8[2] - loc_8[0])));
2671         return ret;
2672 }
2673
2674 result
2675 _TabPresenter::StartReorderTimer(int index)
2676 {
2677
2678         result r = E_SUCCESS;
2679         if (__pTimerInfo[index]->pReorderTimer == null)
2680         {
2681                 __pTimerInfo[index]->pReorderTimer = new (std::nothrow) Timer;
2682                 SysTryReturn(NID_UI_CTRL, (__pTimerInfo[index]->pReorderTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2683
2684                 r = __pTimerInfo[index]->pReorderTimer->Construct(*this);
2685                 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2686         }
2687         else
2688         {
2689                 __pTimerInfo[index]->pReorderTimer->Cancel();
2690         }
2691
2692         r = __pTimerInfo[index]->pReorderTimer->Start(REORDER_TIMER_PERIOD);
2693         SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2694
2695         return r;
2696
2697 CATCH:
2698         ResetReorderTimer();
2699         return r;
2700 }
2701
2702 void
2703 _TabPresenter::FreeHorizontalLineBitmap()
2704 {
2705         if (__pHorizontalLineBitmap != null)
2706         {
2707                 delete __pHorizontalLineBitmap;
2708                 __pHorizontalLineBitmap = null;
2709         }
2710         return;
2711 }
2712
2713
2714 result
2715 _TabPresenter::ResetReorderTimer()
2716 {
2717         for (int index = 0; index < (__pTab->GetItemCount()); index++)
2718         {
2719                 if (index < _TIMER_COUNT && __pTimerInfo[index])
2720                 {
2721                         if (__pTimerInfo[index]->pReorderTimer)
2722                         {
2723                                 __pTimerInfo[index]->pReorderTimer->Cancel();
2724                         }
2725                 }
2726
2727                 if (__pAnimInfo[index])
2728                 {
2729                         __pAnimInfo[index]->totalDistance = __itemWidth;
2730                         __pAnimInfo[index]->move = 0.5f;
2731                         __pAnimInfo[index]->reorderValue = 0;
2732                 }
2733         }
2734         return E_SUCCESS;
2735 }
2736
2737 result
2738 _TabPresenter::CancelReorderTimer(int index)
2739 {
2740         __pAnimInfo[index]->totalDistance = __itemWidth;
2741         __pAnimInfo[index]->move = 0.5f;
2742         __pAnimInfo[index]->reorderValue = 0;
2743
2744         for (int i = 0; i <_TIMER_COUNT; i++)
2745         {
2746                 if (__pTimerInfo[i])
2747                 {
2748                         if (__pTimerInfo[i]->pReorderTimer)
2749                         {
2750                                 __pTimerInfo[i]->pReorderTimer->Cancel();
2751                         }
2752                 }
2753         }
2754         return E_SUCCESS;
2755 }
2756
2757 void
2758 _TabPresenter::StartReorderAnimation(int index, int timerIndex)
2759 {
2760         float dist = CalculateProgress(__pAnimInfo[index]->move);
2761         __reorderDist = -(__pAnimInfo[index]->totalDistance * dist);
2762
2763         __pAnimInfo[index]->move = __pAnimInfo[index]->move + 0.5f;
2764         __pAnimInfo[index]->totalDistance = (__pAnimInfo[index]->totalDistance + __reorderDist);
2765
2766         if (!__isDirectionRight)
2767         {
2768                 __reorderDist = -__reorderDist;
2769         }
2770
2771         __pAnimInfo[index]->reorderValue++;
2772
2773         if (__pAnimInfo[index]->reorderValue <= REORDER_ANIMATION_COUNT)
2774         {
2775                 SwapItems(index, __reorderDist);
2776                 StartReorderTimer(timerIndex);
2777
2778         }
2779         else
2780         {
2781                 CancelReorderTimer(index);
2782         }
2783
2784
2785         Draw();
2786         return;
2787
2788 }
2789
2790 void
2791 _TabPresenter::SwapItems(int indexDest, float distance)
2792 {
2793         _TabItem *pItem;
2794         FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
2795         pItem = GetItemAt(indexDest);
2796         SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2797
2798         itemBounds = pItem->GetItemBounds();
2799         itemBounds.x = itemBounds.x + distance;
2800         SetFirstLoadedItemIndex();
2801         SetLastLoadedItemIndex();
2802         int animIndex;
2803         int index;
2804         index = GetNextItemIndexFromPosition(FloatPoint(itemBounds.x,itemBounds.y), __editItemIndex);
2805
2806         if (distance < 0.0f) //Moving Left
2807         {
2808                 animIndex = indexDest - __lastLoadedItemIndex;
2809
2810                 if (__pTab->GetItemCount() >= __itemMaxCount)
2811                 {
2812                         animIndex = animIndex + (__itemMaxCount - 1);
2813                 }
2814                 else
2815                 {
2816                         animIndex = animIndex + (__pTab->GetItemCount() - 1);
2817                 }
2818
2819                 if ((__lastLoadedItemIndex > __editItemIndex) && (indexDest < __editItemIndex))
2820                 {
2821                         animIndex++;
2822                 }
2823
2824                 if ((itemBounds.x <= __pAnimInfo[animIndex]->xPosition) &&  (itemBounds.x >= __pAnimInfo[animIndex-1]->xPosition))
2825                 {
2826                         if (index == -1 || index == indexDest) //to avoid overlaping of items on each other
2827                         {
2828                                 pItem->SetItemBounds(itemBounds);
2829                         }
2830                 }
2831         }
2832
2833         if (distance > 0.0f)
2834         {
2835                 animIndex = indexDest - __firstLoadedItemIndex;
2836
2837                 if ((__firstLoadedItemIndex < __editItemIndex) && (indexDest > __editItemIndex))
2838                 {
2839                         animIndex--;
2840                 }
2841
2842                 if ((itemBounds.x >= __pAnimInfo[animIndex]->xPosition) &&  (itemBounds.x <= __pAnimInfo[animIndex+1]->xPosition))
2843                 {
2844                         if (index == -1 || index == indexDest)
2845                         {
2846                                 pItem->SetItemBounds(itemBounds);
2847                         }
2848                 }
2849         }
2850
2851         Draw();
2852         return;
2853
2854 }
2855
2856 int
2857 _TabPresenter::GetNextItemIndexFromPosition(const FloatPoint& point, int curIndex) const
2858 {
2859         FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
2860
2861         int itemIndex = GetFirstDrawnItemIndex();
2862
2863         if ((point.x < 0.0f) || (point.x > __pTab->GetBoundsF().width))
2864         {
2865                 return -1;
2866         }
2867
2868         _TabItem* pItem = __pTab->GetItemAt(itemIndex);
2869
2870         if (pItem == null)
2871         {
2872                 return -1;
2873         }
2874
2875         while (pItem != null)
2876         {
2877                 itemBounds = pItem->GetItemBounds();
2878
2879                 if ((point.x > itemBounds.x) && (point.x < itemBounds.x + itemBounds.width))
2880                 {
2881                         if (curIndex != itemIndex)
2882                         {
2883                                 return itemIndex;
2884                         }
2885                 }
2886
2887                 itemIndex++;
2888                 pItem = __pTab->GetItemAt(itemIndex);
2889
2890                 if (pItem == null)
2891                 {
2892                         break;
2893                 }
2894         }
2895
2896         return -1;
2897 }
2898
2899 void
2900 _TabPresenter::SetFirstLoadedItemIndex()
2901 {
2902         for (int i = 0; i < __pTab->GetItemCount(); i++)
2903         {
2904                 if (__editItemIndex == i)
2905                 {
2906                         continue;
2907                 }
2908
2909                 if ((GetItemAt(i)->GetItemBounds().x + (__itemWidth / 2.0f))  <= __itemWidth)
2910                 {
2911                         __firstLoadedItemIndex = i;
2912                 }
2913         }
2914         return;
2915 }
2916
2917 void
2918 _TabPresenter::SetLastLoadedItemIndex()
2919 {
2920         for (int i = 0; i < __pTab->GetItemCount(); i++)
2921         {
2922                 int X = GetItemAt(i)->GetItemBounds().x;
2923
2924                 if (__editItemIndex == i)
2925                 {
2926                         continue;
2927                 }
2928
2929                 if ((X + (__itemWidth / 2.0f)) < __width)
2930                 {
2931                         __lastLoadedItemIndex = i;
2932                 }
2933         }
2934         return;
2935 }
2936
2937 void
2938 _TabPresenter::OnFontChanged(Font* pFont)
2939 {
2940         __pFont = pFont;
2941         return;
2942 }
2943
2944 void
2945 _TabPresenter::OnFontInfoRequested(unsigned long& style, float& size)
2946 {
2947         style = FONT_STYLE_BOLD;
2948         GET_SHAPE_CONFIG(TAB::FONT_SIZE_01, __pTab->GetOrientation(), size);
2949         return;
2950 }
2951
2952 void
2953 _TabPresenter::OnBoundsChanged()
2954 {
2955         FloatRectangle bounds = __pTab->GetBoundsF();
2956
2957         if (bounds.width <= __tabMinimumSize)
2958         {
2959                 bounds.width = __tabMinimumSize;
2960         }
2961
2962         __pTab->SetBounds(bounds);
2963         SetRecalculateItemBounds(true);
2964
2965         return;
2966 }
2967
2968 //void
2969 //_TabPresenter::SetOpacityVisualElement(float xPosition)
2970 //{
2971 //      Canvas * pCanvas = null;
2972 //      float bounceWidth = (__itemWidth / 2.0f);
2973 //
2974 //      if (__pScrollingEffectVe == null)
2975 //      {
2976 //              __pScrollingEffectVe = new (std::nothrow) _VisualElement();
2977 //              SysTryReturnVoidResult(NID_UI_CTRL, __pScrollingEffectVe, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2978 //
2979 //              __pScrollingEffectVe->Construct();
2980 //              __pScrollingEffectVe->SetName(L"Opacity");
2981 //      }
2982 //
2983 //      __pScrollingEffectVe->SetBounds(FloatRectangle(xPosition, 0.0f, bounceWidth, __itemHeight));
2984 //      __pScrollingEffectVe->SetShowState(true);
2985 //      __pScrollingEffectVe->SetImplicitAnimationEnabled(true);
2986 //      __pTab->GetVisualElement()->AttachChild(*__pScrollingEffectVe);
2987 //      pCanvas = __pScrollingEffectVe->GetCanvasN();
2988 //
2989 //      if (!pCanvas)
2990 //      {
2991 //              __pScrollingEffectVe->Destroy();
2992 //              __pScrollingEffectVe = null;
2993 //
2994 //              SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2995 //              return;
2996 //      }
2997 //
2998 //      Color backgroundColor(0, 0, 0, 0);
2999 //      pCanvas->SetBackgroundColor(backgroundColor);
3000 //      pCanvas->Clear();
3001 //      FloatRectangle rect(0.0f, 0.0f, bounceWidth, __itemHeight);
3002 //
3003 //      DrawResourceBitmap(*pCanvas, rect, __pScrollingEffectBitmap);
3004 //
3005 //      delete pCanvas;
3006 //      return;
3007 //}
3008
3009 //void
3010 //_TabPresenter::StartScrollingEffect(void)
3011 //{
3012 //      float __startOpacity = 0.0f;
3013 //      float __endOpacity = 1.0f;
3014 //
3015 //      VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
3016 //      SysTryReturnVoidResult(NID_UI_CTRL, pAnimation, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3017 //
3018 //      pAnimation->SetPropertyName(L"opacity");
3019 //      pAnimation->SetStartValue(Variant(__startOpacity));
3020 //      pAnimation->SetEndValue(Variant(__endOpacity));
3021 //      pAnimation->SetDuration(OVERSCROLL_ANIMATION_DURATION);
3022 //      pAnimation->SetVisualElementAnimationStatusEventListener(this);
3023 //
3024 //      String animationName3(L"opacity");
3025 //      __pScrollingEffectVe->AddAnimation(animationName3, *pAnimation);
3026 //
3027 //      delete pAnimation;
3028 //      __isScrollEffectStarted = true;
3029 //      return;
3030 //
3031 //}
3032
3033 void
3034 _TabPresenter::OnChangeLayout(_ControlOrientation orientation)
3035 {
3036         __isEditMode = false;
3037         __isTimerCanceled = true;
3038         __isRightScrollable = false;
3039         __isLeftScrollable = false;
3040
3041 //      if (__pScrollingEffectVe)
3042 //      {
3043 //              __pScrollingEffectVe->RemoveAllAnimations();
3044 //              __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe);
3045 //              __pScrollingEffectVe->Destroy();
3046 //              __pScrollingEffectVe = null;
3047 //              __isScrollEffectEnded = false;
3048 //              __isScrollEffectStarted = false;
3049 //      }
3050
3051         ResetScrollAnimationTimer();
3052         ResetReorderTimer();
3053         ResetFlickAnimationTimer();
3054         SetRecalculateItemBounds(true);
3055
3056         return;
3057 }
3058
3059 void
3060 _TabPresenter::MoveNext(void)
3061 {
3062         __moveDistance = (__itemWidth) * (-1.0f);
3063         DrawHorizontal();
3064         __pTab->Draw();
3065
3066         return;
3067 }
3068
3069 void
3070 _TabPresenter::MovePrevious(void)
3071 {
3072         __moveDistance = __itemWidth;
3073         DrawHorizontal();
3074         __pTab->Draw();
3075
3076         return;
3077 }
3078
3079 void
3080 _TabPresenter::MoveToFirst(void)
3081 {
3082         SetRecalculateItemBounds(true);
3083         __pTab->Draw();
3084
3085         return;
3086 }
3087
3088 void
3089 _TabPresenter::MoveToLast(int distance)
3090 {
3091         __moveDistance = (distance - __itemWidth * (__itemMaxCount - 1)) * (-1.0f);
3092         DrawHorizontal();
3093         __pTab->Draw();
3094
3095         return;
3096 }
3097
3098 void
3099 _TabPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
3100 {
3101         return;
3102 }
3103
3104 void
3105 _TabPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
3106 {
3107         return;
3108 }
3109
3110 void
3111 _TabPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool isCompletedNormally)
3112 {
3113
3114         return;
3115 }
3116
3117 }}} // Tizen::Ui::Controls