2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
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.
19 * @file FUiCtrl_TableViewItem.cpp
20 * @brief This is the implementation file for _TableViewItem class.
22 * This file contains the implementation of _TableViewItem class.
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"
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Runtime;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Ui::Animations;
38 using namespace Tizen::Graphics;
40 namespace Tizen { namespace Ui { namespace Controls
43 _TableViewItem::_TableViewItem(int itemHeight)
47 , __itemHeight(itemHeight)
48 , __itemGroupIndex(-1)
50 , __checkedState(false)
51 , __enabledState(true)
53 , __reorderMode(false)
54 , __itemSelected(false)
55 , __childMarginState(false)
56 , __annexStyle(TABLE_VIEW_ANNEX_STYLE_NORMAL)
57 , __drawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
58 , __selectionStyle(TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE)
59 , __itemType(TABLE_VIEW_ITEM_TYPE_NONE)
60 , __pContextItem(null)
61 , __isContextItem(false)
62 , __isContextItemActivated(false)
63 , __checkItemHeightNeeded(false)
64 , __pItemDivider(null)
65 , __pItemTopDivider(null)
68 , __pDrawingProperty(null)
69 , __itemDividerEnabled(true)
70 , __pSimpleItemText(null)
71 , __pSimpleItemBitmap(null)
72 , __simpleItemTextSize(0)
74 , __touchStartPosition(0, 0)
75 , __isTouchMoved(false)
76 , __childControlCenterAlign(false)
79 , __pAccessibilityElement(null)
80 , __pCheckedTimer(null)
81 , __isCheckedTimerEnabled(false)
82 , __isCheckedAnimationEnabled(false)
84 , __checkedBounds(Rectangle(0, 0, 0, 0))
85 , __pHighlightVisualElement(null)
87 for (int i = 0; i < 3; i++)
89 __pItemBgBitmap[i] = null;
92 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_NORMAL, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]); // for support opacity 0x00
93 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_PRESSED, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED]);
94 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_HIGHLIGHTED, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED]);
96 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_NORMAL, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
97 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_PRESSED, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED]);
98 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_HIGHLIGHTED, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED]);
99 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_NORMAL, __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]);
100 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_PRESSED, __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED]);
101 GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_DISABLED, __simpleItemTextColor[TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED]);
104 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
107 pContainer->Activate(true);
108 pContainer->AddListener(*this);
112 _TableViewItem::~_TableViewItem()
114 _VisualElement* pVisualElement = GetVisualElement();
115 if (pVisualElement != null)
117 pVisualElement->RemoveAllAnimations();
120 for (int j = 0; j < 3; j++)
122 delete __pItemBgBitmap[j];
123 __pItemBgBitmap[j] = null;
126 if (__pHighlightVisualElement != null)
128 __pHighlightVisualElement->RemoveAllAnimations();
129 __pHighlightVisualElement->SetAnimationProvider(null);
130 __pHighlightVisualElement->Destroy();
131 __pHighlightVisualElement = null;
136 if (GetParent() != null && __isContextItem == true)
138 GetParent()->DetachChild(*this);
141 delete __pItemDivider;
142 __pItemDivider = null;
144 delete __pItemTopDivider;
145 __pItemTopDivider = null;
153 if (__isCheckedTimerEnabled)
155 __pCheckedTimer->Cancel();
158 delete __pCheckedTimer;
159 __pCheckedTimer = null;
161 if (__pAccessibilityElement)
163 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
166 pContainer->RemoveAllElement();
168 __pAccessibilityElement = null;
173 _TableViewItem::CreateTableViewItemN(int itemHeight)
175 result r = E_SUCCESS;
177 _TableViewItem* pItem = null;
178 pItem = new (std::nothrow) _TableViewItem(itemHeight);
179 SysTryReturn(NID_UI_CTRL, pItem, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
181 pItem->AcquireHandle();
183 r = pItem->Initialize();
184 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] Unable to create TableView Item");
195 _TableViewItem::Initialize(void)
197 GetVisualElement()->SetSurfaceOpaque(false);
199 result r = E_SUCCESS;
201 __pHighlightVisualElement = new (std::nothrow) _VisualElement();
202 SysTryCatch(NID_UI_CTRL, __pHighlightVisualElement != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
204 r = __pHighlightVisualElement->Construct();
205 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct Visual Element.", GetErrorMessage(r));
207 r = __pHighlightVisualElement->SetSurfaceOpaque(false);
208 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set surface opaque.", GetErrorMessage(r));
210 __pHighlightVisualElement->SetImplicitAnimationEnabled(false);
212 r = GetVisualElement()->AttachChild(*__pHighlightVisualElement);
213 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach child to the control VisualElement.", GetErrorMessage(r));
215 r = SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
216 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r));
218 __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f));
219 __pHighlightVisualElement->SetShowState(true);
221 r = __individualSelectionControls.Construct(DEFAULT_CAPTURED_CONTROL_COUNT);
222 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to construct ArrayList", GetErrorMessage(r));
224 SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE);
229 if (__pHighlightVisualElement != null)
231 __pHighlightVisualElement->RemoveAllAnimations();
232 __pHighlightVisualElement->SetAnimationProvider(null);
233 __pHighlightVisualElement->Destroy();
234 __pHighlightVisualElement = null;
241 _TableViewItem::GetContextItem(void) const
243 return __pContextItem;
247 _TableViewItem::SetContextItem(_TableViewItem* pContextItem)
249 if (pContextItem != null)
251 pContextItem->__isContextItem = true;
254 __pContextItem = pContextItem;
258 _TableViewItem::IsContextItem(void) const
260 return __isContextItem;
264 _TableViewItem::SetContextItemActivation(bool activated)
266 __isContextItemActivated = activated;
270 _TableViewItem::IsContextItemActivated(void) const
272 return __isContextItemActivated;
276 _TableViewItem::CreateItemDimLayer(void)
278 result r = E_SUCCESS;
280 if (__pDimLayer == null)
282 __pDimLayer = _Label::CreateLabelN();
285 SysTryReturn(NID_UI_CTRL, __pDimLayer != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
287 __pDimLayer->SetBackgroundColor(Color(0, 0, 0, BACKGROUND_DIMMED_OPACITY * 0xff));
288 __pDimLayer->SetVisibleState(false);
290 AttachSystemChild(*__pDimLayer);
297 _TableViewItem::ExposeContextItem(Rectangle itemBounds, int targetWidth)
300 if (__pDimLayer == null)
302 if (CreateItemDimLayer() != E_SUCCESS)
308 SetBounds(itemBounds);
312 if ((itemBounds.width <= 0) || (itemBounds.width >= targetWidth))
320 float dimLayerOpacity = 0.0f;
322 GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, rightMargin);
323 dimLayerOpacity = BACKGROUND_DIMMED_OPACITY - ((itemBounds.width * BACKGROUND_DIMMED_OPACITY) / (targetWidth - rightMargin));
324 dimLayerOpacity = ((dimLayerOpacity < 0) ? 0 : dimLayerOpacity);
326 __pDimLayer->SetBounds(Rectangle(0, 0, itemBounds.width, itemBounds.height));
327 __pDimLayer->SetBackgroundColor(Color(0, 0, 0, dimLayerOpacity * 0xff));
330 __pDimLayer->SetVisibleState(visible);
335 _TableViewItem::DrawItemDimLayer(bool visible)
337 if (__pDimLayer == null)
339 if (CreateItemDimLayer() != E_SUCCESS)
347 Dimension itemSize = GetSize();
348 __pDimLayer->SetBounds(Rectangle(0, 0, itemSize.width, itemSize.height));
349 __pDimLayer->SetBackgroundColor(Color(0, 0, 0, BACKGROUND_DISABLED_OPACITY * 0xff));
352 __pDimLayer->SetVisibleState(visible);
356 _TableViewItem::SetItemWidth(int width)
362 _TableViewItem::SetItemBackgroundBitmap(ListItemState itemState, const Bitmap* pBitmap)
364 Bitmap* pCopyBitmap = null;
366 pCopyBitmap = _BitmapImpl::CloneN(*pBitmap);
367 SysTryReturn(NID_UI_CTRL, pCopyBitmap != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
369 delete __pItemBgBitmap[itemState];
370 __pItemBgBitmap[itemState] = pCopyBitmap;
372 SetItemChanged(true);
377 Tizen::Graphics::Bitmap*
378 _TableViewItem::GetItemBackgroundBitmap(ListItemState itemState) const
380 return __pItemBgBitmap[itemState];
384 _TableViewItem::SetItemBackgroundColor(ListItemState itemState, const Color bgColor)
386 __colorItemBg[itemState] = bgColor;
388 SetItemChanged(true);
392 _TableViewItem::GetItemBackgroundColor(ListItemState itemState) const
394 return __colorItemBg[itemState];
398 _TableViewItem::SetItemStyle(TableViewAnnexStyle style)
400 if (__annexStyle == style)
405 __annexStyle = style;
409 _TableViewItem::SetSelectionStyle(TableViewItemSelectionStyle style)
411 __selectionStyle = style;
416 TableViewItemSelectionStyle
417 _TableViewItem::GetSelectionStyle(void) const
419 return __selectionStyle;
423 _TableViewItem::GetItemHeight(void) const
425 return GetSize().height;
429 _TableViewItem::SetItemHeight(int itemHeight)
431 SetSize(Dimension(GetSize().width, itemHeight));
435 _TableViewItem::SetChecked(bool checked)
437 if (__checkedState == checked)
442 __checkedState = checked;
444 SetItemChanged(true);
448 _TableViewItem::IsChecked(void) const
450 return __checkedState;
454 _TableViewItem::SetCheckedAnimationEnabled(bool enabled)
456 __isCheckedAnimationEnabled = enabled;
458 if (__isCheckedAnimationEnabled == false)
460 StopCheckBoxAnimation();
465 _TableViewItem::SetItemEnabled(bool enabled)
467 if (__enabledState == enabled)
472 __enabledState = enabled;
474 SetEnableState(enabled);
476 SetItemChanged(true);
484 _TableViewItem::IsItemEnabled(void) const
486 return __enabledState;
490 _TableViewItem::SetItemType(const TableViewItemType itemType)
492 __itemType = itemType;
494 if (__pContextItem != null)
496 __pContextItem->SetItemType(__itemType);
501 _TableViewItem::SetItemIndex(int groupIndex, int itemIndex)
503 __itemGroupIndex = groupIndex;
504 __itemIndex = itemIndex;
508 _TableViewItem::GetItemIndex(int& groupIndex, int& itemIndex) const
510 groupIndex = __itemGroupIndex;
511 itemIndex = __itemIndex;
516 _TableViewItem::GetItemType(void) const
522 _TableViewItem::IsReorderMode(void) const
524 return __reorderMode;
528 _TableViewItem::SetReorderMode(bool enabled)
530 __reorderMode = enabled;
532 if (GetItemStyle() != TABLE_VIEW_ANNEX_STYLE_NORMAL)
534 if (__pItemAnnex != null)
536 __pItemAnnex->SetVisibleState(!enabled);
540 SetItemChanged(true);
547 _TableViewItem::SetAppInfo(const void* pAppInfo)
549 __pAppInfo = const_cast<void*>(pAppInfo);
553 _TableViewItem::GetAppInfo(void) const
559 _TableViewItem::SetItemChanged(bool changed)
561 __itemChanged = changed;
565 _TableViewItem::IsItemChanged(void) const
567 return __itemChanged;
571 _TableViewItem::GetItemStyle(void) const
577 _TableViewItem::DrawItem(Rectangle& rcItem, ListItemState itemState, bool itemDivider)
583 _TableViewItem::FireItemEvent(bool selectedBody)
585 if (HasParent() == false)
595 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
601 TableViewNotifyType eventType = TABLEVIEW_NOTIFY_TYPE_SELECTED_ITEM;
603 if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
604 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
605 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING))
609 eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK;
613 eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK;
616 else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
620 eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_MORE;
624 __checkItemHeightNeeded = true;
629 GetItemIndex(groupIndex, itemIndex);
630 pParent->FireTableViewItemEvent(groupIndex, itemIndex, eventType, this);
634 _TableViewItem::FireItemSweepEvent(TableViewSweepDirection direction)
636 if (HasParent() == false)
641 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
649 GetItemIndex(groupIndex, itemIndex);
651 pParent->FireTableViewItemSweepEvent(groupIndex, itemIndex, direction);
655 _TableViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
657 if (&source != this || IsAnimationPlaying())
662 if (IsContextItem() || __isContextItemActivated)
667 __isTouchMoved = false;
668 __touchStartPosition = touchinfo.GetCurrentPosition();
670 __itemSelected = true;
671 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
673 SetItemChanged(true);
680 _TableViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
687 bool fireEvent = false;
689 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
691 if (__itemSelected == true)
693 if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
694 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
695 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING))
697 bool checked = IsChecked();
698 SetChecked(!checked);
699 SetCheckedAnimationEnabled(!checked);
705 SetItemChanged(true);
708 __itemSelected = false;
719 _TableViewItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
721 if (__itemSelected == true)
723 Point touchPosition = touchinfo.GetCurrentPosition();
725 __isTouchMoved = true;
727 __itemSelected = false;
728 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
730 SetItemChanged(true);
738 _TableViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
745 __isTouchMoved = false;
747 __itemSelected = false;
748 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
750 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
755 SetItemChanged(true);
761 _UiTouchEventDelivery
762 _TableViewItem::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
764 if (__isContextItemActivated || IsAnimationPlaying() || !IsValidSelectionState())
766 return _UI_TOUCH_EVENT_DELIVERY_YES;
769 __itemSelected = true;
770 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED;
772 __isTouchMoved = false;
773 __touchStartPosition = touchinfo.GetCurrentPosition();
775 if (__selectionStyle == TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE && !IsIndividualSelectionEnabled(source))
777 if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) && (&source == __pItemAnnex))
784 SetItemChanged(true);
790 if (&source == __pItemAnnex)
792 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
799 SetItemChanged(true);
805 return _UI_TOUCH_EVENT_DELIVERY_YES;
808 _UiTouchEventDelivery
809 _TableViewItem::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
811 if (__isContextItemActivated)
813 return _UI_TOUCH_EVENT_DELIVERY_YES;
816 int selectedBody = true;
817 bool fireItemEvent = false;
819 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
821 if (__itemSelected == true)
823 if (__selectionStyle == TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE && !IsIndividualSelectionEnabled(source))
825 if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
826 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
827 || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING))
829 bool checked = IsChecked();
830 SetChecked(!checked);
831 SetCheckedAnimationEnabled(!checked);
833 else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
835 if (&source == __pItemAnnex)
837 SetChecked(!IsChecked());
839 selectedBody = false;
843 SetItemChanged(true);
846 fireItemEvent = true;
850 if (&source == __pItemAnnex)
852 bool checked = IsChecked();
853 SetChecked(!checked);
854 SetCheckedAnimationEnabled(!checked);
856 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
859 selectedBody = false;
866 fireItemEvent = true;
871 __itemSelected = false;
875 FireItemEvent(selectedBody);
878 return _UI_TOUCH_EVENT_DELIVERY_YES;
881 _UiTouchEventDelivery
882 _TableViewItem::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
884 if (__itemSelected == true)
886 Point touchPosition = touchinfo.GetCurrentPosition();
888 __isTouchMoved = true;
890 __itemSelected = false;
891 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
893 SetItemChanged(true);
898 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED && IsChecked())
904 return _UI_TOUCH_EVENT_DELIVERY_YES;
907 _UiTouchEventDelivery
908 _TableViewItem::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
910 __isTouchMoved = false;
912 __itemSelected = false;
913 __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
915 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
920 SetItemChanged(true);
923 return _UI_TOUCH_EVENT_DELIVERY_YES;
927 _TableViewItem::OnDraw(void)
929 if (IsItemChanged() == true)
931 DrawItemBackground();
936 SetAccessibilityElement();
937 SetItemChanged(false);
942 _TableViewItem::OnChildAttached(const _Control& child)
944 _AccessibilityContainer* pContainer = const_cast<_Control*>(&child)->GetAccessibilityContainer();
945 pContainer->Activate(false);
947 _Control* pControl = const_cast<_Control*>(&child);
948 pControl->SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE);
950 if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO))
952 if (__pItemAnnex == &child)
957 Rectangle bounds = child.GetBounds();
961 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
962 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
964 bounds.x += (leftMargin * 2) + annexWidth;
965 pControl->SetBounds(bounds);
970 _TableViewItem::OnChildDetached(const _Control& child)
972 if (__individualSelectionControls.Contains(child))
974 __individualSelectionControls.Remove(child, false);
977 if (&child == __pSimpleItemText)
979 __pSimpleItemText = null;
981 if (&child == __pSimpleItemBitmap)
983 __pSimpleItemBitmap = null;
988 _TableViewItem::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
990 result r = E_SUCCESS;
992 if (&timer == __pCheckedTimer)
994 if (__checkedCount < MAX_CHECKED_COUNT)
996 r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION);
997 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1000 r = PlayCheckBoxAnimation();
1001 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1003 if (__checkedCount < MAX_CHECKED_COUNT)
1010 __isCheckedAnimationEnabled = false;
1011 __isCheckedTimerEnabled = false;
1017 _TableViewItem::StartCheckBoxAnimation(void)
1019 result r = E_SUCCESS;
1021 if (__pCheckedTimer == null)
1023 __pCheckedTimer = new (std::nothrow) Timer();
1024 SysTryCatch(NID_UI_CTRL, __pCheckedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1026 r = __pCheckedTimer->Construct(*this);
1027 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage);
1030 if (__isCheckedTimerEnabled == false)
1032 r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION);
1033 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage);
1035 __isCheckedTimerEnabled = true;
1041 if (__isCheckedTimerEnabled)
1043 __pCheckedTimer->Cancel();
1046 delete __pCheckedTimer;
1047 __pCheckedTimer = null;
1053 _TableViewItem::StopCheckBoxAnimation(void)
1055 result r = E_SUCCESS;
1057 SysTryReturnVoidResult(NID_UI_CTRL, __pCheckedTimer != null, E_SYSTEM, "[E_SYSTEM] Timer is invalid.");
1059 if (__isCheckedTimerEnabled)
1061 r = __pCheckedTimer->Cancel();
1062 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1066 __isCheckedAnimationEnabled = false;
1067 __isCheckedTimerEnabled = false;
1073 _TableViewItem::PlayCheckBoxAnimation(void)
1075 Bitmap* pCheckBox = null;
1076 Bitmap* pCheckBoxBg = null;
1077 Bitmap* pMergeBitmap = null;
1078 Canvas* pCanvas = null;
1079 result r = E_SUCCESS;
1082 int annexWidth = 0, annexHeight = 0;
1084 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1086 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1088 else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
1090 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1092 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1094 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
1095 SysTryCatch(NID_UI_CTRL,(r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1097 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1098 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1099 bounds.SetBounds(0, 0, annexWidth, annexHeight);
1101 pCanvas = new (std::nothrow) Canvas();
1102 SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1104 if (pCanvas != null)
1106 r = pCanvas->Construct(bounds);
1108 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1111 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg);
1113 __checkedBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox);
1114 if (IsChecked() == true)
1116 if (pCheckBox->IsNinePatchedBitmap())
1118 r = pCanvas->DrawNinePatchedBitmap(Rectangle(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width, __checkedBounds.height), *pCheckBox);
1122 Rectangle bitmapSourceRect(0, 0, pCheckBox->GetWidth()*__checkedCount * 0.1, pCheckBox->GetHeight());
1123 Rectangle drawingRect(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width * __checkedCount * 0.1, __checkedBounds.height);
1124 r = pCanvas->DrawBitmap(drawingRect, *pCheckBox, bitmapSourceRect);
1129 pMergeBitmap = new (std::nothrow) Bitmap();
1130 SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1132 if (pMergeBitmap != null)
1134 pMergeBitmap->Construct(*pCanvas, bounds);
1137 if (__pItemAnnex == null)
1139 __pItemAnnex = _Label::CreateLabelN();
1141 r = GetLastResult();
1142 SysTryCatch(NID_UI_CTRL, __pItemAnnex != null, , r, "[%s] Propagating.", GetErrorMessage(r));
1145 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1147 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1148 __pItemAnnex->SetBounds(Rectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1149 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1151 AttachSystemChild(*__pItemAnnex);
1154 __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1155 __pItemAnnex->Invalidate();
1160 delete pMergeBitmap;
1167 _TableViewItem::OnBoundsChanged(void)
1169 if (__checkItemHeightNeeded && HasParent())
1171 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
1172 if (pParent != null)
1174 int groupIndex = -1;
1176 GetItemIndex(groupIndex, itemIndex);
1178 pParent->CheckItemHeightAndRefreshLayout(groupIndex, itemIndex);
1181 __checkItemHeightNeeded = false;
1184 AdjustAnnexBounds();
1186 SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
1190 _TableViewItem::SetDrawingProperty(_ItemDrawingProperty* pDrawingProperty)
1192 __pDrawingProperty = pDrawingProperty;
1195 _ItemDrawingProperty*
1196 _TableViewItem::GetDrawingProperty(void)
1198 return __pDrawingProperty;
1202 _TableViewItem::DrawItemBackground(void)
1204 Canvas* pCanvas = null;
1205 Bitmap* pDrawBitmap = __pItemBgBitmap[__drawingStatus];
1206 Color bgColor = __colorItemBg[__drawingStatus];
1207 Rectangle bounds = GetBounds();
1209 SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds());
1211 if (pDrawBitmap != null)
1213 const _BitmapImpl* pBitmapImpl = _BitmapImpl::GetInstance(*pDrawBitmap);
1214 SysTryReturnVoidResult(NID_UI_CTRL, pBitmapImpl != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1216 pCanvas = GetVisualElement()->GetCanvasN();
1217 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1221 pCanvas->SetBackgroundColor(bgColor);
1225 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1226 pCanvas->SetBackgroundColor(bgColor);
1229 DrawBitmap(*pCanvas, Rectangle(0, 0, bounds.width, bounds.height), *pDrawBitmap);
1234 else if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
1238 SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
1239 __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1243 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1244 SetBackgroundColor(bgColor);
1247 else if (__itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
1251 SetBackgroundColor(Color(0, 0, 0, 0));
1252 __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f));
1256 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1257 SetBackgroundColor(bgColor);
1260 else if (IsContextItem())
1264 SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
1265 __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1269 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1270 SetBackgroundColor(bgColor);
1273 else if (__pDrawingProperty->sectionStyleEnabled == true)
1275 DrawSectionStyleBackground();
1281 SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
1282 __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f));
1286 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1287 SetBackgroundColor(bgColor);
1290 if (__pDrawingProperty->groupedLookEnabled == true)
1298 _TableViewItem::DrawGroupedLook(void)
1300 if (IsTitleStyleItem())
1306 Color outlineColor = __pDrawingProperty->dividerColor;
1309 Canvas* pCanvas = GetVisualElement()->GetCanvasN();
1310 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1312 Rectangle bounds = GetBounds();
1313 pCanvas->SetBackgroundColor(GetBackgroundColor());
1316 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor);
1317 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth);
1319 pCanvas->FillRectangle(barColor, Rectangle(0, 0, barWidth, bounds.height));
1321 if (__pDrawingProperty->sectionStyleEnabled == true)
1323 pCanvas->FillRectangle(outlineColor, Rectangle(bounds.width - 1, 0, 1, bounds.height));
1325 if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP || __itemType == TABLE_VIEW_ITEM_TYPE_ONE)
1327 pCanvas->FillRectangle(outlineColor, Rectangle(0, 0, bounds.width, 1));
1335 _TableViewItem::DrawSectionStyleBackground(void)
1337 Canvas* pCanvas = null;
1338 Bitmap* pSectionBg = null;
1339 Bitmap* pSectionPressedBg = null;
1340 Bitmap* pReplacementSectionBg = null;
1341 Rectangle bounds = GetBounds();
1342 result r = E_SUCCESS;
1344 pCanvas = GetVisualElement()->GetCanvasN();
1345 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1347 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1350 if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
1352 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
1354 else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
1356 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
1358 else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
1360 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
1362 else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
1364 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg);
1370 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] SectionStyle image load failed");
1374 pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), __pDrawingProperty->sectionStyleBgColor);
1379 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor);
1380 pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor);
1382 DrawBitmap(*pCanvas, Rectangle(0, 0, bounds.width, bounds.height), *pReplacementSectionBg);
1384 if (__drawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1386 if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE)
1388 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg);
1390 else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP)
1392 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg);
1394 else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE)
1396 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg);
1398 else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM)
1400 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg);
1403 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] SectionStyle image load failed");
1405 if (__drawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1410 GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_PRESSED, pressColor);
1411 pSectionPressedBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), pressColor);
1412 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, dividerHeight);
1413 DrawBitmap(*pCanvas, Rectangle(0, dividerHeight, bounds.width, bounds.height-dividerHeight*2), *pSectionPressedBg);
1416 if (__pDrawingProperty->groupedLookEnabled == true)
1419 int barWidth = 0, barMargin = 0;
1421 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor);
1422 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth);
1423 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, barMargin);
1425 pCanvas->FillRectangle(barColor, Rectangle(0, barMargin, barWidth, bounds.height-barMargin));
1430 delete pSectionPressedBg;
1431 delete pReplacementSectionBg;
1436 _TableViewItem::DrawAnnexStyle(void)
1443 switch (__annexStyle)
1445 case TABLE_VIEW_ANNEX_STYLE_MARK:
1448 case TABLE_VIEW_ANNEX_STYLE_RADIO:
1451 case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
1454 case TABLE_VIEW_ANNEX_STYLE_DETAILED:
1463 _TableViewItem::DrawCheckBox(void)
1465 Bitmap* pCheckBox = null;
1466 Bitmap* pCheckBoxBg = null;
1467 Bitmap* pMergeBitmap = null;
1468 Canvas* pCanvas = null;
1469 result r = E_SUCCESS;
1472 int annexWidth = 0, annexHeight = 0;
1474 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1476 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1478 else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
1480 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg);
1482 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1484 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox);
1485 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1487 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1488 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1489 bounds.SetBounds(0, 0, annexWidth, annexHeight);
1491 pCanvas = new (std::nothrow) Canvas();
1492 SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1494 if (pCanvas != null)
1496 pCanvas->Construct(bounds);
1498 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1501 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg);
1503 if (IsChecked() == true)
1505 if (__isCheckedAnimationEnabled == true)
1507 StartCheckBoxAnimation();
1511 if (pCheckBox != null)
1513 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox), *pCheckBox);
1519 pMergeBitmap = new (std::nothrow) Bitmap();
1520 SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1522 if (pMergeBitmap != null)
1524 pMergeBitmap->Construct(*pCanvas, bounds);
1527 if (__pItemAnnex == null)
1529 __pItemAnnex = _Label::CreateLabelN();
1531 r = GetLastResult();
1532 SysTryCatch(NID_UI_CTRL, __pItemAnnex != null, , r, "[%s] Propagating.", GetErrorMessage(r));
1535 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1537 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1538 __pItemAnnex->SetBounds(Rectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1539 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1541 AttachSystemChild(*__pItemAnnex);
1544 __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1545 __pItemAnnex->Invalidate();
1550 delete pMergeBitmap;
1557 _TableViewItem::DrawRadioBox(void)
1559 Bitmap* pRadioButton = null;
1560 Bitmap* pRadioButtonBg = null;
1561 Bitmap* pMergeBitmap = null;
1562 Canvas* pCanvas = null;
1563 result r = E_SUCCESS;
1566 int annexWidth = 0, annexHeight = 0;
1568 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1570 r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
1572 else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED))
1574 r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg);
1576 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButtonBg != null), , E_SYSTEM, "[E_SYSTEM] RadioButtonBg image load failed");
1578 r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButton);
1579 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButton != null), , E_SYSTEM, "[E_SYSTEM] CheckBox image load failed");
1581 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1582 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1583 bounds.SetBounds(0, 0, annexWidth, annexHeight);
1585 pCanvas = new (std::nothrow) Canvas();
1586 SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1588 if (pCanvas != null)
1590 pCanvas->Construct(bounds);
1592 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1595 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButtonBg), *pRadioButtonBg);
1597 if (IsChecked() == true)
1599 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButton), *pRadioButton);
1603 pMergeBitmap = new (std::nothrow) Bitmap();
1604 SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1606 if (pMergeBitmap != null)
1608 pMergeBitmap->Construct(*pCanvas, bounds);
1611 if (__pItemAnnex == null)
1613 __pItemAnnex = _Label::CreateLabelN();
1614 SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1617 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1619 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1620 __pItemAnnex->SetBounds(Rectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1621 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1623 AttachSystemChild(*__pItemAnnex);
1626 __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1627 __pItemAnnex->Invalidate();
1630 delete pRadioButton;
1631 delete pRadioButtonBg;
1632 delete pMergeBitmap;
1639 _TableViewItem::DrawOnOffButton(void)
1641 Bitmap* pOnOffButton = null;
1642 Bitmap* pOnOffButtonHandler = null;
1643 Bitmap* pMergeBitmap = null;
1644 Canvas* pCanvas = null;
1645 result r = E_SUCCESS;
1648 Rectangle backgroundBounds;
1649 int annexWidth = 0, annexHeight = 0;
1651 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler);
1652 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButtonHandler != null), , E_SYSTEM, "[E_SYSTEM] OnOffHandlerButton button image load failed");
1654 if (IsChecked() == true)
1656 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
1660 r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton);
1662 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButton != null), , E_SYSTEM, "[E_SYSTEM] OnOffButton image load failed");
1664 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1665 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1666 bounds.SetBounds(0, 0, annexWidth, annexHeight);
1668 pCanvas = new (std::nothrow) Canvas();
1669 SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1671 pCanvas->Construct(bounds);
1672 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1675 backgroundBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButton);
1676 DrawBitmap(*pCanvas, backgroundBounds, *pOnOffButton);
1678 if (IsChecked() == true)
1680 Rectangle handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
1681 handlerBounds.x = backgroundBounds.width - handlerBounds.width;
1682 handlerBounds.y = backgroundBounds.y;
1683 DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler);
1687 Rectangle handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler);
1688 handlerBounds.x = backgroundBounds.x;
1689 handlerBounds.y = backgroundBounds.y;
1690 DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler);
1693 pMergeBitmap = new (std::nothrow) Bitmap();
1694 SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1696 pMergeBitmap->Construct(*pCanvas, bounds);
1698 if (__pItemAnnex == null)
1700 __pItemAnnex = _Label::CreateLabelN();
1701 SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1704 int annexWidth = 0, annexHeight = 0;
1705 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1706 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1707 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1709 leftMargin += __pDrawingProperty->scrollMargin;
1711 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1712 __pItemAnnex->SetBounds(Rectangle((GetBounds().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1713 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1715 AttachSystemChild(*__pItemAnnex);
1718 __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1719 __pItemAnnex->Invalidate();
1722 delete pOnOffButton;
1723 delete pOnOffButtonHandler;
1724 delete pMergeBitmap;
1731 _TableViewItem::DrawDetailButton(void)
1733 Bitmap* pDetail = null;
1734 Bitmap* pDetailBg = null;
1735 Bitmap* pDetailBgEffect = null;
1736 Bitmap* pReplacementDetail = null;
1737 Bitmap* pReplacementDetailBg = null;
1738 Bitmap* pMergeBitmap = null;
1739 Canvas* pCanvas = null;
1740 Color replacementNewColor;
1741 Color replacementNewBgColor;
1742 result r = E_SUCCESS;
1745 int annexWidth = 0, annexHeight = 0;
1747 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBg);
1748 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBg != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1750 if (IsChecked() != true)
1752 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
1753 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBgEffect != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1755 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_NORMAL, replacementNewColor);
1756 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_NORMAL, replacementNewBgColor);
1760 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect);
1761 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBgEffect != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1763 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_PRESSED, replacementNewColor);
1764 GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_PRESSED, replacementNewBgColor);
1767 pReplacementDetailBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pDetailBg, Color::GetColor(COLOR_ID_MAGENTA), replacementNewBgColor);
1768 SysTryCatch(NID_UI_CTRL, pReplacementDetailBg != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1770 r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDetail);
1771 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetail != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1773 pReplacementDetail = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pDetail, Color::GetColor(COLOR_ID_MAGENTA), replacementNewColor);
1774 SysTryCatch(NID_UI_CTRL, pReplacementDetail != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Detail button image load failed");
1776 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
1777 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight);
1778 bounds.SetBounds(0, 0, annexWidth, annexHeight);
1780 pCanvas = new (std::nothrow) Canvas();
1781 SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1783 pCanvas->Construct(bounds);
1784 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1787 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetailBg), *pReplacementDetailBg);
1788 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pDetailBgEffect), *pDetailBgEffect);
1789 DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetail), *pReplacementDetail);
1791 pMergeBitmap = new (std::nothrow) Bitmap();
1792 SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1794 pMergeBitmap->Construct(*pCanvas, bounds);
1796 if (__pItemAnnex == null)
1798 __pItemAnnex = _Label::CreateLabelN();
1799 SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1802 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
1804 leftMargin += __pDrawingProperty->scrollMargin;
1805 int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height);
1806 __pItemAnnex->SetBounds(Rectangle((GetBounds().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight));
1807 __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0));
1809 AttachSystemChild(*__pItemAnnex);
1812 __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap);
1813 __pItemAnnex->Invalidate();
1818 delete pDetailBgEffect;
1819 delete pReplacementDetail;
1820 delete pReplacementDetailBg;
1821 delete pMergeBitmap;
1828 _TableViewItem::DrawItemDivider(void)
1830 if (__pDrawingProperty->itemDividerEnabled == false || __itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER || __itemDividerEnabled == false)
1832 if (__pItemDivider != null)
1834 __pItemDivider->SetVisibleState(false);
1837 if (__pItemTopDivider != null)
1839 __pItemTopDivider->SetVisibleState(false);
1842 else if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
1844 if (__pItemDivider == null)
1846 __pItemDivider = _Label::CreateLabelN();
1847 SysTryReturnVoidResult(NID_UI_CTRL, __pItemDivider, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1849 AttachSystemChild(*__pItemDivider);
1852 Color underLineColor;
1853 Rectangle bounds = GetBounds();
1854 int lineHeight = 0, lineLeftMargin = 0, lineBottomMargin = 0;
1856 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
1858 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_NORMAL, underLineColor);
1862 GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_PRESSED, underLineColor);
1864 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
1865 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
1866 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineBottomMargin);
1868 __pItemDivider->SetBounds(Rectangle(lineLeftMargin, bounds.height - lineBottomMargin, bounds.width - lineLeftMargin * 2, lineHeight));
1869 __pItemDivider->SetBackgroundColor(underLineColor);
1870 __pItemDivider->Invalidate();
1874 if (__pItemDivider == null)
1876 __pItemDivider = _Label::CreateLabelN();
1877 SysTryReturnVoidResult(NID_UI_CTRL, __pItemDivider, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1879 AttachSystemChild(*__pItemDivider);
1883 Rectangle bounds = GetBounds();
1884 int lineLeftMargin = 0, lineHeight = 0;
1885 int groupIndex = -1, itemIndex = -1;
1887 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_TOP_BG_NORMAL, dividerColor);
1888 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin);
1889 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight);
1891 __pItemDivider->SetBounds(Rectangle(lineLeftMargin, (bounds.height - lineHeight), bounds.width - lineLeftMargin * 2, lineHeight));
1892 __pItemDivider->SetBackgroundColor(__pDrawingProperty->dividerColor);
1893 __pItemDivider->Invalidate();
1895 GetItemIndex(groupIndex, itemIndex);
1898 if (__pItemTopDivider == null)
1900 __pItemTopDivider = _Label::CreateLabelN();
1901 SysTryReturnVoidResult(NID_UI_CTRL, __pItemTopDivider, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1903 AttachSystemChild(*__pItemTopDivider);
1905 __pItemTopDivider->SetBounds(Rectangle(lineLeftMargin, 0, bounds.width - lineLeftMargin * 2, lineHeight));
1906 __pItemTopDivider->SetBackgroundColor(dividerColor);
1907 __pItemTopDivider->Invalidate();
1911 if (__pItemDivider != null)
1913 _AccessibilityContainer* pContainer = __pItemDivider->GetAccessibilityContainer();
1914 pContainer->Activate(false);
1917 if (__pItemTopDivider != null)
1919 _AccessibilityContainer* pContainer = __pItemTopDivider->GetAccessibilityContainer();
1920 pContainer->Activate(false);
1925 _TableViewItem::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap)
1927 result r = E_SUCCESS;
1928 if (bitmap.IsNinePatchedBitmap())
1930 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1931 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Fail to draw ninepatched bitmap.", GetErrorMessage(r))
1935 r = canvas.DrawBitmap(bounds, bitmap);
1936 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Fail to draw bitmap.", GetErrorMessage(r))
1943 _TableViewItem::SetItemHighlightBounds(_VisualElement& highlightVisualElement, const Rectangle& bounds)
1945 FloatRectangle veBounds(bounds.x, bounds.y, bounds.width, bounds.height);
1946 return highlightVisualElement.SetBounds(veBounds);
1950 _TableViewItem::CalculateItemHighlightBounds(void)
1952 int itemHighlightMargin = 0;
1953 Rectangle itemBounds = GetBounds();
1956 if (IsTitleStyleItem() == false)
1958 GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, itemHighlightMargin);
1960 bounds.SetBounds(0, itemHighlightMargin, itemBounds.width, itemBounds.height - itemHighlightMargin *2);
1966 _TableViewItem::CalculateAnnexBitmapBounds(int annexWidth, int annexHeight, const Bitmap& bitmap)
1969 int width = 0, height = 0;
1970 int leftMargin = 0, topMargin = 0;
1972 if (annexWidth > bitmap.GetWidth())
1974 leftMargin = (annexWidth - bitmap.GetWidth()) / 2;
1975 width = bitmap.GetWidth();
1982 if(annexHeight > bitmap.GetHeight())
1984 topMargin = (annexHeight - bitmap.GetHeight()) / 2;
1985 height = bitmap.GetHeight();
1989 height = annexHeight;
1992 bounds.SetBounds(leftMargin, topMargin, width, height);
1998 _TableViewItem::IsTitleStyleItem(void) const
2000 if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE || __itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER)
2009 _TableViewItem::IsValidSelectionState(void)
2011 _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
2012 if (pParent == null)
2017 if (pParent->GetPressedItemCount() > 0)
2026 _TableViewItem::DrawSimpleItem(void)
2028 if (__pSimpleItemText != null)
2030 Color textColor = __simpleItemTextColor[__drawingStatus];
2033 textColor = __simpleItemTextColor[TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED];
2036 if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
2038 if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)
2040 textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL];
2044 textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED];
2048 __pSimpleItemText->SetTextColor(textColor);
2049 __pSimpleItemText->Invalidate();
2053 _TableViewItem::SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType)
2055 result r = E_SUCCESS;
2056 bool textOnly = true;
2058 if (pBitmap != null)
2063 r = CreateSimpleItemContents(textOnly);
2064 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2066 Rectangle bitmapRect = Rectangle(0, 0, 0, 0);
2067 Rectangle textRect = Rectangle(0, 0, 0, 0);
2068 int elementWidth = 0;
2069 int elementHeight = 0;
2071 int itemHeight = __itemHeight;
2072 int annexWidth = GetAnnexWidth(__annexStyle);
2076 if (__simpleItemTextSize == 0)
2078 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize);
2080 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
2084 if (__simpleItemTextSize == 0)
2086 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize);
2088 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
2093 elementWidth = itemHeight * SIMPLE_ITEM_ELEMENT_BITMAP_SIZE_RATIO;
2094 elementHeight = elementWidth;
2096 bitmapRect.x = leftMargin;
2097 bitmapRect.y = (itemHeight - elementHeight) / 2;
2098 bitmapRect.width = elementWidth;
2099 bitmapRect.height = elementHeight;
2102 // if (annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
2104 // bitmapRect.x += annexWidth + leftMargin;
2107 textRect.x = bitmapRect.x + elementWidth + leftMargin;
2111 elementWidth = __itemWidth - textRect.x - annexWidth - leftMargin;
2115 elementWidth = __itemWidth - textRect.x;
2119 textRect.width = elementWidth;
2120 textRect.height = itemHeight;
2122 if (__pSimpleItemBitmap != null && pBitmap != null)
2124 __pSimpleItemBitmap->SetBackgroundBitmap(*pBitmap);
2125 __pSimpleItemBitmap->SetBounds(bitmapRect);
2127 if (!__pSimpleItemBitmap->HasParent())
2129 r = AttachChild(*__pSimpleItemBitmap);
2130 SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
2134 if (__pSimpleItemText != null)
2136 __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL);
2137 __pSimpleItemText->SetText(text);
2138 __pSimpleItemText->SetBounds(textRect);
2140 if (!__pSimpleItemText->HasParent())
2142 r = AttachChild(*__pSimpleItemText);
2143 SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
2151 _TableViewItem::CreateSimpleItemContents(bool textOnly)
2153 result r = E_SUCCESS;
2155 if (__pSimpleItemText == null)
2157 __pSimpleItemText = _Label::CreateLabelN();
2159 r = GetLastResult();
2160 SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
2162 __pSimpleItemText->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
2163 __pSimpleItemText->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
2164 if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE)
2166 __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]);
2170 __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]);
2172 __pSimpleItemText->SetBackgroundColor(Color(0, 0, 0, 0));
2178 if (__pSimpleItemBitmap == null)
2180 __pSimpleItemBitmap = _Label::CreateLabelN();
2181 SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
2183 __pSimpleItemText->SetBackgroundColor(Color(0, 0, 0, 0));
2189 if (__pSimpleItemBitmap != null)
2191 delete __pSimpleItemBitmap;
2192 __pSimpleItemBitmap = null;
2200 _TableViewItem::SetSimpleTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status)
2202 __simpleItemTextColor[status] = color;
2207 Tizen::Graphics::Color
2208 _TableViewItem::GetSimpleItemTextColor(TableViewItemDrawingStatus status) const
2210 return __simpleItemTextColor[status];
2214 _TableViewItem::SetSimpleItemTextSize(int size)
2216 __simpleItemTextSize = size;
2218 if (__pSimpleItemText != null)
2220 __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL);
2226 _TableViewItem::GetSimpleItemTextSize(void) const
2228 return __simpleItemTextSize;
2232 _TableViewItem::GetAnnexWidth(TableViewAnnexStyle style)
2238 case TABLE_VIEW_ANNEX_STYLE_NORMAL:
2242 case TABLE_VIEW_ANNEX_STYLE_MARK:
2243 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2246 case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
2247 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2250 case TABLE_VIEW_ANNEX_STYLE_DETAILED:
2251 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2254 case TABLE_VIEW_ANNEX_STYLE_RADIO:
2255 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth);
2266 _TableViewItem::SetDrawingStatus(TableViewItemDrawingStatus status)
2268 __drawingStatus = status;
2271 TableViewItemDrawingStatus
2272 _TableViewItem::GetDrawingStatus(void)
2274 return __drawingStatus;
2278 _TableViewItem::AdjustChildControlMargin(void)
2280 if (__childMarginState)
2285 if (IsTitleStyleItem())
2290 __childMarginState = true;
2294 if (__pDrawingProperty->groupedLookEnabled)
2296 int groupedBarMargin = 0;
2297 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, groupedBarMargin);
2299 margin = margin + groupedBarMargin;
2304 _VisualElement* pVisualElement = GetVisualElement();
2306 if (pVisualElement != null)
2308 FloatPoint position;
2310 position.SetPosition(margin, 0.0f);
2311 pVisualElement->ScrollByPoint(position, false);
2317 _TableViewItem::AdjustContextItemBounds(void)
2319 _TableViewItem* pContextItem = GetContextItem();
2321 if (pContextItem == null)
2326 Dimension contextItemSize = pContextItem->GetSize();
2327 Dimension itemSize = GetSize();
2329 if (contextItemSize.height != itemSize.height)
2331 contextItemSize.height = itemSize.height;
2333 pContextItem->SetSize(contextItemSize);
2336 pContextItem->AdjustChildControlCenterAlign();
2340 _TableViewItem::AdjustAnnexBounds(void)
2342 if (__pItemAnnex == null)
2348 if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || __annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED)
2350 if (__pItemAnnex->HasParent())
2352 Rectangle annexBounds = __pItemAnnex->GetBounds();
2353 int annexPositionX = annexBounds.x;
2356 GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin);
2357 leftMargin += __pDrawingProperty->scrollMargin;
2359 annexPositionX = GetBounds().width - annexBounds.width - leftMargin;
2361 if (annexPositionX != annexBounds.x)
2363 __pItemAnnex->SetPosition(Point(annexPositionX, annexBounds.y));
2369 Rectangle itemBounds = GetBounds();
2370 Rectangle annexBounds = __pItemAnnex->GetBounds();
2372 if (__customHeight > 0)
2374 itemBounds.height = __customHeight;
2377 annexBounds.y = (itemBounds.height - annexBounds.height) / 2;
2378 __pItemAnnex->SetPosition(Point(annexBounds.x, annexBounds.y));
2382 _TableViewItem::SetItemCustomHeight(int height)
2384 __customHeight = height;
2388 _TableViewItem::AdjustChildControlCenterAlign(void)
2390 if (__childControlCenterAlign)
2392 Dimension itemSize = GetSize();
2394 int childControlCount = GetChildCount();
2396 for (int i = 0; i < childControlCount; i++)
2398 _Control* pChildControl = GetChild(i);
2400 if (pChildControl == null)
2405 if (__pItemDivider == pChildControl)
2407 int positionX = pChildControl->GetPosition().x;
2408 pChildControl->SetPosition(Point(positionX, itemSize.height - 1));
2412 if (__pItemTopDivider == pChildControl)
2414 int positionX = pChildControl->GetPosition().x;
2415 pChildControl->SetPosition(Point(positionX, 0));
2419 Rectangle itemBounds = pChildControl->GetBounds();
2421 itemBounds.y = (itemSize.height - itemBounds.height) / 2;
2423 pChildControl->SetPosition(Point(itemBounds.x, itemBounds.y));
2429 _TableViewItem::SetChildControlCenterAlign(bool centerAlign)
2431 __childControlCenterAlign = centerAlign;
2435 _TableViewItem::GetLastTouchPressedPosition(void)
2437 return __touchStartPosition;
2441 _TableViewItem::SetLastTouchPressedPosition(Point position)
2443 // This function was made to modify of ListView::RefreshList().
2444 // This function could adversely affect touch event handling. So, you should be used with caution.
2445 __touchStartPosition = position;
2449 _TableViewItem::GetSelectionState(void)
2451 return __itemSelected;
2455 _TableViewItem::SetSelectionState(bool selected)
2457 // This function was made to modify of ListView::RefreshList().
2458 // This function could adversely affect touch event handling. So, you should be used with caution.
2459 __itemSelected = selected;
2463 _TableViewItem::MoveItem(Point position, int duration, int delay, Tizen::Base::String* pName)
2465 _VisualElement* pVisualElement = GetVisualElement();
2467 String animationName = L"MoveTableViewItem";
2469 VisualElementValueAnimation* pAnimation = dynamic_cast<VisualElementValueAnimation*>(pVisualElement->GetAnimationN(animationName));
2471 if (pAnimation != null)
2473 pVisualElement->RemoveAnimation(animationName);
2476 pAnimation = new (std::nothrow) VisualElementValueAnimation();
2477 SysTryReturn(NID_UI_CTRL, pAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2479 pAnimation->SetDuration(duration);
2480 pAnimation->SetDelay(delay);
2481 pAnimation->SetStartValue(Variant(GetPosition()));
2482 pAnimation->SetEndValue(Variant(position));
2483 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseInOut"));
2484 pAnimation->SetVisualElementAnimationStatusEventListener(this);
2485 pAnimation->SetVisualElementAnimationTickEventListener(this);
2488 String* pUserData = new (std::nothrow) String(*pName);
2489 SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2491 if (pUserData != null)
2493 pAnimation->SetUserData((void*)pUserData);
2497 if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
2515 _TableViewItem::ZoomInOutItem(bool zoomOut, int duration, int delay, Tizen::Base::String* pName)
2517 _VisualElement* pVisualElement = GetVisualElement();
2519 String animationName = L"ZoomInOutTableViewItem";
2521 VisualElementValueAnimation* pAnimation = dynamic_cast<VisualElementValueAnimation*>(pVisualElement->GetAnimationN(animationName));
2523 if (pAnimation != null)
2525 pVisualElement->RemoveAnimation(animationName);
2528 pAnimation = new (std::nothrow) VisualElementValueAnimation();
2529 SysTryReturn(NID_UI_CTRL, pAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2531 Dimension itemSize = GetSize();
2532 Dimension startValue;
2537 startValue = itemSize;
2538 endValue = Dimension(itemSize.width, itemSize.height / 2);
2539 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut"));
2543 startValue = Dimension(itemSize.width, itemSize.height / 2);
2544 endValue = itemSize;
2545 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn"));
2548 pAnimation->SetDuration(duration);
2549 pAnimation->SetDelay(delay);
2550 pAnimation->SetStartValue(Variant(startValue));
2551 pAnimation->SetEndValue(Variant(endValue));
2552 pAnimation->SetVisualElementAnimationStatusEventListener(this);
2553 pAnimation->SetVisualElementAnimationTickEventListener(this);
2557 String* pUserData = new (std::nothrow) String(*pName);
2558 SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2560 if (pUserData != null)
2562 pAnimation->SetUserData((void*)pUserData);
2566 if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
2584 _TableViewItem::FadeInOutItem(bool fadeOut, int duration, int delay, Tizen::Base::String* pName)
2586 _VisualElement* pVisualElement = GetVisualElement();
2588 String animationName = L"FadeInOutTableViewItem";;
2590 VisualElementValueAnimation* pAnimation = dynamic_cast<VisualElementValueAnimation*>(pVisualElement->GetAnimationN(animationName));
2592 if (pAnimation != null)
2594 pVisualElement->RemoveAnimation(animationName);
2597 pAnimation = new (std::nothrow) VisualElementValueAnimation();
2598 SysTryReturn(NID_UI_CTRL, pAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2600 float startValue = 0.0f;
2601 float endValue = 1.0f;
2607 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut"));
2611 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn"));
2614 pAnimation->SetDuration(duration);
2615 pAnimation->SetDelay(delay);
2616 pAnimation->SetStartValue(Variant(startValue));
2617 pAnimation->SetEndValue(Variant(endValue));
2618 pAnimation->SetVisualElementAnimationStatusEventListener(this);
2619 pAnimation->SetVisualElementAnimationTickEventListener(this);
2622 String* pUserData = new (std::nothrow) String(*pName);
2623 SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
2625 if (pUserData != null)
2627 pAnimation->SetUserData((void*)pUserData);
2631 if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS)
2649 _TableViewItem::SetIndividualSelectionEnabled(const _Control& control, bool enable)
2651 result r = E_SUCCESS;
2654 if (!__individualSelectionControls.Contains(control))
2656 r = __individualSelectionControls.Add(control);
2659 _AccessibilityContainer* pContainer = const_cast<_Control*>(&control)->GetAccessibilityContainer();
2660 pContainer->Activate(true);
2664 if (__individualSelectionControls.Contains(control))
2666 r = __individualSelectionControls.Remove(control, false);
2673 _TableViewItem::IsIndividualSelectionEnabled(const _Control& control)
2675 return __individualSelectionControls.Contains(control);
2679 _TableViewItem::AddRef(void)
2681 return ++__refCount;
2685 _TableViewItem::Release(void)
2688 if (__refCount <= 0)
2698 _TableViewItem::IsAnimationPlaying(void)
2700 if (__animationCount > 0)
2709 _TableViewItem::StopAllAnimation(void)
2711 _VisualElement* pVisualElement = GetVisualElement();
2713 pVisualElement->RemoveAllAnimations();
2717 _TableViewItem::SetItemDividerEnabled(bool enable)
2719 __itemDividerEnabled = enable;
2723 _TableViewItem::OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue)
2725 if (keyName == L"MoveTableViewItem")
2727 Point position = currentValue.ToPoint();
2728 SetPosition(position);
2730 else if (keyName == L"FadeInOutTableViewItem")
2732 float opacity = currentValue.ToFloat();
2734 _VisualElement* pVisualElement = GetVisualElement();
2736 if (pVisualElement != null)
2738 pVisualElement->SetOpacity(opacity);
2741 else if (keyName == L"ZoomInOutTableViewItem")
2743 Dimension size = currentValue.ToDimension();
2750 _TableViewItem::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
2755 _TableViewItem::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
2760 _TableViewItem::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
2762 if (!completedNormally)
2768 bool tableViewItemAnimation = true;
2769 const VisualElementValueAnimation *pAnimation = dynamic_cast<const VisualElementValueAnimation*>(&(animation));
2771 if (keyName == L"MoveTableViewItem")
2773 if (pAnimation != null)
2775 Point position = pAnimation->GetEndValue().ToPoint();
2777 SetPosition(position);
2780 else if (keyName == L"FadeInOutTableViewItem")
2782 if (pAnimation != null)
2784 float opacity = pAnimation->GetEndValue().ToFloat();
2786 _VisualElement* pVisualElement = GetVisualElement();
2788 if (pVisualElement != null)
2790 pVisualElement->SetOpacity(opacity);
2795 else if (keyName == L"ZoomInOutTableViewItem")
2797 if (pAnimation != null)
2799 Dimension size = pAnimation->GetEndValue().ToDimension();
2806 tableViewItemAnimation = false;
2809 if (tableViewItemAnimation)
2818 _TableViewItem::SetAccessibilityElement(void)
2820 if(__pAccessibilityElement)
2825 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
2829 __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
2830 SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
2832 __pAccessibilityElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height));
2833 __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
2834 __pAccessibilityElement->SetName(L"TableViewItem");
2836 pContainer->AddElement(*__pAccessibilityElement);
2841 _TableViewItem::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2847 _TableViewItem::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2853 _TableViewItem::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2855 String accessibilityLable;
2856 int childControlCount = GetChildCount();
2858 for (int i = 0; i < childControlCount; i++)
2860 _Control* pChildControl = GetChild(i);
2862 if (pChildControl == null)
2867 if (__pItemDivider == pChildControl || __pItemTopDivider == pChildControl)
2872 if (!IsIndividualSelectionEnabled(*pChildControl))
2874 _AccessibilityContainer* pContainer = pChildControl->GetAccessibilityContainer();
2875 LinkedListT<_AccessibilityElement*> accessibilityElements;
2876 _AccessibilityElement* pElement = null;
2878 pContainer->GetElements(accessibilityElements);
2879 pContainer->Activate(false);
2880 int elementCount = accessibilityElements.GetCount();
2882 for (int i = 0; i < elementCount; i++)
2884 if (accessibilityElements.GetAt(i, pElement) == E_SUCCESS)
2886 accessibilityLable += pElement->GetLabel();
2892 __pAccessibilityElement->SetLabel(accessibilityLable);
2898 _TableViewItem::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2904 _TableViewItem::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2910 _TableViewItem::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2915 _TableViewItem::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2920 _TableViewItem::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
2924 }}} // Tizen::Ui::Controls