Tizen 2.1 base
[framework/osp/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 Flora License, Version 1.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://floralicense.org/license/
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
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Runtime;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Ui::Animations;
38 using namespace Tizen::Graphics;
39
40 namespace Tizen { namespace Ui { namespace Controls
41 {
42
43 _TableViewItem::_TableViewItem(int itemHeight)
44         : _Control()
45         , __pAppInfo(null)
46         , __refCount(1)
47         , __itemHeight(itemHeight)
48         , __itemGroupIndex(-1)
49         , __itemIndex(-1)
50         , __checkedState(false)
51         , __enabledState(true)
52         , __itemChanged(true)
53         , __reorderMode(false)
54         , __itemSelected(false)
55         , __childMarginState(false)
56         , __annexStyle(TABLE_VIEW_ANNEX_STYLE_NORMAL)
57         , __drawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
58         , __selectionStyle(TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE)
59         , __itemType(TABLE_VIEW_ITEM_TYPE_NONE)
60         , __pContextItem(null)
61         , __isContextItem(false)
62         , __isContextItemActivated(false)
63         , __checkItemHeightNeeded(false)
64         , __pItemDivider(null)
65         , __pItemTopDivider(null)
66         , __pItemAnnex(null)
67         , __itemWidth(0)
68         , __pDrawingProperty(null)
69         , __itemDividerEnabled(true)
70         , __pSimpleItemText(null)
71         , __pSimpleItemBitmap(null)
72         , __simpleItemTextSize(0)
73         , __pDimLayer(null)
74         , __touchStartPosition(0, 0)
75         , __isTouchMoved(false)
76         , __childControlCenterAlign(false)
77         , __customHeight(0)
78         , __animationCount(0)
79         , __pAccessibilityElement(null)
80         , __pCheckedTimer(null)
81         , __isCheckedTimerEnabled(false)
82         , __isCheckedAnimationEnabled(false)
83         , __checkedCount(0)
84         , __checkedBounds(Rectangle(0, 0, 0, 0))
85         , __pHighlightVisualElement(null)
86 {
87         for (int i = 0; i < 3; i++)
88         {
89                 __pItemBgBitmap[i] = null;
90         }
91
92         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_NORMAL, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]); // for support opacity 0x00
93         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_PRESSED, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED]);
94         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_HIGHLIGHTED, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED]);
95
96         GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_NORMAL, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
97         GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_PRESSED, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED]);
98         GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_HIGHLIGHTED, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED]);
99         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_NORMAL, __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]);
100         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_PRESSED, __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED]);
101         GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_DISABLED, __simpleItemTextColor[TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED]);
102
103
104         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
105         if (pContainer)
106         {
107                 pContainer->Activate(true);
108                 pContainer->AddListener(*this);
109         }
110 }
111
112 _TableViewItem::~_TableViewItem()
113 {
114         _VisualElement* pVisualElement = GetVisualElement();
115         if (pVisualElement != null)
116         {
117                 pVisualElement->RemoveAllAnimations();
118         }
119
120         for (int j = 0; j < 3; j++)
121         {
122                 delete __pItemBgBitmap[j];
123                 __pItemBgBitmap[j] = null;
124         }
125
126         if (__pHighlightVisualElement != null)
127         {
128                 __pHighlightVisualElement->RemoveAllAnimations();
129                 __pHighlightVisualElement->SetAnimationProvider(null);
130                 __pHighlightVisualElement->Destroy();
131                 __pHighlightVisualElement = null;
132         }
133
134         DetachAllChildren();
135
136         if (GetParent() != null && __isContextItem == true)
137         {
138                 GetParent()->DetachChild(*this);
139         }
140
141         delete __pItemDivider;
142         __pItemDivider = null;
143
144         delete __pItemTopDivider;
145         __pItemTopDivider = null;
146
147         delete __pItemAnnex;
148         __pItemAnnex = null;
149
150         delete __pDimLayer;
151         __pDimLayer = null;
152
153         if (__isCheckedTimerEnabled)
154         {
155                 __pCheckedTimer->Cancel();
156         }
157
158         delete __pCheckedTimer;
159         __pCheckedTimer = null;
160
161         if (__pAccessibilityElement)
162         {
163                 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
164                 if(pContainer)
165                 {
166                         pContainer->RemoveAllElement();
167                 }
168                 __pAccessibilityElement = null;
169         }
170 }
171
172 _TableViewItem*
173 _TableViewItem::CreateTableViewItemN(int itemHeight)
174 {
175         result r = E_SUCCESS;
176
177         _TableViewItem* pItem = null;
178         pItem = new (std::nothrow) _TableViewItem(itemHeight);
179         SysTryReturn(NID_UI_CTRL, pItem, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
180
181         pItem->AcquireHandle();
182
183         r = pItem->Initialize();
184         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] Unable to create TableView Item");
185
186         return pItem;
187
188 CATCH:
189         delete pItem;
190
191         return null;
192 }
193
194 result
195 _TableViewItem::Initialize(void)
196 {
197         GetVisualElement()->SetSurfaceOpaque(false);
198
199         result r = E_SUCCESS;
200
201         __pHighlightVisualElement = new (std::nothrow) _VisualElement();
202         SysTryCatch(NID_UI_CTRL, __pHighlightVisualElement != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
203
204         r = __pHighlightVisualElement->Construct();
205         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct Visual Element.", GetErrorMessage(r));
206
207         r = __pHighlightVisualElement->SetSurfaceOpaque(false);
208         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set surface opaque.", GetErrorMessage(r));
209
210         __pHighlightVisualElement->SetImplicitAnimationEnabled(false);
211
212         r = GetVisualElement()->AttachChild(*__pHighlightVisualElement);
213         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach child to the control VisualElement.", GetErrorMessage(r));
214
215         r = SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
216         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r));
217
218         __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f));
219         __pHighlightVisualElement->SetShowState(true);
220
221         r = __individualSelectionControls.Construct(DEFAULT_CAPTURED_CONTROL_COUNT);
222         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to construct ArrayList", GetErrorMessage(r));
223
224         SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE);
225
226         return r;
227
228 CATCH:
229         if (__pHighlightVisualElement != null)
230         {
231                 __pHighlightVisualElement->RemoveAllAnimations();
232                 __pHighlightVisualElement->SetAnimationProvider(null);
233                 __pHighlightVisualElement->Destroy();
234                 __pHighlightVisualElement = null;
235         }
236
237         return r;
238 }
239
240 _TableViewItem*
241 _TableViewItem::GetContextItem(void) const
242 {
243         return __pContextItem;
244 }
245
246 void
247 _TableViewItem::SetContextItem(_TableViewItem* pContextItem)
248 {
249         if (pContextItem != null)
250         {
251                 pContextItem->__isContextItem = true;
252         }
253
254         __pContextItem = pContextItem;
255 }
256
257 bool
258 _TableViewItem::IsContextItem(void) const
259 {
260         return __isContextItem;
261 }
262
263 void
264 _TableViewItem::SetContextItemActivation(bool activated)
265 {
266         __isContextItemActivated = activated;
267 }
268
269 bool
270 _TableViewItem::IsContextItemActivated(void) const
271 {
272         return __isContextItemActivated;
273 }
274
275 result
276 _TableViewItem::CreateItemDimLayer(void)
277 {
278         result r = E_SUCCESS;
279
280         if (__pDimLayer == null)
281         {
282                 __pDimLayer = _Label::CreateLabelN();
283
284                 r = GetLastResult();
285                 SysTryReturn(NID_UI_CTRL, __pDimLayer != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
286
287                 __pDimLayer->SetBackgroundColor(Color(0, 0, 0, BACKGROUND_DIMMED_OPACITY * 0xff));
288                 __pDimLayer->SetVisibleState(false);
289
290                 AttachSystemChild(*__pDimLayer);
291         }
292
293         return r;
294 }
295
296 void
297 _TableViewItem::ExposeContextItem(Rectangle itemBounds, int targetWidth)
298 {
299         DrawItemDivider();
300         if (__pDimLayer == null)
301         {
302                 if (CreateItemDimLayer() != E_SUCCESS)
303                 {
304                         return;
305                 }
306         }
307
308         SetBounds(itemBounds);
309
310         bool visible = true;
311
312         if ((itemBounds.width <= 0) || (itemBounds.width >= targetWidth))
313         {
314                 visible = false;
315         }
316
317         if (visible)
318         {
319                 int rightMargin = 0;
320                 float dimLayerOpacity = 0.0f;
321
322                 GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, rightMargin);
323                 dimLayerOpacity = BACKGROUND_DIMMED_OPACITY - ((itemBounds.width * BACKGROUND_DIMMED_OPACITY) / (targetWidth - rightMargin));
324                 dimLayerOpacity = ((dimLayerOpacity < 0) ? 0 :  dimLayerOpacity);
325
326                 __pDimLayer->SetBounds(Rectangle(0, 0, itemBounds.width, itemBounds.height));
327                 __pDimLayer->SetBackgroundColor(Color(0, 0, 0, dimLayerOpacity * 0xff));
328         }
329
330         __pDimLayer->SetVisibleState(visible);
331
332 }
333
334 void
335 _TableViewItem::DrawItemDimLayer(bool visible)
336 {
337         if (__pDimLayer == null)
338         {
339                 if (CreateItemDimLayer() != E_SUCCESS)
340                 {
341                         return;
342                 }
343         }
344
345         if (visible)
346         {
347                 Dimension itemSize = GetSize();
348                 __pDimLayer->SetBounds(Rectangle(0, 0, itemSize.width, itemSize.height));
349                 __pDimLayer->SetBackgroundColor(Color(0, 0, 0, BACKGROUND_DISABLED_OPACITY * 0xff));
350         }
351
352         __pDimLayer->SetVisibleState(visible);
353 }
354
355 void
356 _TableViewItem::SetItemWidth(int width)
357 {
358         __itemWidth = width;
359 }
360
361 bool
362 _TableViewItem::SetItemBackgroundBitmap(ListItemState itemState, const Bitmap* pBitmap)
363 {
364         Bitmap* pCopyBitmap = null;
365
366         pCopyBitmap = _BitmapImpl::CloneN(*pBitmap);
367         SysTryReturn(NID_UI_CTRL, pCopyBitmap != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
368
369         delete __pItemBgBitmap[itemState];
370         __pItemBgBitmap[itemState] = pCopyBitmap;
371
372         SetItemChanged(true);
373
374         return true;
375 }
376
377 Tizen::Graphics::Bitmap*
378 _TableViewItem::GetItemBackgroundBitmap(ListItemState itemState) const
379 {
380         return __pItemBgBitmap[itemState];
381 }
382
383 void
384 _TableViewItem::SetItemBackgroundColor(ListItemState itemState, const Color bgColor)
385 {
386         __colorItemBg[itemState] = bgColor;
387
388         SetItemChanged(true);
389 }
390
391 Color
392 _TableViewItem::GetItemBackgroundColor(ListItemState itemState) const
393 {
394         return __colorItemBg[itemState];
395 }
396
397 void
398 _TableViewItem::SetItemStyle(TableViewAnnexStyle style)
399 {
400         if (__annexStyle == style)
401         {
402                 return;
403         }
404
405         __annexStyle = style;
406 }
407
408 result
409 _TableViewItem::SetSelectionStyle(TableViewItemSelectionStyle style)
410 {
411         __selectionStyle = style;
412
413         return E_SUCCESS;
414 }
415
416 TableViewItemSelectionStyle
417 _TableViewItem::GetSelectionStyle(void) const
418 {
419         return __selectionStyle;
420 }
421
422 int
423 _TableViewItem::GetItemHeight(void) const
424 {
425         return GetSize().height;
426 }
427
428 void
429 _TableViewItem::SetItemHeight(int itemHeight)
430 {
431         SetSize(Dimension(GetSize().width, itemHeight));
432 }
433
434 void
435 _TableViewItem::SetChecked(bool checked)
436 {
437         if (__checkedState == checked)
438         {
439                 return;
440         }
441
442         __checkedState = checked;
443
444         SetItemChanged(true);
445 }
446
447 bool
448 _TableViewItem::IsChecked(void) const
449 {
450         return __checkedState;
451 }
452
453 void
454 _TableViewItem::SetCheckedAnimationEnabled(bool enabled)
455 {
456         __isCheckedAnimationEnabled = enabled;
457
458         if (__isCheckedAnimationEnabled == false)
459         {
460                 StopCheckBoxAnimation();
461         }
462 }
463
464 void
465 _TableViewItem::SetItemEnabled(bool enabled)
466 {
467         if (__enabledState == enabled)
468         {
469                 return;
470         }
471
472         __enabledState = enabled;
473
474         SetEnableState(enabled);
475
476         SetItemChanged(true);
477
478         Invalidate();
479
480         return;
481 }
482
483 bool
484 _TableViewItem::IsItemEnabled(void) const
485 {
486         return __enabledState;
487 }
488
489 void
490 _TableViewItem::SetItemType(const TableViewItemType itemType)
491 {
492         __itemType = itemType;
493
494         if (__pContextItem != null)
495         {
496                 __pContextItem->SetItemType(__itemType);
497         }
498 }
499
500 void
501 _TableViewItem::SetItemIndex(int groupIndex, int itemIndex)
502 {
503         __itemGroupIndex = groupIndex;
504         __itemIndex = itemIndex;
505 }
506
507 void
508 _TableViewItem::GetItemIndex(int& groupIndex, int& itemIndex) const
509 {
510         groupIndex = __itemGroupIndex;
511         itemIndex = __itemIndex;
512 }
513
514
515 TableViewItemType
516 _TableViewItem::GetItemType(void) const
517 {
518         return __itemType;
519 }
520
521 bool
522 _TableViewItem::IsReorderMode(void) const
523 {
524         return __reorderMode;
525 }
526
527 void
528 _TableViewItem::SetReorderMode(bool enabled)
529 {
530         __reorderMode = enabled;
531
532         if (GetItemStyle() != TABLE_VIEW_ANNEX_STYLE_NORMAL)
533         {
534                 if (__pItemAnnex != null)
535                 {
536                         __pItemAnnex->SetVisibleState(!enabled);
537                 }
538                 else
539                 {
540                         SetItemChanged(true);
541                         Invalidate();
542                 }
543         }
544 }
545
546 void
547 _TableViewItem::SetAppInfo(const void* pAppInfo)
548 {
549         __pAppInfo = const_cast<void*>(pAppInfo);
550 }
551
552 void*
553 _TableViewItem::GetAppInfo(void) const
554 {
555         return __pAppInfo;
556 }
557
558 void
559 _TableViewItem::SetItemChanged(bool changed)
560 {
561         __itemChanged = changed;
562 }
563
564 bool
565 _TableViewItem::IsItemChanged(void) const
566 {
567         return __itemChanged;
568 }
569
570 TableViewAnnexStyle
571 _TableViewItem::GetItemStyle(void) const
572 {
573         return __annexStyle;
574 }
575
576 bool
577 _TableViewItem::DrawItem(Rectangle& rcItem, ListItemState itemState, bool itemDivider)
578 {
579         return true;
580 }
581
582 void
583 _TableViewItem::FireItemEvent(bool selectedBody)
584 {
585         if (HasParent() == false)
586         {
587                 return;
588         }
589
590         if (IsContextItem())
591         {
592                 return;
593         }
594
595         _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
596         if (pParent == null)
597         {
598                 return;
599         }
600
601         TableViewNotifyType eventType = TABLEVIEW_NOTIFY_TYPE_SELECTED_ITEM;
602
603         if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
604                 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
605                 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING))
606         {
607                 if (IsChecked())
608                 {
609                         eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK;
610                 }
611                 else
612                 {
613                         eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK;
614                 }
615         }
616         else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
617         {
618                 if (!selectedBody)
619                 {
620                         eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_MORE;
621                 }
622         }
623
624         __checkItemHeightNeeded = true;
625
626         int groupIndex = -1;
627         int itemIndex = -1;
628
629         GetItemIndex(groupIndex, itemIndex);
630         pParent->FireTableViewItemEvent(groupIndex, itemIndex, eventType, this);
631 }
632
633 void
634 _TableViewItem::FireItemSweepEvent(TableViewSweepDirection direction)
635 {
636         if (HasParent() == false)
637         {
638                 return;
639         }
640
641         _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
642         if (pParent == null)
643         {
644                 return;
645         }
646
647         int groupIndex = -1;
648         int itemIndex = -1;
649         GetItemIndex(groupIndex, itemIndex);
650
651         pParent->FireTableViewItemSweepEvent(groupIndex, itemIndex, direction);
652 }
653
654 bool
655 _TableViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
656 {
657         if (&source != this || IsAnimationPlaying())
658         {
659                 return false;
660         }
661
662         if (IsContextItem() || __isContextItemActivated)
663         {
664                 return true;
665         }
666
667         __isTouchMoved = false;
668         __touchStartPosition = touchinfo.GetCurrentPosition();
669
670         __itemSelected = true;
671         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
672
673         SetItemChanged(true);
674         Invalidate();
675
676         return true;
677 }
678
679 bool
680 _TableViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
681 {
682         if (&source != this)
683         {
684                 return false;
685         }
686
687         bool fireEvent = false;
688
689         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
690
691         if (__itemSelected == true)
692         {
693                 if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
694                         || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
695                         || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING))
696                 {
697                         bool checked = IsChecked();
698                         SetChecked(!checked);
699                         SetCheckedAnimationEnabled(!checked);
700                 }
701
702                 fireEvent = true;
703         }
704
705         SetItemChanged(true);
706         Invalidate();
707
708         __itemSelected = false;
709
710         if (fireEvent)
711         {
712                 FireItemEvent(true);
713         }
714
715         return true;
716 }
717
718 bool
719 _TableViewItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
720 {
721         if (__itemSelected == true)
722         {
723                 Point touchPosition = touchinfo.GetCurrentPosition();
724
725                 __isTouchMoved = true;
726
727                 __itemSelected = false;
728                 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
729
730                 SetItemChanged(true);
731                 Invalidate();
732         }
733
734         return false;
735 }
736
737 bool
738 _TableViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
739 {
740         if (&source != this)
741         {
742                 return false;
743         }
744
745         __isTouchMoved = false;
746
747         __itemSelected = false;
748         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
749
750         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
751         {
752                 SetChecked(false);
753         }
754
755         SetItemChanged(true);
756         Invalidate();
757
758         return true;
759 }
760
761 _UiTouchEventDelivery
762 _TableViewItem::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
763 {
764         if (__isContextItemActivated || IsAnimationPlaying() || !IsValidSelectionState())
765         {
766                 return _UI_TOUCH_EVENT_DELIVERY_YES;
767         }
768
769         __itemSelected = true;
770         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
771
772         __isTouchMoved = false;
773         __touchStartPosition = touchinfo.GetCurrentPosition();
774
775         if (__selectionStyle == TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE && !IsIndividualSelectionEnabled(source))
776         {
777                 if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) && (&source == __pItemAnnex))
778                 {
779                         SetChecked(true);
780                         DrawAnnexStyle();
781                 }
782                 else
783                 {
784                         SetItemChanged(true);
785                         Invalidate();
786                 }
787         }
788         else
789         {
790                 if (&source == __pItemAnnex)
791                 {
792                         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
793                         {
794                                 SetChecked(true);
795                                 DrawAnnexStyle();
796                         }
797                         else
798                         {
799                                 SetItemChanged(true);
800                                 Invalidate();
801                         }
802                 }
803         }
804
805         return _UI_TOUCH_EVENT_DELIVERY_YES;
806 }
807
808 _UiTouchEventDelivery
809 _TableViewItem::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
810 {
811         if (__isContextItemActivated)
812         {
813                 return _UI_TOUCH_EVENT_DELIVERY_YES;
814         }
815
816         int selectedBody = true;
817         bool fireItemEvent = false;
818
819         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
820
821         if (__itemSelected == true)
822         {
823                 if (__selectionStyle == TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE && !IsIndividualSelectionEnabled(source))
824                 {
825                         if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
826                                 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
827                                 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING))
828                         {
829                                 bool checked = IsChecked();
830                                 SetChecked(!checked);
831                                 SetCheckedAnimationEnabled(!checked);
832                         }
833                         else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
834                         {
835                                 if (&source == __pItemAnnex)
836                                 {
837                                         SetChecked(!IsChecked());
838
839                                         selectedBody = false;
840                                 }
841                         }
842
843                         SetItemChanged(true);
844                         Invalidate();
845
846                         fireItemEvent = true;
847                 }
848                 else
849                 {
850                         if (&source == __pItemAnnex)
851                         {
852                                 bool checked = IsChecked();
853                                 SetChecked(!checked);
854                                 SetCheckedAnimationEnabled(!checked);
855
856                                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
857                                 {
858                                         DrawAnnexStyle();
859                                         selectedBody = false;
860                                 }
861                                 else
862                                 {
863                                         Invalidate();
864                                 }
865
866                                 fireItemEvent = true;
867                         }
868                 }
869         }
870
871         __itemSelected = false;
872
873         if (fireItemEvent)
874         {
875                 FireItemEvent(selectedBody);
876         }
877
878         return _UI_TOUCH_EVENT_DELIVERY_YES;
879 }
880
881 _UiTouchEventDelivery
882 _TableViewItem::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
883 {
884         if (__itemSelected == true)
885         {
886                 Point touchPosition = touchinfo.GetCurrentPosition();
887
888                 __isTouchMoved = true;
889
890                 __itemSelected = false;
891                 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
892
893                 SetItemChanged(true);
894                 Invalidate();
895         }
896         else
897         {
898                 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED && IsChecked())
899                 {
900                         SetChecked(false);
901                         DrawAnnexStyle();
902                 }
903         }
904         return _UI_TOUCH_EVENT_DELIVERY_YES;
905 }
906
907 _UiTouchEventDelivery
908 _TableViewItem::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
909 {
910         __isTouchMoved = false;
911
912         __itemSelected = false;
913         __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
914
915         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
916         {
917                 SetChecked(false);
918         }
919
920         SetItemChanged(true);
921         Invalidate();
922
923         return _UI_TOUCH_EVENT_DELIVERY_YES;
924 }
925
926 void
927 _TableViewItem::OnDraw(void)
928 {
929         if (IsItemChanged() == true)
930         {
931                 DrawItemBackground();
932                 DrawAnnexStyle();
933                 DrawItemDivider();
934                 DrawSimpleItem();
935
936                 SetAccessibilityElement();
937                 SetItemChanged(false);
938         }
939 }
940
941 void
942 _TableViewItem::OnChildAttached(const _Control& child)
943 {
944         _AccessibilityContainer* pContainer = const_cast<_Control*>(&child)->GetAccessibilityContainer();
945         pContainer->Activate(false);
946
947         _Control* pControl = const_cast<_Control*>(&child);
948         pControl->SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE);
949
950         if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO))
951         {
952                 if (__pItemAnnex == &child)
953                 {
954                         return;
955                 }
956
957                 Rectangle bounds = child.GetBounds();
958                 int leftMargin = 0;
959                 int annexWidth = 0;
960
961                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
962                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
963
964                 bounds.x += (leftMargin * 2) + annexWidth;
965                 pControl->SetBounds(bounds);
966         }
967 }
968
969 void
970 _TableViewItem::OnChildDetached(const _Control& child)
971 {
972         if (__individualSelectionControls.Contains(child))
973         {
974                 __individualSelectionControls.Remove(child, false);
975         }
976
977         if (&child == __pSimpleItemText)
978         {
979                 __pSimpleItemText = null;
980         }
981         if (&child == __pSimpleItemBitmap)
982         {
983                 __pSimpleItemBitmap = null;
984         }
985 }
986
987 void
988 _TableViewItem::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
989 {
990         result r = E_SUCCESS;
991
992         if (&timer == __pCheckedTimer)
993         {
994                 if (__checkedCount < MAX_CHECKED_COUNT)
995                 {
996                         r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION);
997                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
998                 }
999
1000                 r = PlayCheckBoxAnimation();
1001                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1002
1003                 if (__checkedCount < MAX_CHECKED_COUNT)
1004                 {
1005                         __checkedCount++;
1006                 }
1007                 else
1008                 {
1009                         __checkedCount = 0;
1010                         __isCheckedAnimationEnabled = false;
1011                         __isCheckedTimerEnabled = false;
1012                 }
1013         }
1014 }
1015
1016 result
1017 _TableViewItem::StartCheckBoxAnimation(void)
1018 {
1019         result r = E_SUCCESS;
1020
1021         if (__pCheckedTimer == null)
1022         {
1023                 __pCheckedTimer = new (std::nothrow) Timer();
1024                 SysTryCatch(NID_UI_CTRL, __pCheckedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1025
1026                 r = __pCheckedTimer->Construct(*this);
1027                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage);
1028         }
1029
1030         if (__isCheckedTimerEnabled == false)
1031         {
1032                 r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION);
1033                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage);
1034
1035                 __isCheckedTimerEnabled = true;
1036         }
1037
1038         return r;
1039
1040 CATCH:
1041         if (__isCheckedTimerEnabled)
1042         {
1043                 __pCheckedTimer->Cancel();
1044         }
1045
1046         delete __pCheckedTimer;
1047         __pCheckedTimer = null;
1048
1049         return r;
1050 }
1051
1052 void
1053 _TableViewItem::StopCheckBoxAnimation(void)
1054 {
1055         result r = E_SUCCESS;
1056
1057         SysTryReturnVoidResult(NID_UI_CTRL, __pCheckedTimer != null, E_SYSTEM, "[E_SYSTEM] Timer is invalid.");
1058
1059         if (__isCheckedTimerEnabled)
1060         {
1061                 r = __pCheckedTimer->Cancel();
1062                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1063         }
1064
1065         __checkedCount = 0;
1066         __isCheckedAnimationEnabled = false;
1067         __isCheckedTimerEnabled = false;
1068
1069         return;
1070 }
1071
1072 result
1073 _TableViewItem::PlayCheckBoxAnimation(void)
1074 {
1075         Bitmap* pCheckBox = null;
1076         Bitmap* pCheckBoxBg = null;
1077         Bitmap* pMergeBitmap = null;
1078         Canvas* pCanvas = null;
1079         result r = E_SUCCESS;
1080
1081         Rectangle bounds;
1082         int annexWidth = 0, annexHeight = 0;
1083
1084         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1085         {
1086                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1087         }
1088         else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
1089         {
1090                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1091         }
1092         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1093
1094         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
1095         SysTryCatch(NID_UI_CTRL,(r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1096
1097         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1098         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1099         bounds.SetBounds(0, 0, annexWidth, annexHeight);
1100
1101         pCanvas = new (std::nothrow) Canvas();
1102         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1103
1104         if (pCanvas != null)
1105         {
1106                 r = pCanvas->Construct(bounds);
1107
1108                 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1109                 pCanvas->Clear();
1110
1111                 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg);
1112
1113                 __checkedBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox);
1114                 if (IsChecked() == true)
1115                 {
1116                         if (pCheckBox->IsNinePatchedBitmap())
1117                         {
1118                                 r = pCanvas->DrawNinePatchedBitmap(Rectangle(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width, __checkedBounds.height), *pCheckBox);
1119                         }
1120                         else
1121                         {
1122                                 Rectangle bitmapSourceRect(0, 0, pCheckBox->GetWidth()*__checkedCount * 0.1, pCheckBox->GetHeight());
1123                                 Rectangle drawingRect(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width * __checkedCount * 0.1, __checkedBounds.height);
1124                                 r = pCanvas->DrawBitmap(drawingRect, *pCheckBox, bitmapSourceRect);
1125                         }
1126                 }
1127         }
1128
1129         pMergeBitmap = new (std::nothrow) Bitmap();
1130         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1131
1132         if (pMergeBitmap != null)
1133         {
1134                 pMergeBitmap->Construct(*pCanvas, bounds);
1135         }
1136
1137         if (__pItemAnnex == null)
1138         {
1139                 __pItemAnnex = _Label::CreateLabelN();
1140
1141                 r = GetLastResult();
1142                 SysTryCatch(NID_UI_CTRL, __pItemAnnex != null, , r, "[%s] Propagating.", GetErrorMessage(r));
1143
1144                 int leftMargin = 0;
1145                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1146
1147                 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1148                 __pItemAnnex->SetBounds(Rectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1149                 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1150
1151                 AttachSystemChild(*__pItemAnnex);
1152         }
1153
1154         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1155         __pItemAnnex->Invalidate();
1156
1157 CATCH:
1158         delete pCheckBox;
1159         delete pCheckBoxBg;
1160         delete pMergeBitmap;
1161         delete pCanvas;
1162
1163         return r;
1164 }
1165
1166 void
1167 _TableViewItem::OnBoundsChanged(void)
1168 {
1169         if (__checkItemHeightNeeded && HasParent())
1170         {
1171                 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
1172                 if (pParent != null)
1173                 {
1174                         int groupIndex = -1;
1175                         int itemIndex = -1;
1176                         GetItemIndex(groupIndex, itemIndex);
1177
1178                         pParent->CheckItemHeightAndRefreshLayout(groupIndex, itemIndex);
1179                 }
1180
1181                 __checkItemHeightNeeded = false;
1182         }
1183
1184         AdjustAnnexBounds();
1185
1186         SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
1187 }
1188
1189 void
1190 _TableViewItem::SetDrawingProperty(_ItemDrawingProperty* pDrawingProperty)
1191 {
1192         __pDrawingProperty = pDrawingProperty;
1193 }
1194
1195 _ItemDrawingProperty*
1196 _TableViewItem::GetDrawingProperty(void)
1197 {
1198         return __pDrawingProperty;
1199 }
1200
1201 void
1202 _TableViewItem::DrawItemBackground(void)
1203 {
1204         Canvas* pCanvas = null;
1205         Bitmap* pDrawBitmap = __pItemBgBitmap[__drawingStatus];
1206         Color bgColor = __colorItemBg[__drawingStatus];
1207         Rectangle bounds = GetBounds();
1208
1209         SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
1210
1211         if (pDrawBitmap != null)
1212         {
1213                 const _BitmapImpl* pBitmapImpl = _BitmapImpl::GetInstance(*pDrawBitmap);
1214                 SysTryReturnVoidResult(NID_UI_CTRL, pBitmapImpl != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1215
1216                 pCanvas = GetVisualElement()->GetCanvasN();
1217                 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1218
1219                 if (__enabledState)
1220                 {
1221                         pCanvas->SetBackgroundColor(bgColor);
1222                 }
1223                 else
1224                 {
1225                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1226                         pCanvas->SetBackgroundColor(bgColor);
1227                 }
1228                 pCanvas->Clear();
1229                 DrawBitmap(*pCanvas, Rectangle(0, 0, bounds.width, bounds.height), *pDrawBitmap);
1230
1231                 delete pCanvas;
1232                 pCanvas = null;
1233         }
1234         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
1235         {
1236                 if (__enabledState)
1237                 {
1238                         SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
1239                         __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1240                 }
1241                 else
1242                 {
1243                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1244                         SetBackgroundColor(bgColor);
1245                 }
1246         }
1247         else if (__itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
1248         {
1249                 if (__enabledState)
1250                 {
1251                         SetBackgroundColor(Color(0, 0, 0, 0));
1252                         __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f));
1253                 }
1254                 else
1255                 {
1256                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1257                         SetBackgroundColor(bgColor);
1258                 }
1259         }
1260         else if (IsContextItem())
1261         {
1262                 if (__enabledState)
1263                 {
1264                         SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
1265                         __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1266                 }
1267                 else
1268                 {
1269                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1270                         SetBackgroundColor(bgColor);
1271                 }
1272         }
1273         else if (__pDrawingProperty->sectionStyleEnabled == true)
1274         {
1275                 DrawSectionStyleBackground();
1276         }
1277         else
1278         {
1279                 if (__enabledState)
1280                 {
1281                         SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
1282                         __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1283                 }
1284                 else
1285                 {
1286                         GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1287                         SetBackgroundColor(bgColor);
1288                 }
1289
1290                 if (__pDrawingProperty->groupedLookEnabled == true)
1291                 {
1292                         DrawGroupedLook();
1293                 }
1294         }
1295 }
1296
1297 void
1298 _TableViewItem::DrawGroupedLook(void)
1299 {
1300         if (IsTitleStyleItem())
1301         {
1302                 return;
1303         }
1304
1305         Color barColor;
1306         Color outlineColor = __pDrawingProperty->dividerColor;
1307         int barWidth = 0;
1308
1309         Canvas* pCanvas = GetVisualElement()->GetCanvasN();
1310         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1311
1312         Rectangle bounds = GetBounds();
1313         pCanvas->SetBackgroundColor(GetBackgroundColor());
1314         pCanvas->Clear();
1315
1316         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor);
1317         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth);
1318
1319         pCanvas->FillRectangle(barColor, Rectangle(0, 0, barWidth, bounds.height));
1320
1321         if (__pDrawingProperty->sectionStyleEnabled == true)
1322         {
1323                 pCanvas->FillRectangle(outlineColor, Rectangle(bounds.width - 1, 0, 1, bounds.height));
1324
1325                 if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP || __itemType == TABLE_VIEW_ITEM_TYPE_ONE)
1326                 {
1327                         pCanvas->FillRectangle(outlineColor, Rectangle(0, 0, bounds.width, 1));
1328                 }
1329         }
1330
1331         delete pCanvas;
1332 }
1333
1334 void
1335 _TableViewItem::DrawSectionStyleBackground(void)
1336 {
1337         Canvas* pCanvas = null;
1338         Bitmap* pSectionBg = null;
1339         Bitmap* pSectionPressedBg = null;
1340         Bitmap* pReplacementSectionBg = null;
1341         Rectangle bounds = GetBounds();
1342         result r = E_SUCCESS;
1343
1344         pCanvas = GetVisualElement()->GetCanvasN();
1345         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1346
1347         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1348         pCanvas->Clear();
1349
1350         if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
1351         {
1352                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
1353         }
1354         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
1355         {
1356                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
1357         }
1358         else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
1359         {
1360                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
1361         }
1362         else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
1363         {
1364                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
1365         }
1366         else
1367         {
1368                 r = E_SYSTEM;
1369         }
1370         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] SectionStyle image load failed");
1371
1372         if (__enabledState)
1373         {
1374                 pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), __pDrawingProperty->sectionStyleBgColor);
1375         }
1376         else
1377         {
1378                 Color bgColor;
1379                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1380                 pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
1381         }
1382         DrawBitmap(*pCanvas, Rectangle(0, 0, bounds.width, bounds.height), *pReplacementSectionBg);
1383
1384         if (__drawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1385         {
1386                 if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
1387                 {
1388                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg);
1389                 }
1390                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
1391                 {
1392                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg);
1393                 }
1394                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
1395                 {
1396                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg);
1397                 }
1398                 else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
1399                 {
1400                         r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg);
1401                 }
1402         }
1403         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] SectionStyle image load failed");
1404
1405         if (__drawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1406         {
1407                 Color pressColor;
1408                 int dividerHeight;
1409
1410                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_PRESSED, pressColor);
1411                 pSectionPressedBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), pressColor);
1412                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, dividerHeight);
1413                 DrawBitmap(*pCanvas, Rectangle(0, dividerHeight, bounds.width, bounds.height-dividerHeight*2), *pSectionPressedBg);
1414         }
1415
1416         if (__pDrawingProperty->groupedLookEnabled == true)
1417         {
1418                 Color barColor;
1419                 int barWidth = 0, barMargin = 0;
1420
1421                 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor);
1422                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth);
1423                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, barMargin);
1424
1425                 pCanvas->FillRectangle(barColor, Rectangle(0, barMargin, barWidth, bounds.height-barMargin));
1426         }
1427
1428 CATCH:
1429         delete pSectionBg;
1430         delete pSectionPressedBg;
1431         delete pReplacementSectionBg;
1432         delete pCanvas;
1433 }
1434
1435 void
1436 _TableViewItem::DrawAnnexStyle(void)
1437 {
1438         if (__reorderMode)
1439         {
1440                 return;
1441         }
1442
1443         switch (__annexStyle)
1444         {
1445         case TABLE_VIEW_ANNEX_STYLE_MARK:
1446                 DrawCheckBox();
1447                 break;
1448         case TABLE_VIEW_ANNEX_STYLE_RADIO:
1449                 DrawRadioBox();
1450                 break;
1451         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
1452                 DrawOnOffButton();
1453                 break;
1454         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
1455                 DrawDetailButton();
1456                 break;
1457         default:
1458                 break;
1459         }
1460 }
1461
1462 void
1463 _TableViewItem::DrawCheckBox(void)
1464 {
1465         Bitmap* pCheckBox = null;
1466         Bitmap* pCheckBoxBg = null;
1467         Bitmap* pMergeBitmap = null;
1468         Canvas* pCanvas = null;
1469         result r = E_SUCCESS;
1470
1471         Rectangle bounds;
1472         int annexWidth = 0, annexHeight = 0;
1473
1474         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1475         {
1476                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1477         }
1478         else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
1479         {
1480                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1481         }
1482         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1483
1484         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
1485         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1486
1487         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1488         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1489         bounds.SetBounds(0, 0, annexWidth, annexHeight);
1490
1491         pCanvas = new (std::nothrow) Canvas();
1492         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1493
1494         if (pCanvas != null)
1495         {
1496                 pCanvas->Construct(bounds);
1497
1498                 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1499                 pCanvas->Clear();
1500
1501                 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg);
1502
1503                 if (IsChecked() == true)
1504                 {
1505                         if (__isCheckedAnimationEnabled == true)
1506                         {
1507                                 StartCheckBoxAnimation();
1508                         }
1509                         else
1510                         {
1511                                 if (pCheckBox != null)
1512                                 {
1513                                         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox), *pCheckBox);
1514                                 }
1515                         }
1516                 }
1517         }
1518
1519         pMergeBitmap = new (std::nothrow) Bitmap();
1520         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1521
1522         if (pMergeBitmap != null)
1523         {
1524                 pMergeBitmap->Construct(*pCanvas, bounds);
1525         }
1526
1527         if (__pItemAnnex == null)
1528         {
1529                 __pItemAnnex = _Label::CreateLabelN();
1530
1531                 r = GetLastResult();
1532                 SysTryCatch(NID_UI_CTRL, __pItemAnnex != null, , r, "[%s] Propagating.", GetErrorMessage(r));
1533
1534                 int leftMargin = 0;
1535                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1536
1537                 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1538                 __pItemAnnex->SetBounds(Rectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1539                 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1540
1541                 AttachSystemChild(*__pItemAnnex);
1542         }
1543
1544         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1545         __pItemAnnex->Invalidate();
1546
1547 CATCH:
1548         delete pCheckBox;
1549         delete pCheckBoxBg;
1550         delete pMergeBitmap;
1551         delete pCanvas;
1552
1553         return;
1554 }
1555
1556 void
1557 _TableViewItem::DrawRadioBox(void)
1558 {
1559         Bitmap* pRadioButton = null;
1560         Bitmap* pRadioButtonBg = null;
1561         Bitmap* pMergeBitmap = null;
1562         Canvas* pCanvas = null;
1563         result r = E_SUCCESS;
1564
1565         Rectangle bounds;
1566         int annexWidth = 0, annexHeight = 0;
1567
1568         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1569         {
1570                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
1571         }
1572         else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
1573         {
1574                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
1575         }
1576         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButtonBg != null), , E_SYSTEM, "[E_SYSTEM] RadioButtonBg image load failed");
1577
1578         r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButton);
1579         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButton != null), , E_SYSTEM, "[E_SYSTEM] CheckBox image load failed");
1580
1581         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1582         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1583         bounds.SetBounds(0, 0, annexWidth, annexHeight);
1584
1585         pCanvas = new (std::nothrow) Canvas();
1586         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1587
1588         if (pCanvas != null)
1589         {
1590                 pCanvas->Construct(bounds);
1591
1592                 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1593                 pCanvas->Clear();
1594
1595                 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButtonBg), *pRadioButtonBg);
1596
1597                 if (IsChecked() == true)
1598                 {
1599                         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButton), *pRadioButton);
1600                 }
1601         }
1602
1603         pMergeBitmap = new (std::nothrow) Bitmap();
1604         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1605
1606         if (pMergeBitmap != null)
1607         {
1608                 pMergeBitmap->Construct(*pCanvas, bounds);
1609         }
1610
1611         if (__pItemAnnex == null)
1612         {
1613                 __pItemAnnex = _Label::CreateLabelN();
1614                 SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1615
1616                 int leftMargin = 0;
1617                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1618
1619                 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1620                 __pItemAnnex->SetBounds(Rectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1621                 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1622
1623                 AttachSystemChild(*__pItemAnnex);
1624         }
1625
1626         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1627         __pItemAnnex->Invalidate();
1628
1629 CATCH:
1630         delete pRadioButton;
1631         delete pRadioButtonBg;
1632         delete pMergeBitmap;
1633         delete pCanvas;
1634
1635         return;
1636 }
1637
1638 void
1639 _TableViewItem::DrawOnOffButton(void)
1640 {
1641         Bitmap* pOnOffButton = null;
1642         Bitmap* pOnOffButtonHandler = null;
1643         Bitmap* pMergeBitmap = null;
1644         Canvas* pCanvas = null;
1645         result r = E_SUCCESS;
1646
1647         Rectangle bounds;
1648         Rectangle backgroundBounds;
1649         int annexWidth = 0, annexHeight = 0;
1650
1651         r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
1652         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButtonHandler != null), , E_SYSTEM, "[E_SYSTEM] OnOffHandlerButton button image load failed");
1653
1654         if (IsChecked() == true)
1655         {
1656                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
1657         }
1658         else
1659         {
1660                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
1661         }
1662         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButton != null), , E_SYSTEM, "[E_SYSTEM] OnOffButton image load failed");
1663
1664         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1665         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1666         bounds.SetBounds(0, 0, annexWidth, annexHeight);
1667
1668         pCanvas = new (std::nothrow) Canvas();
1669         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1670
1671         pCanvas->Construct(bounds);
1672         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1673         pCanvas->Clear();
1674
1675         backgroundBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButton);
1676         DrawBitmap(*pCanvas, backgroundBounds, *pOnOffButton);
1677
1678         if (IsChecked() == true)
1679         {
1680                 Rectangle handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
1681                 handlerBounds.x = backgroundBounds.width - handlerBounds.width;
1682                 handlerBounds.y  = backgroundBounds.y;
1683                 DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler);
1684         }
1685         else
1686         {
1687                 Rectangle handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
1688                 handlerBounds.x = backgroundBounds.x;
1689                 handlerBounds.y  = backgroundBounds.y;
1690                 DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler);
1691         }
1692
1693         pMergeBitmap = new (std::nothrow) Bitmap();
1694         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1695
1696         pMergeBitmap->Construct(*pCanvas, bounds);
1697
1698         if (__pItemAnnex == null)
1699         {
1700                 __pItemAnnex = _Label::CreateLabelN();
1701                 SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1702
1703                 int leftMargin = 0;
1704                 int annexWidth = 0, annexHeight = 0;
1705                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1706                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1707                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1708
1709                 leftMargin += __pDrawingProperty->scrollMargin;
1710
1711                 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1712                 __pItemAnnex->SetBounds(Rectangle((GetBounds().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1713                 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1714
1715                 AttachSystemChild(*__pItemAnnex);
1716         }
1717
1718         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1719         __pItemAnnex->Invalidate();
1720
1721 CATCH:
1722         delete pOnOffButton;
1723         delete pOnOffButtonHandler;
1724         delete pMergeBitmap;
1725         delete pCanvas;
1726
1727         return;
1728 }
1729
1730 void
1731 _TableViewItem::DrawDetailButton(void)
1732 {
1733         Bitmap* pDetail = null;
1734         Bitmap* pDetailBg = null;
1735         Bitmap* pDetailBgEffect = null;
1736         Bitmap* pReplacementDetail = null;
1737         Bitmap* pReplacementDetailBg = null;
1738         Bitmap* pMergeBitmap = null;
1739         Canvas* pCanvas = null;
1740         Color replacementNewColor;
1741         Color replacementNewBgColor;
1742         result r = E_SUCCESS;
1743
1744         Rectangle bounds;
1745         int annexWidth = 0, annexHeight = 0;
1746
1747         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBg);
1748         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBg != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1749
1750         if (IsChecked() != true)
1751         {
1752                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
1753                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBgEffect != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1754
1755                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_NORMAL, replacementNewColor);
1756                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_NORMAL, replacementNewBgColor);
1757         }
1758         else
1759         {
1760                 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
1761                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBgEffect != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1762
1763                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_PRESSED, replacementNewColor);
1764                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_PRESSED, replacementNewBgColor);
1765         }
1766
1767         pReplacementDetailBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pDetailBg, Color::GetColor(COLOR_ID_MAGENTA), replacementNewBgColor);
1768         SysTryCatch(NID_UI_CTRL, pReplacementDetailBg != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1769
1770         r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDetail);
1771         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetail != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1772
1773         pReplacementDetail = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pDetail, Color::GetColor(COLOR_ID_MAGENTA), replacementNewColor);
1774         SysTryCatch(NID_UI_CTRL, pReplacementDetail != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1775
1776         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1777         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1778         bounds.SetBounds(0, 0, annexWidth, annexHeight);
1779
1780         pCanvas = new (std::nothrow) Canvas();
1781         SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1782
1783         pCanvas->Construct(bounds);
1784         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1785         pCanvas->Clear();
1786
1787         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetailBg), *pReplacementDetailBg);
1788         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pDetailBgEffect), *pDetailBgEffect);
1789         DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetail), *pReplacementDetail);
1790
1791         pMergeBitmap = new (std::nothrow) Bitmap();
1792         SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1793
1794         pMergeBitmap->Construct(*pCanvas, bounds);
1795
1796         if (__pItemAnnex == null)
1797         {
1798                 __pItemAnnex = _Label::CreateLabelN();
1799                 SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1800
1801                 int leftMargin = 0;
1802                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1803
1804                 leftMargin += __pDrawingProperty->scrollMargin;
1805                 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1806                 __pItemAnnex->SetBounds(Rectangle((GetBounds().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1807                 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1808
1809                 AttachSystemChild(*__pItemAnnex);
1810         }
1811
1812         __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1813         __pItemAnnex->Invalidate();
1814
1815 CATCH:
1816         delete pDetail;
1817         delete pDetailBg;
1818         delete pDetailBgEffect;
1819         delete pReplacementDetail;
1820         delete pReplacementDetailBg;
1821         delete pMergeBitmap;
1822         delete pCanvas;
1823
1824         return;
1825 }
1826
1827 void
1828 _TableViewItem::DrawItemDivider(void)
1829 {
1830         if (__pDrawingProperty->itemDividerEnabled == false || __itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER || __itemDividerEnabled == false)
1831         {
1832                 if (__pItemDivider != null)
1833                 {
1834                         __pItemDivider->SetVisibleState(false);
1835                 }
1836
1837                 if (__pItemTopDivider != null)
1838                 {
1839                         __pItemTopDivider->SetVisibleState(false);
1840                 }
1841         }
1842         else if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
1843         {
1844                 if (__pItemDivider == null)
1845                 {
1846                         __pItemDivider = _Label::CreateLabelN();
1847                         SysTryReturnVoidResult(NID_UI_CTRL, __pItemDivider, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1848
1849                         AttachSystemChild(*__pItemDivider);
1850                 }
1851
1852                 Color underLineColor;
1853                 Rectangle bounds = GetBounds();
1854                 int lineHeight = 0, lineLeftMargin = 0, lineBottomMargin = 0;
1855
1856                 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1857                 {
1858                         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_NORMAL, underLineColor);
1859                 }
1860                 else
1861                 {
1862                         GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_PRESSED, underLineColor);
1863                 }
1864                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
1865                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
1866                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineBottomMargin);
1867
1868                 __pItemDivider->SetBounds(Rectangle(lineLeftMargin, bounds.height - lineBottomMargin, bounds.width - lineLeftMargin * 2, lineHeight));
1869                 __pItemDivider->SetBackgroundColor(underLineColor);
1870                 __pItemDivider->Invalidate();
1871         }
1872         else
1873         {
1874                 if (__pItemDivider == null)
1875                 {
1876                         __pItemDivider = _Label::CreateLabelN();
1877                         SysTryReturnVoidResult(NID_UI_CTRL, __pItemDivider, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1878
1879                         AttachSystemChild(*__pItemDivider);
1880                 }
1881
1882                 Color dividerColor;
1883                 Rectangle bounds = GetBounds();
1884                 int lineLeftMargin = 0, lineHeight = 0;
1885                 int groupIndex = -1, itemIndex = -1;
1886
1887                 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_TOP_BG_NORMAL, dividerColor);
1888                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
1889                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
1890
1891                 __pItemDivider->SetBounds(Rectangle(lineLeftMargin, (bounds.height - lineHeight), bounds.width - lineLeftMargin * 2, lineHeight));
1892                 __pItemDivider->SetBackgroundColor(__pDrawingProperty->dividerColor);
1893                 __pItemDivider->Invalidate();
1894
1895                 GetItemIndex(groupIndex, itemIndex);
1896                 if (itemIndex != 0)
1897                 {
1898                         if (__pItemTopDivider == null)
1899                         {
1900                                 __pItemTopDivider = _Label::CreateLabelN();
1901                                 SysTryReturnVoidResult(NID_UI_CTRL, __pItemTopDivider, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1902
1903                                 AttachSystemChild(*__pItemTopDivider);
1904                         }
1905                         __pItemTopDivider->SetBounds(Rectangle(lineLeftMargin, 0, bounds.width - lineLeftMargin * 2, lineHeight));
1906                         __pItemTopDivider->SetBackgroundColor(dividerColor);
1907                         __pItemTopDivider->Invalidate();
1908                 }
1909         }
1910
1911         if (__pItemDivider != null)
1912         {
1913                 _AccessibilityContainer* pContainer = __pItemDivider->GetAccessibilityContainer();
1914                 pContainer->Activate(false);
1915         }
1916
1917         if (__pItemTopDivider != null)
1918         {
1919                 _AccessibilityContainer* pContainer = __pItemTopDivider->GetAccessibilityContainer();
1920                 pContainer->Activate(false);
1921         }
1922 }
1923
1924 result
1925 _TableViewItem::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap)
1926 {
1927         result r = E_SUCCESS;
1928         if (bitmap.IsNinePatchedBitmap())
1929         {
1930                 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1931                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Fail to draw ninepatched bitmap.", GetErrorMessage(r))
1932         }
1933         else
1934         {
1935                 r = canvas.DrawBitmap(bounds, bitmap);
1936                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Fail to draw bitmap.", GetErrorMessage(r))
1937         }
1938
1939         return r;
1940 }
1941
1942 result
1943 _TableViewItem::SetItemHighlightBounds(_VisualElement& highlightVisualElement, const Rectangle& bounds)
1944 {
1945         FloatRectangle veBounds(bounds.x, bounds.y, bounds.width, bounds.height);
1946         return highlightVisualElement.SetBounds(veBounds);
1947 }
1948
1949 Rectangle
1950 _TableViewItem::CalculateItemHighlightBounds(void)
1951 {
1952         int itemHighlightMargin = 0;
1953         Rectangle itemBounds = GetBounds();
1954         Rectangle bounds;
1955
1956         if (IsTitleStyleItem() == false)
1957         {
1958                 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, itemHighlightMargin);
1959         }
1960         bounds.SetBounds(0, itemHighlightMargin, itemBounds.width, itemBounds.height - itemHighlightMargin *2);
1961
1962         return bounds;
1963 }
1964
1965 Rectangle
1966 _TableViewItem::CalculateAnnexBitmapBounds(int annexWidth, int annexHeight, const Bitmap& bitmap)
1967 {
1968         Rectangle bounds;
1969         int width = 0, height = 0;
1970         int leftMargin = 0, topMargin = 0;
1971
1972         if (annexWidth > bitmap.GetWidth())
1973         {
1974                 leftMargin = (annexWidth - bitmap.GetWidth()) / 2;
1975                 width = bitmap.GetWidth();
1976         }
1977         else
1978         {
1979                 width = annexWidth;
1980         }
1981
1982         if(annexHeight > bitmap.GetHeight())
1983         {
1984                 topMargin = (annexHeight - bitmap.GetHeight()) / 2;
1985                 height = bitmap.GetHeight();
1986         }
1987         else
1988         {
1989                 height = annexHeight;
1990         }
1991
1992         bounds.SetBounds(leftMargin, topMargin, width, height);
1993
1994         return bounds;
1995 }
1996
1997 bool
1998 _TableViewItem::IsTitleStyleItem(void) const
1999 {
2000         if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE || __itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
2001         {
2002                 return true;
2003         }
2004
2005         return false;
2006 }
2007
2008 bool
2009 _TableViewItem::IsValidSelectionState(void)
2010 {
2011         _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
2012         if (pParent == null)
2013         {
2014                 return true;
2015         }
2016
2017         if (pParent->GetPressedItemCount() > 0)
2018         {
2019                 return false;
2020         }
2021
2022         return true;
2023 }
2024
2025 void
2026 _TableViewItem::DrawSimpleItem(void)
2027 {
2028         if (__pSimpleItemText != null)
2029         {
2030                 Color textColor = __simpleItemTextColor[__drawingStatus];
2031                 if (!IsEnabled())
2032                 {
2033                         textColor = __simpleItemTextColor[TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED];
2034                 }
2035
2036                 if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
2037                 {
2038                         if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
2039                         {
2040                                 textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL];
2041                         }
2042                         else
2043                         {
2044                                 textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED];
2045                         }
2046                 }
2047
2048                 __pSimpleItemText->SetTextColor(textColor);
2049                 __pSimpleItemText->Invalidate();
2050         }
2051 }
2052 result
2053 _TableViewItem::SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType)
2054 {
2055         result r = E_SUCCESS;
2056         bool textOnly = true;
2057
2058         if (pBitmap != null)
2059         {
2060                 textOnly = false;
2061         }
2062
2063         r = CreateSimpleItemContents(textOnly);
2064         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2065
2066         Rectangle bitmapRect = Rectangle(0, 0, 0, 0);
2067         Rectangle textRect = Rectangle(0, 0, 0, 0);
2068         int elementWidth = 0;
2069         int elementHeight = 0;
2070         int leftMargin = 0;
2071         int itemHeight = __itemHeight;
2072         int annexWidth = GetAnnexWidth(__annexStyle);
2073
2074         if (groupType)
2075         {
2076                 if (__simpleItemTextSize == 0)
2077                 {
2078                         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize);
2079                 }
2080                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
2081         }
2082         else
2083         {
2084                 if (__simpleItemTextSize == 0)
2085                 {
2086                         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize);
2087                 }
2088                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
2089         }
2090
2091         if (!textOnly)
2092         {
2093                 elementWidth = itemHeight * SIMPLE_ITEM_ELEMENT_BITMAP_SIZE_RATIO;
2094                 elementHeight = elementWidth;
2095
2096                 bitmapRect.x = leftMargin;
2097                 bitmapRect.y = (itemHeight - elementHeight) / 2;
2098                 bitmapRect.width = elementWidth;
2099                 bitmapRect.height = elementHeight;
2100         }
2101
2102 //      if (annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
2103 //      {
2104 //              bitmapRect.x += annexWidth + leftMargin;
2105 //      }
2106
2107         textRect.x = bitmapRect.x + elementWidth + leftMargin;
2108
2109         if (annexWidth > 0)
2110         {
2111                 elementWidth = __itemWidth - textRect.x - annexWidth - leftMargin;
2112         }
2113         else
2114         {
2115                 elementWidth = __itemWidth - textRect.x;
2116         }
2117
2118         textRect.y = 0;
2119         textRect.width = elementWidth;
2120         textRect.height = itemHeight;
2121
2122         if (__pSimpleItemBitmap != null && pBitmap != null)
2123         {
2124                 __pSimpleItemBitmap->SetBackgroundBitmap(*pBitmap);
2125                 __pSimpleItemBitmap->SetBounds(bitmapRect);
2126
2127                 if (!__pSimpleItemBitmap->HasParent())
2128                 {
2129                         r = AttachChild(*__pSimpleItemBitmap);
2130                         SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
2131                 }
2132         }
2133
2134         if (__pSimpleItemText != null)
2135         {
2136                 __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL);
2137                 __pSimpleItemText->SetText(text);
2138                 __pSimpleItemText->SetBounds(textRect);
2139
2140                 if (!__pSimpleItemText->HasParent())
2141                 {
2142                         r = AttachChild(*__pSimpleItemText);
2143                         SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
2144                 }
2145         }
2146
2147         return E_SUCCESS;
2148 }
2149
2150 result
2151 _TableViewItem::CreateSimpleItemContents(bool textOnly)
2152 {
2153         result r = E_SUCCESS;
2154
2155         if (__pSimpleItemText == null)
2156         {
2157                 __pSimpleItemText = _Label::CreateLabelN();
2158
2159                 r = GetLastResult();
2160                 SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
2161
2162                 __pSimpleItemText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2163                 __pSimpleItemText->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
2164                 if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
2165                 {
2166                         __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]);
2167                 }
2168                 else
2169                 {
2170                         __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
2171                 }
2172                 __pSimpleItemText->SetBackgroundColor(Color(0, 0, 0, 0));
2173
2174         }
2175
2176         if (!textOnly)
2177         {
2178                 if (__pSimpleItemBitmap == null)
2179                 {
2180                         __pSimpleItemBitmap = _Label::CreateLabelN();
2181                         SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
2182
2183                         __pSimpleItemText->SetBackgroundColor(Color(0, 0, 0, 0));
2184                 }
2185
2186         }
2187         else
2188         {
2189                 if (__pSimpleItemBitmap != null)
2190                 {
2191                         delete __pSimpleItemBitmap;
2192                         __pSimpleItemBitmap = null;
2193                 }
2194         }
2195
2196         return E_SUCCESS;
2197 }
2198
2199 result
2200 _TableViewItem::SetSimpleTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status)
2201 {
2202         __simpleItemTextColor[status] = color;
2203
2204         return E_SUCCESS;
2205 }
2206
2207 Tizen::Graphics::Color
2208 _TableViewItem::GetSimpleItemTextColor(TableViewItemDrawingStatus status) const
2209 {
2210         return __simpleItemTextColor[status];
2211 }
2212
2213 result
2214 _TableViewItem::SetSimpleItemTextSize(int size)
2215 {
2216         __simpleItemTextSize = size;
2217
2218         if (__pSimpleItemText != null)
2219         {
2220                 __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL);
2221         }
2222         return E_SUCCESS;
2223 }
2224
2225 int
2226 _TableViewItem::GetSimpleItemTextSize(void) const
2227 {
2228         return __simpleItemTextSize;
2229 }
2230
2231 int
2232 _TableViewItem::GetAnnexWidth(TableViewAnnexStyle style)
2233 {
2234         int annexWidth = 0;
2235
2236         switch (style)
2237         {
2238         case TABLE_VIEW_ANNEX_STYLE_NORMAL:
2239                 annexWidth = 0;
2240                 break;
2241
2242         case TABLE_VIEW_ANNEX_STYLE_MARK:
2243                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2244                 break;
2245
2246         case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
2247                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2248                 break;
2249
2250         case TABLE_VIEW_ANNEX_STYLE_DETAILED:
2251                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2252                 break;
2253
2254         case TABLE_VIEW_ANNEX_STYLE_RADIO:
2255                 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2256                 break;
2257
2258         default:
2259                 break;
2260         }
2261
2262         return annexWidth;
2263 }
2264
2265 void
2266 _TableViewItem::SetDrawingStatus(TableViewItemDrawingStatus status)
2267 {
2268         __drawingStatus = status;
2269 }
2270
2271 TableViewItemDrawingStatus
2272 _TableViewItem::GetDrawingStatus(void)
2273 {
2274         return __drawingStatus;
2275 }
2276
2277 void
2278 _TableViewItem::AdjustChildControlMargin(void)
2279 {
2280         if (__childMarginState)
2281         {
2282                 return;
2283         }
2284
2285         if (IsTitleStyleItem())
2286         {
2287                 return;
2288         }
2289
2290         __childMarginState = true;
2291
2292         int margin = 0;
2293
2294         if (__pDrawingProperty->groupedLookEnabled)
2295         {
2296                 int groupedBarMargin = 0;
2297                 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, groupedBarMargin);
2298
2299                 margin = margin + groupedBarMargin;
2300         }
2301
2302         if (margin > 0)
2303         {
2304                 _VisualElement* pVisualElement = GetVisualElement();
2305
2306                 if (pVisualElement != null)
2307                 {
2308                         FloatPoint position;
2309
2310                         position.SetPosition(margin, 0.0f);
2311                         pVisualElement->ScrollByPoint(position, false);
2312                 }
2313         }
2314 }
2315
2316 void
2317 _TableViewItem::AdjustContextItemBounds(void)
2318 {
2319         _TableViewItem* pContextItem = GetContextItem();
2320
2321         if (pContextItem == null)
2322         {
2323                 return;
2324         }
2325
2326         Dimension contextItemSize = pContextItem->GetSize();
2327         Dimension itemSize = GetSize();
2328
2329         if (contextItemSize.height != itemSize.height)
2330         {
2331                 contextItemSize.height = itemSize.height;
2332
2333                 pContextItem->SetSize(contextItemSize);
2334         }
2335
2336         pContextItem->AdjustChildControlCenterAlign();
2337 }
2338
2339 void
2340 _TableViewItem::AdjustAnnexBounds(void)
2341 {
2342         if (__pItemAnnex == null)
2343         {
2344                 return;
2345         }
2346
2347         // h align
2348         if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || __annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
2349         {
2350                 if (__pItemAnnex->HasParent())
2351                 {
2352                         Rectangle annexBounds = __pItemAnnex->GetBounds();
2353                         int annexPositionX = annexBounds.x;
2354                         int leftMargin = 0;
2355
2356                         GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
2357                         leftMargin += __pDrawingProperty->scrollMargin;
2358
2359                         annexPositionX = GetBounds().width - annexBounds.width - leftMargin;
2360
2361                         if (annexPositionX != annexBounds.x)
2362                         {
2363                                 __pItemAnnex->SetPosition(Point(annexPositionX, annexBounds.y));
2364                         }
2365                 }
2366         }
2367
2368         // v align
2369         Rectangle itemBounds = GetBounds();
2370         Rectangle annexBounds = __pItemAnnex->GetBounds();
2371
2372         if (__customHeight > 0)
2373         {
2374                 itemBounds.height = __customHeight;
2375         }
2376
2377         annexBounds.y = (itemBounds.height - annexBounds.height) / 2;
2378         __pItemAnnex->SetPosition(Point(annexBounds.x, annexBounds.y));
2379 }
2380
2381 void
2382 _TableViewItem::SetItemCustomHeight(int height)
2383 {
2384         __customHeight = height;
2385 }
2386
2387 void
2388 _TableViewItem::AdjustChildControlCenterAlign(void)
2389 {
2390         if (__childControlCenterAlign)
2391         {
2392                 Dimension itemSize = GetSize();
2393
2394                 int childControlCount = GetChildCount();
2395
2396                 for (int i = 0; i < childControlCount; i++)
2397                 {
2398                         _Control* pChildControl = GetChild(i);
2399
2400                         if (pChildControl == null)
2401                         {
2402                                 continue;
2403                         }
2404
2405                         if (__pItemDivider == pChildControl)
2406                         {
2407                                 int positionX = pChildControl->GetPosition().x;
2408                                 pChildControl->SetPosition(Point(positionX, itemSize.height - 1));
2409                                 continue;
2410                         }
2411
2412                         if (__pItemTopDivider == pChildControl)
2413                         {
2414                                 int positionX = pChildControl->GetPosition().x;
2415                                 pChildControl->SetPosition(Point(positionX, 0));
2416                                 continue;
2417                         }
2418
2419                         Rectangle itemBounds = pChildControl->GetBounds();
2420
2421                         itemBounds.y = (itemSize.height - itemBounds.height) / 2;
2422
2423                         pChildControl->SetPosition(Point(itemBounds.x, itemBounds.y));
2424                 }
2425         }
2426 }
2427
2428 void
2429 _TableViewItem::SetChildControlCenterAlign(bool centerAlign)
2430 {
2431         __childControlCenterAlign = centerAlign;
2432 }
2433
2434 Point
2435 _TableViewItem::GetLastTouchPressedPosition(void)
2436 {
2437         return __touchStartPosition;
2438 }
2439
2440 void
2441 _TableViewItem::SetLastTouchPressedPosition(Point position)
2442 {
2443         // This function was made to modify of ListView::RefreshList().
2444         // This function could adversely affect touch event handling. So, you should be used with caution.
2445         __touchStartPosition = position;
2446 }
2447
2448 bool
2449 _TableViewItem::GetSelectionState(void)
2450 {
2451         return __itemSelected;
2452 }
2453
2454 void
2455 _TableViewItem::SetSelectionState(bool selected)
2456 {
2457         // This function was made to modify of ListView::RefreshList().
2458         // This function could adversely affect touch event handling. So, you should be used with caution.
2459         __itemSelected = selected;
2460 }
2461
2462 bool
2463 _TableViewItem::MoveItem(Point position, int duration, int delay, Tizen::Base::String* pName)
2464 {
2465         _VisualElement* pVisualElement = GetVisualElement();
2466
2467         String animationName = L"MoveTableViewItem";
2468
2469         VisualElementValueAnimation* pAnimation = dynamic_cast<VisualElementValueAnimation*>(pVisualElement->GetAnimationN(animationName));
2470
2471         if (pAnimation != null)
2472         {
2473                 pVisualElement->RemoveAnimation(animationName);
2474         }
2475
2476         pAnimation = new (std::nothrow) VisualElementValueAnimation();
2477         SysTryReturn(NID_UI_CTRL, pAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2478
2479         pAnimation->SetDuration(duration);
2480         pAnimation->SetDelay(delay);
2481         pAnimation->SetStartValue(Variant(GetPosition()));
2482         pAnimation->SetEndValue(Variant(position));
2483         pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseInOut"));
2484         pAnimation->SetVisualElementAnimationStatusEventListener(this);
2485         pAnimation->SetVisualElementAnimationTickEventListener(this);
2486         if (pName != null)
2487         {
2488                 String* pUserData = new (std::nothrow) String(*pName);
2489                 SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2490
2491                 if (pUserData != null)
2492                 {
2493                         pAnimation->SetUserData((void*)pUserData);
2494                 }
2495         }
2496
2497         if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
2498         {
2499                 return false;
2500         }
2501
2502         delete pAnimation;
2503
2504         __animationCount++;
2505
2506         return true;
2507
2508 CATCH:
2509         delete pAnimation;
2510
2511         return false;
2512 }
2513
2514 bool
2515 _TableViewItem::ZoomInOutItem(bool zoomOut, int duration, int delay, Tizen::Base::String* pName)
2516 {
2517         _VisualElement* pVisualElement = GetVisualElement();
2518
2519         String animationName = L"ZoomInOutTableViewItem";
2520
2521         VisualElementValueAnimation* pAnimation = dynamic_cast<VisualElementValueAnimation*>(pVisualElement->GetAnimationN(animationName));
2522
2523         if (pAnimation != null)
2524         {
2525                 pVisualElement->RemoveAnimation(animationName);
2526         }
2527
2528         pAnimation = new (std::nothrow) VisualElementValueAnimation();
2529         SysTryReturn(NID_UI_CTRL, pAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2530
2531         Dimension itemSize = GetSize();
2532         Dimension startValue;
2533         Dimension endValue;
2534
2535         if (zoomOut)
2536         {
2537                 startValue = itemSize;
2538                 endValue = Dimension(itemSize.width, itemSize.height / 2);
2539                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut"));
2540         }
2541         else
2542         {
2543                 startValue = Dimension(itemSize.width, itemSize.height / 2);
2544                 endValue = itemSize;
2545                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn"));
2546         }
2547
2548         pAnimation->SetDuration(duration);
2549         pAnimation->SetDelay(delay);
2550         pAnimation->SetStartValue(Variant(startValue));
2551         pAnimation->SetEndValue(Variant(endValue));
2552         pAnimation->SetVisualElementAnimationStatusEventListener(this);
2553         pAnimation->SetVisualElementAnimationTickEventListener(this);
2554
2555         if (pName != null)
2556         {
2557                 String* pUserData = new (std::nothrow) String(*pName);
2558                 SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2559
2560                 if (pUserData != null)
2561                 {
2562                         pAnimation->SetUserData((void*)pUserData);
2563                 }
2564         }
2565
2566         if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
2567         {
2568                 return false;
2569         }
2570
2571         delete pAnimation;
2572
2573         __animationCount++;
2574
2575         return true;
2576
2577 CATCH:
2578         delete pAnimation;
2579
2580         return false;
2581 }
2582
2583 bool
2584 _TableViewItem::FadeInOutItem(bool fadeOut, int duration, int delay, Tizen::Base::String* pName)
2585 {
2586         _VisualElement* pVisualElement = GetVisualElement();
2587
2588         String animationName = L"FadeInOutTableViewItem";;
2589
2590         VisualElementValueAnimation* pAnimation = dynamic_cast<VisualElementValueAnimation*>(pVisualElement->GetAnimationN(animationName));
2591
2592         if (pAnimation != null)
2593         {
2594                 pVisualElement->RemoveAnimation(animationName);
2595         }
2596
2597         pAnimation = new (std::nothrow) VisualElementValueAnimation();
2598         SysTryReturn(NID_UI_CTRL, pAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2599
2600         float startValue = 0.0f;
2601         float endValue = 1.0f;
2602
2603         if (fadeOut)
2604         {
2605                 startValue = 1.0f;
2606                 endValue = 0.0f;
2607                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut"));
2608         }
2609         else
2610         {
2611                 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn"));
2612         }
2613
2614         pAnimation->SetDuration(duration);
2615         pAnimation->SetDelay(delay);
2616         pAnimation->SetStartValue(Variant(startValue));
2617         pAnimation->SetEndValue(Variant(endValue));
2618         pAnimation->SetVisualElementAnimationStatusEventListener(this);
2619         pAnimation->SetVisualElementAnimationTickEventListener(this);
2620         if (pName != null)
2621         {
2622                 String* pUserData = new (std::nothrow) String(*pName);
2623                 SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2624
2625                 if (pUserData != null)
2626                 {
2627                         pAnimation->SetUserData((void*)pUserData);
2628                 }
2629         }
2630
2631         if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
2632         {
2633                 return false;
2634         }
2635
2636         delete pAnimation;
2637
2638         __animationCount++;
2639
2640         return true;
2641
2642 CATCH:
2643         delete pAnimation;
2644
2645         return false;
2646 }
2647
2648 result
2649 _TableViewItem::SetIndividualSelectionEnabled(const _Control& control, bool enable)
2650 {
2651         result r = E_SUCCESS;
2652         if (enable)
2653         {
2654                 if (!__individualSelectionControls.Contains(control))
2655                 {
2656                         r =  __individualSelectionControls.Add(control);
2657                 }
2658
2659                 _AccessibilityContainer* pContainer = const_cast<_Control*>(&control)->GetAccessibilityContainer();
2660                 pContainer->Activate(true);
2661         }
2662         else
2663         {
2664                 if (__individualSelectionControls.Contains(control))
2665                 {
2666                         r = __individualSelectionControls.Remove(control, false);
2667                 }
2668         }
2669         return r;
2670 }
2671
2672 bool
2673 _TableViewItem::IsIndividualSelectionEnabled(const _Control& control)
2674 {
2675         return __individualSelectionControls.Contains(control);
2676 }
2677
2678 int
2679 _TableViewItem::AddRef(void)
2680 {
2681         return ++__refCount;
2682 }
2683
2684 int
2685 _TableViewItem::Release(void)
2686 {
2687         --__refCount;
2688         if (__refCount <= 0)
2689         {
2690                 delete this;
2691                 return 0;
2692         }
2693
2694         return __refCount;
2695 }
2696
2697 bool
2698 _TableViewItem::IsAnimationPlaying(void)
2699 {
2700         if (__animationCount > 0)
2701         {
2702                 return true;
2703         }
2704
2705         return false;
2706 }
2707
2708 void
2709 _TableViewItem::StopAllAnimation(void)
2710 {
2711         _VisualElement* pVisualElement = GetVisualElement();
2712
2713         pVisualElement->RemoveAllAnimations();
2714 }
2715
2716 void
2717 _TableViewItem::SetItemDividerEnabled(bool enable)
2718 {
2719         __itemDividerEnabled = enable;
2720 }
2721
2722 void
2723 _TableViewItem::OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue)
2724 {
2725         if (keyName == L"MoveTableViewItem")
2726         {
2727                 Point position = currentValue.ToPoint();
2728                 SetPosition(position);
2729         }
2730         else if (keyName == L"FadeInOutTableViewItem")
2731         {
2732                 float opacity = currentValue.ToFloat();
2733
2734                 _VisualElement* pVisualElement = GetVisualElement();
2735
2736                 if (pVisualElement != null)
2737                 {
2738                         pVisualElement->SetOpacity(opacity);
2739                 }
2740         }
2741         else if (keyName == L"ZoomInOutTableViewItem")
2742         {
2743                 Dimension size = currentValue.ToDimension();
2744
2745                 SetSize(size);
2746         }
2747 }
2748
2749 void
2750 _TableViewItem::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
2751 {
2752 }
2753
2754 void
2755 _TableViewItem::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
2756 {
2757 }
2758
2759 void
2760 _TableViewItem::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
2761 {
2762         if (!completedNormally)
2763         {
2764                 __animationCount--;
2765                 return;
2766         }
2767
2768         bool tableViewItemAnimation = true;
2769         const VisualElementValueAnimation *pAnimation = dynamic_cast<const VisualElementValueAnimation*>(&(animation));
2770
2771         if (keyName == L"MoveTableViewItem")
2772         {
2773                 if (pAnimation != null)
2774                 {
2775                         Point position = pAnimation->GetEndValue().ToPoint();
2776
2777                         SetPosition(position);
2778                 }
2779         }
2780         else if (keyName == L"FadeInOutTableViewItem")
2781         {
2782                 if (pAnimation != null)
2783                 {
2784                         float opacity = pAnimation->GetEndValue().ToFloat();
2785
2786                         _VisualElement* pVisualElement = GetVisualElement();
2787
2788                         if (pVisualElement != null)
2789                         {
2790                                 pVisualElement->SetOpacity(opacity);
2791                                 Invalidate();
2792                         }
2793                 }
2794         }
2795         else if (keyName == L"ZoomInOutTableViewItem")
2796         {
2797                 if (pAnimation != null)
2798                 {
2799                         Dimension size = pAnimation->GetEndValue().ToDimension();
2800
2801                         SetSize(size);
2802                 }
2803         }
2804         else
2805         {
2806                 tableViewItemAnimation = false;
2807         }
2808
2809         if (tableViewItemAnimation)
2810         {
2811                 __animationCount--;
2812         }
2813
2814         return;
2815 }
2816
2817 void
2818 _TableViewItem::SetAccessibilityElement(void)
2819 {
2820         if(__pAccessibilityElement)
2821         {
2822                 return ;
2823         }
2824
2825         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
2826
2827         if(pContainer)
2828         {
2829                 __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
2830                 SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
2831
2832                 __pAccessibilityElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height));
2833                 __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
2834                 __pAccessibilityElement->SetName(L"TableViewItem");
2835
2836                 pContainer->AddElement(*__pAccessibilityElement);
2837         }
2838 }
2839
2840 bool
2841 _TableViewItem::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2842 {
2843         return false;
2844 }
2845
2846 bool
2847 _TableViewItem::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2848 {
2849         return false;
2850 }
2851
2852 bool
2853 _TableViewItem::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2854 {
2855         String accessibilityLable;
2856         int childControlCount = GetChildCount();
2857
2858         for (int i = 0; i < childControlCount; i++)
2859         {
2860                 _Control* pChildControl = GetChild(i);
2861
2862                 if (pChildControl == null)
2863                 {
2864                         continue;
2865                 }
2866
2867                 if (__pItemDivider == pChildControl || __pItemTopDivider == pChildControl)
2868                 {
2869                         continue;
2870                 }
2871
2872                 if (!IsIndividualSelectionEnabled(*pChildControl))
2873                 {
2874                         _AccessibilityContainer* pContainer = pChildControl->GetAccessibilityContainer();
2875                         LinkedListT<_AccessibilityElement*> accessibilityElements;
2876                         _AccessibilityElement* pElement = null;
2877
2878                         pContainer->GetElements(accessibilityElements);
2879                         pContainer->Activate(false);
2880                         int elementCount = accessibilityElements.GetCount();
2881
2882                         for (int i = 0; i < elementCount; i++)
2883                         {
2884                                 if (accessibilityElements.GetAt(i, pElement) == E_SUCCESS)
2885                                 {
2886                                         accessibilityLable += pElement->GetLabel();
2887                                 }
2888                         }
2889                 }
2890         }
2891
2892         __pAccessibilityElement->SetLabel(accessibilityLable);
2893
2894         return false;
2895 }
2896
2897 bool
2898 _TableViewItem::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2899 {
2900         return false;
2901 }
2902
2903 bool
2904 _TableViewItem::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2905 {
2906         return false;
2907 }
2908
2909 bool
2910 _TableViewItem::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2911 {
2912         return false;
2913 }
2914 bool
2915 _TableViewItem::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2916 {
2917         return false;
2918 }
2919 bool
2920 _TableViewItem::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2921 {
2922         return false;
2923 }
2924 }}} // Tizen::Ui::Controls
2925