Merge "apply E_SUCCESS return" into tizen_2.2
[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();
282         delete __pPressedTimer;
283         __pPressedTimer = null;
284
285         StopTouchReleasedTimer();
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* label)
730 {
731         if (label == null)
732         {
733                 return null;
734         }
735
736         _LabelImpl* pImpl = _LabelImpl::GetInstance(*label);
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()
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                 FireItemEvent(selectedItem);
1518         }
1519 }
1520
1521 bool
1522 _TableViewItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1523 {
1524         if (IsReorderMode())
1525         {
1526                 return false;
1527         }
1528
1529         if (IsTouchPressOnScroll())
1530         {
1531                 SetTouchPressOnScroll(false);
1532         }
1533
1534         if (__isPressedTimerEnabled)
1535         {
1536                 StopTouchPressedTimer();
1537         }
1538
1539         bool retVal = false;
1540
1541         if (&source == this)
1542         {
1543                 __itemSelected = false;
1544                 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1545
1546                 SetItemChanged(true);
1547                 Invalidate();
1548         }
1549         else if (&source == GetLabelCore(__pItemAnnex))
1550         {
1551                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
1552                 {
1553                         __isSelectedDetailButton = false;
1554                         __itemSelected = false;
1555                         DrawAnnexStyle();
1556                 }
1557                 else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING ||
1558                         __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
1559                 {
1560                         __annexOnOffHandlerMoved = true;
1561                         DrawAnnexOnOffHandler(touchinfo.GetCurrentPosition().x);
1562                         retVal = true;
1563                 }
1564                 else
1565                 {
1566                         __itemSelected = false;
1567                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1568
1569                         SetItemChanged(true);
1570                         Invalidate();
1571                 }
1572         }
1573         else
1574         {
1575                 if (!IsIndividualSelectionEnabled(source))
1576                 {
1577                         __itemSelected = false;
1578                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1579
1580                         SetItemChanged(true);
1581                         Invalidate();
1582                 }
1583         }
1584
1585         __itemTouchMoved = true;
1586
1587         return retVal;
1588 }
1589
1590 bool
1591 _TableViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1592 {
1593         __isTouchCancelOnPressRelease = true;
1594
1595         if (__isPressedTimerEnabled)
1596         {
1597                 StopTouchPressedTimer();
1598         }
1599
1600         __annexOnOffHandlerMoved = false;
1601         __itemTouchMoved = false;
1602
1603         ResetItemState();
1604
1605         if (&source != this)
1606         {
1607                 return false;
1608         }
1609
1610         return true;
1611 }
1612
1613 _UiTouchEventDelivery
1614 _TableViewItem::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1615 {
1616         if (IsTouchPressOnScroll())
1617         {
1618                 SetTouchPressOnScroll(false);
1619                 return _UI_TOUCH_EVENT_DELIVERY_NO;
1620         }
1621         return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1622 }
1623
1624 _UiTouchEventDelivery
1625 _TableViewItem::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1626 {
1627         return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1628 }
1629
1630 _UiTouchEventDelivery
1631 _TableViewItem::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1632 {
1633         return _UI_TOUCH_EVENT_DELIVERY_YES;
1634 }
1635
1636 _UiTouchEventDelivery
1637 _TableViewItem::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1638 {
1639         return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
1640 }
1641
1642 void
1643 _TableViewItem::OnDraw(void)
1644 {
1645         if (IsItemChanged() == true)
1646         {
1647                 DrawItemBackground();
1648                 DrawAnnexStyle();
1649                 DrawItemDivider();
1650                 DrawSimpleItem();
1651                 DrawSectionStyleBackgroundCover();
1652
1653                 SetItemChanged(false);
1654         }
1655 }
1656
1657 void
1658 _TableViewItem::OnChildAttached(const _Control& child)
1659 {
1660         _Control* pControl = const_cast<_Control*>(&child);
1661         _AccessibilityContainer* pContainer = pControl->GetAccessibilityContainer();
1662
1663         if (__individualSelectionControls.Contains(child))
1664         {
1665                 pContainer->Activate(true);
1666         }
1667         else
1668         {
1669                 pContainer->Activate(false);
1670
1671                 if (!(pControl == static_cast<_Control*>(__pItemAnnexLeftDivider)
1672                         || pControl == static_cast<_Control*>(__pItemAnnexRightDivider)
1673                         || pControl == static_cast<_Control*>(__pItemCover)
1674                         || pControl == static_cast<_Control*>(__pItemDivider)
1675                         || pControl== static_cast<_Control*>(__pItemTopDivider)))
1676                 {
1677                         GetAccessibilityContainer()->Activate(true);
1678                 }
1679         }
1680
1681         DeactivateChildAccessibilityContainer(child);
1682
1683         pControl->SetTouchPressThreshold(SENSITIVE);
1684
1685         FloatRectangle bounds = child.GetBoundsF();
1686
1687         if (__pDrawingProperty != null && __pDrawingProperty->groupedLookEnabled)
1688         {
1689                 float groupedBarMargin = 0.0f;
1690                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, groupedBarMargin);
1691
1692                 bounds.x += groupedBarMargin;
1693         }
1694
1695         if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO))
1696         {
1697                 if (GetLabelCore(__pItemAnnex) == &child ||
1698                         GetLabelCore(__pSimpleItemBitmap) == &child ||
1699                         GetLabelCore(__pSimpleItemText) == &child)
1700                 {
1701                         return;
1702                 }
1703
1704                 float leftMargin = 0.0f;
1705                 float annexWidth = 0.0f;
1706
1707                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1708                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1709
1710                 bounds.x += (leftMargin * 2) + annexWidth;
1711         }
1712
1713         pControl->SetBounds(bounds);
1714 }
1715
1716 void
1717 _TableViewItem::OnChildDetached(const _Control& child)
1718 {
1719         if (__individualSelectionControls.Contains(child))
1720         {
1721                 __individualSelectionControls.Remove(child, false);
1722         }
1723
1724         _Label* pSimpleItemTextCore = GetLabelCore(__pSimpleItemText);
1725         _Label* pSimpleItemBitmapCore = GetLabelCore(__pSimpleItemBitmap);
1726
1727         if (&child == pSimpleItemTextCore)
1728         {
1729                 __pSimpleItemText = null;
1730         }
1731
1732         if (&child == pSimpleItemBitmapCore)
1733         {
1734                 __pSimpleItemBitmap = null;
1735         }
1736 }
1737
1738 void
1739 _TableViewItem::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1740 {
1741         result r = E_SUCCESS;
1742
1743         if (&timer == __pCheckedTimer)
1744         {
1745                 if (__checkedCount < MAX_CHECKED_COUNT)
1746                 {
1747                         r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION);
1748                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1749                 }
1750
1751                 r = PlayCheckBoxAnimation();
1752                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1753
1754                 if (__checkedCount < MAX_CHECKED_COUNT)
1755                 {
1756                         __checkedCount++;
1757                 }
1758                 else
1759                 {
1760                         __checkedCount = 0;
1761                         __isCheckedAnimationEnabled = false;
1762                         __isCheckedTimerEnabled = false;
1763                 }
1764         }
1765         else if (&timer == __pPressedTimer)
1766         {
1767                 __isPressedTimerEnabled = false;
1768                 FireItemTouchPressed();
1769         }
1770         else if (&timer == __pReleasedTimer)
1771         {
1772                 __isReleasedTimerEnabled = false;
1773                 FireItemTouchReleased();
1774         }
1775 }
1776
1777 result
1778 _TableViewItem::StartTouchPressedTimer(const _Control& source, const _TouchInfo& touchinfo)
1779 {
1780         result r = E_SUCCESS;
1781
1782         if (__pPressedTimer == null)
1783         {
1784                 __pPressedTimer = new (std::nothrow) Timer();
1785                 SysTryCatch(NID_UI_CTRL, __pPressedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1786
1787                 r = __pPressedTimer->Construct(*this);
1788                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage);
1789         }
1790
1791         if (__isPressedTimerEnabled == false)
1792         {
1793                 r = __pPressedTimer->Start(TOUCH_PRESSED_DURATION);
1794                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1795
1796                 __isPressedTimerEnabled = true;
1797         }
1798
1799         return r;
1800
1801 CATCH:
1802         if (__isPressedTimerEnabled && __pPressedTimer != null)
1803         {
1804                 __pPressedTimer->Cancel();
1805         }
1806
1807         delete __pPressedTimer;
1808         __pPressedTimer = null;
1809
1810         return r;
1811 }
1812
1813 void
1814 _TableViewItem::StopTouchPressedTimer(void)
1815 {
1816         result r = E_SUCCESS;
1817
1818         if (__pPressedTimer == null)
1819         {
1820                 return;
1821         }
1822
1823         if (__isPressedTimerEnabled)
1824         {
1825                 r = __pPressedTimer->Cancel();
1826                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1827         }
1828
1829         __isPressedTimerEnabled = false;
1830
1831         return;
1832 }
1833
1834 result
1835 _TableViewItem::StartTouchReleasedTimer()
1836 {
1837         result r = E_SUCCESS;
1838
1839         if (__pReleasedTimer == null)
1840         {
1841                 __pReleasedTimer = new (std::nothrow) Timer();
1842                 SysTryCatch(NID_UI_CTRL, __pReleasedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1843
1844
1845                 r = __pReleasedTimer->Construct(*this);
1846                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage);
1847         }
1848
1849         if (!__isReleasedTimerEnabled)
1850         {
1851                 r = __pReleasedTimer->Start(TOUCH_RELEASED_DURATION);
1852                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1853         }
1854         __isReleasedTimerEnabled = true;
1855
1856         return r;
1857
1858 CATCH:
1859         if (__isReleasedTimerEnabled && __pReleasedTimer != null)
1860         {
1861                 __pReleasedTimer->Cancel();
1862         }
1863
1864         delete __pReleasedTimer;
1865         __pReleasedTimer = null;
1866
1867         return r;
1868 }
1869
1870 void
1871 _TableViewItem::StopTouchReleasedTimer(void)
1872 {
1873         result r = E_SUCCESS;
1874
1875         if (__pReleasedTimer == null)
1876         {
1877                 return;
1878         }
1879
1880         if (__isReleasedTimerEnabled)
1881         {
1882                 r = __pReleasedTimer->Cancel();
1883                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1884         }
1885
1886         __isReleasedTimerEnabled = false;
1887
1888         return;
1889 }
1890
1891 void
1892 _TableViewItem::OnAncestorInputEnableStateChanged(const _Control& control)
1893 {
1894         if (__isPressedTimerEnabled)
1895         {
1896                 StopTouchPressedTimer();
1897         }
1898
1899         __annexOnOffHandlerMoved = false;
1900         __itemTouchMoved = false;
1901
1902         __itemSelected = false;
1903         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
1904
1905         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
1906         {
1907                 __isSelectedDetailButton = false;
1908         }
1909
1910         SetItemChanged(true);
1911         Invalidate();
1912 }
1913
1914 result
1915 _TableViewItem::StartCheckBoxAnimation(void)
1916 {
1917         result r = E_SUCCESS;
1918
1919         if (__pCheckedTimer == null)
1920         {
1921                 __pCheckedTimer = new (std::nothrow) Timer();
1922                 SysTryCatch(NID_UI_CTRL, __pCheckedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1923 ;
1924
1925                 r = __pCheckedTimer->Construct(*this);
1926                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage);
1927         }
1928
1929         if (__isCheckedTimerEnabled == false)
1930         {
1931                 r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION);
1932                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1933
1934                 __isCheckedTimerEnabled = true;
1935         }
1936
1937         return r;
1938
1939 CATCH:
1940         if (__isCheckedTimerEnabled)
1941         {
1942                 __pCheckedTimer->Cancel();
1943         }
1944
1945         delete __pCheckedTimer;
1946         __pCheckedTimer = null;
1947
1948         return r;
1949 }
1950
1951 void
1952 _TableViewItem::StopCheckBoxAnimation(void)
1953 {
1954         result r = E_SUCCESS;
1955
1956         SysTryReturnVoidResult(NID_UI_CTRL, __pCheckedTimer != null, E_SYSTEM, "[%s] A system error has been occurred. Timer is invalid.", GetErrorMessage(E_SYSTEM));
1957
1958
1959         if (__isCheckedTimerEnabled)
1960         {
1961                 r = __pCheckedTimer->Cancel();
1962                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1963         }
1964
1965         __checkedCount = 0;
1966         __isCheckedAnimationEnabled = false;
1967         __isCheckedTimerEnabled = false;
1968
1969         return;
1970 }
1971
1972 result
1973 _TableViewItem::PlayCheckBoxAnimation(void)
1974 {
1975         Bitmap* pCheckBox = null;
1976         Bitmap* pCheckBoxBg = null;
1977         Bitmap* pMergeBitmap = null;
1978         Canvas* pCanvas = null;
1979         result r = E_SUCCESS;
1980
1981         FloatRectangle bounds;
1982
1983         float annexWidth = 0.0f;
1984         float annexHeight = 0.0f;
1985
1986         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1987         {
1988                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1989         }
1990         else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
1991         {
1992                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1993         }
1994         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1995
1996         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
1997         SysTryCatch(NID_UI_CTRL,(r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1998
1999         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2000         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2001
2002         bounds.SetBounds(0, 0, annexWidth, annexHeight);
2003
2004         pCanvas = new (std::nothrow) Canvas();
2005         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY,  "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2006
2007         r = pCanvas->Construct(bounds);
2008         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2009         pCanvas->Clear();
2010
2011         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg);
2012
2013         __checkedBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox);
2014         if (IsChecked() == true)
2015         {
2016                 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pCheckBox))
2017                 {
2018                         FloatRectangle drawingRect(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width, __checkedBounds.height);
2019                         r = pCanvas->DrawNinePatchedBitmap(drawingRect, *pCheckBox); // +++ check floating
2020                 }
2021                 else
2022                 {
2023                         FloatRectangle bitmapSourceRect(0.0f, 0.0f, pCheckBox->GetWidthF()*__checkedCount * 0.1, pCheckBox->GetHeightF());
2024                         FloatRectangle drawingRect(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width * __checkedCount * 0.1, __checkedBounds.height);
2025                         r = pCanvas->DrawBitmap(drawingRect, *pCheckBox, bitmapSourceRect); // +++ check floating
2026                 }
2027         }
2028
2029         pMergeBitmap = new (std::nothrow) Bitmap();
2030         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY,  "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2031
2032         pMergeBitmap->Construct(*pCanvas, bounds);
2033         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2034
2035         if (__pItemAnnex)
2036         {
2037                 __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
2038                 __pItemAnnex->Invalidate(false);
2039         }
2040
2041 CATCH:
2042         delete pCheckBox;
2043         delete pCheckBoxBg;
2044         delete pMergeBitmap;
2045         delete pCanvas;
2046
2047         return r;
2048 }
2049
2050 void
2051 _TableViewItem::SetItemLayoutEnabled(bool enabled)
2052 {
2053         __isItemLayoutEnabled = enabled;
2054 }
2055
2056 bool
2057 _TableViewItem::GetItemLayoutEnabled(void)
2058 {
2059         return __isItemLayoutEnabled;
2060 }
2061
2062 void
2063 _TableViewItem::OnBoundsChanged(void)
2064 {
2065         if (__checkItemHeightNeeded && HasParent())
2066         {
2067                 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
2068                 if (pParent != null)
2069                 {
2070                         int groupIndex = -1;
2071                         int itemIndex = -1;
2072                         GetItemIndex(groupIndex, itemIndex);
2073
2074                         pParent->CheckItemHeightAndRefreshLayout(groupIndex, itemIndex);
2075                 }
2076
2077                 __checkItemHeightNeeded = false;
2078         }
2079
2080         AdjustAnnexBounds();
2081
2082         SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
2083
2084         if (__pHeaderFooterItemText != null)
2085         {
2086                 FloatRectangle textBounds = __pHeaderFooterItemText->GetBoundsF();
2087                 textBounds.width = GetBoundsF().width;
2088
2089                 if (__itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
2090                 {
2091                         textBounds.x -= __pDrawingProperty->scrollMargin;
2092                 }
2093
2094                 __pHeaderFooterItemText->SetBounds(textBounds);
2095         }
2096
2097         if (__pBitmapVisualElement != null)
2098         {
2099                 FloatRectangle bounds = GetBoundsF();
2100                 __pBitmapVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
2101         }
2102
2103         if (__pAccessibilityElement != null)
2104         {
2105                 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f,0.0f, GetBoundsF().width, GetBoundsF().height));
2106         }
2107 }
2108
2109 void
2110 _TableViewItem::SetDrawingProperty(_ItemDrawingProperty* pDrawingProperty)
2111 {
2112
2113         SysTryReturnVoidResult(NID_UI_CTRL, pDrawingProperty != null, E_INVALID_ARG, "[%s] Invalid argument(s) is used. The pDrawingProperty is null.", GetErrorMessage(E_INVALID_ARG));
2114
2115         __pDrawingProperty = pDrawingProperty;
2116
2117         if (__pDrawingProperty->sectionStyleEnabled == true &&
2118                 !IsContextItem())
2119         {
2120                 CreateItemCover();
2121         }
2122
2123         if (__pDrawingProperty->itemDividerEnabled)
2124         {
2125                 CreateItemDivider();
2126         }
2127
2128         CreateAnnexStyle();
2129 }
2130
2131 _ItemDrawingProperty*
2132 _TableViewItem::GetDrawingProperty(void)
2133 {
2134         return __pDrawingProperty;
2135 }
2136
2137 void
2138 _TableViewItem::DrawItemBackground(void)
2139 {
2140         Canvas* pCanvas = null;
2141         Bitmap* pDrawBitmap = __pItemBgBitmap[__drawingStatus];
2142         Color bgColor = __colorItemBg[__drawingStatus];
2143         FloatRectangle bounds = GetBoundsF();
2144
2145         SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
2146         __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f));
2147
2148         if (pDrawBitmap != null && __enabledState)
2149         {
2150                 if (__pBitmapVisualElement == null)
2151                 {
2152                         return;
2153                 }
2154
2155                 String imagePath = null;
2156                 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pDrawBitmap) == false)
2157                 {
2158                         imagePath = _BitmapImpl::GetInstance(*pDrawBitmap)->GetFileName();
2159                 }
2160
2161                 if (imagePath.IsEmpty() == false)
2162                 {
2163                         __pBitmapVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() /255, (float)bgColor.GetGreen() / 255, (float)bgColor.GetBlue() / 255, (float)bgColor.GetAlpha() / 255));
2164                         __pBitmapVisualElement->SetImageSource(imagePath);
2165                 }
2166                 else
2167                 {
2168                         pCanvas = __pBitmapVisualElement->GetCanvasN();
2169                         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2170                         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2171                         pCanvas->Clear();
2172
2173                         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pDrawBitmap);
2174                 }
2175         }
2176
2177         if (IsContextItem())
2178         {
2179                 DrawContextItemBackground();
2180         }
2181         else if (__pDrawingProperty->sectionStyleEnabled == true)
2182         {
2183                 DrawSectionStyleBackground();
2184         }
2185         else
2186         {
2187                 if (__enabledState)
2188                 {
2189                         if (__itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
2190                         {
2191                                 SetBackgroundColor(Color(0, 0, 0, 0));
2192                                 __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f));
2193                         }
2194                         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
2195                         {
2196                                 __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
2197                         }
2198                         else
2199                         {
2200                                 SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
2201
2202                                 __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
2203
2204                                 if (__pDrawingProperty->groupedLookEnabled == true)
2205                                 {
2206                                         DrawGroupedLook();
2207                                 }
2208                         }
2209                 }
2210                 else
2211                 {
2212                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
2213                         SetBackgroundColor(bgColor);
2214                         __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
2215
2216                         if (__pDrawingProperty->groupedLookEnabled == true)
2217                         {
2218                                 DrawGroupedLook();
2219                         }
2220                 }
2221         }
2222
2223         delete pCanvas;
2224         return;
2225
2226 CATCH:
2227
2228         if (__pBitmapVisualElement != null)
2229         {
2230                 __pBitmapVisualElement->RemoveAllAnimations();
2231                 __pBitmapVisualElement->SetAnimationProvider(null);
2232                 __pBitmapVisualElement->Destroy();
2233                 __pBitmapVisualElement = null;
2234         }
2235 }
2236
2237 void
2238 _TableViewItem::DrawGroupedLook(void)
2239 {
2240         if (IsTitleStyleItem() || IsContextItem())
2241         {
2242                 return;
2243         }
2244
2245         Color barColor;
2246         Color outlineColor = __pDrawingProperty->dividerColor;
2247
2248         float barWidth = 0.0f;
2249
2250         Canvas* pCanvas = GetVisualElement()->GetCanvasN();
2251         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2252
2253         FloatRectangle bounds = GetBoundsF();
2254         pCanvas->SetBackgroundColor(GetBackgroundColor());
2255         pCanvas->Clear();
2256
2257         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor);
2258         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth);
2259
2260         pCanvas->FillRectangle(barColor, FloatRectangle(0.0f, 0.0f, barWidth, bounds.height));
2261
2262         if (__pDrawingProperty->sectionStyleEnabled == true)
2263         {
2264                 pCanvas->FillRectangle(outlineColor, FloatRectangle(bounds.width - 1.0f, 0.0f, 1.0f, bounds.height));
2265
2266                 if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP || __itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2267                 {
2268                         pCanvas->FillRectangle(outlineColor, FloatRectangle(0.0f, 0.0f, bounds.width, 1.0f));
2269                 }
2270         }
2271
2272         delete pCanvas;
2273 }
2274
2275 void
2276 _TableViewItem::DrawSectionStyleBackground(void)
2277 {
2278         Canvas* pCanvas = null;
2279         Bitmap* pSectionBg = null;
2280         Bitmap* pSectionPressBg = null;
2281         Bitmap* pSectionDisabledBg = null;
2282         Bitmap* pReplacementSectionPressBg = null;
2283         Bitmap* pReplacementSectionBg = null;
2284         Color bgColor = __colorItemBg[__drawingStatus];
2285         FloatRectangle bounds = GetBoundsF();
2286         float dividerHeight = 0.0f;
2287
2288         result r = E_SUCCESS;
2289
2290         pCanvas = GetVisualElement()->GetCanvasN();
2291         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
2292
2293         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2294         pCanvas->Clear();
2295
2296         if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2297         {
2298                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
2299         }
2300         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2301         {
2302                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
2303         }
2304         else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2305         {
2306                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
2307         }
2308         else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2309         {
2310                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
2311         }
2312         else
2313         {
2314                 r = E_SYSTEM;
2315         }
2316         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred.  SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2317
2318         if (__enabledState)
2319         {
2320                 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED || __drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED)
2321                 {
2322                         if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2323                         {
2324                                 if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_SINGLE_BG_PRESSED))
2325                                 {
2326                                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressBg);
2327                                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2328                                 }
2329                         }
2330                         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2331                         {
2332                                 if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_TOP_BG_PRESSED))
2333                                 {
2334                                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressBg);
2335                                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2336                                 }
2337                         }
2338                         else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2339                         {
2340                                 if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_CENTER_BG_PRESSED))
2341                                 {
2342                                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressBg);
2343                                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2344                                 }
2345                         }
2346                         else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2347                         {
2348                                 if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_BOTTOM_BG_PRESSED))
2349                                 {
2350                                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressBg);
2351                                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2352                                 }
2353                         }
2354
2355                         GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, dividerHeight);
2356
2357                         if (pSectionPressBg)
2358                         {
2359                                 pReplacementSectionPressBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionPressBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
2360                         }
2361                         else
2362                         {
2363                                 pReplacementSectionPressBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
2364                         }
2365
2366                         DrawBitmap(*pCanvas, FloatRectangle(0.0f, dividerHeight, bounds.width, bounds.height - (dividerHeight * 2)), *pReplacementSectionPressBg);
2367                 }
2368                 else
2369                 {
2370                         if (bgColor != null)
2371                         {
2372                                 pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
2373                         }
2374                         else
2375                         {
2376                                 pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), __pDrawingProperty->sectionStyleBgColor);
2377                         }
2378
2379                         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementSectionBg);
2380                 }
2381         }
2382         else
2383         {
2384                 if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2385                 {
2386                         if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_SINGLE_BG_DISABLED))
2387                         {
2388                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionDisabledBg);
2389                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2390                         }
2391                 }
2392                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2393                 {
2394                         if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_TOP_BG_DISABLED))
2395                         {
2396                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionDisabledBg);
2397                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2398                         }
2399                 }
2400                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2401                 {
2402                         if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_CENTER_BG_DISABLED))
2403                         {
2404                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionDisabledBg);
2405                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2406                         }
2407                 }
2408                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2409                 {
2410                         if (IS_CUSTOM_BITMAP(TABLEVIEW::SECTIONITEM_BOTTOM_BG_DISABLED))
2411                         {
2412                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionDisabledBg);
2413                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2414                         }
2415                 }
2416
2417                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
2418                 if (pSectionDisabledBg)
2419                 {
2420                         pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionDisabledBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
2421                 }
2422                 else
2423                 {
2424                         pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
2425                 }
2426                 DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementSectionBg);
2427         }
2428
2429         if (__pDrawingProperty->groupedLookEnabled == true)
2430         {
2431                 Color barColor;
2432
2433                 float barWidth = 0.0f;
2434                 float barMargin = 0.0f;
2435
2436                 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor);
2437                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth);
2438                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, barMargin);
2439
2440                 pCanvas->FillRectangle(barColor, FloatRectangle(0.0f, barMargin, barWidth, bounds.height-barMargin));
2441         }
2442
2443 CATCH:
2444         delete pSectionBg;
2445         delete pSectionPressBg;
2446         delete pSectionDisabledBg;
2447         delete pReplacementSectionPressBg;
2448         delete pReplacementSectionBg;
2449         delete pCanvas;
2450 }
2451
2452 void
2453 _TableViewItem::DrawSectionStyleBackgroundCover(void)
2454 {
2455         if (!__pDrawingProperty->sectionStyleEnabled ||
2456                 __pItemCover == null)
2457         {
2458                 return;
2459         }
2460
2461         Bitmap* pSectionBgCoverEf = null;
2462         Bitmap* pReplacementSectionBgEf = null;
2463         Bitmap* pReplacementSectionBg = null;
2464         Bitmap* pSectionBgCoverBg = null;
2465         Bitmap* pMergeBitmap = null;
2466         Canvas* pCanvas = null;
2467         Color bgColor;
2468
2469         result r = E_SUCCESS;
2470         FloatRectangle bounds = GetBoundsF();
2471         if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2472         {
2473                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_COVER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBgCoverEf);
2474         }
2475         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2476         {
2477                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_COVER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBgCoverEf);
2478         }
2479         else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2480         {
2481                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_COVER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBgCoverEf);
2482         }
2483         else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2484         {
2485                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_COVER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBgCoverEf);
2486         }
2487         else
2488         {
2489                 r = E_SYSTEM;
2490         }
2491         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2492
2493         if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
2494         {
2495                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_COVER_ROUND_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBgCoverBg);
2496         }
2497         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
2498         {
2499                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_COVER_ROUND_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBgCoverBg);
2500         }
2501         else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
2502         {
2503                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_COVER_ROUND_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBgCoverBg);
2504         }
2505         else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
2506         {
2507                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_COVER_ROUND_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBgCoverBg);
2508         }
2509         else
2510         {
2511                 r = E_SYSTEM;
2512         }
2513         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. SectionStyle image load failed", GetErrorMessage(E_SYSTEM) );
2514
2515         __pItemCover->SetBounds(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
2516
2517         if (__enabledState)
2518         {
2519                 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
2520                 SysTryCatch(NID_UI_CTRL, pParent != null, , E_SYSTEM, "[%s] A system error has been occurred. SectionTableView  load failed", GetErrorMessage(E_SYSTEM) );
2521
2522                 bgColor = pParent->GetBackgroundColor();
2523         }
2524         else
2525         {
2526                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
2527         }
2528
2529         pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBgCoverBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
2530         pReplacementSectionBgEf = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBgCoverEf, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
2531
2532         pCanvas = new (std::nothrow) Canvas();
2533         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2534         pCanvas->Construct(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
2535         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2536         pCanvas->Clear();
2537
2538         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementSectionBg);
2539         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementSectionBgEf);
2540
2541         pMergeBitmap = new (std::nothrow) Bitmap();
2542         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2543
2544         pMergeBitmap->Construct(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
2545
2546         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2547
2548         __pItemCover->SetBackgroundBitmap(*pMergeBitmap);
2549
2550 CATCH:
2551         delete pSectionBgCoverEf;
2552         delete pReplacementSectionBgEf;
2553         delete pReplacementSectionBg;
2554         delete pSectionBgCoverBg;
2555         delete pCanvas;
2556         delete pMergeBitmap;
2557 }
2558
2559 void
2560 _TableViewItem::DrawContextItemBackground(void)
2561 {
2562         Canvas* pCanvas = null;
2563         Bitmap* pContextBg = null;
2564         Bitmap* pContextBgEf = null;
2565         Bitmap* pReplacementContextBg = null;
2566         Color bgColor = __colorItemBg[__drawingStatus];
2567
2568         FloatRectangle bounds = GetBoundsF();
2569         result r = E_SUCCESS;
2570
2571         r = GET_BITMAP_CONFIG_N(TABLEVIEW::QUICK_MENU_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pContextBg);
2572         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. ContextItem image load failed", GetErrorMessage(E_SYSTEM));
2573
2574         r = GET_BITMAP_CONFIG_N(TABLEVIEW::QUICK_MENU_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pContextBgEf);
2575         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] A system error has been occurred. ContextItem image load failed", GetErrorMessage(E_SYSTEM));
2576
2577         pCanvas = GetVisualElement()->GetCanvasN();
2578         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2579
2580         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2581         pCanvas->Clear();
2582
2583         if (__enabledState)
2584         {
2585                 if (bgColor == null)
2586                 {
2587                         GET_COLOR_CONFIG(TABLEVIEW::CONTEXTITEM_BG_NORMAL, bgColor);
2588                 }
2589         }
2590         else
2591         {
2592                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
2593         }
2594         pReplacementContextBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pContextBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
2595         SysTryCatch(NID_UI_CTRL, pReplacementContextBg != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2596
2597         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pReplacementContextBg);
2598         DrawBitmap(*pCanvas, FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pContextBgEf);
2599
2600 CATCH:
2601         delete pCanvas;
2602         delete pContextBg;
2603         delete pContextBgEf;
2604         delete pReplacementContextBg;
2605 }
2606
2607
2608 void
2609 _TableViewItem::CreateAnnexStyle(void)
2610 {
2611         switch (__annexStyle)
2612         {
2613         case TABLE_VIEW_ANNEX_STYLE_MARK:
2614                 CreateCheckBox();
2615                 break;
2616         case TABLE_VIEW_ANNEX_STYLE_RADIO:
2617                 CreateRadioBox();
2618                 break;
2619         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
2620                 CreateOnOffButton();
2621                 break;
2622         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
2623                 CreateItemAnnexDivider();
2624                 CreateOnOffButton();
2625                 break;
2626         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
2627                 CreateDetailButton();
2628                 break;
2629         default:
2630                 break;
2631         }
2632 }
2633
2634 void
2635 _TableViewItem::DrawAnnexStyle(void)
2636 {
2637         switch (__annexStyle)
2638         {
2639         case TABLE_VIEW_ANNEX_STYLE_MARK:
2640                 DrawCheckBox();
2641                 break;
2642         case TABLE_VIEW_ANNEX_STYLE_RADIO:
2643                 DrawRadioBox();
2644                 break;
2645         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
2646                 DrawOnOffButton();
2647                 break;
2648         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
2649                 DrawItemAnnexDivider();
2650                 DrawOnOffButton();
2651                 break;
2652         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
2653                 DrawDetailButton();
2654                 break;
2655         default:
2656                 break;
2657         }
2658 }
2659
2660 void
2661 _TableViewItem::DrawCheckBox(void)
2662 {
2663         Bitmap* pCheckBox = null;
2664         Bitmap* pCheckBoxBg = null;
2665         Bitmap* pMergeBitmap = null;
2666         Canvas* pCanvas = null;
2667         result r = E_SUCCESS;
2668
2669         FloatRectangle bounds;
2670         float annexWidth = 0.0f;
2671         float annexHeight = 0.0f;
2672
2673         if (__enabledState)
2674         {
2675                 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
2676                 {
2677                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
2678                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2679
2680                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
2681                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2682                 }
2683                 else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
2684                 {
2685                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
2686                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2687
2688                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
2689                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2690                 }
2691
2692         }
2693         else
2694         {
2695                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
2696                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2697
2698                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
2699                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
2700         }
2701
2702         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2703         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2704
2705         bounds.SetBounds(0.0f, 0.0f, annexWidth, annexHeight);
2706
2707         pCanvas = new (std::nothrow) Canvas();
2708         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2709
2710         pCanvas->Construct(bounds);
2711         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2712         pCanvas->Clear();
2713
2714         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg);
2715
2716         if (__isCheckedAnimationEnabled == true)
2717         {
2718                 StartCheckBoxAnimation();
2719         }
2720         else
2721         {
2722                 if (IsChecked() == true && pCheckBox != null)
2723                 {
2724                         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox), *pCheckBox);
2725                 }
2726         }
2727
2728         pMergeBitmap = new (std::nothrow) Bitmap();
2729         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2730
2731         pMergeBitmap->Construct(*pCanvas, bounds);
2732         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2733
2734         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
2735         __pItemAnnex->Invalidate(false);
2736
2737 CATCH:
2738         delete pCheckBox;
2739         delete pCheckBoxBg;
2740         delete pMergeBitmap;
2741         delete pCanvas;
2742
2743         return;
2744 }
2745
2746 void
2747 _TableViewItem::DrawRadioBox(void)
2748 {
2749         Bitmap* pRadioButton = null;
2750         Bitmap* pRadioButtonBg = null;
2751         Bitmap* pMergeBitmap = null;
2752         Canvas* pCanvas = null;
2753         result r = E_SUCCESS;
2754
2755         FloatRectangle bounds;
2756         float annexWidth = 0.0f;
2757         float annexHeight = 0.0f;
2758
2759         if (__enabledState)
2760         {
2761                 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
2762                 {
2763                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
2764                         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));
2765
2766                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_BUTTON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButton);
2767                         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));
2768                 }
2769                 else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
2770                 {
2771                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
2772                         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));
2773
2774
2775                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_BUTTON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButton);
2776                         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));
2777                 }
2778         }
2779         else
2780         {
2781                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_NORMAL_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
2782                 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));
2783
2784                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_BUTTON_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButton);
2785                 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));
2786         }
2787
2788         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2789         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2790         bounds.SetBounds(0.0f, 0.0f, annexWidth, annexHeight);
2791
2792         pCanvas = new (std::nothrow) Canvas();
2793         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2794
2795         pCanvas->Construct(bounds);
2796         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2797         pCanvas->Clear();
2798
2799         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButtonBg), *pRadioButtonBg);
2800
2801         if (pRadioButton != null && IsChecked() == true)
2802         {
2803                 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButton), *pRadioButton);
2804         }
2805
2806         pMergeBitmap = new (std::nothrow) Bitmap();
2807         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2808
2809         pMergeBitmap->Construct(*pCanvas, bounds);
2810         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2811
2812         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
2813         __pItemAnnex->Invalidate(false);
2814
2815 CATCH:
2816         delete pRadioButton;
2817         delete pRadioButtonBg;
2818         delete pMergeBitmap;
2819         delete pCanvas;
2820
2821         return;
2822 }
2823
2824 void
2825 _TableViewItem::DrawOnOffButton(void)
2826 {
2827         Bitmap* pOnOffButton = null;
2828         Bitmap* pOnOffButtonHandler = null;
2829         Bitmap* pMergeBitmap = null;
2830         Canvas* pCanvas = null;
2831         result r = E_SUCCESS;
2832
2833         FloatRectangle bounds;
2834         FloatRectangle backgroundBounds;
2835         FloatRectangle handlerBounds;
2836         float annexWidth = 0.0f;
2837         float annexHeight = 0.0f;
2838         float annexMargin = 0.0f;
2839
2840         if (IsChecked() == true)
2841         {
2842                 if (__enabledState)
2843                 {
2844                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2845                 }
2846                 else
2847                 {
2848                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON_HANDLER_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2849                 }
2850         }
2851         else
2852         {
2853                 if (__enabledState)
2854                 {
2855                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2856                 }
2857                 else
2858                 {
2859                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF_HANDLER_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2860                 }
2861         }
2862         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));
2863
2864         if (__enabledState)
2865         {
2866                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_BG, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
2867         }
2868         else
2869         {
2870                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
2871         }
2872         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));
2873
2874         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2875         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2876         bounds.SetBounds(0, 0, annexWidth, annexHeight);
2877
2878         pCanvas = new (std::nothrow) Canvas();
2879         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2880
2881         pCanvas->Construct(bounds);
2882         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2883         pCanvas->Clear();
2884
2885         backgroundBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButton);
2886         DrawBitmap(*pCanvas, backgroundBounds, *pOnOffButton);
2887
2888         handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
2889         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexMargin);
2890         if (IsChecked() == true)
2891         {
2892                 handlerBounds.x = backgroundBounds.width - handlerBounds.width - annexMargin;
2893         }
2894         else
2895         {
2896                 handlerBounds.x = backgroundBounds.x + annexMargin;
2897         }
2898
2899         DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler);
2900
2901         pMergeBitmap = new (std::nothrow) Bitmap();
2902         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
2903
2904         pMergeBitmap->Construct(*pCanvas, bounds);
2905         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
2906
2907         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
2908         __pItemAnnex->Invalidate(false);
2909
2910 CATCH:
2911         delete pOnOffButton;
2912         delete pOnOffButtonHandler;
2913         delete pMergeBitmap;
2914         delete pCanvas;
2915
2916         return;
2917 }
2918
2919 void
2920 _TableViewItem::AdjustAnnexOnOffHandlerPosition()
2921 {
2922         float annexWidth = 0.0f;
2923         float annexHeight = 0.0f;
2924         float annexMargin = 0.0f;
2925
2926         float annexStartPositionX = 0.0f;
2927         float annexEndPositionX = 0.0f;
2928         float handlerPositionX = 0.0f;
2929         FloatRectangle handlerBounds;
2930         result r = E_SUCCESS;
2931
2932         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexMargin);
2933
2934         Bitmap* pOnOffButtonHandler = null;
2935         if (IsChecked() == true)
2936         {
2937                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2938         }
2939         else
2940         {
2941                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
2942         }
2943         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));
2944
2945         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2946         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
2947
2948         annexStartPositionX = __pItemAnnex->GetBoundsF().x;
2949         annexEndPositionX = annexStartPositionX + annexWidth + annexMargin;
2950
2951         handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
2952
2953         if (__annexOnOffHandlerMoved)
2954         {
2955                 if (annexStartPositionX <= __annexOnOffHandlerPositionX
2956                         && annexEndPositionX >= __annexOnOffHandlerPositionX)
2957                 {
2958                         if (((annexEndPositionX - annexStartPositionX) / 2) < (__annexOnOffHandlerPositionX + (handlerBounds.width / 2)) - annexStartPositionX )
2959                         {
2960                                 handlerPositionX = annexEndPositionX;
2961                                 SetChecked(true);
2962                         }
2963                         else
2964                         {
2965                                 handlerPositionX = annexStartPositionX;
2966                                 SetChecked(false);
2967                         }
2968                 }
2969         }
2970         else
2971         {
2972                 SetChecked(!IsChecked());
2973                 if (IsChecked())
2974                 {
2975                         handlerPositionX = annexEndPositionX;
2976                 }
2977                 else
2978                 {
2979                         handlerPositionX = annexStartPositionX;
2980                 }
2981         }
2982
2983         DrawAnnexOnOffHandler(handlerPositionX);
2984
2985         delete pOnOffButtonHandler;
2986
2987         return;
2988 }
2989
2990 void
2991 _TableViewItem::DrawAnnexOnOffHandler(float touchEndPosition)
2992 {
2993         if (__pItemAnnex == null)
2994         {
2995                 return;
2996         }
2997
2998         Bitmap* pOnOffButton = null;
2999         Bitmap* pOnOffButtonHandler = null;
3000         Bitmap* pMergeBitmap = null;
3001         Canvas* pCanvas = null;
3002         result r = E_SUCCESS;
3003
3004         FloatRectangle backgroundBounds;
3005         FloatRectangle handlerBounds;
3006         float annexWidth = 0.0f;
3007         float annexHeight = 0.0f;
3008         float annexMargin = 0.0f;
3009         float annexX = 0.0f;
3010         float nextHandlerX = 0.0f;
3011
3012         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_BG, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
3013         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));
3014
3015         if (IsChecked() == true)
3016         {
3017                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
3018         }
3019         else
3020         {
3021                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
3022         }
3023         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));
3024
3025         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3026         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
3027         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexMargin);
3028
3029         pCanvas = new (std::nothrow) Canvas();
3030         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3031
3032         pCanvas->Construct(FloatRectangle(0, 0, annexWidth, annexHeight));
3033         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
3034         pCanvas->Clear();
3035
3036         backgroundBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButton);
3037         DrawBitmap(*pCanvas, backgroundBounds, *pOnOffButton);
3038
3039         handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
3040         handlerBounds.y  = backgroundBounds.y;
3041
3042         if (IsChecked())
3043         {
3044                 handlerBounds.x = backgroundBounds.width - handlerBounds.width - annexMargin;
3045         }
3046         else
3047         {
3048                 handlerBounds.x = backgroundBounds.x + annexMargin;
3049         }
3050
3051         nextHandlerX = handlerBounds.x + (touchEndPosition - __annexTouchStartPosition);
3052         annexX = __pItemAnnex->GetBoundsF().x;
3053
3054         if ((annexX + nextHandlerX + handlerBounds.width) < (annexX + annexWidth + annexMargin)
3055                 && (annexX + nextHandlerX) > annexX)
3056         {
3057                 handlerBounds.x = nextHandlerX;
3058         }
3059         else if (_FloatCompareGE((annexX + nextHandlerX + handlerBounds.width), (annexX + annexWidth + annexMargin)))
3060         {
3061                 handlerBounds.x = backgroundBounds.width - handlerBounds.width - annexMargin;
3062         }
3063         else if (_FloatCompareLE((annexX + nextHandlerX), annexX))
3064         {
3065                 handlerBounds.x = backgroundBounds.x + annexMargin;
3066         }
3067
3068         __annexOnOffHandlerPositionX = annexX + handlerBounds.x;
3069         DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler);
3070
3071         pMergeBitmap = new (std::nothrow) Bitmap();
3072         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3073
3074         pMergeBitmap->Construct(*pCanvas, FloatRectangle(0, 0, annexWidth, annexHeight));
3075         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
3076
3077         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
3078         __pItemAnnex->Invalidate(false);
3079
3080 CATCH:
3081         delete pOnOffButton;
3082         delete pOnOffButtonHandler;
3083         delete pMergeBitmap;
3084         delete pCanvas;
3085
3086         return;
3087 }
3088
3089 void
3090 _TableViewItem::DrawDetailButton(void)
3091 {
3092         Bitmap* pDetail = null;
3093         Bitmap* pDetailBg = null;
3094         Bitmap* pDetailBgEffect = null;
3095         Bitmap* pDetailEffect = null;
3096         Bitmap* pReplacementDetail = null;
3097         Bitmap* pReplacementDetailBg = null;
3098         Bitmap* pMergeBitmap = null;
3099         Canvas* pCanvas = null;
3100         Color replacementNewColor;
3101         Color replacementNewBgColor;
3102         result r = E_SUCCESS;
3103
3104         FloatRectangle bounds;
3105         float annexWidth = 0.0f;
3106         float annexHeight = 0.0f;
3107         bool themeBackgroundBitmap = false;
3108
3109         themeBackgroundBitmap = IS_CUSTOM_BITMAP(TABLEVIEW::CIRCLE_BUTTON_BG_NORMAL);
3110
3111         if (__enabledState)
3112         {
3113                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBg);
3114                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBg != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3115
3116                 if (__isSelectedDetailButton)
3117                 {
3118                         if (!themeBackgroundBitmap)
3119                         {
3120                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
3121                                 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));
3122
3123                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailEffect);
3124                                 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));
3125                         }
3126
3127                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetail);
3128                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetail != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3129
3130                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_PRESSED, replacementNewColor);
3131                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_PRESSED, replacementNewBgColor);
3132                 }
3133                 else
3134                 {
3135                         if (!themeBackgroundBitmap)
3136                         {
3137                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
3138                                 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));
3139
3140                                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailEffect);
3141                                 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));
3142                         }
3143
3144                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDetail);
3145                         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetail != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3146
3147                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_NORMAL, replacementNewColor);
3148                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_NORMAL, replacementNewBgColor);
3149                 }
3150         }
3151         else
3152         {
3153
3154                 if (!themeBackgroundBitmap)
3155                 {
3156                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
3157                         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));
3158
3159                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailEffect);
3160                         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));
3161                 }
3162
3163                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetail);
3164                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetail != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3165
3166                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBg);
3167                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBg != null), , E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3168
3169                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_NORMAL, replacementNewColor);
3170         }
3171         pReplacementDetailBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pDetailBg, Color::GetColor(COLOR_ID_MAGENTA), replacementNewBgColor);
3172         SysTryCatch(NID_UI_CTRL, pReplacementDetailBg != null, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3173
3174         pReplacementDetail = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pDetail, Color::GetColor(COLOR_ID_MAGENTA), replacementNewColor);
3175         SysTryCatch(NID_UI_CTRL, pReplacementDetail != null, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Detail button image load failed", GetErrorMessage(E_SYSTEM));
3176
3177         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3178         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
3179
3180         bounds.SetBounds(0, 0, annexWidth, annexHeight);
3181
3182         pCanvas = new (std::nothrow) Canvas();
3183         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3184
3185         pCanvas->Construct(bounds);
3186         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
3187         pCanvas->Clear();
3188
3189         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetailBg), *pReplacementDetailBg);
3190         if (pDetailBgEffect)
3191         {
3192                 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pDetailBgEffect), *pDetailBgEffect);
3193         }
3194         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetail), *pReplacementDetail);
3195         if (pDetailEffect)
3196         {
3197                 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pDetailEffect), *pDetailEffect);
3198         }
3199
3200         pMergeBitmap = new (std::nothrow) Bitmap();
3201         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
3202         pMergeBitmap->Construct(*pCanvas, bounds);
3203         _BitmapImpl::ConvertToNonpremultiplied(*pMergeBitmap, true);
3204
3205         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
3206         __pItemAnnex->Invalidate(false);
3207
3208 CATCH:
3209         delete pDetail;
3210         delete pDetailBg;
3211         delete pDetailBgEffect;
3212         delete pDetailEffect;
3213         delete pReplacementDetail;
3214         delete pReplacementDetailBg;
3215         delete pMergeBitmap;
3216         delete pCanvas;
3217
3218         return;
3219 }
3220
3221 void
3222 _TableViewItem::DrawItemDivider(void)
3223 {
3224         if (__pItemDivider == null || __pItemTopDivider == null)
3225         {
3226                 return;
3227         }
3228
3229         if (__pDrawingProperty->itemDividerEnabled == false ||
3230                 __itemType == TABLE_VIEW_ITEM_TYPE_HEADER ||
3231                 __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER ||
3232                 __itemDividerEnabled == false ||
3233                 __isSectionItem)
3234         {
3235                 __pItemDivider->SetVisibleState(false);
3236                 __pItemTopDivider->SetVisibleState(false);
3237
3238                 return;
3239         }
3240
3241         FloatRectangle dividerBottomBounds;
3242         FloatRectangle dividerTopBounds;
3243         Color topLineColor;
3244         Color bottomLineColor;
3245         Color customDividerColor;
3246         FloatRectangle bounds;
3247         FloatPoint bottomPoint;
3248
3249         __pItemDivider->SetVisibleState(true);
3250         __pItemTopDivider->SetVisibleState(true);
3251
3252         if (    __drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED ||
3253                 __drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED)
3254         {
3255                 if (__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL] != __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED])
3256                 {
3257                         if (__itemType != TABLE_VIEW_ITEM_TYPE_TITLE)
3258                         {
3259                                 __pItemDivider->SetVisibleState(false);
3260                         }
3261
3262                         __pItemTopDivider->SetVisibleState(false);
3263                 }
3264         }
3265
3266         if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
3267         {
3268                 if (__pItemBgBitmap[__drawingStatus] != null)
3269                 {
3270                         __pItemDivider->SetVisibleState(false);
3271                 }
3272                 else
3273                 {
3274                         float lineHeight = 0.0f;
3275                         float lineLeftMargin = 0.0f;
3276                         float lineBottomMargin = 0.0f;
3277                         bounds = GetBoundsF();
3278
3279                         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
3280                         {
3281                                 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_NORMAL, bottomLineColor);
3282                         }
3283                         else
3284                         {
3285                                 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_PRESSED, bottomLineColor);
3286                         }
3287
3288                         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
3289                         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
3290                         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineBottomMargin);
3291
3292                         lineHeight = Tizen::Graphics::CoordinateSystem::ConvertToLogicalY(lineHeight);
3293                         lineBottomMargin = Tizen::Graphics::CoordinateSystem::ConvertToLogicalY(lineBottomMargin);
3294                         bottomPoint = Tizen::Graphics::CoordinateSystem::AlignToDevice(FloatPoint(lineLeftMargin, bounds.height));
3295                         dividerBottomBounds = FloatRectangle(bottomPoint.x, bottomPoint.y - lineBottomMargin, bounds.width - lineLeftMargin * 2.0f, lineHeight);
3296                 }
3297         }
3298         else
3299         {
3300                 float lineLeftMargin = 0.0f;
3301                 float lineHeight = 0.0f;
3302                 bounds = GetBoundsF();
3303
3304                 if (!IsContextItem())
3305                 {
3306                         if (!__isSimpleLastItem)
3307                         {
3308                                 if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM || __itemType == TABLE_VIEW_ITEM_TYPE_ONE)
3309                                 {
3310                                         __pItemDivider->SetVisibleState(false);
3311                                         __pItemTopDivider->SetVisibleState(false);
3312                                 }
3313                         }
3314                 }
3315
3316                 customDividerColor = __pDrawingProperty->dividerColor;
3317                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_TOP_BG_NORMAL, topLineColor);
3318                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_BOTTOM_BG_NORMAL, bottomLineColor);
3319                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
3320                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
3321
3322                 lineLeftMargin = Tizen::Graphics::CoordinateSystem::ConvertToLogicalX(lineLeftMargin);
3323                 lineHeight = Tizen::Graphics::CoordinateSystem::ConvertToLogicalY(lineHeight);
3324                 bottomPoint = Tizen::Graphics::CoordinateSystem::AlignToDevice(FloatPoint(lineLeftMargin, (bounds.height)));
3325
3326                 dividerTopBounds.SetBounds(lineLeftMargin, bottomPoint.y - (lineHeight * 2.0f), bounds.width - lineLeftMargin * 2.0f, lineHeight);
3327                 dividerBottomBounds.SetBounds(lineLeftMargin, bottomPoint.y - lineHeight, bounds.width - lineLeftMargin * 2.0f, lineHeight);
3328         }
3329
3330         if (__pItemDivider->GetVisibleState())
3331         {
3332                 __pItemDivider->SetBounds(dividerBottomBounds);
3333                 if (customDividerColor == bottomLineColor || __itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
3334                 {
3335                         __pItemDivider->SetBackgroundColor(bottomLineColor);
3336                 }
3337                 else
3338                 {
3339                         __pItemDivider->SetBackgroundColor(customDividerColor);
3340                         __pItemDivider->GetVisualElement()->SetOpacity(ITEM_BOTTOM_DIVIDER_OPACITY);
3341                 }
3342                         __pItemDivider->Invalidate();
3343         }
3344
3345         if (__pItemTopDivider->GetVisibleState())
3346         {
3347                 __pItemTopDivider->SetBounds(dividerTopBounds);
3348                 if (customDividerColor == bottomLineColor)
3349                 {
3350                         __pItemTopDivider->SetBackgroundColor(topLineColor);
3351                 }
3352                 else
3353                 {
3354                         __pItemTopDivider->SetBackgroundColor(customDividerColor);
3355                         __pItemTopDivider->GetVisualElement()->SetOpacity(ITEM_TOP_DIVIDER_OPACITY);
3356                 }
3357                 __pItemTopDivider->Invalidate();
3358         }
3359 }
3360
3361 void
3362 _TableViewItem::DrawItemAnnexDivider(void)
3363 {
3364         if (__itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
3365         {
3366                 if (__pItemAnnexLeftDivider != null)
3367                 {
3368                         __pItemAnnexLeftDivider->SetVisibleState(false);
3369                 }
3370
3371                 if (__pItemAnnexRightDivider != null)
3372                 {
3373                         __pItemAnnexRightDivider->SetVisibleState(false);
3374                 }
3375         }
3376         else
3377         {
3378                 Color dividerLeftColor;
3379                 Color dividerRightColor;
3380                 Color customDividerColor;
3381                 Color bottomLineColor;
3382                 FloatRectangle bounds = GetBoundsF();
3383                 float dividerHeight = 0;
3384                 float itemHeight = 0;
3385                 float dividerWidth = 0.0f;
3386                 float dividerTopMargin = 0.0f;
3387                 float annexWidth = 0.0f;
3388                 float annexLeftMargin = 0.0f;
3389                 float itemLeftMargin = 0.0f;
3390
3391                 customDividerColor = __pDrawingProperty->dividerColor;
3392                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, itemLeftMargin);
3393                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexLeftMargin);
3394                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3395                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_LEFT_BG_NORMAL, dividerLeftColor);
3396                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_RIGHT_BG_NORMAL, dividerRightColor);
3397                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_BOTTOM_BG_NORMAL, bottomLineColor);
3398                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, dividerWidth);
3399                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, dividerTopMargin);
3400
3401                 itemLeftMargin += __pDrawingProperty->scrollMargin;
3402                 itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height);
3403                 dividerHeight = itemHeight - (dividerTopMargin*2);
3404                 dividerHeight = (dividerHeight > 0) ? dividerHeight : 0;
3405                 __pItemAnnexLeftDivider->SetBounds(FloatRectangle((GetBoundsF().width - annexWidth - (itemLeftMargin + annexLeftMargin) - (dividerWidth*2)), dividerTopMargin, dividerWidth, dividerHeight));
3406                 __pItemAnnexRightDivider->SetBounds(FloatRectangle((GetBoundsF().width - annexWidth - (itemLeftMargin + annexLeftMargin) - dividerWidth), dividerTopMargin, dividerWidth, dividerHeight));
3407
3408                 if (customDividerColor == bottomLineColor)
3409                 {
3410                         __pItemAnnexLeftDivider->SetBackgroundColor(dividerLeftColor);
3411                 }
3412                 else
3413                 {
3414                         __pItemAnnexLeftDivider->SetBackgroundColor(customDividerColor);
3415                         __pItemAnnexLeftDivider->GetVisualElement()->SetOpacity(ITEM_TOP_DIVIDER_OPACITY);
3416                 }
3417
3418                 if (customDividerColor == bottomLineColor)
3419                 {
3420                         __pItemAnnexRightDivider->SetBackgroundColor(dividerRightColor);
3421                 }
3422                 else
3423                 {
3424                         __pItemAnnexRightDivider->SetBackgroundColor(customDividerColor);
3425                         __pItemAnnexRightDivider->GetVisualElement()->SetOpacity(ITEM_BOTTOM_DIVIDER_OPACITY);
3426                 }
3427
3428                 __pItemAnnexLeftDivider->Invalidate();
3429                 __pItemAnnexRightDivider->Invalidate();
3430         }
3431
3432         if (__pItemAnnexLeftDivider != null)
3433         {
3434                 _AccessibilityContainer* pContainer = __pItemAnnexLeftDivider->GetAccessibilityContainer();
3435                 pContainer->Activate(false);
3436         }
3437
3438         if (__pItemAnnexRightDivider != null)
3439         {
3440                 _AccessibilityContainer* pContainer = __pItemAnnexRightDivider->GetAccessibilityContainer();
3441                 pContainer->Activate(false);
3442         }
3443 }
3444
3445
3446 result
3447 _TableViewItem::DrawBitmap(Canvas& canvas, const FloatRectangle& bounds, const Bitmap& bitmap)
3448 {
3449         result r = E_SUCCESS;
3450         if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
3451         {
3452                 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
3453                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw ninepatched bitmap.");
3454         }
3455         else
3456         {
3457                 r = canvas.DrawBitmap(bounds, bitmap);
3458                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw bitmap.");
3459         }
3460
3461         return r;
3462 }
3463
3464 result
3465 _TableViewItem::SetItemHighlightBounds(_VisualElement& highlightVisualElement, const FloatRectangle& bounds)
3466 {
3467         return highlightVisualElement.SetBounds(bounds);
3468 }
3469
3470 FloatRectangle
3471 _TableViewItem::CalculateItemHighlightBounds(void)
3472 {
3473         FloatRectangle itemBounds = GetBoundsF();
3474         return FloatRectangle(0.0f, 0.0f, itemBounds.width, itemBounds.height);
3475 }
3476
3477 FloatRectangle
3478 _TableViewItem::CalculateAnnexBitmapBounds(float annexWidth, float annexHeight, const Bitmap& bitmap)
3479 {
3480         FloatRectangle bounds;
3481         float width = 0;
3482         float height = 0;
3483         float leftMargin = 0;
3484         float topMargin = 0;
3485
3486         if (annexWidth > bitmap.GetWidthF())
3487         {
3488                 leftMargin = (annexWidth - bitmap.GetWidthF()) / 2;
3489                 width = bitmap.GetWidthF();
3490         }
3491         else
3492         {
3493                 width = annexWidth;
3494         }
3495
3496         if (annexHeight > bitmap.GetHeightF())
3497         {
3498                 topMargin = (annexHeight - bitmap.GetHeightF()) / 2;
3499                 height = bitmap.GetHeightF();
3500         }
3501         else
3502         {
3503                 height = annexHeight;
3504         }
3505
3506         bounds.SetBounds(leftMargin, topMargin, width, height);
3507
3508         return bounds;
3509 }
3510
3511 bool
3512 _TableViewItem::IsTitleStyleItem(void) const
3513 {
3514         if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE || __itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
3515         {
3516                 return true;
3517         }
3518
3519         return false;
3520 }
3521
3522 bool
3523 _TableViewItem::IsValidSelectionState(void)
3524 {
3525         _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
3526         if (pParent == null)
3527         {
3528                 return true;
3529         }
3530
3531         if (pParent->GetPressedItemCount() > 0)
3532         {
3533                 return false;
3534         }
3535
3536         return true;
3537 }
3538
3539 void
3540 _TableViewItem::DrawSimpleItem(void)
3541 {
3542         if (__pSimpleItemText != null)
3543         {
3544                 Color textColor = __simpleItemTextColor[__drawingStatus];
3545                 if (!IsEnabled())
3546                 {
3547                         textColor = __simpleItemTextColor[TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED];
3548                 }
3549
3550                 if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
3551                 {
3552                         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
3553                         {
3554                                 textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL];
3555                         }
3556                         else
3557                         {
3558                                 textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED];
3559                         }
3560                 }
3561
3562                 __pSimpleItemText->SetTextColor(textColor);
3563                 __pSimpleItemText->Invalidate(false);
3564         }
3565 }
3566 result
3567 _TableViewItem::SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType)
3568 {
3569         result r = E_SUCCESS;
3570         bool textOnly = true;
3571
3572         if (pBitmap != null)
3573         {
3574                 textOnly = false;
3575         }
3576
3577         r = CreateSimpleItemContents(textOnly);
3578         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3579
3580         FloatRectangle bitmapRect = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
3581         FloatRectangle textRect = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
3582         float leftMargin = 0.0f;
3583         float annexMargin = 0.0f;
3584         float elementWidth = 0;
3585         float elementHeight = 0;
3586         float itemHeight = GetBoundsF().height;
3587         float itemWidth = GetBoundsF().width;
3588         float annexWidth = GetAnnexWidth(__annexStyle);
3589
3590         if (groupType)
3591         {
3592                 if (__simpleItemTextSize == 0)
3593                 {
3594                         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize);
3595                 }
3596                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
3597         }
3598         else
3599         {
3600                 if (__simpleItemTextSize == 0)
3601                 {
3602                         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize);
3603                 }
3604                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
3605         }
3606
3607         if (!textOnly)
3608         {
3609                 elementWidth = itemHeight * SIMPLE_ITEM_ELEMENT_BITMAP_SIZE_RATIO;
3610                 elementHeight = elementWidth;
3611
3612                 bitmapRect.x = leftMargin;
3613                 bitmapRect.y = (itemHeight - elementHeight) / 2;
3614                 bitmapRect.width = elementWidth;
3615                 bitmapRect.height = elementHeight;
3616         }
3617
3618         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_NORMAL)
3619         {
3620                 textRect.x = bitmapRect.x + elementWidth + leftMargin;
3621                 elementWidth = itemWidth - textRect.x - leftMargin;
3622         }
3623         else
3624         {
3625                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexMargin);
3626                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || __annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
3627                 {
3628                         bitmapRect.x = leftMargin + annexWidth + annexMargin;
3629                         textRect.x = bitmapRect.x + elementWidth + leftMargin;
3630                         elementWidth = itemWidth - textRect.x - leftMargin;
3631                 }
3632                 else
3633                 {
3634                         textRect.x = bitmapRect.x + elementWidth + leftMargin;
3635                         elementWidth = itemWidth - textRect.x - annexWidth - leftMargin - annexMargin;
3636                 }
3637         }
3638
3639         textRect.y = 0.0f;
3640         textRect.width = elementWidth < 0 ? 0 : elementWidth;;
3641         textRect.height = itemHeight;
3642
3643         if (__pSimpleItemBitmap != null && pBitmap != null)
3644         {
3645                 __pSimpleItemBitmap->SetBackgroundBitmap(*pBitmap);
3646                 __pSimpleItemBitmap->SetBounds(bitmapRect);
3647
3648                 _Label* pSimpleItemBitmapCore = GetLabelCore(__pSimpleItemBitmap);
3649                 if (!pSimpleItemBitmapCore->HasParent())
3650                 {
3651                         r = AttachChild(*pSimpleItemBitmapCore);
3652                         SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3653                 }
3654         }
3655
3656         if (__pSimpleItemText != null)
3657         {
3658                 __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL);
3659                 __pSimpleItemText->SetText(text);
3660                 __pSimpleItemText->SetBounds(textRect);
3661
3662                 _Label* pSimpleItemTextCore = GetLabelCore(__pSimpleItemText);
3663                 if (!pSimpleItemTextCore->HasParent())
3664                 {
3665                         r = AttachChild(*pSimpleItemTextCore);
3666                         SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3667                 }
3668         }
3669
3670         return E_SUCCESS;
3671 }
3672
3673 result
3674 _TableViewItem::CreateSimpleItemContents(bool textOnly)
3675 {
3676         result r = E_SUCCESS;
3677
3678         if (__pSimpleItemText == null)
3679         {
3680                 __pSimpleItemText = new (std::nothrow) Label();
3681
3682                 r = GetLastResult();
3683                 SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3684
3685                 __pSimpleItemText->Construct(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), L"");
3686
3687                 __pSimpleItemText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
3688                 __pSimpleItemText->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
3689                 if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
3690                 {
3691                         __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]);
3692                 }
3693                 else
3694                 {
3695                         __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
3696                 }
3697                 __pSimpleItemText->SetBackgroundColor(Color(0, 0, 0, 0));
3698                 GetLabelCore(__pSimpleItemText)->SetFocusable(true);
3699
3700         }
3701
3702         if (!textOnly)
3703         {
3704                 if (__pSimpleItemBitmap == null)
3705                 {
3706                         __pSimpleItemBitmap = new (std::nothrow) Label();
3707
3708                         r = GetLastResult();
3709                         SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3710
3711                         __pSimpleItemBitmap->Construct(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), L"");
3712                         __pSimpleItemBitmap->SetBackgroundColor(Color(0, 0, 0, 0));
3713                         GetLabelCore(__pSimpleItemBitmap)->SetFocusable(true);
3714                 }
3715
3716         }
3717         else
3718         {
3719                 if (__pSimpleItemBitmap != null)
3720                 {
3721                         delete __pSimpleItemBitmap;
3722                         __pSimpleItemBitmap = null;
3723                 }
3724         }
3725
3726         return E_SUCCESS;
3727 }
3728
3729 result
3730 _TableViewItem::SetSimpleTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status)
3731 {
3732         __simpleItemTextColor[status] = color;
3733
3734         return E_SUCCESS;
3735 }
3736
3737 Tizen::Graphics::Color
3738 _TableViewItem::GetSimpleItemTextColor(TableViewItemDrawingStatus status) const
3739 {
3740         return __simpleItemTextColor[status];
3741 }
3742
3743 result
3744 _TableViewItem::SetSimpleGroupItemTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status)
3745 {
3746         if (status == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
3747         {
3748                 __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL] = color;
3749         }
3750         else if (status == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED)
3751         {
3752                 __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED] = color;
3753         }
3754
3755         return E_SUCCESS;
3756 }
3757
3758 Tizen::Graphics::Color
3759 _TableViewItem::GetSimpleGroupItemTextColor(TableViewItemDrawingStatus status) const
3760 {
3761         if (status == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED)
3762         {
3763                 return __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED];
3764         }
3765         else
3766         {
3767                 return __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL];
3768         }
3769 }
3770
3771 result
3772 _TableViewItem::SetSimpleItemTextSize(int size)
3773 {
3774         if (__simpleItemTextSize == size)
3775         {
3776                 return E_SUCCESS;
3777         }
3778
3779         __simpleItemTextSize = size;
3780
3781         if (__pSimpleItemText != null)
3782         {
3783                 __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL);
3784         }
3785         return E_SUCCESS;
3786 }
3787
3788 int
3789 _TableViewItem::GetSimpleItemTextSize(void) const
3790 {
3791         return __simpleItemTextSize;
3792 }
3793
3794 result
3795 _TableViewItem::SetSectionHeaderFooterContents(const Tizen::Base::String& text, HorizontalAlignment alignment, bool isHeader)
3796 {
3797         if (__pHeaderFooterItemText == null)
3798         {
3799                 result r = E_SUCCESS;
3800                 float contentsHeight = 0.0f;
3801                 float positionY = 0.0f;
3802                 Color textColor;
3803
3804                 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_NORMAL, textColor);
3805                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, contentsHeight);
3806
3807                 __pHeaderFooterItemText = new (std::nothrow) Label();
3808
3809                 r = GetLastResult();
3810                 SysTryReturn(NID_UI_CTRL, __pHeaderFooterItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
3811
3812                 if (isHeader)
3813                 {
3814                         positionY = GetBoundsF().height - contentsHeight;
3815                 }
3816                 __pHeaderFooterItemText->Construct(FloatRectangle(0.0f, positionY, GetBoundsF().width, contentsHeight), text);
3817                 __pHeaderFooterItemText->SetTextHorizontalAlignment(alignment);
3818                 __pHeaderFooterItemText->SetTextColor(textColor);
3819                 __pHeaderFooterItemText->SetBackgroundColor(Color(0, 0, 0, 0));
3820
3821                 _Label* pHeaderFooterItemTextCore = GetLabelCore(__pHeaderFooterItemText);
3822                 pHeaderFooterItemTextCore->SetFocusable(false);
3823                 AttachChild(*pHeaderFooterItemTextCore);
3824         }
3825
3826         return E_SUCCESS;
3827 }
3828
3829 result
3830 _TableViewItem::SetSectionHeaderFooterAlignment(HorizontalAlignment alignment)
3831 {
3832         if (__pHeaderFooterItemText != null)
3833         {
3834                 __pHeaderFooterItemText->SetTextHorizontalAlignment(alignment);
3835                 __pHeaderFooterItemText->Invalidate(false);
3836         }
3837
3838         return E_SUCCESS;
3839 }
3840
3841 float
3842 _TableViewItem::GetAnnexWidth(TableViewAnnexStyle style)
3843 {
3844         float annexWidth = 0.0f;
3845         float annexDividerWidth = 0.0f;
3846
3847         switch (style)
3848         {
3849         case TABLE_VIEW_ANNEX_STYLE_NORMAL:
3850                 annexWidth = 0.0f;
3851                 break;
3852
3853         case TABLE_VIEW_ANNEX_STYLE_MARK:
3854                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3855                 break;
3856
3857         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
3858                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3859                 break;
3860
3861         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
3862                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, annexDividerWidth);
3863                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_ANNEX_DIVIDER_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexDividerWidth);
3864                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3865                 annexWidth = annexWidth + (annexDividerWidth*2) + annexDividerWidth;
3866                 break;
3867
3868         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
3869                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3870                 break;
3871
3872         case TABLE_VIEW_ANNEX_STYLE_RADIO:
3873                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
3874                 break;
3875
3876         default:
3877                 break;
3878         }
3879
3880         return annexWidth;
3881 }
3882
3883 void
3884 _TableViewItem::SetDrawingStatus(TableViewItemDrawingStatus status)
3885 {
3886         __drawingStatus = status;
3887 }
3888
3889 TableViewItemDrawingStatus
3890 _TableViewItem::GetDrawingStatus(void)
3891 {
3892         return __drawingStatus;
3893 }
3894
3895 void
3896 _TableViewItem::SetPressedControl(TableViewItemPressedControl pressedControl)
3897 {
3898         __pressedControl = pressedControl;
3899
3900         if (__pressedControl == TABLE_VIEW_ITEM_PRESSED_ITEM)
3901         {
3902                 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
3903         }
3904         else if (__pressedControl == TABLE_VIEW_ITEM_PRESSED_ANNEX)
3905         {
3906                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
3907                 {
3908                         __isSelectedDetailButton = true;
3909                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
3910                 }
3911                 else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING ||
3912                         __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
3913                 {
3914                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
3915                 }
3916                 else
3917                 {
3918                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
3919                 }
3920         }
3921         else
3922         {
3923                 if (__pressedControl != TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL)
3924                 {
3925                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
3926                 }
3927         }
3928 }
3929
3930 TableViewItemPressedControl
3931 _TableViewItem::GetPressedControl(void)
3932 {
3933         return __pressedControl;
3934 }
3935
3936 void
3937 _TableViewItem::AdjustChildControlMargin(void)
3938 {
3939         if (__childMarginState)
3940         {
3941                 return;
3942         }
3943
3944         if (IsTitleStyleItem())
3945         {
3946                 return;
3947         }
3948
3949         __childMarginState = true;
3950
3951         float margin = 0;
3952
3953         if (__pDrawingProperty->groupedLookEnabled)
3954         {
3955                 float groupedBarMargin = 0.0f;
3956                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, groupedBarMargin);
3957
3958                 margin = margin + groupedBarMargin;
3959         }
3960
3961         if (margin > 0)
3962         {
3963                 _VisualElement* pVisualElement = GetVisualElement();
3964
3965                 if (pVisualElement != null)
3966                 {
3967                         FloatPoint position;
3968
3969                         position.SetPosition(margin, 0.0f);
3970                         pVisualElement->ScrollByPoint(position, false);
3971                 }
3972         }
3973 }
3974
3975 void
3976 _TableViewItem::AdjustContextItemBounds(void)
3977 {
3978         _TableViewItem* pContextItem = GetContextItem();
3979
3980         if (pContextItem == null)
3981         {
3982                 return;
3983         }
3984
3985         FloatDimension contextItemSize = pContextItem->GetSizeF();
3986         FloatDimension itemSize = GetSizeF();
3987
3988         if (!_FloatCompare(contextItemSize.height, itemSize.height))
3989         {
3990                 contextItemSize.height = itemSize.height;
3991
3992                 pContextItem->SetSize(contextItemSize);
3993         }
3994
3995         pContextItem->AdjustChildControlCenterAlign();
3996 }
3997
3998 void
3999 _TableViewItem::AdjustAnnexBounds(void)
4000 {
4001         if (__pItemAnnex == null || __isMoveItemAnimationEnabled || __isZoomInOutItemAnimationEnabled ||__isFadeInOutItemAnimationEnabled)
4002         {
4003                 return;
4004         }
4005
4006         // h align
4007         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER || __annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
4008         {
4009                 _Label* pAnnexCore = GetLabelCore(__pItemAnnex);
4010                 if (pAnnexCore->HasParent())
4011                 {
4012                         FloatRectangle annexBounds = __pItemAnnex->GetBoundsF();
4013                         float annexPositionX = annexBounds.x;
4014                         float leftMargin = 0.0f;
4015
4016                         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
4017                         leftMargin += __pDrawingProperty->scrollMargin;
4018
4019                         annexPositionX = GetBoundsF().width - annexBounds.width - leftMargin;
4020
4021                         if (!_FloatCompare(annexPositionX, annexBounds.x))
4022                         {
4023                                 __pItemAnnex->SetPosition(FloatPoint(annexPositionX, annexBounds.y));
4024
4025                                 if (__pAccessibilityOnOffElement != null)
4026                                 {
4027                                         __pAccessibilityOnOffElement->SetBounds(__pItemAnnex->GetBoundsF());
4028                                 }
4029                         }
4030                 }
4031         }
4032
4033         // v align
4034         FloatRectangle itemBounds = GetBoundsF();
4035         FloatRectangle annexBounds = __pItemAnnex->GetBoundsF();
4036
4037         if (__customHeight > 0)
4038         {
4039                 itemBounds.height = __customHeight;
4040         }
4041
4042         annexBounds.y = (itemBounds.height - annexBounds.height) / 2;
4043         __pItemAnnex->SetPosition(FloatPoint(annexBounds.x, annexBounds.y));
4044         if (__pAccessibilityOnOffElement != null)
4045         {
4046                 __pAccessibilityOnOffElement->SetBounds(__pItemAnnex->GetBoundsF());
4047         }
4048 }
4049
4050 void
4051 _TableViewItem::SetItemCustomHeight(float height)
4052 {
4053         __customHeight = height;
4054 }
4055
4056 float
4057 _TableViewItem::GetItemCustomHeight(void)
4058 {
4059         return __customHeight;
4060 }
4061
4062 void
4063 _TableViewItem::AdjustChildControlCenterAlign(void)
4064 {
4065         if (__childControlCenterAlign)
4066         {
4067                 FloatDimension itemSize = GetSizeF();
4068
4069                 int childControlCount = GetChildCount();
4070
4071                 for (int i = 0; i < childControlCount; i++)
4072                 {
4073                         _Control* pChildControl = GetChild(i);
4074
4075                         if (pChildControl == null)
4076                         {
4077                                 continue;
4078                         }
4079
4080                         if (__pItemDivider == pChildControl)
4081                         {
4082                                 float positionX = pChildControl->GetPositionF().x;
4083                                 pChildControl->SetPosition(FloatPoint(positionX, itemSize.height - 1));
4084                                 continue;
4085                         }
4086
4087                         if (__pItemTopDivider == pChildControl)
4088                         {
4089                                 float positionX = pChildControl->GetPositionF().x;
4090                                 pChildControl->SetPosition(FloatPoint(positionX, 0));
4091                                 continue;
4092                         }
4093
4094                         FloatRectangle itemBounds = pChildControl->GetBoundsF();
4095
4096                         itemBounds.y = (itemSize.height - itemBounds.height) / 2;
4097
4098                         pChildControl->SetPosition(FloatPoint(itemBounds.x, itemBounds.y));
4099                 }
4100         }
4101 }
4102
4103 void
4104 _TableViewItem::SetChildControlCenterAlign(bool centerAlign)
4105 {
4106         __childControlCenterAlign = centerAlign;
4107 }
4108
4109 Point
4110 _TableViewItem::GetLastTouchPressedPosition(void)
4111 {
4112         return _CoordinateSystemUtils::ConvertToInteger(__touchStartPosition);
4113 }
4114
4115 FloatPoint
4116 _TableViewItem::GetLastTouchPressedPositionF(void)
4117 {
4118         return __touchStartPosition;
4119 }
4120
4121 void
4122 _TableViewItem::SetLastTouchPressedPosition(FloatPoint position)
4123 {
4124         // This function was made to modify of ListView::RefreshList().
4125         // This function could adversely affect touch event handling. So, you should be used with caution.
4126         __touchStartPosition = position;
4127 }
4128
4129 void
4130 _TableViewItem::SetLastTouchPressedPosition(Point position)
4131 {
4132         // This function was made to modify of ListView::RefreshList().
4133         // This function could adversely affect touch event handling. So, you should be used with caution.
4134         __touchStartPosition = _CoordinateSystemUtils::ConvertToFloat(position);
4135 }
4136
4137 bool
4138 _TableViewItem::GetSelectionState(void)
4139 {
4140         return __itemSelected;
4141 }
4142
4143 void
4144 _TableViewItem::SetSelectionState(bool selected)
4145 {
4146         // This function was made to modify of ListView::RefreshList().
4147         // This function could adversely affect touch event handling. So, you should be used with caution.
4148         __itemSelected = selected;
4149 }
4150
4151 bool
4152 _TableViewItem::MoveItem(FloatPoint position, int duration, int delay)
4153 {
4154         _VisualElement* pVisualElement = GetVisualElement();
4155         VisualElementValueAnimation* pAnimation = null;
4156         String animationName = L"MOVE_ITEM";
4157         FloatPoint itemPosition = GetPositionF();
4158         result r = E_SUCCESS;
4159
4160         if (position == itemPosition)
4161         {
4162                 return false;
4163         }
4164
4165         if (__pMoveItemAnimation == null)
4166         {
4167                 __pMoveItemAnimation = new (std::nothrow) VisualElementValueAnimation;
4168                 SysTryCatch(NID_UI_CTRL, __pMoveItemAnimation != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4169
4170                 __pMoveItemAnimation->SetVisualElementAnimationTickEventListener(this);
4171                 r = GetLastResult();
4172                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4173
4174                 __pMoveItemAnimation->SetVisualElementAnimationStatusEventListener(this);
4175                 r = GetLastResult();
4176                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4177         }
4178
4179         pAnimation = __pMoveItemAnimation;
4180
4181         pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut"));
4182         pAnimation->SetDuration(duration);
4183         pAnimation->SetDelay(delay);
4184         pAnimation->SetStartValue(Variant(GetPositionF()));
4185         pAnimation->SetEndValue(Variant(position));
4186
4187         if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
4188         {
4189                 return false;
4190         }
4191
4192         __animationCount++;
4193
4194         return true;
4195
4196 CATCH:
4197
4198         delete __pMoveItemAnimation;
4199         __pMoveItemAnimation = null;
4200
4201         return false;
4202 }
4203
4204 bool
4205 _TableViewItem::ZoomInOutItem(bool zoomOut, int duration, int delay)
4206 {
4207         _VisualElement* pVisualElement = GetVisualElement();
4208         VisualElementValueAnimation* pAnimation = null;
4209         String animationName = L"ZOOM_IN_OUT_ITEM";
4210         FloatDimension itemSize = GetSizeF();
4211         FloatDimension startValue;
4212         FloatDimension endValue;
4213         result r = E_SUCCESS;
4214
4215         if (__pZoomInOutItemAnimation == null)
4216         {
4217                 __pZoomInOutItemAnimation = new (std::nothrow) VisualElementValueAnimation;
4218                 SysTryCatch(NID_UI_CTRL, __pZoomInOutItemAnimation != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4219
4220                 __pZoomInOutItemAnimation->SetVisualElementAnimationTickEventListener(this);
4221                 r = GetLastResult();
4222                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4223
4224                 __pZoomInOutItemAnimation->SetVisualElementAnimationStatusEventListener(this);
4225                 r = GetLastResult();
4226                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4227         }
4228
4229         pAnimation = __pZoomInOutItemAnimation;
4230
4231         if (zoomOut)
4232         {
4233                 startValue = itemSize;
4234                 endValue = FloatDimension(itemSize.width, itemSize.height / 2);
4235                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut"));
4236         }
4237         else
4238         {
4239                 startValue = FloatDimension(itemSize.width, itemSize.height / 2);
4240                 endValue = itemSize;
4241                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn"));
4242         }
4243
4244         pAnimation->SetDuration(duration);
4245         pAnimation->SetDelay(delay);
4246         pAnimation->SetStartValue(Variant(startValue));
4247         pAnimation->SetEndValue(Variant(endValue));
4248
4249         if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
4250         {
4251                 return false;
4252         }
4253
4254         __animationCount++;
4255
4256         return true;
4257
4258 CATCH:
4259         delete __pZoomInOutItemAnimation;
4260         __pZoomInOutItemAnimation = null;
4261
4262         return false;
4263 }
4264
4265 bool
4266 _TableViewItem::FadeInOutItem(bool fadeOut, int duration, int delay)
4267 {
4268         _VisualElement* pVisualElement = GetVisualElement();
4269         VisualElementValueAnimation* pAnimation = null;
4270         String animationName = L"FADE_IN_OUT_ITEM";
4271         float startValue = 0.0f;
4272         float endValue = 1.0f;
4273         result r = E_SUCCESS;
4274
4275         if (__pFadeInOutItemtAnimation == null)
4276         {
4277                 __pFadeInOutItemtAnimation = new (std::nothrow) VisualElementValueAnimation;
4278                 SysTryCatch(NID_UI_CTRL, __pFadeInOutItemtAnimation != null, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4279
4280                 __pFadeInOutItemtAnimation->SetVisualElementAnimationTickEventListener(this);
4281                 r = GetLastResult();
4282                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4283
4284                 __pFadeInOutItemtAnimation->SetVisualElementAnimationStatusEventListener(this);
4285                 r = GetLastResult();
4286                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4287         }
4288
4289         pAnimation = __pFadeInOutItemtAnimation;
4290
4291         if (fadeOut)
4292         {
4293                 startValue = 1.0f;
4294                 endValue = 0.0f;
4295                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut"));
4296         }
4297         else
4298         {
4299                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn"));
4300         }
4301
4302         pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseIn"));
4303         pAnimation->SetDuration(duration);
4304         pAnimation->SetDelay(delay);
4305         pAnimation->SetStartValue(Variant(startValue));
4306         pAnimation->SetEndValue(Variant(endValue));
4307
4308         if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
4309         {
4310                 return false;
4311         }
4312
4313         pVisualElement->SetOpacity(startValue);
4314
4315         __animationCount++;
4316
4317         return true;
4318
4319 CATCH:
4320
4321         delete __pFadeInOutItemtAnimation;
4322         __pFadeInOutItemtAnimation = null;
4323
4324         return false;
4325 }
4326
4327 result
4328 _TableViewItem::SetIndividualSelectionEnabled(const _Control& control, bool enable)
4329 {
4330         result r = E_SUCCESS;
4331         if (enable)
4332         {
4333                 if (!__individualSelectionControls.Contains(control))
4334                 {
4335                         r =  __individualSelectionControls.Add(control);
4336                 }
4337
4338                 _AccessibilityContainer* pContainer = const_cast<_Control*>(&control)->GetAccessibilityContainer();
4339                 pContainer->Activate(true);
4340                 int controlCount = 0;
4341                 for (int i=0; i<GetChildCount(); i++)
4342                 {
4343                         _Control* pChildControl = GetChild(i);
4344                         if (pChildControl == static_cast<_Control*>(__pItemAnnexLeftDivider)
4345                                 || pChildControl == static_cast<_Control*>(__pItemAnnexRightDivider)
4346                                 || pChildControl == static_cast<_Control*>(__pItemCover)
4347                                 || pChildControl == static_cast<_Control*>(__pItemDivider)
4348                                 || pChildControl== static_cast<_Control*>(__pItemTopDivider))
4349                         {
4350                                 continue;
4351                         }
4352
4353                         controlCount++;
4354                 }
4355
4356                 if (controlCount == 0 || __individualSelectionControls.GetCount() == controlCount)
4357                 {
4358                         GetAccessibilityContainer()->Activate(false);
4359                 }
4360                 else
4361                 {
4362                         GetAccessibilityContainer()->Activate(true);
4363                 }
4364         }
4365         else
4366         {
4367                 if (__individualSelectionControls.Contains(control))
4368                 {
4369                         r = __individualSelectionControls.Remove(control, false);
4370                 }
4371         }
4372         return r;
4373 }
4374
4375 bool
4376 _TableViewItem::IsIndividualSelectionEnabled(const _Control& control)
4377 {
4378         return __individualSelectionControls.Contains(control);
4379 }
4380
4381 int
4382 _TableViewItem::AddRef(void)
4383 {
4384         return ++__refCount;
4385 }
4386
4387 int
4388 _TableViewItem::Release(void)
4389 {
4390         --__refCount;
4391         if (__refCount <= 0)
4392         {
4393                 delete this;
4394                 return 0;
4395         }
4396
4397         return __refCount;
4398 }
4399
4400 bool
4401 _TableViewItem::IsAnimationPlaying(void)
4402 {
4403         if (__animationCount > 0)
4404         {
4405                 return true;
4406         }
4407
4408         return false;
4409 }
4410
4411 void
4412 _TableViewItem::StopAllAnimation(void)
4413 {
4414         _VisualElement* pVisualElement = GetVisualElement();
4415
4416         pVisualElement->RemoveAllAnimations();
4417 }
4418
4419 void
4420 _TableViewItem::SetItemDividerEnabled(bool enable)
4421 {
4422         __itemDividerEnabled = enable;
4423 }
4424
4425 void
4426 _TableViewItem::OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue)
4427 {
4428         if (keyName == L"MOVE_ITEM")
4429         {
4430                 FloatPoint position = currentValue.ToFloatPoint();
4431                 SetPosition(position);
4432         }
4433         else if (keyName == L"FADE_IN_OUT_ITEM")
4434         {
4435                 float opacity = currentValue.ToFloat();
4436
4437                 _VisualElement* pVisualElement = GetVisualElement();
4438
4439                 if (pVisualElement != null)
4440                 {
4441                         pVisualElement->SetOpacity(opacity);
4442                 }
4443         }
4444         else if (keyName == L"ZOOM_IN_OUT_ITEM")
4445         {
4446                 FloatDimension size = currentValue.ToFloatDimension();
4447                 SetSize(size);
4448         }
4449 }
4450
4451 void
4452 _TableViewItem::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
4453 {
4454         if (keyName == L"MOVE_ITEM")
4455         {
4456                 __isMoveItemAnimationEnabled = true;
4457         }
4458         else if (keyName == L"FADE_IN_OUT_ITEM")
4459         {
4460                 __isFadeInOutItemAnimationEnabled = true;
4461         }
4462         else if (keyName == L"ZOOM_IN_OUT_ITEM")
4463         {
4464                 __isZoomInOutItemAnimationEnabled = true;
4465         }
4466 }
4467
4468 void
4469 _TableViewItem::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
4470 {
4471 }
4472
4473 void
4474 _TableViewItem::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
4475 {
4476         if (__isAnimationCallbackBlocked)
4477         {
4478                 return;
4479         }
4480
4481         bool tableViewItemAnimation = true;
4482         const VisualElementValueAnimation *pAnimation = dynamic_cast<const VisualElementValueAnimation*>(&(animation));
4483
4484         if (keyName == L"MOVE_ITEM")
4485         {
4486                 if (pAnimation != null)
4487                 {
4488                         FloatPoint position = pAnimation->GetEndValue().ToFloatPoint();
4489
4490                         SetPosition(position);
4491                 }
4492                 __isMoveItemAnimationEnabled = false;
4493         }
4494         else if (keyName == L"FADE_IN_OUT_ITEM")
4495         {
4496                 if (pAnimation != null)
4497                 {
4498                         float opacity = pAnimation->GetEndValue().ToFloat();
4499
4500                         _VisualElement* pVisualElement = GetVisualElement();
4501
4502                         if (pVisualElement != null)
4503                         {
4504                                 pVisualElement->SetOpacity(opacity);
4505                                 Invalidate();
4506                         }
4507                 }
4508                 __isFadeInOutItemAnimationEnabled = false;
4509         }
4510         else if (keyName == L"ZOOM_IN_OUT_ITEM")
4511         {
4512                 if (pAnimation != null)
4513                 {
4514                         FloatDimension size = pAnimation->GetEndValue().ToFloatDimension();
4515
4516                         SetSize(size);
4517                 }
4518                 __isZoomInOutItemAnimationEnabled = false;
4519         }
4520         else
4521         {
4522                 tableViewItemAnimation = false;
4523         }
4524
4525         if (tableViewItemAnimation)
4526         {
4527                 __animationCount--;
4528         }
4529
4530         return;
4531 }
4532
4533 result
4534 _TableViewItem::OnAttachedToMainTree(void)
4535 {
4536         if (!_FloatCompare(GetBoundsF().height, 0.0f))
4537         {
4538                 SetAccessibilityElement();
4539         }
4540
4541         return E_SUCCESS;
4542 }
4543
4544 void
4545 _TableViewItem::SetAccessibilityElement(void)
4546 {
4547         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
4548
4549         if (pContainer != null)
4550         {
4551                 if (__pAccessibilityElement == null)
4552                 {
4553                         __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
4554                         SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4555
4556                         __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
4557                         __pAccessibilityElement->SetName(L"TableViewItem");
4558
4559                         pContainer->AddElement(*__pAccessibilityElement);
4560                 }
4561                 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f,0.0f, GetBoundsF().width, GetBoundsF().height));
4562
4563                 if (__pAccessibilityOnOffElement == null && __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER)
4564                 {
4565                         __pAccessibilityOnOffElement = new (std::nothrow) _AccessibilityElement(true);
4566                         SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityOnOffElement, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
4567
4568                         __pAccessibilityOnOffElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_ON_OFF_BUTTON_T_TTS");
4569                         __pAccessibilityOnOffElement->SetName(L"OnOffButton");
4570                         __pAccessibilityOnOffElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_MOVE_TO_CONTENT_T_TTS");
4571
4572                         pContainer->AddElement(*__pAccessibilityOnOffElement);
4573                         __pAccessibilityOnOffElement->SetBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f));
4574                 }
4575         }
4576 }
4577
4578 _AccessibilityElement*
4579 _TableViewItem::GetAccessibilityElement(void)
4580 {
4581         return __pAccessibilityElement;
4582 }
4583 void
4584 _TableViewItem::SetAccessibilityElementTrait(void)
4585 {
4586         if (__pAccessibilityElement == null)
4587         {
4588                 return;
4589         }
4590         int groupIndex = -1;
4591         int itemIndex = -1;
4592
4593         switch (__annexStyle)
4594         {
4595         case TABLE_VIEW_ANNEX_STYLE_NORMAL:
4596                 GetItemIndex(groupIndex, itemIndex);
4597                 if (groupIndex != -1 && itemIndex == -1)
4598                 {
4599                         __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_GROUP_INDEX");
4600                 }
4601                 break;
4602
4603         case TABLE_VIEW_ANNEX_STYLE_MARK:
4604                 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_TICKBOX_T_TTS");
4605                 break;
4606
4607         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
4608                 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_ON_OFF_BUTTON_T_TTS");
4609                 break;
4610
4611         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
4612                 break;
4613
4614         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
4615                 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_BUTTON_T_TTS");
4616                 break;
4617
4618         case TABLE_VIEW_ANNEX_STYLE_RADIO:
4619                 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_RADIO_BUTTON_T_TTS");
4620                 break;
4621
4622         default:
4623                 break;
4624         }
4625 }
4626 void
4627 _TableViewItem::SetAccessibilityElementValue(void)
4628 {
4629         if (__pAccessibilityElement == null)
4630         {
4631                 return;
4632         }
4633
4634         switch (__annexStyle)
4635         {
4636         case TABLE_VIEW_ANNEX_STYLE_MARK:
4637                 if (IsChecked())
4638                 {
4639                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_TICK_T_TTS");
4640                 }
4641                 else
4642                 {
4643                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_UNTICK_T_TTS");
4644                 }
4645                 break;
4646
4647         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
4648                 if (IsChecked())
4649                 {
4650                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_ON");
4651                 }
4652                 else
4653                 {
4654                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_OFF");
4655                 }
4656                 break;
4657
4658         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
4659                 if (IsChecked())
4660                 {
4661                         if (__pAccessibilityOnOffElement != null)
4662                         {
4663                                 __pAccessibilityOnOffElement->SetValueWithStringId("IDS_TPLATFORM_BODY_ON");
4664                         }
4665                 }
4666                 else
4667                 {
4668                         if (__pAccessibilityOnOffElement != null)
4669                         {
4670                                 __pAccessibilityOnOffElement->SetValueWithStringId("IDS_TPLATFORM_BODY_OFF");
4671                         }
4672                 }
4673                 break;
4674
4675         case TABLE_VIEW_ANNEX_STYLE_RADIO:
4676                 if (IsChecked())
4677                 {
4678                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_SELECTED_T_TTS");
4679                 }
4680                 else
4681                 {
4682                         __pAccessibilityElement->SetValueWithStringId("IDS_TPLATFORM_BODY_NOT_SELECTED_T_TTS");
4683                 }
4684                 break;
4685
4686         default:
4687                 break;
4688         }
4689 }
4690 void
4691 _TableViewItem::SetAccessibilityElementLabel(void)
4692 {
4693         if (__pAccessibilityElement == null)
4694         {
4695                 return;
4696         }
4697
4698         if (__pAccessibilityElement->IsPublicLabelUpdated())
4699         {
4700                 return;
4701         }
4702
4703         String accessibilityLabel;
4704         String space = L" ";
4705         int childControlCount = GetChildCount();
4706
4707         for (int i = 0; i < childControlCount; i++)
4708         {
4709                 _Control* pChildControl = GetChild(i);
4710
4711                 if (pChildControl == null)
4712                 {
4713                         continue;
4714                 }
4715
4716                 if (__pItemDivider == pChildControl || __pItemTopDivider == pChildControl || __pItemCover == pChildControl)
4717                 {
4718                         continue;
4719                 }
4720
4721                 accessibilityLabel += GetChildAccessibilityLabelContent(*pChildControl);
4722                 accessibilityLabel += space;
4723         }
4724
4725         __pAccessibilityElement->SetLabel(accessibilityLabel);
4726 }
4727
4728
4729 bool
4730 _TableViewItem::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4731 {
4732         return false;
4733 }
4734
4735 bool
4736 _TableViewItem::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4737 {
4738         return false;
4739 }
4740
4741 bool
4742 _TableViewItem::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4743 {
4744         return false;
4745 }
4746
4747 bool
4748 _TableViewItem::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4749 {
4750         SetAccessibilityElementLabel();
4751         SetAccessibilityElementTrait();
4752         SetAccessibilityElementValue();
4753         return false;
4754 }
4755
4756 bool
4757 _TableViewItem::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4758 {
4759         return false;
4760 }
4761
4762 bool
4763 _TableViewItem::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4764 {
4765         return false;
4766 }
4767
4768 bool
4769 _TableViewItem::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4770 {
4771         switch (__annexStyle)
4772         {
4773         case TABLE_VIEW_ANNEX_STYLE_NORMAL:
4774                 break;
4775
4776         case TABLE_VIEW_ANNEX_STYLE_MARK:
4777                 if (IsChecked())
4778                 {
4779                         String string;
4780                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_TICK_T_TTS,string);
4781                         _AccessibilityManager::GetInstance()->ReadContent(string);
4782                 }
4783                 else
4784                 {
4785                         String string;
4786                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_UNTICK_T_TTS,string);
4787                         _AccessibilityManager::GetInstance()->ReadContent(string);
4788                 }
4789                 break;
4790         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
4791                 if (IsChecked())
4792                 {
4793                         String string;
4794                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_ON,string);
4795                         _AccessibilityManager::GetInstance()->ReadContent(string);
4796                 }
4797                 else
4798                 {
4799                         String string;
4800                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_OFF,string);
4801                         _AccessibilityManager::GetInstance()->ReadContent(string);
4802                 }
4803                 break;
4804
4805         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER:
4806                 if (&element == __pAccessibilityOnOffElement && IsEnabled())
4807                 {
4808                         if (IsChecked())
4809                         {
4810                                 SetChecked(false);
4811                                 String string;
4812                                 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_OFF,string);
4813                                 _AccessibilityManager::GetInstance()->ReadContent(string);
4814                         }
4815                         else
4816                         {
4817                                 SetChecked(true);
4818                                 String string;
4819                                 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_ON,string);
4820                                 _AccessibilityManager::GetInstance()->ReadContent(string);
4821                         }
4822                 }
4823                 break;
4824
4825         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
4826                 break;
4827
4828         case TABLE_VIEW_ANNEX_STYLE_RADIO:
4829                 if (IsChecked())
4830                 {
4831                         String string;
4832                         GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT,string);
4833                         _AccessibilityManager::GetInstance()->ReadContent(string);
4834                 }
4835                 else
4836                 {
4837                         String string;
4838                         GET_STRING_CONFIG(IDS_TPLATFORM_BODY_NOT_SELECTED_T_TTS,string);
4839                         _AccessibilityManager::GetInstance()->ReadContent(string);
4840                 }
4841                 break;
4842         default:
4843                 break;
4844         }
4845
4846         return false;
4847 }
4848
4849 bool
4850 _TableViewItem::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4851 {
4852         return false;
4853 }
4854
4855 bool
4856 _TableViewItem::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
4857 {
4858         return false;
4859 }
4860
4861 bool
4862 _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
4863 {
4864         __isTouchCancelOnPressRelease = false;
4865
4866         if (!IsFocusModeStateEnabled())
4867         {
4868                 return false;
4869         }
4870
4871         _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
4872         _KeyCode keyCode = keyInfo.GetKeyCode();
4873         IListT<_Control*>* pFocusList = GetFocusListN();
4874         SysTryReturn(NID_UI_CTRL, pFocusList != null, true, GetLastResult(), "[%s] propagating.", GetErrorMessage(GetLastResult()));
4875
4876         _Control* pChildControl = null;
4877         _Control* pFocusedControl = null;
4878         _Window* pTop = source.GetRootWindow();
4879
4880         if (pTop)
4881         {
4882                 pFocusedControl = pTop->GetCurrentFocusControl();
4883         }
4884
4885         int count  = pFocusList->GetCount();
4886
4887         if (pFocusedControl == null)
4888         {
4889                   return false;
4890         }
4891
4892         switch (keyCode)
4893         {
4894         case _KEY_LEFT:
4895                 if (!IsFocused())
4896                 {
4897                         for (int i=count-1; i>=0; i--)
4898                         {
4899                                 pFocusList->GetAt(i, pChildControl);
4900                                 if (pChildControl == null)
4901                                 {
4902                                         continue;
4903                                 }
4904
4905                                 if (pChildControl->IsFocused())
4906                                 {
4907                                         if (i == 0)
4908                                         {
4909                                                 pChildControl = null;
4910                                                 break;
4911                                         }
4912
4913                                         for (int j=i-1; j>=0; j--)
4914                                         {
4915                                                 pFocusList->GetAt(j, pChildControl);
4916                                                 if (pChildControl == null)
4917                                                 {
4918                                                         continue;
4919                                                 }
4920
4921                                                 if (pChildControl->IsFocusable() && pChildControl->GetEnableState()
4922                                                                 && pChildControl->GetVisibleState())
4923                                                 {
4924                                                         break;
4925                                                 }
4926                                                 else
4927                                                 {
4928                                                         pChildControl = null;
4929                                                 }
4930                                         }
4931                                         break;
4932                                 }
4933                         }
4934
4935                         if (pChildControl && pChildControl->GetEnableState()
4936                                         && pChildControl->GetVisibleState() && pChildControl->IsFocusable())
4937                         {
4938                                 if (pParent != null)
4939                                 {
4940                                         pParent->SetAnnexFocused(true);
4941                                 }
4942                                 pChildControl->SetFocused(true);
4943                                 pChildControl->DrawFocus();
4944                         }
4945                         else
4946                         {
4947                                 _Control* pParentControl = pFocusedControl->GetParent();
4948                                 _TableViewItem* pItem = dynamic_cast<_TableViewItem*>(pParentControl);
4949
4950                                 if (pItem != null && pItem->GetEnableState() && !pItem->IsFocused()
4951                                                 && pItem->GetVisibleState() && pItem->IsFocusable())
4952                                 {
4953                                         if (pParent != null)
4954                                         {
4955                                                 pParent->SetAnnexFocused(false);
4956                                         }
4957                                         pItem->SetFocused(true);
4958                                         pItem->DrawFocus();
4959                                 }
4960                         }
4961                 }
4962                 break;
4963
4964         case _KEY_RIGHT:
4965                 if (IsFocused())
4966                 {
4967                         if (pChildControl == null)
4968                         {
4969                                 for (int i=0; i<count; i++)
4970                                 {
4971                                         pFocusList->GetAt(i, pChildControl);
4972                                         if (pChildControl == null)
4973                                         {
4974                                                 continue;
4975                                         }
4976
4977                                         if (pChildControl->IsFocusable() && pChildControl->GetEnableState()
4978                                                         && pChildControl->GetVisibleState())
4979                                         {
4980                                                 break;
4981                                         }
4982                                         else
4983                                         {
4984                                                 pChildControl = null;
4985                                         }
4986                                 }
4987                         }
4988                 }
4989                 else
4990                 {
4991                         for (int i=0; i<count; i++)
4992                         {
4993                                 pFocusList->GetAt(i, pChildControl);
4994                                 if (pChildControl == null)
4995                                 {
4996                                         continue;
4997                                 }
4998
4999                                 if (pChildControl->IsFocused())
5000                                 {
5001                                         if (i == count -1)
5002                                         {
5003                                                 pChildControl = null;
5004                                                 break;
5005                                         }
5006
5007                                         for (int j=i+1; j<count; j++)
5008                                         {
5009                                                 pFocusList->GetAt(j, pChildControl);
5010                                                 if (pChildControl == null)
5011                                                 {
5012                                                         continue;
5013                                                 }
5014
5015                                                 if (pChildControl->IsFocusable() && pChildControl->GetEnableState()
5016                                                                 && pChildControl->GetVisibleState())
5017                                                 {
5018                                                         break;
5019                                                 }
5020                                                 else
5021                                                 {
5022                                                         pChildControl = null;
5023                                                 }
5024                                         }
5025                                         break;
5026                                 }
5027                         }
5028                 }
5029
5030                 if (pChildControl && pChildControl->GetEnableState() && pChildControl->GetVisibleState()
5031                                 && pChildControl->IsFocusable())
5032                 {
5033                         if (pParent != null)
5034                         {
5035                                 pParent->SetAnnexFocused(true);
5036                         }
5037                         pChildControl->SetFocused(true);
5038                         pChildControl->DrawFocus();
5039                 }
5040                 break;
5041
5042         case _KEY_ENTER:
5043                 if (&source == this)
5044                 {
5045                         __pressedControl = TABLE_VIEW_ITEM_PRESSED_ITEM;
5046                 }
5047                 else if (&source == GetLabelCore(__pItemAnnex))
5048                 {
5049                         __pressedControl = TABLE_VIEW_ITEM_PRESSED_ANNEX;
5050                 }
5051                 else if (IsIndividualSelectionEnabled(source))
5052                 {
5053                         __pressedControl = TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL;
5054                 }
5055                 else
5056                 {
5057                         __pressedControl = TABLE_VIEW_ITEM_PRESSED_NONE;
5058                 }
5059                 __itemSelected = true;
5060                 FireItemTouchPressed();
5061                 break;
5062
5063         default:
5064                 if (__itemSelected)
5065                 {
5066                         __annexOnOffHandlerMoved = false;
5067                         __itemTouchMoved = false;
5068
5069                         __itemSelected = false;
5070                         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
5071
5072                         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
5073                         {
5074                                 __isSelectedDetailButton = false;
5075                         }
5076
5077                         SetItemChanged(true);
5078                         Invalidate();
5079                 }
5080                 return false;
5081         }
5082
5083         return true;
5084 }
5085
5086 bool
5087 _TableViewItem::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
5088 {
5089         if (!IsFocusModeStateEnabled())
5090         {
5091                 return false;
5092         }
5093
5094         _KeyCode keyCode = keyInfo.GetKeyCode();
5095
5096         if (keyCode == _KEY_ENTER)
5097         {
5098                 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
5099                 SysTryReturn(NID_UI_CTRL, pParent != null, true, GetLastResult(), "[%s] propagating.", GetErrorMessage(GetLastResult()));
5100
5101                 pParent->StopExpandCollapseAnimation();
5102                 if (&source == this)
5103                 {
5104                         __releasedControl = TABLE_VIEW_ITEM_PRESSED_ITEM;
5105                 }
5106                 else if (&source == GetLabelCore(__pItemAnnex))
5107                 {
5108                         __releasedControl = TABLE_VIEW_ITEM_PRESSED_ANNEX;
5109                 }
5110                 else if (IsIndividualSelectionEnabled(source))
5111                 {
5112                         __releasedControl = TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL;
5113                 }
5114                 else
5115                 {
5116                         __releasedControl = TABLE_VIEW_ITEM_PRESSED_NONE;
5117                 }
5118                 FireItemTouchReleased();
5119                 return true;
5120         }
5121         else if (keyCode == _KEY_LEFT || keyCode == _KEY_RIGHT)
5122         {
5123                 return true;
5124         }
5125
5126         return false;
5127 }
5128
5129 void
5130 _TableViewItem::OnFocusModeStateChanged(void)
5131 {
5132         __releasedControl = TABLE_VIEW_ITEM_PRESSED_NONE;
5133
5134         ResetItemState();
5135 }
5136
5137 void
5138 _TableViewItem::ResetItemState(void)
5139 {
5140         __itemSelected = false;
5141         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
5142
5143         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
5144         {
5145                 __isSelectedDetailButton = false;
5146         }
5147
5148         SetItemChanged(true);
5149         Invalidate();
5150 }
5151
5152 _Control*
5153 _TableViewItem::GetPreviousFocusChildControl(const _Control& source)
5154 {
5155          _Control* pParentControl = null;
5156          float sourcePosition = 0.0f;
5157
5158          _Control* pSource = const_cast<_Control*>(&source);
5159          _TableViewItem* pItem = dynamic_cast<_TableViewItem*>(pSource);
5160          if (pItem != null)
5161          {
5162                  pParentControl = pSource;
5163                  sourcePosition = pParentControl->GetBoundsF().width;
5164          }
5165          else
5166          {
5167                  pParentControl = source.GetParent();
5168                  sourcePosition = source.GetBoundsF().x;
5169          }
5170
5171          if (pParentControl == null)
5172          {
5173                  return null;
5174          }
5175
5176          int childControlCount = pParentControl->GetChildCount();
5177          float position = 0.0f;
5178          _Control* destination = null;
5179
5180          for (int i=0; i<childControlCount; i++)
5181          {
5182                  _Control* pChildControl = pParentControl->GetChild(i);
5183                  if (pChildControl != null && pChildControl->IsFocusable())
5184                  {
5185                          float childPosition = pChildControl->GetBoundsF().x;
5186                          if (childPosition < sourcePosition)
5187                          {
5188                                  if (childPosition > position)
5189                                  {
5190                                          position = childPosition;
5191                                          destination = pChildControl;
5192                                  }
5193                                  else if (_FloatCompare(position, 0.0f))
5194                                  {
5195                                          position = childPosition;
5196                                          destination = pChildControl;
5197                                  }
5198                          }
5199                  }
5200          }
5201          return destination;
5202 }
5203
5204 _Control*
5205 _TableViewItem::GetNextFocusChildControl(const _Control& source)
5206 {
5207          _Control* pParentControl = null;
5208          float sourcePosition = 0.0f;
5209
5210          _Control* pSource = const_cast<_Control*>(&source);
5211          _TableViewItem* pItem = dynamic_cast<_TableViewItem*>(pSource);
5212          if (pItem != null)
5213          {
5214                  pParentControl = pSource;
5215                  sourcePosition = 0.0f;
5216          }
5217          else
5218          {
5219                  pParentControl = source.GetParent();
5220                  sourcePosition = source.GetBoundsF().x;
5221          }
5222
5223          if (pParentControl == null)
5224          {
5225                  return null;
5226          }
5227
5228          int childControlCount = pParentControl->GetChildCount();
5229          float position = 0.0f;
5230          _Control* destination = null;
5231
5232          for (int i=0; i<childControlCount; i++)
5233          {
5234                  _Control* pChildControl = pParentControl->GetChild(i);
5235                  if (pChildControl != null && pChildControl->IsFocusable())
5236                  {
5237                          float childPosition = pChildControl->GetBoundsF().x;
5238                          if (childPosition > sourcePosition)
5239                          {
5240                                  if (childPosition < position)
5241                                  {
5242                                          position = childPosition;
5243                                          destination = pChildControl;
5244                                  }
5245                                  else if (_FloatCompare(position, 0.0f))
5246                                  {
5247                                          position = childPosition;
5248                                          destination = pChildControl;
5249                                  }
5250                          }
5251                  }
5252          }
5253          return destination;
5254 }
5255
5256 bool
5257 _TableViewItem::IsChildControlFocusManage(void) const
5258 {
5259         return true;
5260 }
5261
5262 void
5263 _TableViewItem::SetSimpleLastItemEnabled(bool enable)
5264 {
5265         __isSimpleLastItem = enable;
5266 }
5267
5268 void
5269 _TableViewItem::SetSectionItem(bool isSectionItem)
5270 {
5271     __isSectionItem = isSectionItem;
5272 }
5273
5274 void
5275 _TableViewItem::SetTouchPressOnScroll(bool isTouch)
5276 {
5277         __isTouchPressOnScroll = isTouch;
5278 }
5279
5280 bool
5281 _TableViewItem::IsTouchPressOnScroll(void) const
5282 {
5283         return __isTouchPressOnScroll;
5284 }
5285
5286 void
5287 _TableViewItem::OnVisibleStateChanged(void)
5288 {
5289         if (IsFocused())
5290         {
5291                 RemoveFocusRing();
5292         }
5293 }
5294
5295 void
5296 _TableViewItem::OnAncestorEnableStateChanged(const _Control& control)
5297 {
5298         if (IsFocused())
5299         {
5300                 RemoveFocusRing();
5301         }
5302 }
5303
5304 void
5305 _TableViewItem::OnAncestorVisibleStateChanged(const _Control& control)
5306 {
5307         if (IsFocused())
5308         {
5309                 RemoveFocusRing();
5310         }
5311 }
5312
5313 void
5314 _TableViewItem::OnFocusableStateChanged(bool focusableState)
5315 {
5316         if (IsFocused() && !focusableState)
5317         {
5318                 RemoveFocusRing();
5319         }
5320 }
5321
5322 void
5323 _TableViewItem::SetPublicLabelUpdate(bool resetPublicLabelUpdate)
5324 {
5325         if (__pAccessibilityElement)
5326         {
5327                 __pAccessibilityElement->SetPublicLabelUpdate(resetPublicLabelUpdate);
5328         }
5329 }
5330
5331 String
5332 _TableViewItem::GetChildAccessibilityLabelContent(const _Control& source)
5333 {
5334         String accessibilityLabel = L"";
5335         String space = L" ";
5336
5337         if (IsIndividualSelectionEnabled(source))
5338         {
5339                 return accessibilityLabel;
5340         }
5341
5342         if (!source.IsVisible() || !source.GetEnableState())
5343         {
5344                 return accessibilityLabel;
5345         }
5346
5347         _Control* pSource = const_cast<_Control*>(&source);
5348
5349         if (pSource)
5350         {
5351                 _AccessibilityContainer* pContainer = pSource->GetAccessibilityContainer();
5352                 LinkedListT<_AccessibilityElement*> accessibilityElements;
5353                 _AccessibilityElement* pElement = null;
5354
5355                 if (pContainer)
5356                 {
5357                         pContainer->GetElements(accessibilityElements);
5358                         int elementCount = accessibilityElements.GetCount();
5359
5360                         for (int i = 0; i < elementCount; i++)
5361                         {
5362                                 if (accessibilityElements.GetAt(i, pElement) == E_SUCCESS)
5363                                 {
5364                                         accessibilityLabel += pElement->GetLabel();
5365                                         accessibilityLabel += space;
5366                                 }
5367                         }
5368                 }
5369         }
5370
5371         //check for children
5372         int childControlCount = source.GetChildCount();
5373
5374         for (int i = 0; i < childControlCount; i++)
5375         {
5376                 _Control* pChildControl = source.GetChild(i);
5377
5378                 if (pChildControl == null)
5379                 {
5380                         continue;
5381                 }
5382
5383                 accessibilityLabel += GetChildAccessibilityLabelContent(*pChildControl);
5384         }
5385
5386         return accessibilityLabel;
5387 }
5388
5389 void
5390 _TableViewItem::DeactivateChildAccessibilityContainer(const _Control& source)
5391 {
5392         _Control* pControl = const_cast<_Control*>(&source);
5393
5394         if (pControl)
5395         {
5396                 _AccessibilityContainer* pContainer = pControl->GetAccessibilityContainer();
5397
5398                 if (pContainer)
5399                 {
5400                         if (__individualSelectionControls.Contains(source))
5401                         {
5402                                 pContainer->Activate(true);
5403                         }
5404                         else
5405                         {
5406                                 pContainer->Activate(false);
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                 DeactivateChildAccessibilityContainer(*pChildControl);
5424         }
5425 }
5426
5427 }}} // Tizen::Ui::Controls
5428