modify Klockwork bug
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_TableViewItem.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_TableViewItem.cpp
20  * @brief       This is the implementation file for _TableViewItem class.
21  *
22  * This file contains the implementation of _TableViewItem class.
23  */
24
25 #include <FBaseUtilMath.h>
26 #include <FGrp_BitmapImpl.h>
27 #include "FUi_ResourceManager.h"
28 #include "FUi_UiTouchEvent.h"
29 #include "FUiAnim_VisualElement.h"
30 #include "FUiAnim_ControlVisualElement.h"
31 #include "FUiCtrl_TableViewItem.h"
32 #include "FUiCtrl_TableView.h"
33 #include "FUi_CoordinateSystemUtils.h"
34 #include "FUi_Math.h"
35 #include "FUiCtrl_LabelImpl.h"
36 #include "FUi_Window.h"
37
38 using namespace Tizen::Base;
39 using namespace Tizen::Base::Runtime;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Ui::Animations;
42 using namespace Tizen::Graphics;
43
44 namespace Tizen { namespace Ui { namespace Controls
45 {
46
47 _TableViewItemControl::_TableViewItemControl(void)
48         :__pBackgroundBitmap(null)
49 {
50 }
51
52 _TableViewItemControl::~_TableViewItemControl(void)
53 {
54         if (__pBackgroundBitmap)
55         {
56                 delete __pBackgroundBitmap;
57                 __pBackgroundBitmap = null;
58         }
59         ClearLastResult();
60 }
61
62 void
63 _TableViewItemControl::OnDraw(void)
64 {
65         Bitmap* pBitmap = GetBackgroundBitmap();
66
67         FloatRectangle bounds(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height); // +++ check floating
68
69         Color bgColor = GetBackgroundColor();
70
71         Canvas* pCanvas = null;
72
73         if (pBitmap != null)
74         {
75                 pCanvas = GetCanvasN();
76                 if (pCanvas == null)
77                 {
78                         SysLog(NID_UI_CTRL, "Cannot get a canvas.");
79
80                         return;
81                 }
82
83                 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
84                 pCanvas->Clear();
85
86                 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
87                 {
88                         pCanvas->DrawNinePatchedBitmap(bounds, *pBitmap);
89                 }
90                 else
91                 {
92                         FloatRectangle drawingRect(0.0f, 0.0f, bounds.width, bounds.height);
93                         pCanvas->DrawBitmap(drawingRect, *pBitmap);
94                 }
95
96         }
97         else
98         {
99                 if (IsCalledGetCanvasN() == false)
100                 {
101                         GetVisualElement()->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255, (float)bgColor.GetGreen() / 255, (float)bgColor.GetBlue() / 255, (float)bgColor.GetAlpha() / 255));
102                 }
103                 else
104                 {
105                         pCanvas = GetCanvasN();
106                         if (pCanvas == null)
107                         {
108                                 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
109
110                                 return;
111                         }
112
113                         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
114                         pCanvas->Clear();
115                         pCanvas->FillRectangle(GetBackgroundColor(), bounds); // +++ check floating
116                 }
117         }
118
119         if (pCanvas)
120         {
121                 delete pCanvas;
122         }
123
124         return;
125 }
126
127 HitTestResult
128 _TableViewItemControl::HitTest(const  Graphics :: FloatPoint & point)
129 {
130         return HIT_TEST_NOWHERE;
131 }
132
133 _TableViewItemControl*
134 _TableViewItemControl::CreateTableViewItemControlN(void)
135 {
136         _TableViewItemControl* pItemControl = new (std::nothrow) _TableViewItemControl();
137         SysTryReturn(NID_UI_CTRL, pItemControl, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
138         SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
139
140
141         pItemControl->AcquireHandle();
142
143         return pItemControl;
144
145 CATCH:
146         delete pItemControl;
147         return null;
148 }
149
150 result
151 _TableViewItemControl::SetBackgroundBitmap(const Bitmap& bitmap)
152 {
153         result r = E_SYSTEM;
154
155         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
156
157         if (pClonedBitmap)
158         {
159                 if (__pBackgroundBitmap != null)
160                 {
161                         delete __pBackgroundBitmap;
162                 }
163
164                 __pBackgroundBitmap = pClonedBitmap;
165
166                 r = E_SUCCESS;
167         }
168
169         return r;
170 }
171
172 Bitmap*
173 _TableViewItemControl::GetBackgroundBitmap(void) const
174 {
175         return __pBackgroundBitmap;
176 }
177
178 _TableViewItem::_TableViewItem(float itemHeight)
179         : _Control()
180         , __pAppInfo(null)
181         , __refCount(1)
182         , __itemHeight(itemHeight)
183         , __itemGroupIndex(-1)
184         , __itemIndex(-1)
185         , __checkedState(false)
186         , __enabledState(true)
187         , __itemChanged(true)
188         , __reorderMode(false)
189         , __itemSelected(false)
190         , __itemTouchMoved(false)
191         , __childMarginState(false)
192         , __annexStyle(TABLE_VIEW_ANNEX_STYLE_NORMAL)
193         , __drawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
194         , __selectionStyle(TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE)
195         , __itemType(TABLE_VIEW_ITEM_TYPE_NONE)
196         , __pContextItem(null)
197         , __isContextItem(false)
198         , __isContextItemActivated(false)
199         , __checkItemHeightNeeded(false)
200         , __pItemDivider(null)
201         , __pItemTopDivider(null)
202         , __pItemAnnex(null)
203         , __pItemCover(null)
204         , __pItemAnnexLeftDivider(null)
205         , __pItemAnnexRightDivider(null)
206         , __itemWidth(0.0f)
207         , __pDrawingProperty(null)
208         , __itemDividerEnabled(true)
209         , __pSimpleItemText(null)
210         , __pSimpleItemBitmap(null)
211         , __simpleItemTextSize(0)
212         , __pHeaderFooterItemText(null)
213         , __pDimLayer(null)
214         , __touchStartPosition(0.0f, 0.0f)
215         , __annexTouchStartPosition(0)
216         , __annexOnOffHandlerMoved(false)
217         , __annexOnOffHandlerPositionX(0.0f)
218         , __childControlCenterAlign(false)
219         , __customHeight(0.0f)
220         , __animationCount(0)
221         , __pAccessibilityElement(null)
222         , __pAccessibilityOnOffElement(null)
223         , __pPressedTimer(null)
224         , __pReleasedTimer(null)
225         , __isPressedTimerEnabled(false)
226         , __isReleasedTimerEnabled(false)
227         , __pressedControl(TABLE_VIEW_ITEM_PRESSED_NONE)
228         , __releasedControl(TABLE_VIEW_ITEM_PRESSED_NONE)
229         , __pCheckedTimer(null)
230         , __isCheckedTimerEnabled(false)
231         , __isCheckedAnimationEnabled(false)
232         , __checkedCount(0)
233         , __checkedBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
234         , __isItemLayoutEnabled(false)
235         , __isMoveItemAnimationEnabled(false)
236         , __isZoomInOutItemAnimationEnabled(false)
237         , __isFadeInOutItemAnimationEnabled(false)
238         , __isAnimationCallbackBlocked(false)
239         , __isItemTapSoundEnabled(true)
240         , __isTabSoundPlayed(false)
241         , __isSelectedDetailButton(false)
242         , __isSimpleLastItem(false)
243         , __isSectionItem(false)
244         , __isTouchPressOnScroll(false)
245         , __isTouchCancelOnPressRelease(false)
246         , __pHighlightVisualElement(null)
247         , __pBitmapVisualElement(null)
248         , __pMoveItemAnimation(null)
249         , __pZoomInOutItemAnimation(null)
250         , __pFadeInOutItemtAnimation(null)
251 {
252         for (int i = 0; i < 3; i++)
253         {
254                 __pItemBgBitmap[i] = null;
255         }
256
257         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_NORMAL, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]); // for support opacity 0x00
258         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_PRESSED, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED]);
259         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_HIGHLIGHTED, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED]);
260
261         GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_NORMAL, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
262         GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_PRESSED, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED]);
263         GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_HIGHLIGHTED, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED]);
264         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_NORMAL, __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]);
265         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_PRESSED, __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED]);
266         GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_DISABLED, __simpleItemTextColor[TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED]);
267
268
269         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
270         if (pContainer)
271         {
272                 pContainer->Activate(true);
273                 pContainer->AddListener(*this);
274         }
275 }
276
277 _TableViewItem::~_TableViewItem()
278 {
279         __isAnimationCallbackBlocked = true;
280
281         StopTouchPressedTimer(true);
282         delete __pPressedTimer;
283         __pPressedTimer = null;
284
285         StopTouchReleasedTimer(true);
286         delete __pReleasedTimer;
287         __pReleasedTimer = null;
288
289         _VisualElement* pVisualElement = GetVisualElement();
290         if (pVisualElement != null)
291         {
292                 if (__pMoveItemAnimation != null)
293                 {
294                         __pMoveItemAnimation->SetVisualElementAnimationTickEventListener(null);
295                         __pMoveItemAnimation->SetVisualElementAnimationStatusEventListener(null);
296                 }
297
298                 if (__pZoomInOutItemAnimation != null)
299                 {
300                         __pZoomInOutItemAnimation->SetVisualElementAnimationTickEventListener(null);
301                         __pZoomInOutItemAnimation->SetVisualElementAnimationStatusEventListener(null);
302                 }
303
304                 if (__pFadeInOutItemtAnimation != null)
305                 {
306                         __pFadeInOutItemtAnimation->SetVisualElementAnimationTickEventListener(null);
307                         __pFadeInOutItemtAnimation->SetVisualElementAnimationStatusEventListener(null);
308                 }
309                 pVisualElement->RemoveAllAnimations();
310         }
311
312         for (int j = 0; j < 3; j++)
313         {
314                 delete __pItemBgBitmap[j];
315                 __pItemBgBitmap[j] = null;
316         }
317
318         if (__pHighlightVisualElement != null)
319         {
320                 __pHighlightVisualElement->RemoveAllAnimations();
321                 __pHighlightVisualElement->SetAnimationProvider(null);
322                 __pHighlightVisualElement->Destroy();
323                 __pHighlightVisualElement = null;
324         }
325
326         if (__pBitmapVisualElement != null)
327         {
328                 __pBitmapVisualElement->RemoveAllAnimations();
329                 __pBitmapVisualElement->SetAnimationProvider(null);
330                 __pBitmapVisualElement->Destroy();
331                 __pBitmapVisualElement = null;
332         }
333
334         DetachAllChildren();
335
336         if (GetParent() != null && __isContextItem == true)
337         {
338                 GetParent()->DetachChild(*this);
339         }
340
341         delete __pItemDivider;
342         __pItemDivider = null;
343
344         delete __pItemTopDivider;
345         __pItemTopDivider = null;
346
347         delete __pItemAnnexLeftDivider;
348         __pItemAnnexLeftDivider = null;
349
350         delete __pItemAnnexRightDivider;
351         __pItemAnnexRightDivider = null;
352
353         delete __pItemAnnex;
354         __pItemAnnex = null;
355
356         delete __pDimLayer;
357         __pDimLayer = null;
358
359         delete __pItemCover;
360         __pItemCover = null;
361
362         delete __pHeaderFooterItemText;
363         __pHeaderFooterItemText = null;
364
365         delete __pMoveItemAnimation;
366         __pMoveItemAnimation = null;
367
368         delete __pZoomInOutItemAnimation;
369         __pZoomInOutItemAnimation = null;
370
371         delete __pFadeInOutItemtAnimation;
372         __pFadeInOutItemtAnimation = null;
373
374         if (__isCheckedTimerEnabled)
375         {
376                 __pCheckedTimer->Cancel();
377         }
378
379         delete __pCheckedTimer;
380         __pCheckedTimer = null;
381
382         if (__pAccessibilityElement)
383         {
384                 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
385                 if (pContainer)
386                 {
387                         pContainer->RemoveAllElement();
388                 }
389                 __pAccessibilityElement = null;
390
391                 if (__pAccessibilityOnOffElement)
392                 {
393                         __pAccessibilityOnOffElement = null;
394                 }
395         }
396 }
397
398 _TableViewItem*
399 _TableViewItem::CreateTableViewItemN(float itemHeight)
400 {
401         result r = E_SUCCESS;
402
403         _TableViewItem* pItem = null;
404         pItem = new (std::nothrow) _TableViewItem(itemHeight);
405         SysTryReturn(NID_UI_CTRL, pItem, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
406
407         pItem->AcquireHandle();
408
409         r = pItem->Initialize();
410         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
411
412
413         return pItem;
414
415 CATCH:
416         delete pItem;
417
418         return null;
419 }
420
421 result
422 _TableViewItem::Initialize(void)
423 {
424         GetVisualElement()->SetSurfaceOpaque(false);
425
426         result r = E_SUCCESS;
427
428         __pHighlightVisualElement = new (std::nothrow) _VisualElement();
429         SysTryCatch(NID_UI_CTRL, __pHighlightVisualElement != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
430
431         r = __pHighlightVisualElement->Construct();
432         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct Visual Element.", GetErrorMessage(r));
433
434         r = __pHighlightVisualElement->SetSurfaceOpaque(false);
435         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set surface opaque.", GetErrorMessage(r));
436
437         __pHighlightVisualElement->SetImplicitAnimationEnabled(false);
438
439         r = GetVisualElement()->AttachChild(*__pHighlightVisualElement);
440         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach child to the control VisualElement.", GetErrorMessage(r));
441
442         r = SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
443         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r));
444
445         __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f));
446         __pHighlightVisualElement->SetShowState(true);
447
448         r = __individualSelectionControls.Construct(DEFAULT_CAPTURED_CONTROL_COUNT);
449         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct ArrayList", GetErrorMessage(r));
450
451         SetTouchPressThreshold(SENSITIVE);
452
453         if (!_FloatCompare(__itemHeight, 0.0f))
454         {
455                 SetAccessibilityElement();
456         }
457
458         GetAccessibilityContainer()->Activate(false);
459
460         return r;
461
462 CATCH:
463         if (__pHighlightVisualElement != null)
464         {
465                 __pHighlightVisualElement->RemoveAllAnimations();
466                 __pHighlightVisualElement->SetAnimationProvider(null);
467                 __pHighlightVisualElement->Destroy();
468                 __pHighlightVisualElement = null;
469         }
470
471         return r;
472 }
473
474 _TableViewItem*
475 _TableViewItem::GetContextItem(void) const
476 {
477         return __pContextItem;
478 }
479
480 void
481 _TableViewItem::SetContextItem(_TableViewItem* pContextItem)
482 {
483         if (pContextItem != null)
484         {
485                 pContextItem->__isContextItem = true;
486         }
487
488         __pContextItem = pContextItem;
489 }
490
491 bool
492 _TableViewItem::IsContextItem(void) const
493 {
494         return __isContextItem;
495 }
496
497 void
498 _TableViewItem::SetContextItemActivation(bool activated)
499 {
500         __isContextItemActivated = activated;
501 }
502
503 bool
504 _TableViewItem::IsContextItemActivated(void) const
505 {
506         return __isContextItemActivated;
507 }
508
509 result
510 _TableViewItem::CreateItemDimLayer(void)
511 {
512         result r = E_SUCCESS;
513
514         if (__pDimLayer == null)
515         {
516                 __pDimLayer = _Label::CreateLabelN();
517
518                 r = GetLastResult();
519                 SysTryReturn(NID_UI_CTRL, __pDimLayer != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
520
521                 __pDimLayer->SetBackgroundColor(Color(0, 0, 0, BACKGROUND_DIMMED_OPACITY * 0xff));
522                 __pDimLayer->SetVisibleState(false);
523
524                 AttachSystemChild(*__pDimLayer);
525         }
526
527         return r;
528 }
529
530 result
531 _TableViewItem::CreateItemDivider(void)
532 {
533         result r = E_SUCCESS;
534
535         if (__pItemDivider == null)
536         {
537                 __pItemDivider = _TableViewItemControl::CreateTableViewItemControlN();
538                 r = GetLastResult();
539                 SysTryReturn(NID_UI_CTRL, __pItemDivider != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
540                 __pItemDivider->SetFocusable(false);
541                 AttachSystemChild(*__pItemDivider);
542
543                 _AccessibilityContainer* pContainer = __pItemDivider->GetAccessibilityContainer();
544                 pContainer->Activate(false);
545         }
546
547         if (__pItemTopDivider == null)
548         {
549                 __pItemTopDivider = _TableViewItemControl::CreateTableViewItemControlN();
550                 SysTryReturn(NID_UI_CTRL, __pItemTopDivider != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
551                 __pItemTopDivider->SetFocusable(false);
552                 AttachSystemChild(*__pItemTopDivider);
553
554                 _AccessibilityContainer* pContainer = __pItemTopDivider->GetAccessibilityContainer();
555                 pContainer->Activate(false);
556         }
557
558         return r;
559 }
560
561 result
562 _TableViewItem::CreateItemAnnexDivider(void)
563 {
564         result r = E_SUCCESS;
565
566         if (__pItemAnnexLeftDivider == null)
567         {
568                 __pItemAnnexLeftDivider = _TableViewItemControl::CreateTableViewItemControlN();
569                 r = GetLastResult();
570                 SysTryReturn(NID_UI_CTRL, __pItemAnnexLeftDivider != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
571                 __pItemAnnexLeftDivider->SetFocusable(false);
572                 AttachSystemChild(*__pItemAnnexLeftDivider);
573         }
574
575         if (__pItemAnnexRightDivider == null)
576         {
577                 __pItemAnnexRightDivider = _TableViewItemControl::CreateTableViewItemControlN();
578                 SysTryReturn(NID_UI_CTRL, __pItemAnnexRightDivider != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
579                 __pItemAnnexRightDivider->SetFocusable(false);
580                 AttachSystemChild(*__pItemAnnexRightDivider);
581         }
582
583         return r;
584 }
585
586 result
587 _TableViewItem::CreateItemCover(void)
588 {
589         result r = E_SUCCESS;
590
591         if (__pItemCover == null)
592         {
593                 __pItemCover = _TableViewItemControl::CreateTableViewItemControlN();
594                 r = GetLastResult();
595                 SysTryReturn(NID_UI_CTRL, __pItemCover != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
596                 __pItemCover->SetFocusable(false);
597                 AttachSystemChild(*__pItemCover);
598         }
599
600         return r;
601 }
602
603 result
604 _TableViewItem::CreateCheckBox(void)
605 {
606         result r = E_SUCCESS;
607
608         if (__pItemAnnex == null)
609         {
610                 float annexWidth = 0.0f;
611                 float annexHeight = 0.0f;
612                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
613                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
614
615                 __pItemAnnex = new (std::nothrow) Label();
616                 r = GetLastResult();
617                 SysTryReturn(NID_UI_CTRL, __pItemAnnex != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
618
619                 float leftMargin = 0.0f;
620                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
621
622                 float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height);
623                 __pItemAnnex->Construct(FloatRectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight), L"");
624                 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
625                 GetLabelCore(__pItemAnnex)->SetFocusable(true);
626
627                 AttachSystemChild(*GetLabelCore(__pItemAnnex));
628         }
629
630         return r;
631 }
632
633
634 result
635 _TableViewItem::CreateRadioBox(void)
636 {
637         result r = E_SUCCESS;
638
639         if (__pItemAnnex == null)
640         {
641                 float annexWidth = 0.0f;
642                 float annexHeight = 0.0f;
643                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
644                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
645
646                 __pItemAnnex = new (std::nothrow) Label();
647                 r = GetLastResult();
648                 SysTryReturn(NID_UI_CTRL, __pItemAnnex != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
649
650                 float leftMargin = 0.0f;
651                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
652
653                 float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height);
654                 __pItemAnnex->Construct(FloatRectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight), L"");
655                 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
656                 GetLabelCore(__pItemAnnex)->SetFocusable(true);
657
658                 AttachSystemChild(*GetLabelCore(__pItemAnnex));
659         }
660
661         return r;
662 }
663
664 result
665 _TableViewItem::CreateOnOffButton(void)
666 {
667         result r = E_SUCCESS;
668
669         if (__pItemAnnex == null)
670         {
671                 float annexWidth = 0.0f;
672                 float annexHeight = 0.0f;
673
674                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
675                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
676
677                 __pItemAnnex = new (std::nothrow) Label();
678                 r = GetLastResult();
679                 SysTryReturn(NID_UI_CTRL, __pItemAnnex != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
680
681                 float leftMargin = 0.0f;
682                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
683
684                 leftMargin += __pDrawingProperty->scrollMargin;
685
686                 float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height);
687                 __pItemAnnex->Construct(FloatRectangle((GetBoundsF().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight), L"");
688                 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
689                 GetLabelCore(__pItemAnnex)->SetFocusable(true);
690
691                 AttachSystemChild(*GetLabelCore(__pItemAnnex));
692         }
693
694         return r;
695 }
696
697 result
698 _TableViewItem::CreateDetailButton(void)
699 {
700         result r = E_SUCCESS;
701
702         if (__pItemAnnex == null)
703         {
704                 float annexWidth = 0.0f;
705                 float annexHeight = 0.0f;
706
707                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
708                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
709                 __pItemAnnex = new (std::nothrow) Label();
710                 r = GetLastResult();
711                 SysTryReturn(NID_UI_CTRL, __pItemAnnex != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
712
713                 float leftMargin = 0.0f;
714                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
715
716                 leftMargin += __pDrawingProperty->scrollMargin;
717                 float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height);
718                 __pItemAnnex->Construct(FloatRectangle((GetBoundsF().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight), L"");
719                 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
720                 GetLabelCore(__pItemAnnex)->SetFocusable(true);
721
722                 AttachSystemChild(*GetLabelCore(__pItemAnnex));
723         }
724
725         return r;
726 }
727
728 _Label*
729 _TableViewItem::GetLabelCore(Label* pLabel)
730 {
731         if (pLabel == null)
732         {
733                 return null;
734         }
735
736         _LabelImpl* pImpl = _LabelImpl::GetInstance(*pLabel);
737         return &pImpl->GetCore();
738 }
739
740 void
741 _TableViewItem::ExposeContextItem(FloatRectangle itemBounds, float targetWidth)
742 {
743         DrawItemDivider();
744         if (__pDimLayer == null)
745         {
746                 if (CreateItemDimLayer() != E_SUCCESS)
747                 {
748                         return;
749                 }
750         }
751
752         SetBounds(itemBounds);
753
754         bool visible = true;
755
756         if ((itemBounds.width <= 0) || (itemBounds.width >= targetWidth)) // +++ check floating
757         {
758                 visible = false;
759         }
760
761         if (visible)
762         {
763                 float rightMargin = 0.0f;
764                 float dimLayerOpacity = 0.0f;
765
766                 GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, rightMargin);
767
768                 dimLayerOpacity = BACKGROUND_DIMMED_OPACITY - ((itemBounds.width * BACKGROUND_DIMMED_OPACITY) / (targetWidth - rightMargin));
769                 dimLayerOpacity = ((dimLayerOpacity < 0) ? 0 :  dimLayerOpacity); // +++ check floating
770
771                 __pDimLayer->SetBounds(FloatRectangle(0.0f, 0.0f, itemBounds.width, itemBounds.height));
772                 __pDimLayer->SetBackgroundColor(Color(0.0f, 0.0f, 0.0f, dimLayerOpacity * 0xff));
773         }
774
775         __pDimLayer->SetVisibleState(visible);
776
777 }
778
779 void
780 _TableViewItem::DrawItemDimLayer(bool visible)
781 {
782         if (__pDimLayer == null)
783         {
784                 if (CreateItemDimLayer() != E_SUCCESS)
785                 {
786                         return;
787                 }
788         }
789
790         if (visible)
791         {
792                 FloatDimension itemSize = GetSizeF();
793                 __pDimLayer->SetBounds(FloatRectangle(0.0f, 0.0f, itemSize.width, itemSize.height));
794                 __pDimLayer->SetBackgroundColor(Color(0, 0, 0, BACKGROUND_DISABLED_OPACITY * 0xff));
795         }
796
797         __pDimLayer->SetVisibleState(visible);
798 }
799
800 void
801 _TableViewItem::SetItemWidth(float width)
802 {
803         __itemWidth = width;
804 }
805
806 bool
807 _TableViewItem::SetItemBackgroundBitmap(ListItemState itemState, const Bitmap* pBitmap)
808 {
809         Bitmap* pCopyBitmap = null;
810
811         pCopyBitmap = _BitmapImpl::CloneN(*pBitmap);
812         SysTryReturn(NID_UI_CTRL, pCopyBitmap != null, false, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
813
814         delete __pItemBgBitmap[itemState];
815         __pItemBgBitmap[itemState] = pCopyBitmap;
816
817
818         if (__pItemBgBitmap[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL] == null &&
819                 __pItemBgBitmap[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED] == null &&
820                 __pItemBgBitmap[TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED] == null)
821         {
822                 if (__pBitmapVisualElement != null)
823                 {
824                         __pBitmapVisualElement->Destroy();
825                         __pBitmapVisualElement = null;
826                 }
827         }
828         else
829         {
830                 if (__pBitmapVisualElement == null)
831                 {
832                         FloatRectangle bounds = GetBoundsF();
833                         result r = E_SUCCESS;
834
835                         __pBitmapVisualElement = new (std::nothrow) _VisualElement();
836                         SysTryCatch(NID_UI_CTRL, __pBitmapVisualElement != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
837
838                         r = __pBitmapVisualElement->Construct();
839                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
840
841                         __pBitmapVisualElement->SetSurfaceOpaque(false);
842                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set surface opaque.", GetErrorMessage(r));
843
844                         __pBitmapVisualElement->SetImplicitAnimationEnabled(false);
845                         __pBitmapVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
846                         __pBitmapVisualElement->SetShowState(true);
847
848                         GetVisualElement()->AttachChild(*__pBitmapVisualElement);
849                 }
850         }
851
852         SetItemChanged(true);
853         return true;
854 CATCH:
855         if (__pBitmapVisualElement != null)
856         {
857                 __pBitmapVisualElement->RemoveAllAnimations();
858                 __pBitmapVisualElement->SetAnimationProvider(null);
859                 __pBitmapVisualElement->Destroy();
860                 __pBitmapVisualElement = null;
861         }
862         return false;
863 }
864
865 Tizen::Graphics::Bitmap*
866 _TableViewItem::GetItemBackgroundBitmap(ListItemState itemState) const
867 {
868         return __pItemBgBitmap[itemState];
869 }
870
871 void
872 _TableViewItem::SetItemBackgroundColor(ListItemState itemState, const Color bgColor)
873 {
874         if (__colorItemBg[itemState] == bgColor)
875         {
876                 return;
877         }
878
879         __colorItemBg[itemState] = bgColor;
880
881         SetItemChanged(true);
882 }
883
884 Color
885 _TableViewItem::GetItemBackgroundColor(ListItemState itemState) const
886 {
887         return __colorItemBg[itemState];
888 }
889
890 void
891 _TableViewItem::SetItemStyle(TableViewAnnexStyle style)
892 {
893         if (__annexStyle == style)
894         {
895                 return;
896         }
897
898         __annexStyle = style;
899 }
900
901 result
902 _TableViewItem::SetSelectionStyle(TableViewItemSelectionStyle style)
903 {
904         __selectionStyle = style;
905
906         return E_SUCCESS;
907 }
908
909 TableViewItemSelectionStyle
910 _TableViewItem::GetSelectionStyle(void) const
911 {
912         return __selectionStyle;
913 }
914
915 float
916 _TableViewItem::GetItemHeight(void) const
917 {
918         return GetSizeF().height;
919 }
920
921 void
922 _TableViewItem::SetItemHeight(int itemHeight)
923 {
924         SetItemHeight(_CoordinateSystemUtils::ConvertToFloat(itemHeight));
925 }
926
927 void
928 _TableViewItem::SetItemHeight(float itemHeight)
929 {
930         if (_FloatCompare(GetSizeF().height, itemHeight))
931         {
932                 return;
933         }
934
935         SetSize(FloatDimension(GetSizeF().width, itemHeight));
936 }
937
938 void
939 _TableViewItem::SetChecked(bool checked)
940 {
941         if (__checkedState == checked)
942         {
943                 return;
944         }
945
946         __checkedState = checked;
947
948         SetItemChanged(true);
949 }
950
951 bool
952 _TableViewItem::IsChecked(void) const
953 {
954         return __checkedState;
955 }
956
957 void
958 _TableViewItem::SetCheckedAnimationEnabled(bool enabled)
959 {
960         if (__isCheckedAnimationEnabled == enabled)
961         {
962                 return;
963         }
964
965         __isCheckedAnimationEnabled = enabled;
966
967         if (__isCheckedAnimationEnabled == false)
968         {
969                 StopCheckBoxAnimation();
970         }
971 }
972
973 void
974 _TableViewItem::SetItemEnabled(bool enabled)
975 {
976         if (__enabledState == enabled)
977         {
978                 return;
979         }
980
981         __enabledState = enabled;
982
983         SetEnableState(enabled);
984
985         SetItemChanged(true);
986
987         Invalidate();
988
989         return;
990 }
991
992 bool
993 _TableViewItem::IsItemEnabled(void) const
994 {
995         return __enabledState;
996 }
997
998 void
999 _TableViewItem::SetItemType(const TableViewItemType itemType)
1000 {
1001         if (__itemType == itemType)
1002         {
1003                 return;
1004         }
1005
1006         __itemType = itemType;
1007
1008         if (__pContextItem != null)
1009         {
1010                 __pContextItem->SetItemType(__itemType);
1011         }
1012
1013         if (itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
1014         {
1015                 Color titleColor;
1016                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_PRESSED, titleColor);
1017                 if (titleColor == __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED])
1018                 {
1019                         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BG_PRESSED, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED]);
1020                 }
1021                 GetAccessibilityContainer()->Activate(true);
1022         }
1023 }
1024
1025 void
1026 _TableViewItem::SetItemIndex(int groupIndex, int itemIndex)
1027 {
1028         __itemGroupIndex = groupIndex;
1029         __itemIndex = itemIndex;
1030 }
1031
1032 void
1033 _TableViewItem::GetItemIndex(int& groupIndex, int& itemIndex) const
1034 {
1035         groupIndex = __itemGroupIndex;
1036         itemIndex = __itemIndex;
1037 }
1038
1039
1040 TableViewItemType
1041 _TableViewItem::GetItemType(void) const
1042 {
1043         return __itemType;
1044 }
1045
1046 bool
1047 _TableViewItem::IsReorderMode(void) const
1048 {
1049         return __reorderMode;
1050 }
1051
1052 void
1053 _TableViewItem::SetReorderMode(bool enabled)
1054 {
1055         __reorderMode = enabled;
1056 }
1057
1058 void
1059 _TableViewItem::SetAppInfo(const void* pAppInfo)
1060 {
1061         __pAppInfo = const_cast<void*>(pAppInfo);
1062 }
1063
1064 void*
1065 _TableViewItem::GetAppInfo(void) const
1066 {
1067         return __pAppInfo;
1068 }
1069
1070 void
1071 _TableViewItem::SetItemChanged(bool changed)
1072 {
1073         __itemChanged = changed;
1074 }
1075
1076 bool
1077 _TableViewItem::IsItemChanged(void) const
1078 {
1079         return __itemChanged;
1080 }
1081
1082 bool
1083 _TableViewItem::IsAnnexOnOffSliding(void)
1084 {
1085         return __annexOnOffHandlerMoved;
1086 }
1087
1088 TableViewAnnexStyle
1089 _TableViewItem::GetItemStyle(void) const
1090 {
1091         return __annexStyle;
1092 }
1093
1094 bool
1095 _TableViewItem::DrawItem(FloatRectangle& rcItem, ListItemState itemState, bool itemDivider)
1096 {
1097         return true;
1098 }
1099
1100 bool
1101 _TableViewItem::SetItemTapSoundEnabled(bool tapSoundEnabled)
1102 {
1103         bool oldValue = __isItemTapSoundEnabled;
1104         __isItemTapSoundEnabled = tapSoundEnabled;
1105         return oldValue;
1106 }
1107
1108 bool
1109 _TableViewItem::GetItemTapSoundEnabled(void)
1110 {
1111         return __isItemTapSoundEnabled;
1112 }
1113
1114 void
1115 _TableViewItem::DrawAnnexFocus(void)
1116 {
1117         if (__pItemAnnex)
1118         {
1119                 __pItemAnnex->SetFocus();
1120         }
1121         return;
1122 }
1123
1124 Tizen::Graphics::Canvas*
1125 _TableViewItem::OnCanvasRequestedN(const Tizen::Graphics::FloatRectangle& bounds)
1126 {
1127         Canvas* pCanvas = null;
1128
1129         if (__pBitmapVisualElement != null && __pBitmapVisualElement->GetImageSource().IsEmpty())
1130         {
1131                 Bitmap* pDrawBitmap = __pItemBgBitmap[__drawingStatus];
1132                 if (pDrawBitmap != null)
1133                 {
1134                         pCanvas = __pBitmapVisualElement->GetCanvasN();
1135                         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1136                         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1137                         pCanvas->Clear();
1138
1139                         pDrawBitmap->IsNinePatchedBitmap();
1140                         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pDrawBitmap);
1141                 }
1142         }
1143
1144 CATCH:
1145
1146         return pCanvas;
1147 }
1148
1149 void
1150 _TableViewItem::FireItemEvent(bool selectedItem)
1151 {
1152         if (!HasParent()
1153                 || IsContextItem()
1154                 || __itemType == TABLE_VIEW_ITEM_TYPE_HEADER
1155                 || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
1156         {
1157                 return;
1158         }
1159
1160         _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
1161         if (pParent == null)
1162         {
1163                 return;
1164         }
1165
1166         TableViewNotifyType eventType = TABLEVIEW_NOTIFY_TYPE_SELECTED_ITEM;
1167
1168         if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
1169                 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1170                 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING))
1171         {
1172                 if (IsChecked())
1173                 {
1174                         eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK;
1175                 }
1176                 else
1177                 {
1178                         eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK;
1179                 }
1180         }
1181         else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
1182         {
1183                 if (!selectedItem)
1184                 {
1185                         eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_MORE;
1186                 }
1187         }
1188         else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
1189         {
1190                 if (selectedItem)
1191                 {
1192                         eventType = TABLEVIEW_NOTIFY_TYPE_SELECTED_ITEM;
1193                 }
1194                 else
1195                 {
1196                         if (IsChecked())
1197                         {
1198                                 eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK;
1199                         }
1200                         else
1201                         {
1202                                 eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK;
1203                         }
1204                 }
1205         }
1206
1207         if (__isItemTapSoundEnabled)
1208         {
1209                 if (!__isTabSoundPlayed)
1210                 {
1211                         PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, this);
1212                 }
1213         }
1214
1215         __isTabSoundPlayed = false;
1216         __checkItemHeightNeeded = true;
1217
1218         int groupIndex = -1;
1219         int itemIndex = -1;
1220         GetItemIndex(groupIndex, itemIndex);
1221         pParent->FireTableViewItemEvent(groupIndex, itemIndex, eventType, this);
1222 }
1223
1224 void
1225 _TableViewItem::FireItemSweepEvent(TableViewSweepDirection direction)
1226 {
1227         if (HasParent() == false)
1228         {
1229                 return;
1230         }
1231
1232         _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
1233         if (pParent == null)
1234         {
1235                 return;
1236         }
1237
1238         int groupIndex = -1;
1239         int itemIndex = -1;
1240         GetItemIndex(groupIndex, itemIndex);
1241
1242         pParent->FireTableViewItemSweepEvent(groupIndex, itemIndex, direction);
1243 }
1244
1245 bool
1246 _TableViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1247 {
1248         __isTouchCancelOnPressRelease = false;
1249
1250         if (IsContextItem() ||
1251                 __isContextItemActivated ||
1252                 IsAnimationPlaying() ||
1253                 IsReorderMode())
1254         {
1255                 return true;
1256         }
1257
1258         if (IsTouchPressOnScroll())
1259         {
1260                 return true;
1261         }
1262
1263         __annexOnOffHandlerMoved = false;
1264         __touchStartPosition = touchinfo.GetCurrentPosition();
1265
1266         if (&source == this)
1267         {
1268                 __pressedControl = TABLE_VIEW_ITEM_PRESSED_ITEM;
1269         }
1270         else if (&source == GetLabelCore(__pItemAnnex))
1271         {
1272                 __pressedControl = TABLE_VIEW_ITEM_PRESSED_ANNEX;
1273
1274                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING ||
1275                         __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
1276                 {
1277                         __annexTouchStartPosition = touchinfo.GetCurrentPosition().x;
1278                 }
1279         }
1280         else if (IsIndividualSelectionEnabled(source))
1281         {
1282                 __pressedControl = TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL;
1283         }
1284         else
1285         {
1286                 __pressedControl = TABLE_VIEW_ITEM_PRESSED_NONE;
1287         }
1288
1289         if (__isReleasedTimerEnabled)
1290         {
1291                 StopTouchReleasedTimer();
1292
1293                 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
1294                 if (pParent != null)
1295                 {
1296                         int groupIndex = -1;
1297                         int itemIndex = -1;
1298                         GetItemIndex(groupIndex, itemIndex);
1299                         pParent->FireItemTouchReleasedEventDuringPressing(groupIndex, itemIndex);
1300                 }
1301         }
1302         else
1303         {
1304                 if (!IsIndividualSelectionEnabled(source))
1305                 {
1306                         __itemSelected = true;
1307                         if (unlikely((_AccessibilityManager::IsActivated())))
1308                         {
1309                                 FireItemTouchPressed();
1310                         }
1311                         else
1312                         {
1313                                 StartTouchPressedTimer(source, touchinfo);
1314                         }
1315                 }
1316         }
1317
1318         return true;
1319 }
1320
1321 bool
1322 _TableViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1323 {
1324         if (IsReorderMode())
1325         {
1326                 return true;
1327         }
1328
1329         if (IsTouchPressOnScroll())
1330         {
1331                 SetTouchPressOnScroll(false);
1332                 return true;
1333         }
1334
1335         if (&source == this)
1336         {
1337                 __releasedControl = TABLE_VIEW_ITEM_PRESSED_ITEM;
1338         }
1339         else if (&source == GetLabelCore(__pItemAnnex))
1340         {
1341                 __releasedControl = TABLE_VIEW_ITEM_PRESSED_ANNEX;
1342         }
1343         else if (IsIndividualSelectionEnabled(source))
1344         {
1345                 __releasedControl = TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL;
1346         }
1347         else
1348         {
1349                 __releasedControl = TABLE_VIEW_ITEM_PRESSED_NONE;
1350         }
1351
1352         __isTabSoundPlayed = IS_PLAYED_FEEDBACK();
1353
1354         if (!__itemTouchMoved && __isPressedTimerEnabled)
1355         {
1356                 StopTouchPressedTimer();
1357
1358                 if (!IsContextItem())
1359                 {
1360                         FireItemTouchPressed();
1361                 }
1362
1363                 StartTouchReleasedTimer();
1364                 return true;
1365         }
1366
1367         FireItemTouchReleased();
1368         return true;
1369 }
1370
1371 void
1372 _TableViewItem::FireItemTouchPressed()
1373 {
1374         if (__isTouchCancelOnPressRelease == true)
1375         {
1376                 return;
1377         }
1378
1379         if (__pressedControl == TABLE_VIEW_ITEM_PRESSED_ITEM)
1380         {
1381                 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
1382                 SetItemChanged(true);
1383                 Invalidate();
1384         }
1385         else if (__pressedControl == TABLE_VIEW_ITEM_PRESSED_ANNEX)
1386         {
1387                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
1388                 {
1389                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1390                         __isSelectedDetailButton = true;
1391                         DrawAnnexStyle();
1392                 }
1393                 else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING ||
1394                                         __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
1395                 {
1396                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1397                 }
1398                 else
1399                 {
1400                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
1401                         SetItemChanged(true);
1402                         Invalidate();
1403                 }
1404         }
1405         else
1406         {
1407                 if (__pressedControl != TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL)
1408                 {
1409                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
1410                         SetItemChanged(true);
1411                         Invalidate();
1412                 }
1413         }
1414 }
1415
1416 void
1417 _TableViewItem::FireItemTouchReleased(bool isTouchRelease)
1418 {
1419         if (__isTouchCancelOnPressRelease == true)
1420         {
1421                 return;
1422         }
1423
1424         bool fireItemEvent = false;
1425         bool selectedItem = true;
1426
1427         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1428
1429         if (__itemSelected == true)
1430         {
1431                 bool checked = IsChecked();
1432                 fireItemEvent = true;
1433
1434                 if (__releasedControl == TABLE_VIEW_ITEM_PRESSED_ITEM)
1435                 {
1436                         if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1437                                 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING))
1438                         {
1439                                 SetChecked(!checked);
1440                         }
1441                         else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
1442                         {
1443                                 SetChecked(!checked);
1444                                 SetCheckedAnimationEnabled(!checked);
1445                         }
1446                 }
1447                 else if (__releasedControl == TABLE_VIEW_ITEM_PRESSED_ANNEX)
1448                 {
1449                         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
1450                         {
1451                                 __isSelectedDetailButton = false;
1452                                 DrawAnnexStyle();
1453                                 selectedItem = false;
1454                         }
1455                         else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING ||
1456                                 __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
1457                         {
1458                                 bool isPreviousChecked = IsChecked();
1459                                 AdjustAnnexOnOffHandlerPosition();
1460                                 selectedItem = false;
1461                                 if (isPreviousChecked == IsChecked())
1462                                 {
1463                                         fireItemEvent = false;
1464                                 }
1465                         }
1466                         else
1467                         {
1468                                 SetChecked(!checked);
1469                                 SetCheckedAnimationEnabled(!checked);
1470                         }
1471                 }
1472                 else
1473                 {
1474                         if (__releasedControl != TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL)
1475                         {
1476                                 if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
1477                                         || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1478                                         || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING))
1479                                 {
1480                                         SetChecked(!checked);
1481                                         SetCheckedAnimationEnabled(!checked);
1482                                 }
1483                         }
1484                         else
1485                         {
1486                                 fireItemEvent = false;
1487                         }
1488                 }
1489
1490                 SetItemChanged(true);
1491                 Invalidate();
1492         }
1493         else
1494         {
1495                 if (__releasedControl == TABLE_VIEW_ITEM_PRESSED_ANNEX)
1496                 {
1497                         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING ||
1498                                 __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
1499                         {
1500                                 bool isPreviousChecked = IsChecked();
1501                                 AdjustAnnexOnOffHandlerPosition();
1502                                 fireItemEvent = true;
1503                                 if (isPreviousChecked == IsChecked())
1504                                 {
1505                                         fireItemEvent = false;
1506                                 }
1507                         }
1508                 }
1509         }
1510
1511         __itemSelected = false;
1512         __annexOnOffHandlerMoved = false;
1513         __itemTouchMoved = false;
1514
1515         if (fireItemEvent)
1516         {
1517                 if (isTouchRelease)
1518                 {
1519                         int groupIndex = -1;
1520                         int itemIndex = -1;
1521                         GetItemIndex(groupIndex, itemIndex);
1522                         if (GetParent())
1523                         {
1524                                 _TableView* pTableView = dynamic_cast<_TableView*>(GetParent());
1525                                 if (pTableView)
1526                                 {
1527                                         pTableView->SetFocusItemOnPressedState(groupIndex, itemIndex);
1528                                 }
1529                         }
1530                 }
1531                 FireItemEvent(selectedItem);
1532         }
1533 }
1534
1535 bool
1536 _TableViewItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1537 {
1538         if (IsReorderMode())
1539         {
1540                 return false;
1541         }
1542
1543         if (IsTouchPressOnScroll())
1544         {
1545                 SetTouchPressOnScroll(false);
1546         }
1547
1548         if (__isPressedTimerEnabled)
1549         {
1550                 StopTouchPressedTimer();
1551         }
1552
1553         bool retVal = false;
1554
1555         if (&source == this)
1556         {
1557                 __itemSelected = false;
1558                 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1559
1560                 SetItemChanged(true);
1561                 Invalidate();
1562         }
1563         else if (&source == GetLabelCore(__pItemAnnex))
1564         {
1565                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
1566                 {
1567                         __isSelectedDetailButton = false;
1568                         __itemSelected = false;
1569                         DrawAnnexStyle();
1570                 }
1571                 else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING ||
1572                         __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
1573                 {
1574                         __annexOnOffHandlerMoved = true;
1575                         DrawAnnexOnOffHandler(touchinfo.GetCurrentPosition().x);
1576                         retVal = true;
1577                 }
1578                 else
1579                 {
1580                         __itemSelected = false;
1581                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1582
1583                         SetItemChanged(true);
1584                         Invalidate();
1585                 }
1586         }
1587         else
1588         {
1589                 if (!IsIndividualSelectionEnabled(source))
1590                 {
1591                         __itemSelected = false;
1592                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1593
1594                         SetItemChanged(true);
1595                         Invalidate();
1596                 }
1597         }
1598
1599         __itemTouchMoved = true;
1600
1601         return retVal;
1602 }
1603
1604 bool
1605 _TableViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1606 {
1607         __isTouchCancelOnPressRelease = true;
1608
1609         if (__isPressedTimerEnabled)
1610         {
1611                 StopTouchPressedTimer();
1612         }
1613
1614         __annexOnOffHandlerMoved = false;
1615         __itemTouchMoved = false;
1616
1617         ResetItemState();
1618
1619         if (&source != this)
1620         {
1621                 return false;
1622         }
1623
1624         return true;
1625 }
1626
1627 _UiTouchEventDelivery
1628 _TableViewItem::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1629 {
1630         if (IsTouchPressOnScroll())
1631         {
1632                 SetTouchPressOnScroll(false);
1633                 return _UI_TOUCH_EVENT_DELIVERY_NO;
1634         }
1635         return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1636 }
1637
1638 _UiTouchEventDelivery
1639 _TableViewItem::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1640 {
1641         return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1642 }
1643
1644 _UiTouchEventDelivery
1645 _TableViewItem::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1646 {
1647         return _UI_TOUCH_EVENT_DELIVERY_YES;
1648 }
1649
1650 _UiTouchEventDelivery
1651 _TableViewItem::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1652 {
1653         return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1654 }
1655
1656 void
1657 _TableViewItem::OnDraw(void)
1658 {
1659         if (IsItemChanged() == true)
1660         {
1661                 DrawItemBackground();
1662                 DrawAnnexStyle();
1663                 DrawItemDivider();
1664                 DrawSimpleItem();
1665                 DrawSectionStyleBackgroundCover();
1666
1667                 SetItemChanged(false);
1668         }
1669 }
1670
1671 void
1672 _TableViewItem::OnChildAttached(const _Control& child)
1673 {
1674         _Control* pControl = const_cast<_Control*>(&child);
1675         _AccessibilityContainer* pContainer = pControl->GetAccessibilityContainer();
1676
1677         if (__individualSelectionControls.Contains(child))
1678         {
1679                 pContainer->Activate(true);
1680         }
1681         else
1682         {
1683                 pContainer->Activate(false);
1684
1685                 if (!(pControl == static_cast<_Control*>(__pItemAnnexLeftDivider)
1686                         || pControl == static_cast<_Control*>(__pItemAnnexRightDivider)
1687                         || pControl == static_cast<_Control*>(__pItemCover)
1688                         || pControl == static_cast<_Control*>(__pItemDivider)
1689                         || pControl== static_cast<_Control*>(__pItemTopDivider)))
1690                 {
1691                         GetAccessibilityContainer()->Activate(true);
1692                 }
1693         }
1694
1695         DeactivateChildAccessibilityContainer(child);
1696
1697         pControl->SetTouchPressThreshold(SENSITIVE);
1698
1699         FloatRectangle bounds = child.GetBoundsF();
1700
1701         if (__pDrawingProperty != null && __pDrawingProperty->groupedLookEnabled)
1702         {
1703                 float groupedBarMargin = 0.0f;
1704                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, groupedBarMargin);
1705
1706                 bounds.x += groupedBarMargin;
1707         }
1708
1709         if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO))
1710         {
1711                 if (GetLabelCore(__pItemAnnex) == &child ||
1712                         GetLabelCore(__pSimpleItemBitmap) == &child ||
1713                         GetLabelCore(__pSimpleItemText) == &child)
1714                 {
1715                         return;
1716                 }
1717
1718                 float leftMargin = 0.0f;
1719                 float annexWidth = 0.0f;
1720
1721                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1722                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1723
1724                 bounds.x += (leftMargin * 2) + annexWidth;
1725         }
1726
1727         pControl->SetBounds(bounds);
1728 }
1729
1730 void
1731 _TableViewItem::OnChildDetached(const _Control& child)
1732 {
1733         if (__individualSelectionControls.Contains(child))
1734         {
1735                 __individualSelectionControls.Remove(child, false);
1736         }
1737
1738         _Label* pSimpleItemTextCore = GetLabelCore(__pSimpleItemText);
1739         _Label* pSimpleItemBitmapCore = GetLabelCore(__pSimpleItemBitmap);
1740
1741         if (&child == pSimpleItemTextCore)
1742         {
1743                 __pSimpleItemText = null;
1744         }
1745
1746         if (&child == pSimpleItemBitmapCore)
1747         {
1748                 __pSimpleItemBitmap = null;
1749         }
1750 }
1751
1752 void
1753 _TableViewItem::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1754 {
1755         result r = E_SUCCESS;
1756
1757         if (&timer == __pCheckedTimer)
1758         {
1759                 if (__checkedCount < MAX_CHECKED_COUNT)
1760                 {
1761                         r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION);
1762                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1763                 }
1764
1765                 r = PlayCheckBoxAnimation();
1766                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1767
1768                 if (__checkedCount < MAX_CHECKED_COUNT)
1769                 {
1770                         __checkedCount++;
1771                 }
1772                 else
1773                 {
1774                         __checkedCount = 0;
1775                         __isCheckedAnimationEnabled = false;
1776                         __isCheckedTimerEnabled = false;
1777                 }
1778         }
1779         else if (&timer == __pPressedTimer)
1780         {
1781                 __isPressedTimerEnabled = false;
1782                 FireItemTouchPressed();
1783         }
1784         else if (&timer == __pReleasedTimer)
1785         {
1786                 __isReleasedTimerEnabled = false;
1787                 FireItemTouchReleased();
1788         }
1789 }
1790
1791 result
1792 _TableViewItem::StartTouchPressedTimer(const _Control& source, const _TouchInfo& touchinfo)
1793 {
1794         result r = E_SUCCESS;
1795
1796         if (__pPressedTimer == null)
1797         {
1798                 __pPressedTimer = new (std::nothrow) Timer();
1799                 SysTryCatch(NID_UI_CTRL, __pPressedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1800
1801                 r = __pPressedTimer->Construct(*this);
1802                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage);
1803         }
1804
1805         if (__isPressedTimerEnabled == false)
1806         {
1807                 r = __pPressedTimer->Start(TOUCH_PRESSED_DURATION);
1808                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1809
1810                 __isPressedTimerEnabled = true;
1811         }
1812
1813         return r;
1814
1815 CATCH:
1816         if (__isPressedTimerEnabled && __pPressedTimer != null)
1817         {
1818                 __pPressedTimer->Cancel();
1819         }
1820
1821         delete __pPressedTimer;
1822         __pPressedTimer = null;
1823
1824         return r;
1825 }
1826
1827 void
1828 _TableViewItem::StopTouchPressedTimer(bool forceStop)
1829 {
1830         result r = E_SUCCESS;
1831
1832         if (__pPressedTimer == null)
1833         {
1834                 return;
1835         }
1836
1837         if (__isPressedTimerEnabled || forceStop)
1838         {
1839                 r = __pPressedTimer->Cancel();
1840                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1841         }
1842
1843         __isPressedTimerEnabled = false;
1844
1845         return;
1846 }
1847
1848 result
1849 _TableViewItem::StartTouchReleasedTimer()
1850 {
1851         result r = E_SUCCESS;
1852
1853         if (__pReleasedTimer == null)
1854         {
1855                 __pReleasedTimer = new (std::nothrow) Timer();
1856                 SysTryCatch(NID_UI_CTRL, __pReleasedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1857
1858
1859                 r = __pReleasedTimer->Construct(*this);
1860                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage);
1861         }
1862
1863         if (!__isReleasedTimerEnabled)
1864         {
1865                 r = __pReleasedTimer->Start(TOUCH_RELEASED_DURATION);
1866                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1867         }
1868         __isReleasedTimerEnabled = true;
1869
1870         return r;
1871
1872 CATCH:
1873         if (__isReleasedTimerEnabled && __pReleasedTimer != null)
1874         {
1875                 __pReleasedTimer->Cancel();
1876         }
1877
1878         delete __pReleasedTimer;
1879         __pReleasedTimer = null;
1880
1881         return r;
1882 }
1883
1884 void
1885 _TableViewItem::StopTouchReleasedTimer(bool forceStop)
1886 {
1887         result r = E_SUCCESS;
1888
1889         if (__pReleasedTimer == null)
1890         {
1891                 return;
1892         }
1893
1894         if (__isReleasedTimerEnabled || forceStop)
1895         {
1896                 r = __pReleasedTimer->Cancel();
1897                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1898         }
1899
1900         __isReleasedTimerEnabled = false;
1901
1902         return;
1903 }
1904
1905 void
1906 _TableViewItem::OnAncestorInputEnableStateChanged(const _Control& control)
1907 {
1908         if (__isPressedTimerEnabled)
1909         {
1910                 StopTouchPressedTimer();
1911         }
1912
1913         __annexOnOffHandlerMoved = false;
1914         __itemTouchMoved = false;
1915
1916         __itemSelected = false;
1917         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1918
1919         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
1920         {
1921                 __isSelectedDetailButton = false;
1922         }
1923
1924         SetItemChanged(true);
1925         Invalidate();
1926 }
1927
1928 result
1929 _TableViewItem::StartCheckBoxAnimation(void)
1930 {
1931         result r = E_SUCCESS;
1932
1933         if (__pCheckedTimer == null)
1934         {
1935                 __pCheckedTimer = new (std::nothrow) Timer();
1936                 SysTryCatch(NID_UI_CTRL, __pCheckedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1937 ;
1938
1939                 r = __pCheckedTimer->Construct(*this);
1940                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage);
1941         }
1942
1943         if (__isCheckedTimerEnabled == false)
1944         {
1945                 r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION);
1946                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1947
1948                 __isCheckedTimerEnabled = true;
1949         }
1950
1951         return r;
1952
1953 CATCH:
1954         if (__isCheckedTimerEnabled)
1955         {
1956                 __pCheckedTimer->Cancel();
1957         }
1958
1959         delete __pCheckedTimer;
1960         __pCheckedTimer = null;
1961
1962         return r;
1963 }
1964
1965 void
1966 _TableViewItem::StopCheckBoxAnimation(void)
1967 {
1968         result r = E_SUCCESS;
1969
1970         SysTryReturnVoidResult(NID_UI_CTRL, __pCheckedTimer != null, E_SYSTEM, "[%s] A system error has been occurred. Timer is invalid.", GetErrorMessage(E_SYSTEM));
1971
1972
1973         if (__isCheckedTimerEnabled)
1974         {
1975                 r = __pCheckedTimer->Cancel();
1976                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1977         }
1978
1979         __checkedCount = 0;
1980         __isCheckedAnimationEnabled = false;
1981         __isCheckedTimerEnabled = false;
1982
1983         return;
1984 }
1985
1986 result
1987 _TableViewItem::PlayCheckBoxAnimation(void)
1988 {
1989         Bitmap* pCheckBox = null;
1990         Bitmap* pCheckBoxBg = null;
1991         Bitmap* pMergeBitmap = null;
1992         Canvas* pCanvas = null;
1993         result r = E_SUCCESS;
1994
1995         FloatRectangle bounds;
1996
1997         float annexWidth = 0.0f;
1998         float annexHeight = 0.0f;
1999
2000         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
2001         {
2002                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
2003         }
2004         else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
2005         {
2006                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
2007         }
2008         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2009
2010         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
2011         SysTryCatch(NID_UI_CTRL,(r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2012
2013         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2014         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2015
2016         bounds.SetBounds(0, 0, annexWidth, annexHeight);
2017
2018         pCanvas = new (std::nothrow) Canvas();
2019         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY,  "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2020
2021         r = pCanvas->Construct(bounds);
2022         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2023         pCanvas->Clear();
2024
2025         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg);
2026
2027         __checkedBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox);
2028         if (IsChecked() == true)
2029         {
2030                 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pCheckBox))
2031                 {
2032                         FloatRectangle drawingRect(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width, __checkedBounds.height);
2033                         r = pCanvas->DrawNinePatchedBitmap(drawingRect, *pCheckBox); // +++ check floating
2034                 }
2035                 else
2036                 {
2037                         FloatRectangle bitmapSourceRect(0.0f, 0.0f, pCheckBox->GetWidthF()*__checkedCount * 0.1, pCheckBox->GetHeightF());
2038                         FloatRectangle drawingRect(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width * __checkedCount * 0.1, __checkedBounds.height);
2039                         r = pCanvas->DrawBitmap(drawingRect, *pCheckBox, bitmapSourceRect); // +++ check floating
2040                 }
2041         }
2042
2043         pMergeBitmap = new (std::nothrow) Bitmap();
2044         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY,  "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2045
2046         pMergeBitmap->Construct(*pCanvas, bounds);
2047         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2048
2049         if (__pItemAnnex)
2050         {
2051                 __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
2052                 __pItemAnnex->Invalidate(false);
2053         }
2054
2055 CATCH:
2056         delete pCheckBox;
2057         delete pCheckBoxBg;
2058         delete pMergeBitmap;
2059         delete pCanvas;
2060
2061         return r;
2062 }
2063
2064 void
2065 _TableViewItem::SetItemLayoutEnabled(bool enabled)
2066 {
2067         __isItemLayoutEnabled = enabled;
2068 }
2069
2070 bool
2071 _TableViewItem::GetItemLayoutEnabled(void)
2072 {
2073         return __isItemLayoutEnabled;
2074 }
2075
2076 void
2077 _TableViewItem::OnBoundsChanged(void)
2078 {
2079         if (__checkItemHeightNeeded && HasParent())
2080         {
2081                 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
2082                 if (pParent != null)
2083                 {
2084                         int groupIndex = -1;
2085                         int itemIndex = -1;
2086                         GetItemIndex(groupIndex, itemIndex);
2087
2088                         pParent->CheckItemHeightAndRefreshLayout(groupIndex, itemIndex);
2089                 }
2090
2091                 __checkItemHeightNeeded = false;
2092         }
2093
2094         AdjustAnnexBounds();
2095
2096         SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
2097
2098         if (__pHeaderFooterItemText != null)
2099         {
2100                 FloatRectangle textBounds = __pHeaderFooterItemText->GetBoundsF();
2101                 textBounds.width = GetBoundsF().width;
2102
2103                 if (__itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
2104                 {
2105                         textBounds.x -= __pDrawingProperty->scrollMargin;
2106                 }
2107
2108                 __pHeaderFooterItemText->SetBounds(textBounds);
2109         }
2110
2111         if (__pBitmapVisualElement != null)
2112         {
2113                 FloatRectangle bounds = GetBoundsF();
2114                 __pBitmapVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
2115         }
2116
2117         if (__pAccessibilityElement != null)
2118         {
2119                 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f,0.0f, GetBoundsF().width, GetBoundsF().height));
2120         }
2121
2122         RemoveFocusRing(true);
2123         if (IsFocusModeStateEnabled())
2124         {
2125                 if (GetRootWindow() && GetRootWindow()->IsActivated()
2126                                 && IsFocused())
2127                 {
2128                         DrawFocus();
2129                 }
2130         }
2131 }
2132
2133 void
2134 _TableViewItem::SetDrawingProperty(_ItemDrawingProperty* pDrawingProperty)
2135 {
2136
2137         SysTryReturnVoidResult(NID_UI_CTRL, pDrawingProperty != null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. The pDrawingProperty is null.", GetErrorMessage(E_INVALID_ARG));
2138
2139         __pDrawingProperty = pDrawingProperty;
2140
2141         if (__pDrawingProperty->sectionStyleEnabled == true &&
2142                 !IsContextItem())
2143         {
2144                 CreateItemCover();
2145         }
2146
2147         if (__pDrawingProperty->itemDividerEnabled)
2148         {
2149                 CreateItemDivider();
2150         }
2151
2152         CreateAnnexStyle();
2153 }
2154
2155 _ItemDrawingProperty*
2156 _TableViewItem::GetDrawingProperty(void)
2157 {
2158         return __pDrawingProperty;
2159 }
2160
2161 void
2162 _TableViewItem::DrawItemBackground(void)
2163 {
2164         Canvas* pCanvas = null;
2165         Bitmap* pDrawBitmap = __pItemBgBitmap[__drawingStatus];
2166         Color bgColor = __colorItemBg[__drawingStatus];
2167         FloatRectangle bounds = GetBoundsF();
2168
2169         SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
2170         __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f));
2171
2172         if (pDrawBitmap != null && __enabledState)
2173         {
2174                 if (__pBitmapVisualElement == null)
2175                 {
2176                         return;
2177                 }
2178
2179                 String imagePath = null;
2180                 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pDrawBitmap) == false)
2181                 {
2182                         imagePath = _BitmapImpl::GetInstance(*pDrawBitmap)->GetFileName();
2183                 }
2184
2185                 if (imagePath.IsEmpty() == false)
2186                 {
2187                         __pBitmapVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() /255, (float)bgColor.GetGreen() / 255, (float)bgColor.GetBlue() / 255, (float)bgColor.GetAlpha() / 255));
2188                         __pBitmapVisualElement->SetImageSource(imagePath);
2189                 }
2190                 else
2191                 {
2192                         pCanvas = __pBitmapVisualElement->GetCanvasN();
2193                         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2194                         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2195                         pCanvas->Clear();
2196
2197                         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pDrawBitmap);
2198                 }
2199         }
2200
2201         if (IsContextItem())
2202         {
2203                 DrawContextItemBackground();
2204         }
2205         else if (__pDrawingProperty->sectionStyleEnabled == true)
2206         {
2207                 DrawSectionStyleBackground();
2208         }
2209         else
2210         {
2211                 if (__enabledState)
2212                 {
2213                         if (__itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
2214                         {
2215                                 SetBackgroundColor(Color(0, 0, 0, 0));
2216                                 __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f));
2217                         }
2218                         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
2219                         {
2220                                 __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
2221                         }
2222                         else
2223                         {
2224                                 SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
2225
2226                                 __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
2227
2228                                 if (__pDrawingProperty->groupedLookEnabled == true)
2229                                 {
2230                                         DrawGroupedLook();
2231                                 }
2232                         }
2233                 }
2234                 else
2235                 {
2236                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
2237                         SetBackgroundColor(bgColor);
2238                         __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
2239
2240                         if (__pDrawingProperty->groupedLookEnabled == true)
2241                         {
2242                                 DrawGroupedLook();
2243                         }
2244                 }
2245         }
2246
2247         delete pCanvas;
2248         return;
2249
2250 CATCH:
2251
2252         if (__pBitmapVisualElement != null)
2253         {
2254                 __pBitmapVisualElement->RemoveAllAnimations();
2255                 __pBitmapVisualElement->SetAnimationProvider(null);
2256                 __pBitmapVisualElement->Destroy();
2257                 __pBitmapVisualElement = null;
2258         }
2259 }
2260
2261 void
2262 _TableViewItem::DrawGroupedLook(void)
2263 {
2264         if (IsTitleStyleItem() || IsContextItem())
2265         {
2266                 return;
2267         }
2268
2269         Color barColor;
2270         Color outlineColor = __pDrawingProperty->dividerColor;
2271
2272         float barWidth = 0.0f;
2273
2274         Canvas* pCanvas = GetVisualElement()->GetCanvasN();
2275         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2276
2277         FloatRectangle bounds = GetBoundsF();
2278         pCanvas->SetBackgroundColor(GetBackgroundColor());
2279         pCanvas->Clear();
2280
2281         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor);
2282         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth);
2283
2284         pCanvas->FillRectangle(barColor, FloatRectangle(0.0f, 0.0f, barWidth, bounds.height));
2285
2286         if (__pDrawingProperty->sectionStyleEnabled == true)
2287         {
2288                 pCanvas->FillRectangle(outlineColor, FloatRectangle(bounds.width - 1.0f, 0.0f, 1.0f, bounds.height));
2289
2290                 if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP || __itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2291                 {
2292                         pCanvas->FillRectangle(outlineColor, FloatRectangle(0.0f, 0.0f, bounds.width, 1.0f));
2293                 }
2294         }
2295
2296         delete pCanvas;
2297 }
2298
2299 void
2300 _TableViewItem::DrawSectionStyleBackground(void)
2301 {
2302         Canvas* pCanvas = null;
2303         Bitmap* pReplacementSectionPressBg = null;
2304         Bitmap* pReplacementSectionBg = null;
2305         Bitmap* pReplacementSectionDisabledBg = null;
2306         Color bgColor = __colorItemBg[__drawingStatus];
2307         FloatRectangle bounds = GetBoundsF();
2308         float dividerHeight = 0.0f;
2309
2310         result r = E_SUCCESS;
2311
2312         pCanvas = GetVisualElement()->GetCanvasN();
2313         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
2314
2315         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2316         pCanvas->Clear();
2317
2318         if (bgColor != null)
2319         {
2320                 if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2321                 {
2322                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBg);
2323                 }
2324                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2325                 {
2326                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBg);
2327                 }
2328                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2329                 {
2330                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBg);
2331                 }
2332                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2333                 {
2334                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBg);
2335                 }
2336                 else
2337                 {
2338                         r = E_SYSTEM;
2339                 }
2340         }
2341         else
2342         {
2343                 if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2344                 {
2345                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDrawingProperty->sectionStyleBgColor, pReplacementSectionBg);
2346                 }
2347                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2348                 {
2349                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDrawingProperty->sectionStyleBgColor, pReplacementSectionBg);
2350                 }
2351                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2352                 {
2353                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDrawingProperty->sectionStyleBgColor, pReplacementSectionBg);
2354                 }
2355                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2356                 {
2357                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDrawingProperty->sectionStyleBgColor, pReplacementSectionBg);
2358                 }
2359                 else
2360                 {
2361                         r = E_SYSTEM;
2362                 }
2363         }
2364         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred.  SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2365
2366         if (__enabledState)
2367         {
2368                 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED || __drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED)
2369                 {
2370                         if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2371                         {
2372                                 if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_SINGLE_BG_PRESSED))
2373                                 {
2374                                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionPressBg);
2375                                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2376                                 }
2377                         }
2378                         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2379                         {
2380                                 if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_TOP_BG_PRESSED))
2381                                 {
2382                                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionPressBg);
2383                                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2384                                 }
2385                         }
2386                         else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2387                         {
2388                                 if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_CENTER_BG_PRESSED))
2389                                 {
2390                                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionPressBg);
2391                                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2392                                 }
2393                         }
2394                         else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2395                         {
2396                                 if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_BOTTOM_BG_PRESSED))
2397                                 {
2398                                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionPressBg);
2399                                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2400                                 }
2401                         }
2402
2403                         GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, dividerHeight);
2404
2405                         if (pReplacementSectionPressBg)
2406                         {
2407                                 DrawBitmap(*pCanvas, FloatRectangle(0.0f, dividerHeight, bounds.width, bounds.height - (dividerHeight * 2)), *pReplacementSectionPressBg);
2408                         }
2409                         else
2410                         {
2411                                 DrawBitmap(*pCanvas, FloatRectangle(0.0f, dividerHeight, bounds.width, bounds.height - (dividerHeight * 2)), *pReplacementSectionBg);
2412                         }
2413                 }
2414                 else
2415                 {
2416                         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementSectionBg);
2417                 }
2418         }
2419         else
2420         {
2421                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
2422
2423                 if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2424                 {
2425                         if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_SINGLE_BG_DISABLED))
2426                         {
2427                                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionDisabledBg);
2428                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2429                         }
2430                 }
2431                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2432                 {
2433                         if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_TOP_BG_DISABLED))
2434                         {
2435                                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionDisabledBg);
2436                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2437                         }
2438                 }
2439                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2440                 {
2441                         if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_CENTER_BG_DISABLED))
2442                         {
2443                                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionDisabledBg);
2444                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2445                         }
2446                 }
2447                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2448                 {
2449                         if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_BOTTOM_BG_DISABLED))
2450                         {
2451                                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionDisabledBg);
2452                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2453                         }
2454                 }
2455
2456                 if (pReplacementSectionDisabledBg)
2457                 {
2458                         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementSectionDisabledBg);
2459                 }
2460                 else
2461                 {
2462                         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementSectionBg);
2463                 }
2464         }
2465
2466         if (__pDrawingProperty->groupedLookEnabled == true)
2467         {
2468                 Color barColor;
2469
2470                 float barWidth = 0.0f;
2471                 float barMargin = 0.0f;
2472
2473                 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor);
2474                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth);
2475                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, barMargin);
2476
2477                 pCanvas->FillRectangle(barColor, FloatRectangle(0.0f, barMargin, barWidth, bounds.height-barMargin));
2478         }
2479
2480 CATCH:
2481         delete pReplacementSectionPressBg;
2482         delete pReplacementSectionBg;
2483         delete pReplacementSectionDisabledBg;
2484         delete pCanvas;
2485 }
2486
2487 void
2488 _TableViewItem::DrawSectionStyleBackgroundCover(void)
2489 {
2490         if (!__pDrawingProperty->sectionStyleEnabled ||
2491                 __pItemCover == null)
2492         {
2493                 return;
2494         }
2495
2496         Bitmap* pReplacementSectionBgEf = null;
2497         Bitmap* pReplacementSectionBg = null;
2498         Bitmap* pMergeBitmap = null;
2499         Canvas* pCanvas = null;
2500         Color bgColor;
2501
2502         result r = E_SUCCESS;
2503         FloatRectangle bounds = GetBoundsF();
2504
2505         if (__enabledState)
2506         {
2507                 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
2508                 SysTryCatch(NID_UI_CTRL, pParent != null, , E_SYSTEM, "[%s] A system error has been occurred. SectionTableView  load failed", GetErrorMessage(E_SYSTEM));
2509
2510                 bgColor = pParent->GetBackgroundColor();
2511         }
2512         else
2513         {
2514                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
2515         }
2516
2517         if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2518         {
2519                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_COVER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBgEf);
2520         }
2521         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2522         {
2523                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_COVER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBgEf);
2524         }
2525         else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2526         {
2527                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_COVER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBgEf);
2528         }
2529         else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2530         {
2531                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_COVER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBgEf);
2532         }
2533         else
2534         {
2535                 r = E_SYSTEM;
2536         }
2537         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2538
2539         if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2540         {
2541                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_COVER_ROUND_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBg);
2542         }
2543         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2544         {
2545                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_COVER_ROUND_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBg);
2546         }
2547         else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2548         {
2549                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_COVER_ROUND_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBg);
2550         }
2551         else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2552         {
2553                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_COVER_ROUND_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementSectionBg);
2554         }
2555         else
2556         {
2557                 r = E_SYSTEM;
2558         }
2559         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM));
2560
2561         __pItemCover->SetBounds(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
2562
2563         pCanvas = new (std::nothrow) Canvas();
2564         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2565         pCanvas->Construct(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
2566         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2567         pCanvas->Clear();
2568
2569         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementSectionBg);
2570         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementSectionBgEf);
2571
2572         pMergeBitmap = new (std::nothrow) Bitmap();
2573         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2574
2575         pMergeBitmap->Construct(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
2576
2577         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2578
2579         __pItemCover->SetBackgroundBitmap(*pMergeBitmap);
2580
2581 CATCH:
2582         delete pReplacementSectionBgEf;
2583         delete pReplacementSectionBg;
2584         delete pCanvas;
2585         delete pMergeBitmap;
2586 }
2587
2588 void
2589 _TableViewItem::DrawContextItemBackground(void)
2590 {
2591         Canvas* pCanvas = null;
2592         Bitmap* pContextBgEf = null;
2593         Bitmap* pReplacementContextBg = null;
2594         Color bgColor = __colorItemBg[__drawingStatus];
2595
2596         FloatRectangle bounds = GetBoundsF();
2597         result r = E_SUCCESS;
2598
2599         if (__enabledState)
2600         {
2601                 if (bgColor == null)
2602                 {
2603                         GET_COLOR_CONFIG(TABLEVIEW::CONTEXTITEM_BG_NORMAL, bgColor);
2604                 }
2605         }
2606         else
2607         {
2608                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
2609         }
2610
2611         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::QUICK_MENU_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, bgColor, pReplacementContextBg);
2612         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. ContextItem image load failed", GetErrorMessage(E_SYSTEM));
2613
2614         r = GET_BITMAP_CONFIG_N(TABLEVIEW::QUICK_MENU_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pContextBgEf);
2615         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. ContextItem image load failed", GetErrorMessage(E_SYSTEM));
2616
2617         pCanvas = GetVisualElement()->GetCanvasN();
2618         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2619
2620         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2621         pCanvas->Clear();
2622
2623         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementContextBg);
2624         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pContextBgEf);
2625
2626 CATCH:
2627         delete pCanvas;
2628         delete pContextBgEf;
2629         delete pReplacementContextBg;
2630 }
2631
2632
2633 void
2634 _TableViewItem::CreateAnnexStyle(void)
2635 {
2636         switch (__annexStyle)
2637         {
2638         case TABLE_VIEW_ANNEX_STYLE_MARK:
2639                 CreateCheckBox();
2640                 break;
2641         case TABLE_VIEW_ANNEX_STYLE_RADIO:
2642                 CreateRadioBox();
2643                 break;
2644         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
2645                 CreateOnOffButton();
2646                 break;
2647         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
2648                 CreateItemAnnexDivider();
2649                 CreateOnOffButton();
2650                 break;
2651         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
2652                 CreateDetailButton();
2653                 break;
2654         default:
2655                 break;
2656         }
2657 }
2658
2659 void
2660 _TableViewItem::DrawAnnexStyle(void)
2661 {
2662         switch (__annexStyle)
2663         {
2664         case TABLE_VIEW_ANNEX_STYLE_MARK:
2665                 DrawCheckBox();
2666                 break;
2667         case TABLE_VIEW_ANNEX_STYLE_RADIO:
2668                 DrawRadioBox();
2669                 break;
2670         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
2671                 DrawOnOffButton();
2672                 break;
2673         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
2674                 DrawItemAnnexDivider();
2675                 DrawOnOffButton();
2676                 break;
2677         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
2678                 DrawDetailButton();
2679                 break;
2680         default:
2681                 break;
2682         }
2683 }
2684
2685 void
2686 _TableViewItem::DrawCheckBox(void)
2687 {
2688         Bitmap* pCheckBox = null;
2689         Bitmap* pCheckBoxBg = null;
2690         Bitmap* pMergeBitmap = null;
2691         Canvas* pCanvas = null;
2692         result r = E_SUCCESS;
2693
2694         FloatRectangle bounds;
2695         float annexWidth = 0.0f;
2696         float annexHeight = 0.0f;
2697
2698         if (__enabledState)
2699         {
2700                 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
2701                 {
2702                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
2703                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2704
2705                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
2706                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2707                 }
2708                 else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
2709                 {
2710                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
2711                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2712
2713                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
2714                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2715                 }
2716
2717         }
2718         else
2719         {
2720                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
2721                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2722
2723                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
2724                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2725         }
2726
2727         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2728         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2729
2730         bounds.SetBounds(0.0f, 0.0f, annexWidth, annexHeight);
2731
2732         pCanvas = new (std::nothrow) Canvas();
2733         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2734
2735         pCanvas->Construct(bounds);
2736         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2737         pCanvas->Clear();
2738
2739         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg);
2740
2741         if (__isCheckedAnimationEnabled == true)
2742         {
2743                 StartCheckBoxAnimation();
2744         }
2745         else
2746         {
2747                 if (IsChecked() == true && pCheckBox != null)
2748                 {
2749                         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox), *pCheckBox);
2750                 }
2751         }
2752
2753         pMergeBitmap = new (std::nothrow) Bitmap();
2754         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2755
2756         pMergeBitmap->Construct(*pCanvas, bounds);
2757         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2758
2759         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
2760         __pItemAnnex->Invalidate(false);
2761
2762 CATCH:
2763         delete pCheckBox;
2764         delete pCheckBoxBg;
2765         delete pMergeBitmap;
2766         delete pCanvas;
2767
2768         return;
2769 }
2770
2771 void
2772 _TableViewItem::DrawRadioBox(void)
2773 {
2774         Bitmap* pRadioButton = null;
2775         Bitmap* pRadioButtonBg = null;
2776         Bitmap* pMergeBitmap = null;
2777         Canvas* pCanvas = null;
2778         result r = E_SUCCESS;
2779
2780         FloatRectangle bounds;
2781         float annexWidth = 0.0f;
2782         float annexHeight = 0.0f;
2783
2784         if (__enabledState)
2785         {
2786                 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
2787                 {
2788                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
2789                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButtonBg != null), , E_SYSTEM, "[%s] A system error has been occurred. RadioButtonBg image load failed", GetErrorMessage(E_SYSTEM));
2790
2791                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_BUTTON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButton);
2792                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButton != null), , E_SYSTEM, "[%s] A system error has been occurred.CheckBox image load failed", GetErrorMessage(E_SYSTEM));
2793                 }
2794                 else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
2795                 {
2796                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
2797                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButtonBg != null), , E_SYSTEM, "[%s] A system error has been occurred. RadioButtonBg image load failed", GetErrorMessage(E_SYSTEM));
2798
2799
2800                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_BUTTON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButton);
2801                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButton != null), , E_SYSTEM, "[%s] A system error has been occurred.CheckBox image load failed", GetErrorMessage(E_SYSTEM));
2802                 }
2803         }
2804         else
2805         {
2806                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_NORMAL_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
2807                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButtonBg != null), , E_SYSTEM, "[%s] A system error has been occurred. RadioButtonBg image load failed", GetErrorMessage(E_SYSTEM));
2808
2809                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_BUTTON_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButton);
2810                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButton != null), , E_SYSTEM, "[%s] A system error has been occurred.CheckBox image load failed", GetErrorMessage(E_SYSTEM));
2811         }
2812
2813         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2814         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2815         bounds.SetBounds(0.0f, 0.0f, annexWidth, annexHeight);
2816
2817         pCanvas = new (std::nothrow) Canvas();
2818         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2819
2820         pCanvas->Construct(bounds);
2821         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2822         pCanvas->Clear();
2823
2824         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButtonBg), *pRadioButtonBg);
2825
2826         if (pRadioButton != null && IsChecked() == true)
2827         {
2828                 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButton), *pRadioButton);
2829         }
2830
2831         pMergeBitmap = new (std::nothrow) Bitmap();
2832         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2833
2834         pMergeBitmap->Construct(*pCanvas, bounds);
2835         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2836
2837         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
2838         __pItemAnnex->Invalidate(false);
2839
2840 CATCH:
2841         delete pRadioButton;
2842         delete pRadioButtonBg;
2843         delete pMergeBitmap;
2844         delete pCanvas;
2845
2846         return;
2847 }
2848
2849 void
2850 _TableViewItem::DrawOnOffButton(void)
2851 {
2852         Bitmap* pOnOffButton = null;
2853         Bitmap* pOnOffButtonHandler = null;
2854         Bitmap* pMergeBitmap = null;
2855         Canvas* pCanvas = null;
2856         result r = E_SUCCESS;
2857
2858         FloatRectangle bounds;
2859         FloatRectangle backgroundBounds;
2860         FloatRectangle handlerBounds;
2861         float annexWidth = 0.0f;
2862         float annexHeight = 0.0f;
2863         float annexMargin = 0.0f;
2864
2865         if (IsChecked() == true)
2866         {
2867                 if (__enabledState)
2868                 {
2869                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2870                 }
2871                 else
2872                 {
2873                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON_HANDLER_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2874                 }
2875         }
2876         else
2877         {
2878                 if (__enabledState)
2879                 {
2880                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2881                 }
2882                 else
2883                 {
2884                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF_HANDLER_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2885                 }
2886         }
2887         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButtonHandler != null), , E_SYSTEM, "[%s] A system error has been occurred. OnOffButtonHandler image load failed", GetErrorMessage(E_SYSTEM));
2888
2889         if (__enabledState)
2890         {
2891                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_BG, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
2892         }
2893         else
2894         {
2895                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
2896         }
2897         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButton != null), , E_SYSTEM, "[%s] A system error has been occurred. OnOffButton image load failed", GetErrorMessage(E_SYSTEM));
2898
2899         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2900         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2901         bounds.SetBounds(0, 0, annexWidth, annexHeight);
2902
2903         pCanvas = new (std::nothrow) Canvas();
2904         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2905
2906         pCanvas->Construct(bounds);
2907         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2908         pCanvas->Clear();
2909
2910         backgroundBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButton);
2911         DrawBitmap(*pCanvas, backgroundBounds, *pOnOffButton);
2912
2913         handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
2914         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexMargin);
2915         if (IsChecked() == true)
2916         {
2917                 handlerBounds.x = backgroundBounds.width - handlerBounds.width - annexMargin;
2918         }
2919         else
2920         {
2921                 handlerBounds.x = backgroundBounds.x + annexMargin;
2922         }
2923
2924         DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler);
2925
2926         pMergeBitmap = new (std::nothrow) Bitmap();
2927         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2928
2929         pMergeBitmap->Construct(*pCanvas, bounds);
2930         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2931
2932         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
2933         __pItemAnnex->Invalidate(false);
2934
2935 CATCH:
2936         delete pOnOffButton;
2937         delete pOnOffButtonHandler;
2938         delete pMergeBitmap;
2939         delete pCanvas;
2940
2941         return;
2942 }
2943
2944 void
2945 _TableViewItem::AdjustAnnexOnOffHandlerPosition()
2946 {
2947         float annexWidth = 0.0f;
2948         float annexHeight = 0.0f;
2949         float annexMargin = 0.0f;
2950
2951         float annexStartPositionX = 0.0f;
2952         float annexEndPositionX = 0.0f;
2953         float handlerPositionX = 0.0f;
2954         FloatRectangle handlerBounds;
2955         result r = E_SUCCESS;
2956
2957         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexMargin);
2958
2959         Bitmap* pOnOffButtonHandler = null;
2960         if (IsChecked() == true)
2961         {
2962                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2963         }
2964         else
2965         {
2966                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2967         }
2968         SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButtonHandler != null), E_SYSTEM, "[%s] A system error has been occurred. OnOffHandlerButton button image load failed.", GetErrorMessage(E_SYSTEM));
2969
2970         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2971         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2972
2973         annexStartPositionX = __pItemAnnex->GetBoundsF().x;
2974         annexEndPositionX = annexStartPositionX + annexWidth + annexMargin;
2975
2976         handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
2977
2978         if (__annexOnOffHandlerMoved)
2979         {
2980                 if (annexStartPositionX <= __annexOnOffHandlerPositionX
2981                         && annexEndPositionX >= __annexOnOffHandlerPositionX)
2982                 {
2983                         if (((annexEndPositionX - annexStartPositionX) / 2) < (__annexOnOffHandlerPositionX + (handlerBounds.width / 2)) - annexStartPositionX)
2984                         {
2985                                 handlerPositionX = annexEndPositionX;
2986                                 SetChecked(true);
2987                         }
2988                         else
2989                         {
2990                                 handlerPositionX = annexStartPositionX;
2991                                 SetChecked(false);
2992                         }
2993                 }
2994         }
2995         else
2996         {
2997                 SetChecked(!IsChecked());
2998                 if (IsChecked())
2999                 {
3000                         handlerPositionX = annexEndPositionX;
3001                 }
3002                 else
3003                 {
3004                         handlerPositionX = annexStartPositionX;
3005                 }
3006         }
3007
3008         DrawAnnexOnOffHandler(handlerPositionX);
3009
3010         delete pOnOffButtonHandler;
3011
3012         return;
3013 }
3014
3015 void
3016 _TableViewItem::DrawAnnexOnOffHandler(float touchEndPosition)
3017 {
3018         if (__pItemAnnex == null)
3019         {
3020                 return;
3021         }
3022
3023         Bitmap* pOnOffButton = null;
3024         Bitmap* pOnOffButtonHandler = null;
3025         Bitmap* pMergeBitmap = null;
3026         Canvas* pCanvas = null;
3027         result r = E_SUCCESS;
3028
3029         FloatRectangle backgroundBounds;
3030         FloatRectangle handlerBounds;
3031         float annexWidth = 0.0f;
3032         float annexHeight = 0.0f;
3033         float annexMargin = 0.0f;
3034         float annexX = 0.0f;
3035         float nextHandlerX = 0.0f;
3036
3037         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_BG, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
3038         SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButton != null), E_SYSTEM, "[%s] A system error has been occurred. OnOffButton image load failed", GetErrorMessage(E_SYSTEM));
3039
3040         if (IsChecked() == true)
3041         {
3042                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
3043         }
3044         else
3045         {
3046                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
3047         }
3048         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButtonHandler != null), , E_SYSTEM, "[%s] A system error has been occurred. OnOffHandlerButton button image load failed.", GetErrorMessage(E_SYSTEM));
3049
3050         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3051         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
3052         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexMargin);
3053
3054         pCanvas = new (std::nothrow) Canvas();
3055         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3056
3057         pCanvas->Construct(FloatRectangle(0, 0, annexWidth, annexHeight));
3058         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
3059         pCanvas->Clear();
3060
3061         backgroundBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButton);
3062         DrawBitmap(*pCanvas, backgroundBounds, *pOnOffButton);
3063
3064         handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
3065         handlerBounds.y  = backgroundBounds.y;
3066
3067         if (IsChecked())
3068         {
3069                 handlerBounds.x = backgroundBounds.width - handlerBounds.width - annexMargin;
3070         }
3071         else
3072         {
3073                 handlerBounds.x = backgroundBounds.x + annexMargin;
3074         }
3075
3076         nextHandlerX = handlerBounds.x + (touchEndPosition - __annexTouchStartPosition);
3077         annexX = __pItemAnnex->GetBoundsF().x;
3078
3079         if ((annexX + nextHandlerX + handlerBounds.width) < (annexX + annexWidth + annexMargin)
3080                 && (annexX + nextHandlerX) > annexX)
3081         {
3082                 handlerBounds.x = nextHandlerX;
3083         }
3084         else if (_FloatCompareGE((annexX + nextHandlerX + handlerBounds.width), (annexX + annexWidth + annexMargin)))
3085         {
3086                 handlerBounds.x = backgroundBounds.width - handlerBounds.width - annexMargin;
3087         }
3088         else if (_FloatCompareLE((annexX + nextHandlerX), annexX))
3089         {
3090                 handlerBounds.x = backgroundBounds.x + annexMargin;
3091         }
3092
3093         __annexOnOffHandlerPositionX = annexX + handlerBounds.x;
3094         DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler);
3095
3096         pMergeBitmap = new (std::nothrow) Bitmap();
3097         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3098
3099         pMergeBitmap->Construct(*pCanvas, FloatRectangle(0, 0, annexWidth, annexHeight));
3100         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
3101
3102         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
3103         __pItemAnnex->Invalidate(false);
3104
3105 CATCH:
3106         delete pOnOffButton;
3107         delete pOnOffButtonHandler;
3108         delete pMergeBitmap;
3109         delete pCanvas;
3110
3111         return;
3112 }
3113
3114 void
3115 _TableViewItem::DrawDetailButton(void)
3116 {
3117         Bitmap* pDetailBgEffect = null;
3118         Bitmap* pDetailEffect = null;
3119         Bitmap* pReplacementDetail = null;
3120         Bitmap* pReplacementDetailBg = null;
3121         Bitmap* pMergeBitmap = null;
3122         Canvas* pCanvas = null;
3123         Color replacementNewColor;
3124         Color replacementNewBgColor;
3125         result r = E_SUCCESS;
3126
3127         FloatRectangle bounds;
3128         float annexWidth = 0.0f;
3129         float annexHeight = 0.0f;
3130         bool themeBackgroundBitmap = false;
3131
3132         themeBackgroundBitmap = IS_CUSTOM_BITMAP(TABLEVIEW::CIRCLE_BUTTON_BG_NORMAL);
3133
3134         if (__enabledState)
3135         {
3136                 if (__isSelectedDetailButton)
3137                 {
3138                         if (!themeBackgroundBitmap)
3139                         {
3140                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
3141                                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBgEffect != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3142
3143                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailEffect);
3144                                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailEffect != null), , E_SYSTEM,"[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3145                         }
3146
3147                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_PRESSED, replacementNewColor);
3148
3149                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, replacementNewColor, pReplacementDetail);
3150                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pReplacementDetail != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3151
3152                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_PRESSED, replacementNewBgColor);
3153                 }
3154                 else
3155                 {
3156                         if (!themeBackgroundBitmap)
3157                         {
3158                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
3159                                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBgEffect != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3160
3161                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailEffect);
3162                                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailEffect != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3163                         }
3164
3165                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_NORMAL, replacementNewColor);
3166
3167                         r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, replacementNewColor, pReplacementDetail);
3168                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pReplacementDetail != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3169
3170                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_NORMAL, replacementNewBgColor);
3171                 }
3172         }
3173         else
3174         {
3175                 if (!themeBackgroundBitmap)
3176                 {
3177                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
3178                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBgEffect != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3179
3180                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailEffect);
3181                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailEffect != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3182                 }
3183
3184                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_NORMAL, replacementNewColor);
3185
3186                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, replacementNewColor, pReplacementDetail);
3187                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pReplacementDetail != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3188
3189                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, replacementNewBgColor, pReplacementDetailBg);
3190                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pReplacementDetailBg != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3191         }
3192
3193         if (pReplacementDetailBg == null)
3194         {
3195                 r = GET_REPLACED_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, replacementNewBgColor, pReplacementDetailBg);
3196                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pReplacementDetailBg != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3197         }
3198
3199         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3200         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
3201
3202         bounds.SetBounds(0, 0, annexWidth, annexHeight);
3203
3204         pCanvas = new (std::nothrow) Canvas();
3205         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3206
3207         pCanvas->Construct(bounds);
3208         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
3209         pCanvas->Clear();
3210
3211         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetailBg), *pReplacementDetailBg);
3212         if (pDetailBgEffect)
3213         {
3214                 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pDetailBgEffect), *pDetailBgEffect);
3215         }
3216         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetail), *pReplacementDetail);
3217         if (pDetailEffect)
3218         {
3219                 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pDetailEffect), *pDetailEffect);
3220         }
3221
3222         pMergeBitmap = new (std::nothrow) Bitmap();
3223         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3224         pMergeBitmap->Construct(*pCanvas, bounds);
3225         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
3226
3227         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
3228         __pItemAnnex->Invalidate(false);
3229
3230 CATCH:
3231         delete pDetailBgEffect;
3232         delete pDetailEffect;
3233         delete pReplacementDetail;
3234         delete pReplacementDetailBg;
3235         delete pMergeBitmap;
3236         delete pCanvas;
3237
3238         return;
3239 }
3240
3241 void
3242 _TableViewItem::DrawItemDivider(void)
3243 {
3244         if (__pItemDivider == null || __pItemTopDivider == null)
3245         {
3246                 return;
3247         }
3248
3249         if (__pDrawingProperty->itemDividerEnabled == false ||
3250                 __itemType == TABLE_VIEW_ITEM_TYPE_HEADER ||
3251                 __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER ||
3252                 __itemDividerEnabled == false ||
3253                 __isSectionItem)
3254         {
3255                 __pItemDivider->SetVisibleState(false);
3256                 __pItemTopDivider->SetVisibleState(false);
3257
3258                 return;
3259         }
3260
3261         FloatRectangle dividerBottomBounds;
3262         FloatRectangle dividerTopBounds;
3263         Color topLineColor;
3264         Color bottomLineColor;
3265         Color customDividerColor;
3266         FloatRectangle bounds;
3267         FloatPoint bottomPoint;
3268
3269         __pItemDivider->SetVisibleState(true);
3270         __pItemTopDivider->SetVisibleState(true);
3271
3272         if (    __drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED ||
3273                 __drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED)
3274         {
3275                 if (__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL] != __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED])
3276                 {
3277                         if (__itemType != TABLE_VIEW_ITEM_TYPE_TITLE)
3278                         {
3279                                 __pItemDivider->SetVisibleState(false);
3280                         }
3281
3282                         __pItemTopDivider->SetVisibleState(false);
3283                 }
3284         }
3285
3286         if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
3287         {
3288                 if (__pItemBgBitmap[__drawingStatus] != null)
3289                 {
3290                         __pItemDivider->SetVisibleState(false);
3291                 }
3292                 else
3293                 {
3294                         float lineHeight = 0.0f;
3295                         float lineLeftMargin = 0.0f;
3296                         float lineBottomMargin = 0.0f;
3297                         bounds = GetBoundsF();
3298
3299                         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
3300                         {
3301                                 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_NORMAL, bottomLineColor);
3302                         }
3303                         else
3304                         {
3305                                 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_PRESSED, bottomLineColor);
3306                         }
3307
3308                         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
3309                         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
3310                         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineBottomMargin);
3311
3312                         lineHeight = Tizen::Graphics::CoordinateSystem::ConvertToLogicalY(lineHeight);
3313                         lineBottomMargin = Tizen::Graphics::CoordinateSystem::ConvertToLogicalY(lineBottomMargin);
3314                         bottomPoint = Tizen::Graphics::CoordinateSystem::AlignToDevice(FloatPoint(lineLeftMargin, bounds.height));
3315                         dividerBottomBounds = FloatRectangle(bottomPoint.x, bottomPoint.y - lineBottomMargin, bounds.width - lineLeftMargin * 2.0f, lineHeight);
3316                 }
3317         }
3318         else
3319         {
3320                 float lineLeftMargin = 0.0f;
3321                 float lineHeight = 0.0f;
3322                 bounds = GetBoundsF();
3323
3324                 if (!IsContextItem())
3325                 {
3326                         if (!__isSimpleLastItem)
3327                         {
3328                                 if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM || __itemType == TABLE_VIEW_ITEM_TYPE_ONE)
3329                                 {
3330                                         __pItemDivider->SetVisibleState(false);
3331                                         __pItemTopDivider->SetVisibleState(false);
3332                                 }
3333                         }
3334                 }
3335
3336                 customDividerColor = __pDrawingProperty->dividerColor;
3337                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_TOP_BG_NORMAL, topLineColor);
3338                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_BOTTOM_BG_NORMAL, bottomLineColor);
3339                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
3340                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
3341
3342                 lineLeftMargin = Tizen::Graphics::CoordinateSystem::ConvertToLogicalX(lineLeftMargin);
3343                 lineHeight = Tizen::Graphics::CoordinateSystem::ConvertToLogicalY(lineHeight);
3344                 bottomPoint = Tizen::Graphics::CoordinateSystem::AlignToDevice(FloatPoint(lineLeftMargin, (bounds.height)));
3345
3346                 dividerTopBounds.SetBounds(lineLeftMargin, bottomPoint.y - (lineHeight * 2.0f), bounds.width - lineLeftMargin * 2.0f, lineHeight);
3347                 dividerBottomBounds.SetBounds(lineLeftMargin, bottomPoint.y - lineHeight, bounds.width - lineLeftMargin * 2.0f, lineHeight);
3348         }
3349
3350         if (__pItemDivider->GetVisibleState())
3351         {
3352                 __pItemDivider->SetBounds(dividerBottomBounds);
3353                 if (customDividerColor == bottomLineColor || __itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
3354                 {
3355                         __pItemDivider->SetBackgroundColor(bottomLineColor);
3356                 }
3357                 else
3358                 {
3359                         __pItemDivider->SetBackgroundColor(customDividerColor);
3360                         __pItemDivider->GetVisualElement()->SetOpacity(ITEM_BOTTOM_DIVIDER_OPACITY);
3361                 }
3362                         __pItemDivider->Invalidate();
3363         }
3364
3365         if (__pItemTopDivider->GetVisibleState())
3366         {
3367                 __pItemTopDivider->SetBounds(dividerTopBounds);
3368                 if (customDividerColor == bottomLineColor)
3369                 {
3370                         __pItemTopDivider->SetBackgroundColor(topLineColor);
3371                 }
3372                 else
3373                 {
3374                         __pItemTopDivider->SetBackgroundColor(customDividerColor);
3375                         __pItemTopDivider->GetVisualElement()->SetOpacity(ITEM_TOP_DIVIDER_OPACITY);
3376                 }
3377                 __pItemTopDivider->Invalidate();
3378         }
3379 }
3380
3381 void
3382 _TableViewItem::DrawItemAnnexDivider(void)
3383 {
3384         if (__itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
3385         {
3386                 if (__pItemAnnexLeftDivider != null)
3387                 {
3388                         __pItemAnnexLeftDivider->SetVisibleState(false);
3389                 }
3390
3391                 if (__pItemAnnexRightDivider != null)
3392                 {
3393                         __pItemAnnexRightDivider->SetVisibleState(false);
3394                 }
3395         }
3396         else
3397         {
3398                 Color dividerLeftColor;
3399                 Color dividerRightColor;
3400                 Color customDividerColor;
3401                 Color bottomLineColor;
3402                 FloatRectangle bounds = GetBoundsF();
3403                 float dividerHeight = 0;
3404                 float itemHeight = 0;
3405                 float dividerWidth = 0.0f;
3406                 float dividerTopMargin = 0.0f;
3407                 float annexWidth = 0.0f;
3408                 float annexLeftMargin = 0.0f;
3409                 float itemLeftMargin = 0.0f;
3410
3411                 customDividerColor = __pDrawingProperty->dividerColor;
3412                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, itemLeftMargin);
3413                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexLeftMargin);
3414                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3415                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_LEFT_BG_NORMAL, dividerLeftColor);
3416                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_RIGHT_BG_NORMAL, dividerRightColor);
3417                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_BOTTOM_BG_NORMAL, bottomLineColor);
3418                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, dividerWidth);
3419                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, dividerTopMargin);
3420
3421                 itemLeftMargin += __pDrawingProperty->scrollMargin;
3422                 itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height);
3423                 dividerHeight = itemHeight - (dividerTopMargin*2);
3424                 dividerHeight = (dividerHeight > 0) ? dividerHeight : 0;
3425                 __pItemAnnexLeftDivider->SetBounds(FloatRectangle((GetBoundsF().width - annexWidth - (itemLeftMargin + annexLeftMargin) - (dividerWidth*2)), dividerTopMargin, dividerWidth, dividerHeight));
3426                 __pItemAnnexRightDivider->SetBounds(FloatRectangle((GetBoundsF().width - annexWidth - (itemLeftMargin + annexLeftMargin) - dividerWidth), dividerTopMargin, dividerWidth, dividerHeight));
3427
3428                 if (customDividerColor == bottomLineColor)
3429                 {
3430                         __pItemAnnexLeftDivider->SetBackgroundColor(dividerLeftColor);
3431                 }
3432                 else
3433                 {
3434                         __pItemAnnexLeftDivider->SetBackgroundColor(customDividerColor);
3435                         __pItemAnnexLeftDivider->GetVisualElement()->SetOpacity(ITEM_TOP_DIVIDER_OPACITY);
3436                 }
3437
3438                 if (customDividerColor == bottomLineColor)
3439                 {
3440                         __pItemAnnexRightDivider->SetBackgroundColor(dividerRightColor);
3441                 }
3442                 else
3443                 {
3444                         __pItemAnnexRightDivider->SetBackgroundColor(customDividerColor);
3445                         __pItemAnnexRightDivider->GetVisualElement()->SetOpacity(ITEM_BOTTOM_DIVIDER_OPACITY);
3446                 }
3447
3448                 __pItemAnnexLeftDivider->Invalidate();
3449                 __pItemAnnexRightDivider->Invalidate();
3450         }
3451
3452         if (__pItemAnnexLeftDivider != null)
3453         {
3454                 _AccessibilityContainer* pContainer = __pItemAnnexLeftDivider->GetAccessibilityContainer();
3455                 pContainer->Activate(false);
3456         }
3457
3458         if (__pItemAnnexRightDivider != null)
3459         {
3460                 _AccessibilityContainer* pContainer = __pItemAnnexRightDivider->GetAccessibilityContainer();
3461                 pContainer->Activate(false);
3462         }
3463 }
3464
3465
3466 result
3467 _TableViewItem::DrawBitmap(Canvas& canvas, const FloatRectangle& bounds, const Bitmap& bitmap)
3468 {
3469         result r = E_SUCCESS;
3470         if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
3471         {
3472                 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
3473                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw ninepatched bitmap.");
3474         }
3475         else
3476         {
3477                 r = canvas.DrawBitmap(bounds, bitmap);
3478                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw bitmap.");
3479         }
3480
3481         return r;
3482 }
3483
3484 result
3485 _TableViewItem::SetItemHighlightBounds(_VisualElement& highlightVisualElement, const FloatRectangle& bounds)
3486 {
3487         return highlightVisualElement.SetBounds(bounds);
3488 }
3489
3490 FloatRectangle
3491 _TableViewItem::CalculateItemHighlightBounds(void)
3492 {
3493         FloatRectangle itemBounds = GetBoundsF();
3494         return FloatRectangle(0.0f, 0.0f, itemBounds.width, itemBounds.height);
3495 }
3496
3497 FloatRectangle
3498 _TableViewItem::CalculateAnnexBitmapBounds(float annexWidth, float annexHeight, const Bitmap& bitmap)
3499 {
3500         FloatRectangle bounds;
3501         float width = 0;
3502         float height = 0;
3503         float leftMargin = 0;
3504         float topMargin = 0;
3505
3506         if (annexWidth > bitmap.GetWidthF())
3507         {
3508                 leftMargin = (annexWidth - bitmap.GetWidthF()) / 2;
3509                 width = bitmap.GetWidthF();
3510         }
3511         else
3512         {
3513                 width = annexWidth;
3514         }
3515
3516         if (annexHeight > bitmap.GetHeightF())
3517         {
3518                 topMargin = (annexHeight - bitmap.GetHeightF()) / 2;
3519                 height = bitmap.GetHeightF();
3520         }
3521         else
3522         {
3523                 height = annexHeight;
3524         }
3525
3526         bounds.SetBounds(leftMargin, topMargin, width, height);
3527
3528         return bounds;
3529 }
3530
3531 bool
3532 _TableViewItem::IsTitleStyleItem(void) const
3533 {
3534         if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE || __itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
3535         {
3536                 return true;
3537         }
3538
3539         return false;
3540 }
3541
3542 bool
3543 _TableViewItem::IsValidSelectionState(void)
3544 {
3545         _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
3546         if (pParent == null)
3547         {
3548                 return true;
3549         }
3550
3551         if (pParent->GetPressedItemCount() > 0)
3552         {
3553                 return false;
3554         }
3555
3556         return true;
3557 }
3558
3559 void
3560 _TableViewItem::DrawSimpleItem(void)
3561 {
3562         if (__pSimpleItemText != null)
3563         {
3564                 Color textColor = __simpleItemTextColor[__drawingStatus];
3565                 if (!IsEnabled())
3566                 {
3567                         textColor = __simpleItemTextColor[TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED];
3568                 }
3569
3570                 if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
3571                 {
3572                         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
3573                         {
3574                                 textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL];
3575                         }
3576                         else
3577                         {
3578                                 textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED];
3579                         }
3580                 }
3581
3582                 __pSimpleItemText->SetTextColor(textColor);
3583                 __pSimpleItemText->Invalidate(false);
3584         }
3585 }
3586 result
3587 _TableViewItem::SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType)
3588 {
3589         result r = E_SUCCESS;
3590         bool textOnly = true;
3591
3592         if (pBitmap != null)
3593         {
3594                 textOnly = false;
3595         }
3596
3597         r = CreateSimpleItemContents(textOnly);
3598         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3599
3600         FloatRectangle bitmapRect = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
3601         FloatRectangle textRect = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
3602         float leftMargin = 0.0f;
3603         float annexMargin = 0.0f;
3604         float elementWidth = 0;
3605         float elementHeight = 0;
3606         float itemHeight = GetBoundsF().height;
3607         float itemWidth = GetBoundsF().width;
3608         float annexWidth = GetAnnexWidth(__annexStyle);
3609
3610         if (groupType)
3611         {
3612                 if (__simpleItemTextSize == 0)
3613                 {
3614                         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize);
3615                 }
3616                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
3617         }
3618         else
3619         {
3620                 if (__simpleItemTextSize == 0)
3621                 {
3622                         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize);
3623                 }
3624                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
3625         }
3626
3627         if (!textOnly)
3628         {
3629                 elementWidth = itemHeight * SIMPLE_ITEM_ELEMENT_BITMAP_SIZE_RATIO;
3630                 elementHeight = elementWidth;
3631
3632                 bitmapRect.x = leftMargin;
3633                 bitmapRect.y = (itemHeight - elementHeight) / 2;
3634                 bitmapRect.width = elementWidth;
3635                 bitmapRect.height = elementHeight;
3636         }
3637
3638         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_NORMAL)
3639         {
3640                 textRect.x = bitmapRect.x + elementWidth + leftMargin;
3641                 elementWidth = itemWidth - textRect.x - leftMargin;
3642         }
3643         else
3644         {
3645                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexMargin);
3646                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || __annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
3647                 {
3648                         bitmapRect.x = leftMargin + annexWidth + annexMargin;
3649                         textRect.x = bitmapRect.x + elementWidth + leftMargin;
3650                         elementWidth = itemWidth - textRect.x - leftMargin;
3651                 }
3652                 else
3653                 {
3654                         textRect.x = bitmapRect.x + elementWidth + leftMargin;
3655                         elementWidth = itemWidth - textRect.x - annexWidth - leftMargin - annexMargin;
3656                 }
3657         }
3658
3659         textRect.y = 0.0f;
3660         textRect.width = elementWidth < 0 ? 0 : elementWidth;;
3661         textRect.height = itemHeight;
3662
3663         if (__pSimpleItemBitmap != null && pBitmap != null)
3664         {
3665                 __pSimpleItemBitmap->SetBackgroundBitmap(*pBitmap);
3666                 __pSimpleItemBitmap->SetBounds(bitmapRect);
3667
3668                 _Label* pSimpleItemBitmapCore = GetLabelCore(__pSimpleItemBitmap);
3669                 if (!pSimpleItemBitmapCore->HasParent())
3670                 {
3671                         r = AttachChild(*pSimpleItemBitmapCore);
3672                         SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3673                 }
3674         }
3675
3676         if (__pSimpleItemText != null)
3677         {
3678                 __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL);
3679                 __pSimpleItemText->SetText(text);
3680                 __pSimpleItemText->SetBounds(textRect);
3681
3682                 _Label* pSimpleItemTextCore = GetLabelCore(__pSimpleItemText);
3683                 if (!pSimpleItemTextCore->HasParent())
3684                 {
3685                         r = AttachChild(*pSimpleItemTextCore);
3686                         SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3687                 }
3688         }
3689
3690         return E_SUCCESS;
3691 }
3692
3693 result
3694 _TableViewItem::CreateSimpleItemContents(bool textOnly)
3695 {
3696         result r = E_SUCCESS;
3697
3698         if (__pSimpleItemText == null)
3699         {
3700                 __pSimpleItemText = new (std::nothrow) Label();
3701
3702                 r = GetLastResult();
3703                 SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3704
3705                 __pSimpleItemText->Construct(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), L"");
3706
3707                 __pSimpleItemText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
3708                 __pSimpleItemText->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
3709                 if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
3710                 {
3711                         __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]);
3712                 }
3713                 else
3714                 {
3715                         __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
3716                 }
3717                 __pSimpleItemText->SetBackgroundColor(Color(0, 0, 0, 0));
3718                 GetLabelCore(__pSimpleItemText)->SetFocusable(true);
3719
3720         }
3721
3722         if (!textOnly)
3723         {
3724                 if (__pSimpleItemBitmap == null)
3725                 {
3726                         __pSimpleItemBitmap = new (std::nothrow) Label();
3727
3728                         r = GetLastResult();
3729                         SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3730
3731                         __pSimpleItemBitmap->Construct(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), L"");
3732                         __pSimpleItemBitmap->SetBackgroundColor(Color(0, 0, 0, 0));
3733                         GetLabelCore(__pSimpleItemBitmap)->SetFocusable(true);
3734                 }
3735
3736         }
3737         else
3738         {
3739                 if (__pSimpleItemBitmap != null)
3740                 {
3741                         delete __pSimpleItemBitmap;
3742                         __pSimpleItemBitmap = null;
3743                 }
3744         }
3745
3746         return E_SUCCESS;
3747 }
3748
3749 result
3750 _TableViewItem::SetSimpleTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status)
3751 {
3752         __simpleItemTextColor[status] = color;
3753
3754         return E_SUCCESS;
3755 }
3756
3757 Tizen::Graphics::Color
3758 _TableViewItem::GetSimpleItemTextColor(TableViewItemDrawingStatus status) const
3759 {
3760         return __simpleItemTextColor[status];
3761 }
3762
3763 result
3764 _TableViewItem::SetSimpleGroupItemTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status)
3765 {
3766         if (status == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
3767         {
3768                 __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL] = color;
3769         }
3770         else if (status == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED)
3771         {
3772                 __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED] = color;
3773         }
3774
3775         return E_SUCCESS;
3776 }
3777
3778 Tizen::Graphics::Color
3779 _TableViewItem::GetSimpleGroupItemTextColor(TableViewItemDrawingStatus status) const
3780 {
3781         if (status == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED)
3782         {
3783                 return __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED];
3784         }
3785         else
3786         {
3787                 return __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL];
3788         }
3789 }
3790
3791 result
3792 _TableViewItem::SetSimpleItemTextSize(int size)
3793 {
3794         if (__simpleItemTextSize == size)
3795         {
3796                 return E_SUCCESS;
3797         }
3798
3799         __simpleItemTextSize = size;
3800
3801         if (__pSimpleItemText != null)
3802         {
3803                 __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL);
3804         }
3805         return E_SUCCESS;
3806 }
3807
3808 int
3809 _TableViewItem::GetSimpleItemTextSize(void) const
3810 {
3811         return __simpleItemTextSize;
3812 }
3813
3814 result
3815 _TableViewItem::SetSectionHeaderFooterContents(const Tizen::Base::String& text, HorizontalAlignment alignment, bool isHeader)
3816 {
3817         if (__pHeaderFooterItemText == null)
3818         {
3819                 result r = E_SUCCESS;
3820                 float contentsHeight = 0.0f;
3821                 float positionY = 0.0f;
3822                 Color textColor;
3823
3824                 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_NORMAL, textColor);
3825                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, contentsHeight);
3826
3827                 __pHeaderFooterItemText = new (std::nothrow) Label();
3828
3829                 r = GetLastResult();
3830                 SysTryReturn(NID_UI_CTRL, __pHeaderFooterItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3831
3832                 if (isHeader)
3833                 {
3834                         positionY = GetBoundsF().height - contentsHeight;
3835                 }
3836                 __pHeaderFooterItemText->Construct(FloatRectangle(0.0f, positionY, GetBoundsF().width, contentsHeight), text);
3837                 __pHeaderFooterItemText->SetTextHorizontalAlignment(alignment);
3838                 __pHeaderFooterItemText->SetTextColor(textColor);
3839                 __pHeaderFooterItemText->SetBackgroundColor(Color(0, 0, 0, 0));
3840
3841                 _Label* pHeaderFooterItemTextCore = GetLabelCore(__pHeaderFooterItemText);
3842                 pHeaderFooterItemTextCore->SetFocusable(false);
3843                 AttachChild(*pHeaderFooterItemTextCore);
3844         }
3845
3846         return E_SUCCESS;
3847 }
3848
3849 result
3850 _TableViewItem::SetSectionHeaderFooterAlignment(HorizontalAlignment alignment)
3851 {
3852         if (__pHeaderFooterItemText != null)
3853         {
3854                 __pHeaderFooterItemText->SetTextHorizontalAlignment(alignment);
3855                 __pHeaderFooterItemText->Invalidate(false);
3856         }
3857
3858         return E_SUCCESS;
3859 }
3860
3861 float
3862 _TableViewItem::GetAnnexWidth(TableViewAnnexStyle style)
3863 {
3864         float annexWidth = 0.0f;
3865         float annexDividerWidth = 0.0f;
3866
3867         switch (style)
3868         {
3869         case TABLE_VIEW_ANNEX_STYLE_NORMAL:
3870                 annexWidth = 0.0f;
3871                 break;
3872
3873         case TABLE_VIEW_ANNEX_STYLE_MARK:
3874                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3875                 break;
3876
3877         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
3878                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3879                 break;
3880
3881         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
3882                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexDividerWidth);
3883                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexDividerWidth);
3884                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3885                 annexWidth = annexWidth + (annexDividerWidth*2) + annexDividerWidth;
3886                 break;
3887
3888         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
3889                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3890                 break;
3891
3892         case TABLE_VIEW_ANNEX_STYLE_RADIO:
3893                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3894                 break;
3895
3896         default:
3897                 break;
3898         }
3899
3900         return annexWidth;
3901 }
3902
3903 void
3904 _TableViewItem::SetDrawingStatus(TableViewItemDrawingStatus status)
3905 {
3906         __drawingStatus = status;
3907 }
3908
3909 TableViewItemDrawingStatus
3910 _TableViewItem::GetDrawingStatus(void)
3911 {
3912         return __drawingStatus;
3913 }
3914
3915 void
3916 _TableViewItem::SetPressedControl(TableViewItemPressedControl pressedControl)
3917 {
3918         __pressedControl = pressedControl;
3919
3920         if (__pressedControl == TABLE_VIEW_ITEM_PRESSED_ITEM)
3921         {
3922                 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
3923         }
3924         else if (__pressedControl == TABLE_VIEW_ITEM_PRESSED_ANNEX)
3925         {
3926                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
3927                 {
3928                         __isSelectedDetailButton = true;
3929                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
3930                 }
3931                 else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING ||
3932                         __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
3933                 {
3934                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
3935                 }
3936                 else
3937                 {
3938                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
3939                 }
3940         }
3941         else
3942         {
3943                 if (__pressedControl != TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL)
3944                 {
3945                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
3946                 }
3947         }
3948 }
3949
3950 TableViewItemPressedControl
3951 _TableViewItem::GetPressedControl(void)
3952 {
3953         return __pressedControl;
3954 }
3955
3956 void
3957 _TableViewItem::AdjustChildControlMargin(void)
3958 {
3959         if (__childMarginState)
3960         {
3961                 return;
3962         }
3963
3964         if (IsTitleStyleItem())
3965         {
3966                 return;
3967         }
3968
3969         __childMarginState = true;
3970
3971         float margin = 0;
3972
3973         if (__pDrawingProperty->groupedLookEnabled)
3974         {
3975                 float groupedBarMargin = 0.0f;
3976                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, groupedBarMargin);
3977
3978                 margin = margin + groupedBarMargin;
3979         }
3980
3981         if (margin > 0)
3982         {
3983                 _VisualElement* pVisualElement = GetVisualElement();
3984
3985                 if (pVisualElement != null)
3986                 {
3987                         FloatPoint position;
3988
3989                         position.SetPosition(margin, 0.0f);
3990                         pVisualElement->ScrollByPoint(position, false);
3991                 }
3992         }
3993 }
3994
3995 void
3996 _TableViewItem::AdjustContextItemBounds(void)
3997 {
3998         _TableViewItem* pContextItem = GetContextItem();
3999
4000         if (pContextItem == null)
4001         {
4002                 return;
4003         }
4004
4005         FloatDimension contextItemSize = pContextItem->GetSizeF();
4006         FloatDimension itemSize = GetSizeF();
4007
4008         if (!_FloatCompare(contextItemSize.height, itemSize.height))
4009         {
4010                 contextItemSize.height = itemSize.height;
4011
4012                 pContextItem->SetSize(contextItemSize);
4013         }
4014
4015         pContextItem->AdjustChildControlCenterAlign();
4016 }
4017
4018 void
4019 _TableViewItem::AdjustAnnexBounds(void)
4020 {
4021         if (__pItemAnnex == null || __isMoveItemAnimationEnabled || __isZoomInOutItemAnimationEnabled ||__isFadeInOutItemAnimationEnabled)
4022         {
4023                 return;
4024         }
4025
4026         // h align
4027         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER || __annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
4028         {
4029                 _Label* pAnnexCore = GetLabelCore(__pItemAnnex);
4030                 if (pAnnexCore->HasParent())
4031                 {
4032                         FloatRectangle annexBounds = __pItemAnnex->GetBoundsF();
4033                         float annexPositionX = annexBounds.x;
4034                         float leftMargin = 0.0f;
4035
4036                         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
4037
4038                         if (__pDrawingProperty != null)
4039                         {
4040                                 leftMargin += __pDrawingProperty->scrollMargin;
4041                         }
4042
4043                         annexPositionX = GetBoundsF().width - annexBounds.width - leftMargin;
4044                         if (__pDrawingProperty != null && __pDrawingProperty->groupedLookEnabled)
4045                         {
4046                                 float groupedBarMargin = 0.0f;
4047                                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, groupedBarMargin);
4048
4049                                 annexPositionX += groupedBarMargin;
4050                         }
4051
4052                         if (!_FloatCompare(annexPositionX, annexBounds.x))
4053                         {
4054                                 __pItemAnnex->SetPosition(FloatPoint(annexPositionX, annexBounds.y));
4055
4056                                 if (__pAccessibilityOnOffElement != null)
4057                                 {
4058                                         __pAccessibilityOnOffElement->SetBounds(__pItemAnnex->GetBoundsF());
4059                                 }
4060                         }
4061                 }
4062         }
4063
4064         // v align
4065         FloatRectangle itemBounds = GetBoundsF();
4066         FloatRectangle annexBounds = __pItemAnnex->GetBoundsF();
4067
4068         if (__customHeight > 0)
4069         {
4070                 itemBounds.height = __customHeight;
4071         }
4072
4073         annexBounds.y = (itemBounds.height - annexBounds.height) / 2;
4074         __pItemAnnex->SetPosition(FloatPoint(annexBounds.x, annexBounds.y));
4075         if (__pAccessibilityOnOffElement != null)
4076         {
4077                 __pAccessibilityOnOffElement->SetBounds(__pItemAnnex->GetBoundsF());
4078         }
4079 }
4080
4081 void
4082 _TableViewItem::SetItemCustomHeight(float height)
4083 {
4084         __customHeight = height;
4085 }
4086
4087 float
4088 _TableViewItem::GetItemCustomHeight(void)
4089 {
4090         return __customHeight;
4091 }
4092
4093 void
4094 _TableViewItem::AdjustChildControlCenterAlign(void)
4095 {
4096         if (__childControlCenterAlign)
4097         {
4098                 FloatDimension itemSize = GetSizeF();
4099
4100                 int childControlCount = GetChildCount();
4101
4102                 for (int i = 0; i < childControlCount; i++)
4103                 {
4104                         _Control* pChildControl = GetChild(i);
4105
4106                         if (pChildControl == null)
4107                         {
4108                                 continue;
4109                         }
4110
4111                         if (__pItemDivider == pChildControl)
4112                         {
4113                                 float positionX = pChildControl->GetPositionF().x;
4114                                 pChildControl->SetPosition(FloatPoint(positionX, itemSize.height - 1));
4115                                 continue;
4116                         }
4117
4118                         if (__pItemTopDivider == pChildControl)
4119                         {
4120                                 float positionX = pChildControl->GetPositionF().x;
4121                                 pChildControl->SetPosition(FloatPoint(positionX, 0));
4122                                 continue;
4123                         }
4124
4125                         FloatRectangle itemBounds = pChildControl->GetBoundsF();
4126
4127                         itemBounds.y = (itemSize.height - itemBounds.height) / 2;
4128
4129                         pChildControl->SetPosition(FloatPoint(itemBounds.x, itemBounds.y));
4130                 }
4131         }
4132 }
4133
4134 void
4135 _TableViewItem::SetChildControlCenterAlign(bool centerAlign)
4136 {
4137         __childControlCenterAlign = centerAlign;
4138 }
4139
4140 Point
4141 _TableViewItem::GetLastTouchPressedPosition(void)
4142 {
4143         return _CoordinateSystemUtils::ConvertToInteger(__touchStartPosition);
4144 }
4145
4146 FloatPoint
4147 _TableViewItem::GetLastTouchPressedPositionF(void)
4148 {
4149         return __touchStartPosition;
4150 }
4151
4152 void
4153 _TableViewItem::SetLastTouchPressedPosition(FloatPoint position)
4154 {
4155         // This function was made to modify of ListView::RefreshList().
4156         // This function could adversely affect touch event handling. So, you should be used with caution.
4157         __touchStartPosition = position;
4158 }
4159
4160 void
4161 _TableViewItem::SetLastTouchPressedPosition(Point position)
4162 {
4163         // This function was made to modify of ListView::RefreshList().
4164         // This function could adversely affect touch event handling. So, you should be used with caution.
4165         __touchStartPosition = _CoordinateSystemUtils::ConvertToFloat(position);
4166 }
4167
4168 bool
4169 _TableViewItem::GetSelectionState(void)
4170 {
4171         return __itemSelected;
4172 }
4173
4174 void
4175 _TableViewItem::SetSelectionState(bool selected)
4176 {
4177         // This function was made to modify of ListView::RefreshList().
4178         // This function could adversely affect touch event handling. So, you should be used with caution.
4179         __itemSelected = selected;
4180 }
4181
4182 bool
4183 _TableViewItem::MoveItem(FloatPoint position, int duration, int delay)
4184 {
4185         _VisualElement* pVisualElement = GetVisualElement();
4186         VisualElementValueAnimation* pAnimation = null;
4187         String animationName = L"MOVE_ITEM";
4188         FloatPoint itemPosition = GetPositionF();
4189         result r = E_SUCCESS;
4190
4191         if (position == itemPosition)
4192         {
4193                 return false;
4194         }
4195
4196         if (__pMoveItemAnimation == null)
4197         {
4198                 __pMoveItemAnimation = new (std::nothrow) VisualElementValueAnimation;
4199                 SysTryCatch(NID_UI_CTRL, __pMoveItemAnimation != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4200
4201                 __pMoveItemAnimation->SetVisualElementAnimationTickEventListener(this);
4202                 r = GetLastResult();
4203                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4204
4205                 __pMoveItemAnimation->SetVisualElementAnimationStatusEventListener(this);
4206                 r = GetLastResult();
4207                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4208         }
4209
4210         pAnimation = __pMoveItemAnimation;
4211
4212         pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut"));
4213         pAnimation->SetDuration(duration);
4214         pAnimation->SetDelay(delay);
4215         pAnimation->SetStartValue(Variant(GetPositionF()));
4216         pAnimation->SetEndValue(Variant(position));
4217
4218         if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
4219         {
4220                 return false;
4221         }
4222
4223         __animationCount++;
4224
4225         return true;
4226
4227 CATCH:
4228
4229         delete __pMoveItemAnimation;
4230         __pMoveItemAnimation = null;
4231
4232         return false;
4233 }
4234
4235 bool
4236 _TableViewItem::ZoomInOutItem(bool zoomOut, int duration, int delay)
4237 {
4238         _VisualElement* pVisualElement = GetVisualElement();
4239         VisualElementValueAnimation* pAnimation = null;
4240         String animationName = L"ZOOM_IN_OUT_ITEM";
4241         FloatDimension itemSize = GetSizeF();
4242         FloatDimension startValue;
4243         FloatDimension endValue;
4244         result r = E_SUCCESS;
4245
4246         if (__pZoomInOutItemAnimation == null)
4247         {
4248                 __pZoomInOutItemAnimation = new (std::nothrow) VisualElementValueAnimation;
4249                 SysTryCatch(NID_UI_CTRL, __pZoomInOutItemAnimation != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4250
4251                 __pZoomInOutItemAnimation->SetVisualElementAnimationTickEventListener(this);
4252                 r = GetLastResult();
4253                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4254
4255                 __pZoomInOutItemAnimation->SetVisualElementAnimationStatusEventListener(this);
4256                 r = GetLastResult();
4257                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4258         }
4259
4260         pAnimation = __pZoomInOutItemAnimation;
4261
4262         if (zoomOut)
4263         {
4264                 startValue = itemSize;
4265                 endValue = FloatDimension(itemSize.width, itemSize.height / 2);
4266                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut"));
4267         }
4268         else
4269         {
4270                 startValue = FloatDimension(itemSize.width, itemSize.height / 2);
4271                 endValue = itemSize;
4272                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn"));
4273         }
4274
4275         pAnimation->SetDuration(duration);
4276         pAnimation->SetDelay(delay);
4277         pAnimation->SetStartValue(Variant(startValue));
4278         pAnimation->SetEndValue(Variant(endValue));
4279
4280         if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
4281         {
4282                 return false;
4283         }
4284
4285         __animationCount++;
4286
4287         return true;
4288
4289 CATCH:
4290         delete __pZoomInOutItemAnimation;
4291         __pZoomInOutItemAnimation = null;
4292
4293         return false;
4294 }
4295
4296 bool
4297 _TableViewItem::FadeInOutItem(bool fadeOut, int duration, int delay)
4298 {
4299         _VisualElement* pVisualElement = GetVisualElement();
4300         VisualElementValueAnimation* pAnimation = null;
4301         String animationName = L"FADE_IN_OUT_ITEM";
4302         float startValue = 0.0f;
4303         float endValue = 1.0f;
4304         result r = E_SUCCESS;
4305
4306         if (__pFadeInOutItemtAnimation == null)
4307         {
4308                 __pFadeInOutItemtAnimation = new (std::nothrow) VisualElementValueAnimation;
4309                 SysTryCatch(NID_UI_CTRL, __pFadeInOutItemtAnimation != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4310
4311                 __pFadeInOutItemtAnimation->SetVisualElementAnimationTickEventListener(this);
4312                 r = GetLastResult();
4313                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4314
4315                 __pFadeInOutItemtAnimation->SetVisualElementAnimationStatusEventListener(this);
4316                 r = GetLastResult();
4317                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4318         }
4319
4320         pAnimation = __pFadeInOutItemtAnimation;
4321
4322         if (fadeOut)
4323         {
4324                 startValue = 1.0f;
4325                 endValue = 0.0f;
4326                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut"));
4327         }
4328         else
4329         {
4330                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn"));
4331         }
4332
4333         pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseIn"));
4334         pAnimation->SetDuration(duration);
4335         pAnimation->SetDelay(delay);
4336         pAnimation->SetStartValue(Variant(startValue));
4337         pAnimation->SetEndValue(Variant(endValue));
4338
4339         if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
4340         {
4341                 return false;
4342         }
4343
4344         pVisualElement->SetOpacity(startValue);
4345
4346         __animationCount++;
4347
4348         return true;
4349
4350 CATCH:
4351
4352         delete __pFadeInOutItemtAnimation;
4353         __pFadeInOutItemtAnimation = null;
4354
4355         return false;
4356 }
4357
4358 result
4359 _TableViewItem::SetIndividualSelectionEnabled(const _Control& control, bool enable)
4360 {
4361         result r = E_SUCCESS;
4362         if (enable)
4363         {
4364                 if (!__individualSelectionControls.Contains(control))
4365                 {
4366                         r =  __individualSelectionControls.Add(control);
4367                 }
4368
4369                 _AccessibilityContainer* pContainer = const_cast<_Control*>(&control)->GetAccessibilityContainer();
4370                 pContainer->Activate(true);
4371                 int controlCount = 0;
4372                 for (int i=0; i<GetChildCount(); i++)
4373                 {
4374                         _Control* pChildControl = GetChild(i);
4375                         if (pChildControl == static_cast<_Control*>(__pItemAnnexLeftDivider)
4376                                 || pChildControl == static_cast<_Control*>(__pItemAnnexRightDivider)
4377                                 || pChildControl == static_cast<_Control*>(__pItemCover)
4378                                 || pChildControl == static_cast<_Control*>(__pItemDivider)
4379                                 || pChildControl== static_cast<_Control*>(__pItemTopDivider))
4380                         {
4381                                 continue;
4382                         }
4383
4384                         controlCount++;
4385                 }
4386
4387                 if (controlCount == 0 || __individualSelectionControls.GetCount() == controlCount)
4388                 {
4389                         GetAccessibilityContainer()->Activate(false);
4390                 }
4391                 else
4392                 {
4393                         GetAccessibilityContainer()->Activate(true);
4394                 }
4395         }
4396         else
4397         {
4398                 if (__individualSelectionControls.Contains(control))
4399                 {
4400                         r = __individualSelectionControls.Remove(control, false);
4401                 }
4402         }
4403         return r;
4404 }
4405
4406 bool
4407 _TableViewItem::IsIndividualSelectionEnabled(const _Control& control)
4408 {
4409         return __individualSelectionControls.Contains(control);
4410 }
4411
4412 int
4413 _TableViewItem::AddRef(void)
4414 {
4415         return ++__refCount;
4416 }
4417
4418 int
4419 _TableViewItem::Release(void)
4420 {
4421         --__refCount;
4422         if (__refCount <= 0)
4423         {
4424                 delete this;
4425                 return 0;
4426         }
4427
4428         return __refCount;
4429 }
4430
4431 bool
4432 _TableViewItem::IsAnimationPlaying(void)
4433 {
4434         if (__animationCount > 0)
4435         {
4436                 return true;
4437         }
4438
4439         return false;
4440 }
4441
4442 void
4443 _TableViewItem::StopAllAnimation(void)
4444 {
4445         _VisualElement* pVisualElement = GetVisualElement();
4446
4447         pVisualElement->RemoveAllAnimations();
4448 }
4449
4450 void
4451 _TableViewItem::SetItemDividerEnabled(bool enable)
4452 {
4453         __itemDividerEnabled = enable;
4454 }
4455
4456 void
4457 _TableViewItem::OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue)
4458 {
4459         if (keyName == L"MOVE_ITEM")
4460         {
4461                 FloatPoint position = currentValue.ToFloatPoint();
4462                 SetPosition(position);
4463         }
4464         else if (keyName == L"FADE_IN_OUT_ITEM")
4465         {
4466                 float opacity = currentValue.ToFloat();
4467
4468                 _VisualElement* pVisualElement = GetVisualElement();
4469
4470                 if (pVisualElement != null)
4471                 {
4472                         pVisualElement->SetOpacity(opacity);
4473                 }
4474         }
4475         else if (keyName == L"ZOOM_IN_OUT_ITEM")
4476         {
4477                 FloatDimension size = currentValue.ToFloatDimension();
4478                 SetSize(size);
4479         }
4480 }
4481
4482 void
4483 _TableViewItem::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
4484 {
4485         if (keyName == L"MOVE_ITEM")
4486         {
4487                 __isMoveItemAnimationEnabled = true;
4488         }
4489         else if (keyName == L"FADE_IN_OUT_ITEM")
4490         {
4491                 __isFadeInOutItemAnimationEnabled = true;
4492         }
4493         else if (keyName == L"ZOOM_IN_OUT_ITEM")
4494         {
4495                 __isZoomInOutItemAnimationEnabled = true;
4496         }
4497 }
4498
4499 void
4500 _TableViewItem::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
4501 {
4502 }
4503
4504 void
4505 _TableViewItem::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
4506 {
4507         if (__isAnimationCallbackBlocked)
4508         {
4509                 return;
4510         }
4511
4512         bool tableViewItemAnimation = true;
4513         const VisualElementValueAnimation *pAnimation = dynamic_cast<const VisualElementValueAnimation*>(&(animation));
4514
4515         if (keyName == L"MOVE_ITEM")
4516         {
4517                 if (pAnimation != null)
4518                 {
4519                         FloatPoint position = pAnimation->GetEndValue().ToFloatPoint();
4520
4521                         SetPosition(position);
4522                 }
4523                 __isMoveItemAnimationEnabled = false;
4524         }
4525         else if (keyName == L"FADE_IN_OUT_ITEM")
4526         {
4527                 if (pAnimation != null)
4528                 {
4529                         float opacity = pAnimation->GetEndValue().ToFloat();
4530
4531                         _VisualElement* pVisualElement = GetVisualElement();
4532
4533                         if (pVisualElement != null)
4534                         {
4535                                 pVisualElement->SetOpacity(opacity);
4536                                 Invalidate();
4537                         }
4538                 }
4539                 __isFadeInOutItemAnimationEnabled = false;
4540         }
4541         else if (keyName == L"ZOOM_IN_OUT_ITEM")
4542         {
4543                 if (pAnimation != null)
4544                 {
4545                         FloatDimension size = pAnimation->GetEndValue().ToFloatDimension();
4546
4547                         SetSize(size);
4548                 }
4549                 __isZoomInOutItemAnimationEnabled = false;
4550         }
4551         else
4552         {
4553                 tableViewItemAnimation = false;
4554         }
4555
4556         if (tableViewItemAnimation)
4557         {
4558                 __animationCount--;
4559         }
4560
4561         return;
4562 }
4563
4564 result
4565 _TableViewItem::OnAttachedToMainTree(void)
4566 {
4567         if (!_FloatCompare(GetBoundsF().height, 0.0f))
4568         {
4569                 SetAccessibilityElement();
4570         }
4571
4572         return E_SUCCESS;
4573 }
4574
4575 void
4576 _TableViewItem::SetAccessibilityElement(void)
4577 {
4578         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
4579
4580         if (pContainer != null)
4581         {
4582                 if (__pAccessibilityElement == null)
4583                 {
4584                         __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
4585                         SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4586
4587                         __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
4588                         __pAccessibilityElement->SetName(L"TableViewItem");
4589
4590                         pContainer->AddElement(*__pAccessibilityElement);
4591                 }
4592                 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f,0.0f, GetBoundsF().width, GetBoundsF().height));
4593
4594                 if (__pAccessibilityOnOffElement == null && __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
4595                 {
4596                         __pAccessibilityOnOffElement = new (std::nothrow) _AccessibilityElement(true);
4597                         SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityOnOffElement, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4598
4599                         __pAccessibilityOnOffElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_ON_OFF_BUTTON_T_TTS");
4600                         __pAccessibilityOnOffElement->SetName(L"OnOffButton");
4601                         __pAccessibilityOnOffElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_MOVE_TO_CONTENT_T_TTS");
4602
4603                         pContainer->AddElement(*__pAccessibilityOnOffElement);
4604                         __pAccessibilityOnOffElement->SetBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f));
4605                 }
4606         }
4607 }
4608
4609 _AccessibilityElement*
4610 _TableViewItem::GetAccessibilityElement(void)
4611 {
4612         return __pAccessibilityElement;
4613 }
4614 void
4615 _TableViewItem::SetAccessibilityElementTrait(void)
4616 {
4617         if (__pAccessibilityElement == null)
4618         {
4619                 return;
4620         }
4621         int groupIndex = -1;
4622         int itemIndex = -1;
4623
4624         switch (__annexStyle)
4625         {
4626         case TABLE_VIEW_ANNEX_STYLE_NORMAL:
4627                 GetItemIndex(groupIndex, itemIndex);
4628                 if (groupIndex != -1 && itemIndex == -1)
4629                 {
4630                         __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_GROUP_INDEX");
4631                 }
4632                 break;
4633
4634         case TABLE_VIEW_ANNEX_STYLE_MARK:
4635                 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_TICKBOX_T_TTS");
4636                 break;
4637
4638         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
4639                 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_ON_OFF_BUTTON_T_TTS");
4640                 break;
4641
4642         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
4643                 break;
4644
4645         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
4646                 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_BUTTON_T_TTS");
4647                 break;
4648
4649         case TABLE_VIEW_ANNEX_STYLE_RADIO:
4650                 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_RADIO_BUTTON_T_TTS");
4651                 break;
4652
4653         default:
4654                 break;
4655         }
4656 }
4657 void
4658 _TableViewItem::SetAccessibilityElementValue(void)
4659 {
4660         if (__pAccessibilityElement == null)
4661         {
4662                 return;
4663         }
4664
4665         switch (__annexStyle)
4666         {
4667         case TABLE_VIEW_ANNEX_STYLE_MARK:
4668                 if (IsChecked())
4669                 {
4670                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_TICK_T_TTS");
4671                 }
4672                 else
4673                 {
4674                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_UNTICK_T_TTS");
4675                 }
4676                 break;
4677
4678         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
4679                 if (IsChecked())
4680                 {
4681                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_ON");
4682                 }
4683                 else
4684                 {
4685                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_OFF");
4686                 }
4687                 break;
4688
4689         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
4690                 if (IsChecked())
4691                 {
4692                         if (__pAccessibilityOnOffElement != null)
4693                         {
4694                                 __pAccessibilityOnOffElement->SetValueWithStringId("IDS_TPLATFORM_BODY_ON");
4695                         }
4696                 }
4697                 else
4698                 {
4699                         if (__pAccessibilityOnOffElement != null)
4700                         {
4701                                 __pAccessibilityOnOffElement->SetValueWithStringId("IDS_TPLATFORM_BODY_OFF");
4702                         }
4703                 }
4704                 break;
4705
4706         case TABLE_VIEW_ANNEX_STYLE_RADIO:
4707                 if (IsChecked())
4708                 {
4709                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_SELECTED_T_TTS");
4710                 }
4711                 else
4712                 {
4713                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_NOT_SELECTED_T_TTS");
4714                 }
4715                 break;
4716
4717         default:
4718                 break;
4719         }
4720 }
4721 void
4722 _TableViewItem::SetAccessibilityElementLabel(void)
4723 {
4724         if (__pAccessibilityElement == null)
4725         {
4726                 return;
4727         }
4728
4729         if (__pAccessibilityElement->IsPublicLabelUpdated())
4730         {
4731                 return;
4732         }
4733
4734         String accessibilityLabel;
4735         String space = L" ";
4736         int childControlCount = GetChildCount();
4737
4738         for (int i = 0; i < childControlCount; i++)
4739         {
4740                 _Control* pChildControl = GetChild(i);
4741
4742                 if (pChildControl == null)
4743                 {
4744                         continue;
4745                 }
4746
4747                 if (__pItemDivider == pChildControl || __pItemTopDivider == pChildControl || __pItemCover == pChildControl)
4748                 {
4749                         continue;
4750                 }
4751
4752                 accessibilityLabel += GetChildAccessibilityLabelContent(*pChildControl);
4753                 accessibilityLabel += space;
4754         }
4755
4756         __pAccessibilityElement->SetLabel(accessibilityLabel);
4757 }
4758
4759
4760 bool
4761 _TableViewItem::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4762 {
4763         return false;
4764 }
4765
4766 bool
4767 _TableViewItem::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4768 {
4769         return false;
4770 }
4771
4772 bool
4773 _TableViewItem::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4774 {
4775         return false;
4776 }
4777
4778 bool
4779 _TableViewItem::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4780 {
4781         SetAccessibilityElementLabel();
4782         SetAccessibilityElementTrait();
4783         SetAccessibilityElementValue();
4784         return false;
4785 }
4786
4787 bool
4788 _TableViewItem::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4789 {
4790         return false;
4791 }
4792
4793 bool
4794 _TableViewItem::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4795 {
4796         return false;
4797 }
4798
4799 bool
4800 _TableViewItem::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4801 {
4802         switch (__annexStyle)
4803         {
4804         case TABLE_VIEW_ANNEX_STYLE_NORMAL:
4805                 break;
4806
4807         case TABLE_VIEW_ANNEX_STYLE_MARK:
4808                 if (IsChecked())
4809                 {
4810                         String string;
4811                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_TICK_T_TTS,string);
4812                         _AccessibilityManager::GetInstance()->ReadContent(string);
4813                 }
4814                 else
4815                 {
4816                         String string;
4817                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_UNTICK_T_TTS,string);
4818                         _AccessibilityManager::GetInstance()->ReadContent(string);
4819                 }
4820                 break;
4821         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
4822                 if (IsChecked())
4823                 {
4824                         String string;
4825                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_ON,string);
4826                         _AccessibilityManager::GetInstance()->ReadContent(string);
4827                 }
4828                 else
4829                 {
4830                         String string;
4831                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_OFF,string);
4832                         _AccessibilityManager::GetInstance()->ReadContent(string);
4833                 }
4834                 break;
4835
4836         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
4837                 if (&element == __pAccessibilityOnOffElement && IsEnabled())
4838                 {
4839                         if (IsChecked())
4840                         {
4841                                 SetChecked(false);
4842                                 String string;
4843                                 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_OFF,string);
4844                                 _AccessibilityManager::GetInstance()->ReadContent(string);
4845                         }
4846                         else
4847                         {
4848                                 SetChecked(true);
4849                                 String string;
4850                                 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_ON,string);
4851                                 _AccessibilityManager::GetInstance()->ReadContent(string);
4852                         }
4853                 }
4854                 break;
4855
4856         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
4857                 break;
4858
4859         case TABLE_VIEW_ANNEX_STYLE_RADIO:
4860                 if (IsChecked())
4861                 {
4862                         String string;
4863                         GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT,string);
4864                         _AccessibilityManager::GetInstance()->ReadContent(string);
4865                 }
4866                 else
4867                 {
4868                         String string;
4869                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_NOT_SELECTED_T_TTS,string);
4870                         _AccessibilityManager::GetInstance()->ReadContent(string);
4871                 }
4872                 break;
4873         default:
4874                 break;
4875         }
4876
4877         return false;
4878 }
4879
4880 bool
4881 _TableViewItem::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4882 {
4883         return false;
4884 }
4885
4886 bool
4887 _TableViewItem::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4888 {
4889         return false;
4890 }
4891
4892 bool
4893 _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
4894 {
4895         __isTouchCancelOnPressRelease = false;
4896
4897         if (!IsFocusModeStateEnabled())
4898         {
4899                 return false;
4900         }
4901
4902         if (IsReorderMode() || IsAnimationPlaying())
4903         {
4904                 return false;
4905         }
4906
4907         _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
4908         _KeyCode keyCode = keyInfo.GetKeyCode();
4909         IListT<_Control*>* pFocusList = GetFocusListN();
4910         SysTryReturn(NID_UI_CTRL, pFocusList != null, true, GetLastResult(), "[%s] propagating.", GetErrorMessage(GetLastResult()));
4911
4912         _Control* pChildControl = null;
4913         _Control* pFocusedControl = null;
4914         _Window* pTop = source.GetRootWindow();
4915
4916         if (pTop)
4917         {
4918                 pFocusedControl = pTop->GetCurrentFocusControl();
4919         }
4920
4921         int count  = pFocusList->GetCount();
4922
4923         if (pFocusedControl == null)
4924         {
4925                   return false;
4926         }
4927
4928         switch (keyCode)
4929         {
4930         case _KEY_LEFT:
4931                 if (!IsFocused())
4932                 {
4933                         for (int i=count-1; i>=0; i--)
4934                         {
4935                                 pFocusList->GetAt(i, pChildControl);
4936                                 if (pChildControl == null)
4937                                 {
4938                                         continue;
4939                                 }
4940
4941                                 if (pChildControl->IsFocused())
4942                                 {
4943                                         if (i == 0)
4944                                         {
4945                                                 pChildControl = null;
4946                                                 break;
4947                                         }
4948
4949                                         for (int j=i-1; j>=0; j--)
4950                                         {
4951                                                 pFocusList->GetAt(j, pChildControl);
4952                                                 if (pChildControl == null)
4953                                                 {
4954                                                         continue;
4955                                                 }
4956
4957                                                 if (pChildControl->IsFocusable() && pChildControl->GetEnableState()
4958                                                                 && pChildControl->GetVisibleState())
4959                                                 {
4960                                                         break;
4961                                                 }
4962                                                 else
4963                                                 {
4964                                                         pChildControl = null;
4965                                                 }
4966                                         }
4967                                         break;
4968                                 }
4969                         }
4970
4971                         if (pChildControl && pChildControl->GetEnableState()
4972                                         && pChildControl->GetVisibleState() && pChildControl->IsFocusable())
4973                         {
4974                                 if (pParent != null)
4975                                 {
4976                                         pParent->SetAnnexFocused(true);
4977                                 }
4978                                 pChildControl->SetFocused(true);
4979                                 pChildControl->DrawFocus();
4980                         }
4981                         else
4982                         {
4983                                 _Control* pParentControl = pFocusedControl->GetParent();
4984                                 _TableViewItem* pItem = dynamic_cast<_TableViewItem*>(pParentControl);
4985
4986                                 if (pItem != null && pItem->GetEnableState() && !pItem->IsFocused()
4987                                                 && pItem->GetVisibleState() && pItem->IsFocusable())
4988                                 {
4989                                         if (pParent != null)
4990                                         {
4991                                                 pParent->SetAnnexFocused(false);
4992                                         }
4993                                         pItem->SetFocused(true);
4994                                         pItem->DrawFocus();
4995                                 }
4996                         }
4997                 }
4998                 break;
4999
5000         case _KEY_RIGHT:
5001                 if (IsFocused())
5002                 {
5003                         if (pChildControl == null)
5004                         {
5005                                 for (int i=0; i<count; i++)
5006                                 {
5007                                         pFocusList->GetAt(i, pChildControl);
5008                                         if (pChildControl == null)
5009                                         {
5010                                                 continue;
5011                                         }
5012
5013                                         if (pChildControl->IsFocusable() && pChildControl->GetEnableState()
5014                                                         && pChildControl->GetVisibleState())
5015                                         {
5016                                                 break;
5017                                         }
5018                                         else
5019                                         {
5020                                                 pChildControl = null;
5021                                         }
5022                                 }
5023                         }
5024                 }
5025                 else
5026                 {
5027                         for (int i=0; i<count; i++)
5028                         {
5029                                 pFocusList->GetAt(i, pChildControl);
5030                                 if (pChildControl == null)
5031                                 {
5032                                         continue;
5033                                 }
5034
5035                                 if (pChildControl->IsFocused())
5036                                 {
5037                                         if (i == count -1)
5038                                         {
5039                                                 pChildControl = null;
5040                                                 break;
5041                                         }
5042
5043                                         for (int j=i+1; j<count; j++)
5044                                         {
5045                                                 pFocusList->GetAt(j, pChildControl);
5046                                                 if (pChildControl == null)
5047                                                 {
5048                                                         continue;
5049                                                 }
5050
5051                                                 if (pChildControl->IsFocusable() && pChildControl->GetEnableState()
5052                                                                 && pChildControl->GetVisibleState())
5053                                                 {
5054                                                         break;
5055                                                 }
5056                                                 else
5057                                                 {
5058                                                         pChildControl = null;
5059                                                 }
5060                                         }
5061                                         break;
5062                                 }
5063                         }
5064                 }
5065
5066                 if (pChildControl && pChildControl->GetEnableState() && pChildControl->GetVisibleState()
5067                                 && pChildControl->IsFocusable())
5068                 {
5069                         if (pParent != null)
5070                         {
5071                                 pParent->SetAnnexFocused(true);
5072                         }
5073                         pChildControl->SetFocused(true);
5074                         pChildControl->DrawFocus();
5075                 }
5076                 break;
5077
5078         case _KEY_ENTER:
5079                 if (&source == this)
5080                 {
5081                         __pressedControl = TABLE_VIEW_ITEM_PRESSED_ITEM;
5082                 }
5083                 else if (&source == GetLabelCore(__pItemAnnex))
5084                 {
5085                         __pressedControl = TABLE_VIEW_ITEM_PRESSED_ANNEX;
5086                 }
5087                 else if (IsIndividualSelectionEnabled(source))
5088                 {
5089                         __pressedControl = TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL;
5090                 }
5091                 else
5092                 {
5093                         __pressedControl = TABLE_VIEW_ITEM_PRESSED_NONE;
5094                 }
5095                 __itemSelected = true;
5096                 FireItemTouchPressed();
5097                 break;
5098
5099         default:
5100                 if (__itemSelected)
5101                 {
5102                         __annexOnOffHandlerMoved = false;
5103                         __itemTouchMoved = false;
5104
5105                         __itemSelected = false;
5106                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
5107
5108                         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
5109                         {
5110                                 __isSelectedDetailButton = false;
5111                         }
5112
5113                         SetItemChanged(true);
5114                         Invalidate();
5115                 }
5116                 return false;
5117         }
5118
5119         return true;
5120 }
5121
5122 bool
5123 _TableViewItem::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
5124 {
5125         if (!IsFocusModeStateEnabled())
5126         {
5127                 return false;
5128         }
5129
5130         if (IsReorderMode() || IsAnimationPlaying())
5131         {
5132                 return false;
5133         }
5134
5135         _KeyCode keyCode = keyInfo.GetKeyCode();
5136
5137         if (keyCode == _KEY_ENTER)
5138         {
5139                 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
5140                 SysTryReturn(NID_UI_CTRL, pParent != null, true, GetLastResult(), "[%s] propagating.", GetErrorMessage(GetLastResult()));
5141
5142                 pParent->StopExpandCollapseAnimation();
5143                 if (&source == this)
5144                 {
5145                         __releasedControl = TABLE_VIEW_ITEM_PRESSED_ITEM;
5146                 }
5147                 else if (&source == GetLabelCore(__pItemAnnex))
5148                 {
5149                         __releasedControl = TABLE_VIEW_ITEM_PRESSED_ANNEX;
5150                 }
5151                 else if (IsIndividualSelectionEnabled(source))
5152                 {
5153                         __releasedControl = TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL;
5154                 }
5155                 else
5156                 {
5157                         __releasedControl = TABLE_VIEW_ITEM_PRESSED_NONE;
5158                 }
5159                 FireItemTouchReleased(false);
5160                 return true;
5161         }
5162         else if (keyCode == _KEY_LEFT || keyCode == _KEY_RIGHT)
5163         {
5164                 return true;
5165         }
5166
5167         return false;
5168 }
5169
5170 void
5171 _TableViewItem::OnFocusModeStateChanged(void)
5172 {
5173         ResetItemState();
5174 }
5175
5176 void
5177 _TableViewItem::ResetItemState(void)
5178 {
5179         __itemSelected = false;
5180         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
5181         __releasedControl = TABLE_VIEW_ITEM_PRESSED_NONE;
5182
5183         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
5184         {
5185                 __isSelectedDetailButton = false;
5186         }
5187
5188         SetItemChanged(true);
5189         Invalidate();
5190 }
5191
5192 _Control*
5193 _TableViewItem::GetPreviousFocusChildControl(const _Control& source)
5194 {
5195          _Control* pParentControl = null;
5196          float sourcePosition = 0.0f;
5197
5198          _Control* pSource = const_cast<_Control*>(&source);
5199          _TableViewItem* pItem = dynamic_cast<_TableViewItem*>(pSource);
5200          if (pItem != null)
5201          {
5202                  pParentControl = pSource;
5203                  sourcePosition = pParentControl->GetBoundsF().width;
5204          }
5205          else
5206          {
5207                  pParentControl = source.GetParent();
5208                  sourcePosition = source.GetBoundsF().x;
5209          }
5210
5211          if (pParentControl == null)
5212          {
5213                  return null;
5214          }
5215
5216          int childControlCount = pParentControl->GetChildCount();
5217          float position = 0.0f;
5218          _Control* destination = null;
5219
5220          for (int i=0; i<childControlCount; i++)
5221          {
5222                  _Control* pChildControl = pParentControl->GetChild(i);
5223                  if (pChildControl != null && pChildControl->IsFocusable())
5224                  {
5225                          float childPosition = pChildControl->GetBoundsF().x;
5226                          if (childPosition < sourcePosition)
5227                          {
5228                                  if (childPosition > position)
5229                                  {
5230                                          position = childPosition;
5231                                          destination = pChildControl;
5232                                  }
5233                                  else if (_FloatCompare(position, 0.0f))
5234                                  {
5235                                          position = childPosition;
5236                                          destination = pChildControl;
5237                                  }
5238                          }
5239                  }
5240          }
5241          return destination;
5242 }
5243
5244 _Control*
5245 _TableViewItem::GetNextFocusChildControl(const _Control& source)
5246 {
5247          _Control* pParentControl = null;
5248          float sourcePosition = 0.0f;
5249
5250          _Control* pSource = const_cast<_Control*>(&source);
5251          _TableViewItem* pItem = dynamic_cast<_TableViewItem*>(pSource);
5252          if (pItem != null)
5253          {
5254                  pParentControl = pSource;
5255                  sourcePosition = 0.0f;
5256          }
5257          else
5258          {
5259                  pParentControl = source.GetParent();
5260                  sourcePosition = source.GetBoundsF().x;
5261          }
5262
5263          if (pParentControl == null)
5264          {
5265                  return null;
5266          }
5267
5268          int childControlCount = pParentControl->GetChildCount();
5269          float position = 0.0f;
5270          _Control* destination = null;
5271
5272          for (int i=0; i<childControlCount; i++)
5273          {
5274                  _Control* pChildControl = pParentControl->GetChild(i);
5275                  if (pChildControl != null && pChildControl->IsFocusable())
5276                  {
5277                          float childPosition = pChildControl->GetBoundsF().x;
5278                          if (childPosition > sourcePosition)
5279                          {
5280                                  if (childPosition < position)
5281                                  {
5282                                          position = childPosition;
5283                                          destination = pChildControl;
5284                                  }
5285                                  else if (_FloatCompare(position, 0.0f))
5286                                  {
5287                                          position = childPosition;
5288                                          destination = pChildControl;
5289                                  }
5290                          }
5291                  }
5292          }
5293          return destination;
5294 }
5295
5296 bool
5297 _TableViewItem::IsChildControlFocusManage(void) const
5298 {
5299         return true;
5300 }
5301
5302 void
5303 _TableViewItem::SetSimpleLastItemEnabled(bool enable)
5304 {
5305         __isSimpleLastItem = enable;
5306 }
5307
5308 void
5309 _TableViewItem::SetSectionItem(bool isSectionItem)
5310 {
5311     __isSectionItem = isSectionItem;
5312 }
5313
5314 void
5315 _TableViewItem::SetTouchPressOnScroll(bool isTouch)
5316 {
5317         __isTouchPressOnScroll = isTouch;
5318 }
5319
5320 bool
5321 _TableViewItem::IsTouchPressOnScroll(void) const
5322 {
5323         return __isTouchPressOnScroll;
5324 }
5325
5326 void
5327 _TableViewItem::OnVisibleStateChanged(void)
5328 {
5329         if (IsFocused() && !GetVisibleState())
5330         {
5331                 RemoveFocusRing();
5332         }
5333 }
5334
5335 void
5336 _TableViewItem::OnAncestorEnableStateChanged(const _Control& control)
5337 {
5338         if (IsFocused() && !IsEnabled())
5339         {
5340                 RemoveFocusRing();
5341         }
5342 }
5343
5344 void
5345 _TableViewItem::OnAncestorVisibleStateChanged(const _Control& control)
5346 {
5347         if (IsFocused() && !IsVisible())
5348         {
5349                 RemoveFocusRing();
5350         }
5351 }
5352
5353 void
5354 _TableViewItem::OnFocusableStateChanged(bool focusableState)
5355 {
5356         if (IsFocused() && !focusableState)
5357         {
5358                 RemoveFocusRing();
5359         }
5360 }
5361
5362 void
5363 _TableViewItem::SetPublicLabelUpdate(bool resetPublicLabelUpdate)
5364 {
5365         if (__pAccessibilityElement)
5366         {
5367                 __pAccessibilityElement->SetPublicLabelUpdate(resetPublicLabelUpdate);
5368         }
5369 }
5370
5371 String
5372 _TableViewItem::GetChildAccessibilityLabelContent(const _Control& source)
5373 {
5374         String accessibilityLabel = L"";
5375         String space = L" ";
5376
5377         if (IsIndividualSelectionEnabled(source))
5378         {
5379                 return accessibilityLabel;
5380         }
5381
5382         if (!source.IsVisible() || !source.GetEnableState())
5383         {
5384                 return accessibilityLabel;
5385         }
5386
5387         _Control* pSource = const_cast<_Control*>(&source);
5388
5389         if (pSource)
5390         {
5391                 _AccessibilityContainer* pContainer = pSource->GetAccessibilityContainer();
5392                 LinkedListT<_AccessibilityElement*> accessibilityElements;
5393                 _AccessibilityElement* pElement = null;
5394
5395                 if (pContainer)
5396                 {
5397                         pContainer->GetElements(accessibilityElements);
5398                         int elementCount = accessibilityElements.GetCount();
5399
5400                         for (int i = 0; i < elementCount; i++)
5401                         {
5402                                 if (accessibilityElements.GetAt(i, pElement) == E_SUCCESS)
5403                                 {
5404                                         accessibilityLabel += pElement->GetLabel();
5405                                         accessibilityLabel += space;
5406                                 }
5407                         }
5408                 }
5409         }
5410
5411         //check for children
5412         int childControlCount = source.GetChildCount();
5413
5414         for (int i = 0; i < childControlCount; i++)
5415         {
5416                 _Control* pChildControl = source.GetChild(i);
5417
5418                 if (pChildControl == null)
5419                 {
5420                         continue;
5421                 }
5422
5423                 accessibilityLabel += GetChildAccessibilityLabelContent(*pChildControl);
5424         }
5425
5426         return accessibilityLabel;
5427 }
5428
5429 void
5430 _TableViewItem::DeactivateChildAccessibilityContainer(const _Control& source)
5431 {
5432         _Control* pControl = const_cast<_Control*>(&source);
5433
5434         if (pControl)
5435         {
5436                 _AccessibilityContainer* pContainer = pControl->GetAccessibilityContainer();
5437
5438                 if (pContainer)
5439                 {
5440                         if (__individualSelectionControls.Contains(source))
5441                         {
5442                                 pContainer->Activate(true);
5443                         }
5444                         else
5445                         {
5446                                 pContainer->Activate(false);
5447                         }
5448                 }
5449         }
5450
5451         //check for children
5452         int childControlCount = source.GetChildCount();
5453
5454         for (int i = 0; i < childControlCount; i++)
5455         {
5456                 _Control* pChildControl = source.GetChild(i);
5457
5458                 if (pChildControl == null)
5459                 {
5460                         continue;
5461                 }
5462
5463                 DeactivateChildAccessibilityContainer(*pChildControl);
5464         }
5465 }
5466
5467 }}} // Tizen::Ui::Controls
5468