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