2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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_TableView.cpp
20 * @brief This file implements the _TableView class.
23 #include <FGrp_BitmapImpl.h>
24 #include "FUi_ControlManager.h"
25 #include "FUi_ResourceManager.h"
26 #include "FUiAnim_VisualElement.h"
27 #include "FUiCtrl_ListViewModel.h"
28 #include "FUiCtrl_FastScroll.h"
29 #include "FUiCtrl_Scroll.h"
30 #include "FUiCtrl_TableView.h"
31 #include "FUiCtrl_TableViewPresenter.h"
32 #include "FUiCtrl_TableViewItem.h"
33 #include "FUiCtrl_TableViewItemProvider.h"
34 #include "FUiCtrl_TableViewItemProviderAdaptor.h"
35 #include "FUiCtrl_UiTableViewItemEvent.h"
36 #include "FUi_CoordinateSystemUtils.h"
39 using namespace Tizen::Base;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Animations;
42 using namespace Tizen::Graphics;
44 namespace Tizen { namespace Ui { namespace Controls
47 IMPLEMENT_PROPERTY(_TableView);
49 _TableView::_TableView(void)
50 : __pTableViewPresenter(null)
52 , __pTableViewItemEvent(null)
53 , __itemDividerEnabled(false)
54 , __sweepEnabled(false)
55 , __reorderEnabled(false)
56 , __sectionStyle(false)
57 , __groupedLookEnable(false)
58 , __tableViewStyle(TABLE_VIEW_STYLE_SIMPLE)
59 , __scrollStyle(TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT)
60 , __pBitmapOfEmptyTableView(null)
61 , __pBackgroundBitmap(null)
62 , __textOfEmptyTableView(L"Empty TableView")
63 , __pExpandGroupAnimation(null)
64 , __pCollapseGroupAnimation(null)
65 , __pSweptAnimation(null)
66 , __pRemoveItemtAnimation(null)
70 GET_COLOR_CONFIG(TABLEVIEW::BG_NORMAL, bgColor);
71 GET_COLOR_CONFIG(TABLEVIEW::SECTIONITEM_BG_NORMAL, __sectionStyleColor);
72 GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_BOTTOM_BG_NORMAL, __itemDividerColor);
74 SetBackgroundColor(bgColor);
77 _TableView::~_TableView(void)
79 __pTableViewPresenter->BlockAnimationCallback(true);
81 if (GetVisualElement() != null)
83 __pExpandGroupAnimation->SetVisualElementAnimationTickEventListener(null);
84 __pExpandGroupAnimation->SetVisualElementAnimationStatusEventListener(null);
86 __pCollapseGroupAnimation->SetVisualElementAnimationTickEventListener(null);
87 __pCollapseGroupAnimation->SetVisualElementAnimationStatusEventListener(null);
89 __pSweptAnimation->SetVisualElementAnimationTickEventListener(null);
90 __pSweptAnimation->SetVisualElementAnimationStatusEventListener(null);
92 __pRemoveItemtAnimation->SetVisualElementAnimationTickEventListener(null);
93 __pRemoveItemtAnimation->SetVisualElementAnimationStatusEventListener(null);
95 GetVisualElement()->RemoveAllAnimations();
98 //SuperClass will delete.
99 __pTableViewPresenter = null;
101 if (__pFastScroll != null)
103 DetachSystemChild(*__pFastScroll);
105 delete __pFastScroll;
106 __pFastScroll = null;
109 delete __pTableViewItemEvent;
110 __pTableViewItemEvent = null;
112 delete __pExpandGroupAnimation;
113 __pExpandGroupAnimation = null;
115 delete __pCollapseGroupAnimation;
116 __pCollapseGroupAnimation = null;
118 delete __pSweptAnimation;
119 __pSweptAnimation = null;
121 delete __pRemoveItemtAnimation;
122 __pRemoveItemtAnimation = null;
126 _TableView::CreateTableViewN(TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle)
129 result r = E_SUCCESS;
131 _TableView* pTableView = null;
133 _ControlManager* pControlManager = _ControlManager::GetInstance();
134 SysTryReturn(NID_UI_CTRL, pControlManager, null, E_SYSTEM, "[E_SYSTEM] System error occurred.");
136 pTableView = new (std::nothrow) _TableView;
137 SysTryCatch(NID_UI_CTRL, pTableView != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
140 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating", GetErrorMessage(r));
142 pTableView->AcquireHandle();
144 r = pTableView->Initialize(style, itemDivider, scrollStyle);
145 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to Initialize", GetErrorMessage(r));
155 _TableView::Initialize(TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle)
157 result r = E_SUCCESS;
159 _TableViewPresenter* pPresenter = new (std::nothrow) _TableViewPresenter();
160 SysTryReturn(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
162 r = pPresenter->Construct(this);
163 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
165 r = _ScrollPanel::Initialize(*pPresenter, false);
166 SetTableViewPresenter(pPresenter);
167 SetScrollAreaAutoResizingEnabled(false);
169 FloatRectangle rect = GetBoundsF();
170 SetScrollAreaBounds(rect);
172 SetTableViewStyle(style);
173 SetScrollStyle(scrollStyle);
174 SetItemDividerEnabled(itemDivider);
176 __pExpandGroupAnimation = new (std::nothrow) VisualElementValueAnimation;
177 SysTryReturn(NID_UI_CTRL, __pExpandGroupAnimation != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
179 __pExpandGroupAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut"));
181 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
183 __pExpandGroupAnimation->SetVisualElementAnimationTickEventListener(__pTableViewPresenter);
185 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
187 __pExpandGroupAnimation->SetVisualElementAnimationStatusEventListener(__pTableViewPresenter);
189 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
191 __pCollapseGroupAnimation = new (std::nothrow) VisualElementValueAnimation;
192 SysTryReturn(NID_UI_CTRL, __pCollapseGroupAnimation != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
194 __pCollapseGroupAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut"));
196 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
198 __pCollapseGroupAnimation->SetVisualElementAnimationTickEventListener(__pTableViewPresenter);
200 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
202 __pCollapseGroupAnimation->SetVisualElementAnimationStatusEventListener(__pTableViewPresenter);
204 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
206 __pSweptAnimation = new (std::nothrow) VisualElementValueAnimation;
207 SysTryReturn(NID_UI_CTRL, __pSweptAnimation != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
209 __pSweptAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut"));
211 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
213 __pSweptAnimation->SetVisualElementAnimationTickEventListener(__pTableViewPresenter);
215 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
217 __pSweptAnimation->SetVisualElementAnimationStatusEventListener(__pTableViewPresenter);
219 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
221 __pRemoveItemtAnimation = new (std::nothrow) VisualElementValueAnimation;
222 SysTryReturn(NID_UI_CTRL, __pRemoveItemtAnimation != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
224 __pRemoveItemtAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseIn"));
226 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
228 __pRemoveItemtAnimation->SetVisualElementAnimationTickEventListener(this);
230 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
232 __pRemoveItemtAnimation->SetVisualElementAnimationStatusEventListener(this);
234 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
239 delete __pExpandGroupAnimation;
240 __pExpandGroupAnimation = null;
242 delete __pCollapseGroupAnimation;
243 __pCollapseGroupAnimation = null;
245 delete __pSweptAnimation;
246 __pSweptAnimation = null;
248 delete __pRemoveItemtAnimation;
249 __pRemoveItemtAnimation = null;
255 _TableView::GetTableViewPresenter(void) const
257 return __pTableViewPresenter;
261 _TableView::SetTableViewPresenter(const _TableViewPresenter* pPresenter)
263 __pTableViewPresenter = const_cast<_TableViewPresenter*>(pPresenter);
267 _TableView::SetItemProvider(const _TableViewItemProvider* pProvider)
269 return __pTableViewPresenter->SetItemProvider(pProvider);
273 _TableView::SetItemProviderAdaptor(_TableViewItemProviderAdaptor* pProviderAdaptor)
275 __pTableViewPresenter->SetTableViewItemProviderAdaptor(pProviderAdaptor);
278 _TableViewItemProviderAdaptor*
279 _TableView::GetItemProviderAdaptor(void) const
281 return __pTableViewPresenter->GetTableViewItemProviderAdaptor();
285 _TableView::SetSweepEnabled(bool enable)
287 __sweepEnabled = enable;
291 _TableView::IsSweepEnabled(void) const
293 return __sweepEnabled;
297 _TableView::IsReorderModeEnabled(void) const
299 return __reorderEnabled;
303 _TableView::SetReorderModeEnabled(bool enable)
305 if (__reorderEnabled != enable)
307 __reorderEnabled = enable;
309 __pTableViewPresenter->SetReorderMode(enable);
316 _TableView::SetItemChecked(int groupIndex, int itemIndex, bool check)
318 if (IsOnProcessing())
320 return E_INVALID_OPERATION;
322 return __pTableViewPresenter->SetItemChecked(groupIndex, itemIndex, check);
326 _TableView::IsItemChecked(int groupIndex, int itemIndex) const
328 return __pTableViewPresenter->IsItemChecked(groupIndex, itemIndex);
332 _TableView::SetItemEnabled(int groupIndex, int itemIndex, bool enable)
334 if (IsOnProcessing())
336 return E_INVALID_OPERATION;
338 return __pTableViewPresenter->SetItemEnabled(groupIndex, itemIndex, enable);
342 _TableView::CheckItemHeightAndRefreshLayout(int groupIndex, int itemIndex)
344 TableViewItemTag itemTag = {groupIndex, itemIndex};
345 __pTableViewPresenter->CheckItemHeightAndRefreshLayout(itemTag, true);
349 _TableView::FindItem(int groupIndex, int itemIndex) const
351 TableViewItemTag itemTag = {groupIndex, itemIndex};
353 return __pTableViewPresenter->FindItem(itemTag);
357 _TableView::UnloadItem(int groupIndex, int itemIndex)
359 if (IsOnProcessing())
363 return __pTableViewPresenter->UnloadItem(groupIndex, itemIndex);
367 _TableView::LoadItem(int groupIndex, int itemIndex)
369 if (IsOnProcessing())
373 return __pTableViewPresenter->LoadItem(groupIndex, itemIndex);
377 _TableView::RefreshItemLayout(int groupIndex, int itemIndex)
379 __pTableViewPresenter->RefreshItemLayout(groupIndex, itemIndex);
383 _TableView::GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const
385 __pTableViewPresenter->GetFirstLoadedItemIndex(groupIndex, itemIndex);
389 _TableView::GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const
391 __pTableViewPresenter->GetLastLoadedItemIndex(groupIndex, itemIndex);
395 _TableView::ResetSweepItem(void)
397 __pTableViewPresenter->ResetSweepItem();
401 _TableView::GetSweepItemIndex(int& groupIndex, int& itemIndex) const
403 __pTableViewPresenter->GetSweepItemIndex(groupIndex, itemIndex);
407 _TableView::GetPressedItemCount(void)
409 return __pTableViewPresenter->GetPressedItemCount();
413 _TableView::GetTopMargin(void) const
415 return __pTableViewPresenter->GetTopMargin();
419 _TableView::SetTopMargin(float topMargin)
421 return __pTableViewPresenter->SetTopMargin(topMargin);
425 _TableView::GetBottomMargin(void) const
427 return __pTableViewPresenter->GetBottomMargin();
431 _TableView::SetBottomMargin(float bottomMargin)
433 return __pTableViewPresenter->SetBottomMargin(bottomMargin);
437 _TableView::IsItemEnabled(int groupIndex, int itemIndex) const
439 return __pTableViewPresenter->IsItemEnabled(groupIndex, itemIndex);
443 _TableView::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
448 return __pTableViewPresenter->GetTopDrawnItemIndex(groupIndex, itemIndex);
452 _TableView::SetTopDrawnItemIndex(int groupIndex, int itemIndex)
454 if (IsOnProcessing())
456 return E_INVALID_OPERATION;
458 return __pTableViewPresenter->SetTopDrawnItemIndex(groupIndex, itemIndex);
462 _TableView::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
467 return __pTableViewPresenter->GetBottomDrawnItemIndex(groupIndex, itemIndex);
471 _TableView::SetBottomDrawnItemIndex(int groupIndex, int itemIndex)
473 if (IsOnProcessing())
475 return E_INVALID_OPERATION;
477 return __pTableViewPresenter->SetBottomDrawnItemIndex(groupIndex, itemIndex);
481 _TableView::ScrollByPixel(float scrollDistance)
483 return __pTableViewPresenter->ScrollByPixel(scrollDistance);
487 _TableView::SetScrollEnabled(bool enable)
489 __pTableViewPresenter->SetScrollEnabled(enable);
493 _TableView::IsScrollEnabled(void) const
495 return __pTableViewPresenter->IsScrollEnabled();
499 _TableView::AddTableViewItemEventListener(const _ITableViewItemEventListener& listener)
501 result r = E_SUCCESS;
503 if (__pTableViewItemEvent == null)
505 __pTableViewItemEvent = new (std::nothrow) _UiTableViewItemEvent();
506 SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
508 r = __pTableViewItemEvent->Construct(this, TABLE_VIEW_STYLE_SIMPLE);
509 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event.");
512 r = __pTableViewItemEvent->AddListener(listener);
513 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
519 _TableView::RemoveTableViewItemEventListener(const _ITableViewItemEventListener& listener)
521 SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed.");
523 return __pTableViewItemEvent->RemoveListener(listener);
527 _TableView::AddGroupedTableViewItemEventListener(const _ITableViewItemEventListener& listener)
529 result r = E_SUCCESS;
531 if (__pTableViewItemEvent == null)
533 __pTableViewItemEvent = new (std::nothrow) _UiTableViewItemEvent();
534 SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
536 r = __pTableViewItemEvent->Construct(this, TABLE_VIEW_STYLE_GROUPED);
537 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event.");
540 r = __pTableViewItemEvent->AddListener(listener);
541 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
547 _TableView::RemoveGroupedTableViewItemEventListener(const _ITableViewItemEventListener& listener)
549 SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed.");
551 return __pTableViewItemEvent->RemoveListener(listener);
555 _TableView::AddSectionTableViewItemEventListener(const _ITableViewItemEventListener& listener)
557 result r = E_SUCCESS;
559 if (__pTableViewItemEvent == null)
561 __pTableViewItemEvent = new (std::nothrow) _UiTableViewItemEvent();
562 SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
564 r = __pTableViewItemEvent->Construct(this, TABLE_VIEW_STYLE_SECTION);
565 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event.");
568 r = __pTableViewItemEvent->AddListener(listener);
569 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
575 _TableView::RemoveSectionTableViewItemEventListener(const _ITableViewItemEventListener& listener)
577 SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed.");
579 return __pTableViewItemEvent->RemoveListener(listener);
583 _TableView::AddFastScrollListener(const _IUiFastScrollListener& listener)
585 SysTryReturn(NID_UI_CTRL, __pFastScroll != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed.");
586 __pFastScroll->AddFastScrollEventListener(listener);
592 _TableView::RemoveFastScrollListener(const _IUiFastScrollListener& listener)
594 SysTryReturn(NID_UI_CTRL, __pFastScroll != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed.");
595 __pFastScroll->RemoveFastScrollEventListener(listener);
601 _TableView::GetFastScrollBar(void) const
603 return __pFastScroll;
607 _TableView::SetFastScrollIndex(const String& text, bool useSearchIcon)
609 SysTryReturn(NID_UI_CTRL,
610 (__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL || __scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL_FIXED),
611 E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView scroll is not TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL");
612 SysTryReturn(NID_UI_CTRL, __pFastScroll != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed.");
613 SysTryReturn(NID_UI_CTRL, (useSearchIcon || (!useSearchIcon && text.GetLength() > 0)), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input argument.");
615 result r = E_SUCCESS;
617 const wchar_t* pIndexTextArray = text.GetPointer();
619 int indexCount = text.GetLength();
622 // Set the primary index.
623 _FastScrollIndex* pRootIndex = __pFastScroll->GetIndex();
624 if (pRootIndex == null)
626 pRootIndex = _FastScrollIndex::CreateFastScrollIndexN();
628 SysTryReturn(NID_UI_CTRL, pRootIndex != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
630 r = __pFastScroll->SetIndex(pRootIndex);
631 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
635 pRootIndex->RemoveChildren(true);
638 if (useSearchIcon == true)
640 Bitmap* pSearchIcon = null;
641 String fastScrollSearchIconIndex(L"[SEARCH_ICON_INDEX]");
643 r = GET_BITMAP_CONFIG_N(TABLEVIEW::SEARCH_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSearchIcon);
644 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] SearchIcon image load failed");
646 _FastScrollIndex* pIndex = pRootIndex->AddChildIndex(&fastScrollSearchIconIndex, pSearchIcon);
647 SysTryReturn(NID_UI_CTRL, pIndex, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to add text array to the primary index.");
652 r = pRootIndex->AddChildTextIndexArray(childOrder, pIndexTextArray, indexLenth, indexCount);
653 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
655 r = __pFastScroll->UpdateIndex();
656 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
661 _TableView::SetScrollStyle(TableViewScrollBarStyle scrollStyle)
663 __scrollStyle = scrollStyle;
669 _TableView::GetTableViewStyle(void) const
671 return __tableViewStyle;
675 _TableView::SetTableViewStyle(TableViewStyle style)
677 if(__tableViewStyle == style)
682 __tableViewStyle = style;
684 if (__tableViewStyle == TABLE_VIEW_STYLE_SECTION)
687 GET_FIXED_VALUE_CONFIG(TABLEVIEW::SECTIONITEM_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, topMargin);
688 SetTopMargin(topMargin);
691 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, x);
692 __pTableViewPresenter->SetLeftMargin(x);
694 __groupedLookEnable = true;
698 TableViewScrollBarStyle
699 _TableView::GetScrollStyle(void) const
701 return __scrollStyle;
705 _TableView::GetGroupCount(void) const
707 return __pTableViewPresenter->GetGroupCount();
711 _TableView::GetItemCountAt(int groupIndex) const
713 SysTryReturn(NID_UI_CTRL, groupIndex >= 0 && groupIndex < GetGroupCount(), -1, E_INVALID_ARG, "[E_INVALID_ARG] Invalid group index.");
715 int itemCount = __pTableViewPresenter->GetItemCountAt(groupIndex);
717 if (GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION)
719 // sub section footer
720 if (__pTableViewPresenter->HasSectionFooter(groupIndex) == true)
734 _TableView::RefreshTableView(int groupIndex, int itemIndex, TableViewRefreshType type, bool animation)
736 if (IsOnProcessing())
738 return E_INVALID_OPERATION;
741 return __pTableViewPresenter->RefreshTableView(groupIndex, itemIndex, type, animation);
745 _TableView::RefreshAllItems(void)
747 if (IsOnProcessing())
749 return E_INVALID_OPERATION;
752 return __pTableViewPresenter->RefreshAllItems();
757 _TableView::UpdateTableView(void)
759 if (IsOnProcessing())
761 return E_INVALID_OPERATION;
763 return __pTableViewPresenter->UpdateTableView();
767 _TableView::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const
769 return __pTableViewPresenter->GetItemIndexFromPosition(_CoordinateSystemUtils::ConvertToFloat(position), groupIndex, itemIndex);
773 _TableView::GetItemIndexFromPosition(const Tizen::Graphics::FloatPoint& position, int& groupIndex, int& itemIndex) const
775 return __pTableViewPresenter->GetItemIndexFromPosition(position, groupIndex, itemIndex);
780 _TableView::SetPropertySectionColor(const Variant& sectionColor)
782 __sectionStyleColor = sectionColor.ToColor();
788 _TableView::SetSectionColor(const Color& color)
790 if (GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION)
792 SysLog(NID_UI_CTRL, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION.");
793 return E_INVALID_OPERATION;
796 if (__sectionStyleColor == color)
801 result r = SetProperty("sectionColor", Variant(color));
802 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
804 return __pTableViewPresenter->SetStatusChanged(true);
808 _TableView::GetPropertySectionColor(void) const
810 return Variant(__sectionStyleColor);
814 _TableView::GetSectionColor(void) const
816 if (GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION)
818 SetLastResult(E_SUCCESS);
822 Variant sectionColor = GetProperty("sectionColor");
824 return sectionColor.ToColor();
828 _TableView::GetPropertyItemDividerColor(void) const
830 return Variant(__itemDividerColor);
834 _TableView::GetItemDividerColor(void) const
836 Variant itemDividerColor = GetProperty("itemDividerColor");
838 return itemDividerColor.ToColor();
842 _TableView::SetPropertyItemDividerColor(const Variant& itemDividerColor)
844 if(__itemDividerColor == itemDividerColor.ToColor())
849 __itemDividerColor = itemDividerColor.ToColor();
851 return __pTableViewPresenter->SetStatusChanged(true);
855 _TableView::SetItemDividerColor(const Color& color)
857 return SetProperty("itemDividerColor", Variant(color));
861 _TableView::IsItemDividerEnabled(void) const
863 return __itemDividerEnabled;
867 _TableView::SetItemDividerEnabled(bool enable)
869 __itemDividerEnabled = enable;
873 _TableView::GetBitmapOfEmptyTableView(void) const
875 return __pBitmapOfEmptyTableView;
879 _TableView::SetBitmapOfEmptyTableView(const Bitmap* pBitmap)
881 Bitmap* pCloneBitmap = null;
885 delete __pBitmapOfEmptyTableView;
886 __pBitmapOfEmptyTableView = null;
892 pCloneBitmap = _BitmapImpl::CloneN(*pBitmap);
893 SysTryReturn(NID_UI_CTRL, pCloneBitmap != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
895 delete __pBitmapOfEmptyTableView;
896 __pBitmapOfEmptyTableView = pCloneBitmap;
899 return __pTableViewPresenter->SetStatusChanged(true);
903 _TableView::GetPropertyTextColorOfEmptyTableView(void) const
905 return Variant(__textColorOfEmptyTableView);
909 _TableView::GetTextColorOfEmptyTableView(void) const
911 Variant textColorOfEmptyTableView = GetProperty("textColorOfEmptyTableView");
913 return textColorOfEmptyTableView.ToColor();
917 _TableView::SetPropertyTextColorOfEmptyTableView(const Variant& textColorOfEmptyTableView)
919 __textColorOfEmptyTableView = textColorOfEmptyTableView.ToColor();
925 _TableView::SetTextColorOfEmptyTableView(const Color& color)
927 if (__textColorOfEmptyTableView == color)
932 result r = SetProperty("textColorOfEmptyTableView", Variant(color));
934 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
936 return __pTableViewPresenter->SetStatusChanged(true);
940 _TableView::GetPropertyTextOfEmptyTableView(void) const
942 return Variant(__textOfEmptyTableView);
946 _TableView::GetTextOfEmptyTableView(void) const
948 Variant textOfEmptyTableView = GetProperty("textOfEmptyTableView");
950 return textOfEmptyTableView.ToString();
954 _TableView::SetPropertyTextOfEmptyTableView(const Variant& textOfEmptyTableView)
956 __textOfEmptyTableView = textOfEmptyTableView.ToString();
962 _TableView::SetTextOfEmptyTableView(const String& text)
964 if (__textOfEmptyTableView == text)
969 result r = SetProperty("textOfEmptyTableView", Variant(text));
971 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
973 return __pTableViewPresenter->SetStatusChanged(true);
977 _TableView::FireTableViewItemEvent(int groupIndex, int itemIndex, TableViewNotifyType type, _TableViewItem* pItem)
979 if (type == TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK)
981 __pTableViewPresenter->GetModel()->SetItemChecked(groupIndex, itemIndex, true);
983 else if (type == TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK)
985 __pTableViewPresenter->GetModel()->SetItemChecked(groupIndex, itemIndex, false);
988 if (__pTableViewItemEvent != null)
990 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, 0, 0, pItem, type);
991 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
992 __pTableViewItemEvent->Fire(*pArg);
997 _TableView::FireTableViewItemSweepEvent(int groupIndex, int itemIndex, TableViewSweepDirection directioin)
999 if (__pTableViewItemEvent != null)
1001 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, directioin, 0, null, TABLEVIEW_NOTIFY_TYPE_ITEM_SWEPT);
1002 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1003 __pTableViewItemEvent->Fire(*pArg);
1008 _TableView::FireTableViewItemReorderEvent(int fromItemIndex, int toItemIndex)
1010 if (__pTableViewItemEvent != null)
1012 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(fromItemIndex, toItemIndex, 0, 0, null, TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM);
1013 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1014 __pTableViewItemEvent->Fire(*pArg);
1018 _TableView::FireTableViewItemReorderEvent(int fromGroupIndex, int fromItemIndex, int toGroupIndex, int toItemIndex)
1020 if (__pTableViewItemEvent != null)
1022 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(fromGroupIndex, fromItemIndex, toGroupIndex, toItemIndex, null, TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM);
1023 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1024 __pTableViewItemEvent->Fire(*pArg);
1029 _TableView::FireTableViewContextItemActivationEvent(int groupIndex, int itemIndex, _TableViewItem* pItem, bool activated)
1031 if (__pTableViewItemEvent != null)
1033 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, 0, 0, pItem, TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION, activated);
1034 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1035 __pTableViewItemEvent->Fire(*pArg);
1040 _TableView::ExpandGroup(int groupIndex)
1042 if (IsOnProcessing())
1044 return E_INVALID_OPERATION;
1046 return __pTableViewPresenter->ExpandGroup(groupIndex, true);
1050 _TableView::CollapseGroup(int groupIndex)
1052 if (IsOnProcessing())
1054 return E_INVALID_OPERATION;
1056 return __pTableViewPresenter->CollapseGroup(groupIndex, true);
1060 _TableView::IsGroupExpanded(int groupIndex) const
1062 return __pTableViewPresenter->IsGroupExpanded(groupIndex);
1066 _TableView::ExpandAllGroup(bool animation)
1068 if (IsOnProcessing())
1070 return E_INVALID_OPERATION;
1073 int groupCount = GetGroupCount();
1075 for (int i = 0; i < groupCount; i++)
1077 __pTableViewPresenter->ExpandGroup(i, false);
1084 _TableView::CollapseAllGroup(bool animation)
1086 if (IsOnProcessing())
1088 return E_INVALID_OPERATION;
1091 int groupCount = GetGroupCount();
1093 for (int i = 0; i < groupCount; i++)
1095 __pTableViewPresenter->CollapseGroup(i, false);
1102 _TableView::StopExpandCollapseAnimation(void)
1104 __pTableViewPresenter->StopExpandCollapseAnimation();
1108 _TableView::SetGroupedLookEnabled(bool enable)
1110 __groupedLookEnable = enable;
1112 if (__tableViewStyle == TABLE_VIEW_STYLE_SECTION && !__groupedLookEnable)
1114 __pTableViewPresenter->SetLeftMargin(0);
1119 _TableView::IsGroupedLookEnabled(void) const
1121 return __groupedLookEnable;
1125 _TableView::GetFirstDrawnFlag(void) const
1127 return __pTableViewPresenter->GetFirstDrawnFlag();
1131 _TableView::GetMaxItemCachingSize(void) const
1133 return __pTableViewPresenter->GetMaxItemCachingSize();
1137 _TableView::OpenContextItem(int groupIndex, int itemIndex)
1139 return __pTableViewPresenter->OpenContextItem(groupIndex, itemIndex);
1142 _TableView::CloseContextItem(int groupIndex, int itemIndex)
1144 return __pTableViewPresenter->CloseContextItem(groupIndex, itemIndex);
1147 _TableView::IsContextItemOpened(int groupIndex, int itemIndex) const
1149 return __pTableViewPresenter->IsContextItemOpened(groupIndex, itemIndex);
1153 _TableView::SetSectionHeaderTextHorizontalAlignment(int sectionIndex, HorizontalAlignment alignment)
1155 return __pTableViewPresenter->SetSectionHeaderTextHorizontalAlignment(sectionIndex, alignment);
1159 _TableView::GetSectionHeaderTextHorizontalAlignment(int sectionIndex) const
1161 return __pTableViewPresenter->GetSectionHeaderTextHorizontalAlignment(sectionIndex);
1165 _TableView::SetSectionFooterTextHorizontalAlignment(int sectionIndex, HorizontalAlignment alignment)
1167 return __pTableViewPresenter->SetSectionFooterTextHorizontalAlignment(sectionIndex, alignment);
1171 _TableView::GetSectionFooterTextHorizontalAlignment(int sectionIndex) const
1173 return __pTableViewPresenter->GetSectionFooterTextHorizontalAlignment(sectionIndex);
1177 _TableView::FireItemTouchReleasedEventDuringPressing(int groupIndex, int itemIndex)
1179 __pTableViewPresenter->FireItemTouchReleasedEventDuringPressing(groupIndex, itemIndex);
1183 _TableView::OnDraw(void)
1185 __pTableViewPresenter->Draw();
1189 _TableView::OnChildAttached(const _Control& child)
1191 _ScrollPanel::OnChildAttached(child);
1195 _TableView::OnChildDetached(const _Control& child)
1197 _ScrollPanel::OnChildDetached(child);
1201 _TableView::OnBoundsChanged(void)
1203 if (__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL || __scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL_FIXED || __scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_NONE)
1205 _Scroll* pScroll = _ScrollPanel::GetScrollBar();
1206 if (pScroll == null)
1208 FloatRectangle bounds = GetBoundsF();
1210 pScroll = _Scroll::CreateScrollN(*this,
1211 SCROLL_DIRECTION_VERTICAL,
1219 SysTryReturnVoidResult(NID_UI_CTRL, pScroll != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1221 pScroll->EnableScrollingEffect(false);
1222 pScroll->SetVisibleState(false);
1223 _ScrollPanel::SetScrollBar(pScroll);
1225 pScroll->AddScrollEventListener(*this);
1226 AttachSystemChild(*pScroll);
1229 if (__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL || __scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL_FIXED)
1231 if (__pFastScroll == null)
1233 if (__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL_FIXED)
1235 __pFastScroll = _FastScroll::CreateFastScrollN(*this, false);
1239 __pFastScroll = _FastScroll::CreateFastScrollN(*this);
1242 if (__pFastScroll != null)
1244 AttachSystemChild(*__pFastScroll);
1249 __pFastScroll->OnParentBoundsChanged();
1255 _Scroll* pScroll = _ScrollPanel::GetScrollBar();
1257 if (pScroll == null)
1259 FloatRectangle bounds = GetBoundsF();
1261 pScroll = _Scroll::CreateScrollN(*this,
1262 SCROLL_DIRECTION_VERTICAL,
1263 ((__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FIXED) ? false : true),
1264 ((__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP) ? true : false),
1265 ((__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_THUMB) ? true : false),
1266 ((__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FIXED) ? true : false),
1270 SysTryReturnVoidResult(NID_UI_CTRL, pScroll != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1272 pScroll->EnableScrollingEffect(true);
1273 _ScrollPanel::SetScrollBar(pScroll);
1275 pScroll->AddScrollEventListener(*this);
1276 AttachSystemChild(*pScroll);
1280 _ScrollPanel::OnBoundsChanged();
1283 _UiTouchEventDelivery
1284 _TableView::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1286 return __pTableViewPresenter->OnPreviewTouchPressed(source, touchinfo);
1289 _UiTouchEventDelivery
1290 _TableView::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1292 return __pTableViewPresenter->OnPreviewTouchMoved(source, touchinfo);
1295 _UiTouchEventDelivery
1296 _TableView::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1298 return __pTableViewPresenter->OnPreviewTouchReleased(source, touchinfo);
1301 _UiTouchEventDelivery
1302 _TableView::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1304 return __pTableViewPresenter->OnPreviewTouchCanceled(source, touchinfo);
1308 _TableView::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1310 return __pTableViewPresenter->OnTouchPressed(source, touchinfo);
1314 _TableView::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1316 return __pTableViewPresenter->OnTouchMoved(source, touchinfo);
1320 _TableView::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1322 return __pTableViewPresenter->OnTouchReleased(source, touchinfo);
1326 _TableView::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1328 return __pTableViewPresenter->OnTouchCanceled(source, touchinfo);
1332 _TableView::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1334 return __pTableViewPresenter->OnFlickGestureDetected(gesture);
1338 _TableView::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
1340 return __pTableViewPresenter->OnFlickGestureCanceled(gesture);
1344 _TableView::SetTableViewStatusChanged(bool changed)
1346 return __pTableViewPresenter->SetStatusChanged(changed);
1350 _TableView::IsOnProcessing(void)
1352 _TableViewItemProviderAdaptor* pProviderAdapter = __pTableViewPresenter->GetTableViewItemProviderAdaptor();
1353 if (pProviderAdapter != null)
1355 if (pProviderAdapter->IsOnProcessing())
1364 VisualElementValueAnimation*
1365 _TableView::GetVisualElementValueAnimation(const Tizen::Base::String& keyName) const
1369 VisualElementValueAnimation* pAnimation = null;
1371 if (keyName == L"EXPAND_GROUP_ANIMATION")
1373 pAnimation = __pExpandGroupAnimation;
1375 else if (keyName == L"COLLAPSE_GROUP_ANIMATION")
1377 pAnimation = __pCollapseGroupAnimation;
1379 else if (keyName == L"SWEEP_ITEM_ANIMATION")
1381 pAnimation = __pSweptAnimation;
1383 else if (keyName == L"REMOVE_ITEM_ANIMATION")
1385 pAnimation = __pRemoveItemtAnimation;
1392 _TableView::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1394 return __pTableViewPresenter->OnKeyPressed(source, keyInfo);
1398 _TableView::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1400 return __pTableViewPresenter->OnKeyReleased(source, keyInfo);
1404 _TableView::IsChildControlFocusManage(void) const
1410 _TableView::OnDrawFocus(void)
1412 return __pTableViewPresenter->OnDrawFocus();
1416 _TableView::OnFocusModeStateChanged(void)
1418 return __pTableViewPresenter->OnFocusModeStateChanged();
1420 }}} // Tizen::Ui::Controls