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