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_GroupedListViewImpl.cpp
20 * @brief This is the implementation file for
21 * _GroupedListViewImpl class.
23 * This file contains the implementation of _GroupedListViewImpl
27 #include <FUiCtrlGroupedListView.h>
28 #include <FBaseSysLog.h>
29 #include <FGrp_TextTextSimple.h>
30 #include "FApp_AppInfo.h"
31 #include "FUi_ResourceManager.h"
32 #include "FUi_TouchManager.h"
33 #include "FUi_UiBuilder.h"
34 #include "FUiCtrl_FastScrollEvent.h"
35 #include "FUiCtrl_FastScrollEventArg.h"
36 #include "FUiCtrl_Label.h"
37 #include "FUiCtrl_GroupedListViewImpl.h"
38 #include "FUiCtrl_GroupedListViewItemProviderAdaptor.h"
39 #include "FUiCtrl_ListItemEvent.h"
40 #include "FUiCtrl_ListItemEventArg.h"
41 #include "FUiCtrl_ListViewItem.h"
42 #include "FUiCtrl_PublicLinkEvent.h"
43 #include "FUiCtrl_ScrollEvent.h"
44 #include "FUiCtrl_ScrollEventArg.h"
46 #ifdef MEMORY_LEAK_CHECK
47 #include "mem_leak_check.h"
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Collection;
52 using namespace Tizen::Base::Runtime;
53 using namespace Tizen::Graphics;
54 using namespace Tizen::Graphics::_Text;
56 namespace Tizen { namespace Ui { namespace Controls
60 _GroupedListViewImpl::GetInstance(GroupedListView& groupedListView)
62 return static_cast <_GroupedListViewImpl*>(groupedListView._pControlImpl);
65 const _GroupedListViewImpl*
66 _GroupedListViewImpl::GetInstance(const GroupedListView& groupedListView)
68 return static_cast <const _GroupedListViewImpl*>(groupedListView._pControlImpl);
71 _GroupedListViewImpl::_GroupedListViewImpl(GroupedListView* pGroupedList, _TableView* pCore)
72 : _ControlImpl(pGroupedList, pCore)
73 , __pListItemEvent(null)
75 , __pScrollEvent(null)
76 , __pFastScrollEvent(null)
77 , __pEmptyBitmap(null)
79 , __redrawListView(true)
80 , __pItemNeedsLazyDeletion(null)
83 GET_COLOR_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_NORMAL, __emptyTextColor);
86 _GroupedListViewImpl::~_GroupedListViewImpl()
88 if (__pListItemEvent != null)
90 delete __pListItemEvent;
91 __pListItemEvent = null;
94 if (__pLinkEvent != null)
100 if (__pScrollEvent != null)
102 delete __pScrollEvent;
103 __pScrollEvent = null;
106 if (__pFastScrollEvent != null)
108 delete __pFastScrollEvent;
109 __pFastScrollEvent = null;
112 if (__pEmptyBitmap != null)
114 GetCore().DetachChild(*__pEmptyBitmap);
116 delete __pEmptyBitmap;
117 __pEmptyBitmap = null;
120 if (__pEmptyText != null)
122 GetCore().DetachChild(*__pEmptyText);
130 _GroupedListViewImpl::GetPublicClassName(void) const
132 return "Tizen::Ui::Controls::GroupedListView";
135 const GroupedListView&
136 _GroupedListViewImpl::GetPublic(void) const
138 return static_cast <const GroupedListView&>(_ControlImpl::GetPublic());
142 _GroupedListViewImpl::GetPublic(void)
144 return static_cast <GroupedListView&>(_ControlImpl::GetPublic());
148 _GroupedListViewImpl::GetCore(void) const
150 return static_cast <const _TableView&>(_ControlImpl::GetCore());
154 _GroupedListViewImpl::GetCore(void)
156 return static_cast <_TableView&>(_ControlImpl::GetCore());
159 _GroupedListViewImpl*
160 _GroupedListViewImpl::CreateGroupedListViewImplN(GroupedListView* pControl, GroupedListViewStyle style, bool itemDivider, ListScrollStyle scrollStyle)
162 result r = E_SUCCESS;
163 TableViewScrollBarStyle scrollBarStyle;
167 case SCROLL_STYLE_FADE_OUT:
168 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT;
170 case SCROLL_STYLE_FIXED:
171 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED;
173 case SCROLL_STYLE_FAST_SCROLL:
174 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL;
176 case SCROLL_STYLE_JUMP_TO_TOP:
177 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP;
179 case SCROLL_STYLE_THUMB:
180 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB;
183 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE;
187 TableViewStyle tableViewStyle = ((style == GROUPED_LIST_VIEW_STYLE_SECTION) ? TABLE_VIEW_STYLE_SECTION : TABLE_VIEW_STYLE_GROUPED);
189 _TableView* pCore = _TableView::CreateTableViewN(tableViewStyle, itemDivider, scrollBarStyle);
190 SysTryReturn(NID_UI_CTRL, (pCore != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
192 _GroupedListViewImpl* pImpl = new (std::nothrow) _GroupedListViewImpl(pControl, pCore);
194 r = CheckConstruction(pCore, pImpl);
195 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
201 _GroupedListViewImpl::SetItemProvider(IGroupedListViewItemProvider& provider)
203 result r = E_SUCCESS;
204 int itemWidth = GetCore().GetBounds().width;
206 if (GetCore().GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION)
209 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin);
211 itemWidth -= (margin * 2);
214 _GroupedListViewItemProviderAdaptor* pProviderAdaptor =
215 static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
217 if (pProviderAdaptor == null)
219 pProviderAdaptor = new (std::nothrow) _GroupedListViewItemProviderAdaptor(provider);
220 SysTryReturn(NID_UI_CTRL, (pProviderAdaptor != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
221 "[E_OUT_OF_MEMORY] The memory is insufficient.");
223 pProviderAdaptor->SetListViewItemEventListener(*this);
225 r = pProviderAdaptor->SetListWidth(itemWidth);
226 GetCore().SetItemProviderAdaptor(pProviderAdaptor);
230 pProviderAdaptor->SetItemProvider(provider);
231 r = pProviderAdaptor->SetListWidth(itemWidth);
236 __redrawListView = true;
238 SetLastResultReturn(r);
242 _GroupedListViewImpl::AddGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener)
244 result r = E_SUCCESS;
246 if (__pListItemEvent == null)
248 __pListItemEvent = new (std::nothrow) _ListItemEvent();
249 SysTryReturnVoidResult(NID_UI_CTRL, (__pListItemEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
251 r = __pListItemEvent->Construct(GetPublic(), CLASSNAME_GROUPEDLISTVIEW);
252 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event.");
255 __pListItemEvent->AddListener(listener);
257 r = GetCore().AddGroupedTableViewItemEventListener(*this);
263 _GroupedListViewImpl::RemoveGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener)
265 result r = E_SUCCESS;
267 if (__pListItemEvent != null)
269 r = __pListItemEvent->RemoveListener(listener);
276 _GroupedListViewImpl::AddFastScrollListener(IFastScrollListener& listener)
278 result r = E_SUCCESS;
280 if (__pFastScrollEvent == null)
282 __pFastScrollEvent = new (std::nothrow) _FastScrollEvent();
283 SysTryReturnVoidResult(NID_UI_CTRL, (__pFastScrollEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
285 r = __pFastScrollEvent->Construct(GetPublic());
286 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct FastScroll Event.");
289 __pFastScrollEvent->AddListener(listener);
291 r = GetCore().AddFastScrollListener(*this);
297 _GroupedListViewImpl::RemoveFastScrollListener(IFastScrollListener& listener)
299 result r = E_SUCCESS;
301 if (__pFastScrollEvent != null)
303 r = __pFastScrollEvent->RemoveListener(listener);
310 _GroupedListViewImpl::AddScrollEventListener(IScrollEventListener& listener)
312 result r = E_SUCCESS;
314 if (__pScrollEvent == null)
316 __pScrollEvent = new (std::nothrow) _ScrollEvent();
317 SysTryReturnVoidResult(NID_UI_CTRL, (__pScrollEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
319 r = __pScrollEvent->Construct(GetPublic());
320 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct Scroll Event.");
323 __pScrollEvent->AddListener(listener);
325 GetCore().AddScrollEventListener(*this);
331 _GroupedListViewImpl::RemoveScrollEventListener(IScrollEventListener& listener)
333 result r = E_SUCCESS;
335 if (__pScrollEvent != null)
337 r = __pScrollEvent->RemoveListener(listener);
344 _GroupedListViewImpl::AddUiLinkEventListener(const IUiLinkEventListener& listener)
346 result r = E_SUCCESS;
348 if (__pLinkEvent == null)
350 __pLinkEvent = _PublicLinkEvent::CreateInstanceN(GetPublic());
351 SysTryReturnVoidResult(NID_UI, (__pLinkEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
354 r = __pLinkEvent->AddListener(listener);
360 _GroupedListViewImpl::RemoveUiLinkEventListener(const IUiLinkEventListener& listener)
362 result r = E_SUCCESS;
364 if (__pLinkEvent != null)
366 r = __pLinkEvent->RemoveListener(listener);
373 _GroupedListViewImpl::SetSweepEnabled(bool enable)
375 GetCore().SetSweepEnabled(enable);
377 SetLastResultReturn(E_SUCCESS);
381 _GroupedListViewImpl::SetFastScrollIndex(const String& text, bool useSearchIcon)
383 result r = GetCore().SetFastScrollIndex(text, useSearchIcon);
384 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS) || (r == E_SYSTEM), E_INVALID_STATE, E_INVALID_STATE,
385 "[E_INVALID_STATE] This instance is in an invalid state.");
387 SetLastResultReturn(r);
391 _GroupedListViewImpl::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
393 return GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex);
397 _GroupedListViewImpl::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
399 return GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
403 _GroupedListViewImpl::ScrollToItem(int groupIndex, int itemIndex, ListScrollItemAlignment itemAlignment)
405 result r = E_SUCCESS;
407 if (itemAlignment == LIST_SCROLL_ITEM_ALIGNMENT_TOP)
409 r = GetCore().SetTopDrawnItemIndex(groupIndex, itemIndex);
411 else if (itemAlignment == LIST_SCROLL_ITEM_ALIGNMENT_BOTTOM)
413 r = GetCore().SetBottomDrawnItemIndex(groupIndex, itemIndex);
417 SysTryReturn(NID_UI_CTRL, false, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
418 "[E_OUT_OF_RANGE] The specified itemAlignment is out of range.");
421 SetLastResultReturn(r);
425 _GroupedListViewImpl::SetItemChecked(int groupIndex, int itemIndex, bool check)
427 return GetCore().SetItemChecked(groupIndex, itemIndex, check);
431 _GroupedListViewImpl::IsItemChecked(int groupIndex, int itemIndex) const
433 return GetCore().IsItemChecked(groupIndex, itemIndex);
437 _GroupedListViewImpl::SetItemEnabled(int groupIndex, int itemIndex, bool enable)
439 return GetCore().SetItemEnabled(groupIndex, itemIndex, enable);
443 _GroupedListViewImpl::IsItemEnabled(int groupIndex, int itemIndex) const
445 return GetCore().IsItemEnabled(groupIndex, itemIndex);
449 _GroupedListViewImpl::GetGroupCount(void) const
451 return GetCore().GetGroupCount();
455 _GroupedListViewImpl::GetItemCountAt(int groupIndex) const
457 return GetCore().GetItemCountAt(groupIndex);
461 _GroupedListViewImpl::ShowItemDescriptionText(int groupIndex, int itemIndex)
463 return SetItemDescriptionTextShowState(groupIndex, itemIndex, true);
467 _GroupedListViewImpl::HideItemDescriptionText(int groupIndex, int itemIndex)
469 return SetItemDescriptionTextShowState(groupIndex, itemIndex, false);
473 _GroupedListViewImpl::SetItemDescriptionTextShowState(int groupIndex, int itemIndex, bool show)
475 result r = E_SUCCESS;
477 SysTryReturn(NID_UI_CTRL, (groupIndex >= 0) && (groupIndex < GetGroupCount()), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
478 "[E_OUT_OF_RANGE] The specified groupIndex is out of range.");
480 SysTryReturn(NID_UI_CTRL, (itemIndex >= 0) && (itemIndex < GetItemCountAt(groupIndex)), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
481 "[E_OUT_OF_RANGE] The specified itemIndex is out of range.");
483 _GroupedListViewItemProviderAdaptor* pProviderAdaptor =
484 static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
485 SysTryReturn(NID_UI_CTRL, (pProviderAdaptor != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] _GroupedListItemProviderAdaptor is not set.");
487 // Save description text show state to provider adaptor
488 pProviderAdaptor->SetDescriptionTextShowState(groupIndex, itemIndex, show);
490 if (GetCore().FindItem(groupIndex, itemIndex) != null)
492 r = GetCore().RefreshTableView(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
495 SetLastResultReturn(r);
499 _GroupedListViewImpl::RefreshList(int groupIndex, int itemIndex, ListRefreshType type)
501 result r = E_SUCCESS;
503 int groupCount = GetCore().GetGroupCount();
504 int itemCount = GetCore().GetItemCountAt(groupIndex);
506 if ((groupIndex < 0) || (groupIndex > groupCount) ||
507 (itemIndex < -1) || (itemIndex > itemCount) ||
508 ((type != LIST_REFRESH_TYPE_ITEM_ADD) && (itemIndex == itemCount)))
510 SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range.");
511 return E_OUT_OF_RANGE;
514 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
516 // for lazy delete item
517 if ((__pItemNeedsLazyDeletion != null) && (type != LIST_REFRESH_TYPE_ITEM_ADD))
519 if (__pItemNeedsLazyDeletion == pListViewItem)
521 _GroupedListViewItemProviderAdaptor* pProviderAdaptor =
522 static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
524 if (pProviderAdaptor != null)
526 pProviderAdaptor->SetItemNeedsLazyDeletion(__pItemNeedsLazyDeletion);
531 if ((__pItemSwept != null) && (type != LIST_REFRESH_TYPE_ITEM_ADD))
533 if (__pItemSwept == pListViewItem)
535 GetCore().ResetSweepItem();
539 if (type == LIST_REFRESH_TYPE_ITEM_MODIFY)
541 int topGroupIndex = -1;
542 int topItemIndex = -1;
543 int bottomGroupIndex = -1;
544 int bottomItemIndex = -1;
546 GetCore().GetFirstLoadedItemIndex(topGroupIndex, topItemIndex);
547 GetCore().GetLastLoadedItemIndex(bottomGroupIndex, bottomItemIndex);
549 if ((topGroupIndex > groupIndex) || (bottomGroupIndex < groupIndex)
550 || ((topGroupIndex == groupIndex) && (topItemIndex > itemIndex))
551 || ((bottomGroupIndex == groupIndex) && (bottomItemIndex < itemIndex)))
553 // not yet loaded item
554 SetLastResultReturn(r);
558 TableViewItemDrawingStatus itemDrawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL;
559 bool itemSelected = false;
560 Point touchPosition(-1, -1);
562 if (pListViewItem != null)
564 itemDrawingStatus = pListViewItem->GetDrawingStatus();
565 itemSelected = pListViewItem->GetSelectionState();
566 touchPosition = pListViewItem->GetLastTouchPressedPosition();
568 pListViewItem = null;
571 GetCore().UnloadItem(groupIndex, itemIndex);
572 GetCore().LoadItem(groupIndex, itemIndex);
574 pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
576 if ((pListViewItem != null) && (itemDrawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL))
578 pListViewItem->SetDrawingStatus(itemDrawingStatus);
579 pListViewItem->SetSelectionState(itemSelected);
580 pListViewItem->SetLastTouchPressedPosition(touchPosition);
583 pListViewItem->Draw();
584 pListViewItem->Show();
586 _Control* target = static_cast<_Control*>(pListViewItem);
588 for (int i = 0; i < pListViewItem->GetChildCount(); i++)
590 if (pListViewItem->GetChild(i)->GetBounds().Contains(touchPosition))
592 target = pListViewItem->GetChild(i);
598 target->SetChangingEventTarget(true);
602 pListViewItem->SetDrawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
603 pListViewItem->SetSelectionState(false);
610 r = GetCore().RefreshTableView(groupIndex, itemIndex, static_cast<TableViewRefreshType>(type));
613 CheckEmptyListShowState();
618 SetLastResultReturn(r);
622 _GroupedListViewImpl::RefreshList(int groupIndex, int itemIndex, int elementId)
624 if ((groupIndex < 0) || (groupIndex >= GetCore().GetGroupCount()) || (itemIndex < 0) || (itemIndex >= GetCore().GetItemCountAt(groupIndex)))
626 return E_OUT_OF_RANGE;
629 result r = E_SUCCESS;
630 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
632 if (pListViewItem != null)
634 r = (pListViewItem->RefreshElement(elementId)) ? E_SUCCESS : E_OUT_OF_RANGE;
637 SetLastResultReturn(r);
641 _GroupedListViewImpl::UpdateList(void)
643 // for lazy delete item
644 if (__pItemNeedsLazyDeletion != null)
646 _GroupedListViewItemProviderAdaptor* pProviderAdaptor =
647 static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
649 if (pProviderAdaptor != null)
651 pProviderAdaptor->SetItemNeedsLazyDeletion(__pItemNeedsLazyDeletion);
655 result r = GetCore().UpdateTableView();
657 CheckEmptyListShowState();
661 // API versioning for initial Show() operation
662 if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
667 SetLastResultReturn(r);
671 _GroupedListViewImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const
673 result r = GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex);
674 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] There is no item at the specified position.");
676 SetLastResultReturn(r);
680 _GroupedListViewImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex, int& elementId) const
684 result r = GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex);
685 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] There is no item at the specified position.");
687 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
689 if (pListViewItem != null)
691 Point originPosition = pListViewItem->GetPosition();
692 originPosition.y -= GetCore().GetScrollPosition();
694 elementId = pListViewItem->GetElementIdFromPosition(Point(position.x - originPosition.x, position.y - originPosition.y));
697 SetLastResultReturn(r);
701 _GroupedListViewImpl::SetSectionColor(const Color& color)
703 return GetCore().SetSectionColor(color);
707 _GroupedListViewImpl::GetSectionColor(void) const
709 return GetCore().GetSectionColor();
713 _GroupedListViewImpl::SetItemDividerColor(const Color& color)
715 return GetCore().SetItemDividerColor(color);
719 _GroupedListViewImpl::GetItemDividerColor(void) const
721 return GetCore().GetItemDividerColor();
725 _GroupedListViewImpl::SetListBackgroundColor(const Color& color)
727 SetBackgroundColor(color);
731 _GroupedListViewImpl::SetBackgroundBitmap(const Bitmap* pBitmap)
733 GetCore().SetBackgroundBitmap(const_cast<Bitmap*>(pBitmap));
734 GetCore().SetBackgroundBitmapStretch(true);
736 SetLastResultReturn(E_SUCCESS);
740 _GroupedListViewImpl::SetBitmapOfEmptyList(const Bitmap* pBitmap)
744 if (__pEmptyBitmap != null)
746 GetCore().DetachChild(*__pEmptyBitmap);
748 delete __pEmptyBitmap;
749 __pEmptyBitmap = null;
754 if (__pEmptyBitmap == null)
756 __pEmptyBitmap = _Label::CreateLabelN();
757 SysTryReturn(NID_UI_CTRL, (__pEmptyBitmap != null), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
759 __pEmptyBitmap->SetVisibleState(false);
760 __pEmptyBitmap->SetMargin(0, 0);
762 GetCore().AttachChild(*__pEmptyBitmap);
765 Dimension bitmapSize(pBitmap->GetWidth(), pBitmap->GetHeight());
766 Dimension listDimension = GetCore().GetSize();
767 Dimension labelDimension;
769 labelDimension.width = ((listDimension.width < bitmapSize.width) ? listDimension.width : bitmapSize.width);
770 labelDimension.height = ((listDimension.height < bitmapSize.height) ? listDimension.height : bitmapSize.height);
772 __pEmptyBitmap->SetSize(labelDimension);
773 __pEmptyBitmap->SetBackgroundColor(Color(0, 0, 0, 0));
774 __pEmptyBitmap->SetBackgroundBitmap(*pBitmap);
777 AdjustLayoutOfEmptyList();
779 SetLastResultReturn(E_SUCCESS);
783 _GroupedListViewImpl::SetTextOfEmptyList(const String& text)
787 if (__pEmptyText != null)
789 GetCore().DetachChild(*__pEmptyText);
797 if (__pEmptyText == null)
799 __pEmptyText = _Label::CreateLabelN();
800 SysTryReturn(NID_UI_CTRL, (__pEmptyText != null), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
802 __pEmptyText->SetVisibleState(false);
803 __pEmptyText->SetMargin(0, 0);
805 GetCore().AttachChild(*__pEmptyText);
808 TextObject* pText = new (std::nothrow) TextObject;
809 SysTryReturn(NID_UI_CTRL, (pText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
813 TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast <wchar_t*>(text.GetPointer()), text.GetLength());
814 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
815 pText->AppendElement(*pSimpleText);
818 GET_SHAPE_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, fontSize);
821 font.Construct(GetFont(), FONT_STYLE_PLAIN, fontSize);
822 pText->SetFont(&font, 0, pText->GetTextLength());
824 Dimension listDimension = GetCore().GetSize();
826 pText->SetBounds(Rectangle(0, 0, listDimension.width, 1));
829 Dimension labelDimension = pText->GetTextExtent(0, pText->GetTextLength());
830 labelDimension.height = pText->GetTotalHeight();
832 if (labelDimension.width > listDimension.width)
834 pText->SetBounds(Rectangle(0, 0, listDimension.width, 1));
837 int labelHeight = pText->GetTotalHeight();
839 labelDimension.width = listDimension.width;
840 labelDimension.height = ((listDimension.height < labelHeight) ? listDimension.height : labelHeight);
845 __pEmptyText->SetSize(labelDimension);
846 __pEmptyText->SetBackgroundColor(Color(0, 0, 0, 0));
847 __pEmptyText->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
848 __pEmptyText->SetTextColor(__emptyTextColor);
849 __pEmptyText->SetText(text);
852 AdjustLayoutOfEmptyList();
854 SetLastResultReturn(E_SUCCESS);
858 _GroupedListViewImpl::GetTextOfEmptyList(void) const
860 return ((__pEmptyText != null) ? __pEmptyText->GetText() : String());
864 _GroupedListViewImpl::SetTextColorOfEmptyList(const Color& color)
866 __emptyTextColor = color;
868 if (__pEmptyText != null)
870 __pEmptyText->SetTextColor(color);
873 SetLastResultReturn(E_SUCCESS);
877 _GroupedListViewImpl::GetTextColorOfEmptyList(void) const
879 return __emptyTextColor;
883 _GroupedListViewImpl::ExpandGroup(int groupIndex)
885 return GetCore().ExpandGroup(groupIndex);
889 _GroupedListViewImpl::CollapseGroup(int groupIndex)
891 return GetCore().CollapseGroup(groupIndex);
895 _GroupedListViewImpl::IsGroupExpanded(int groupIndex) const
897 return GetCore().IsGroupExpanded(groupIndex);
901 _GroupedListViewImpl::CheckEmptyListShowState(void)
903 bool isEmpty = (GetGroupCount() == 0);
905 if (__pEmptyBitmap != null)
907 __pEmptyBitmap->SetVisibleState(isEmpty);
909 if (__pEmptyText != null)
911 __pEmptyText->SetVisibleState(isEmpty);
917 _GroupedListViewImpl::AdjustLayoutOfEmptyList(void)
919 Dimension listDimension = GetCore().GetSize();
920 Dimension emptyBitmap;
926 if (__pEmptyBitmap != null)
928 emptyBitmap = __pEmptyBitmap->GetSize();
930 if (__pEmptyText != null)
932 emptyText = __pEmptyText->GetSize();
935 totalHeight = emptyBitmap.height + emptyText.height;
937 if ((__pEmptyBitmap != null) && (__pEmptyText != null) && (totalHeight < listDimension.height))
939 bitmapPos.x = ((listDimension.width == emptyBitmap.width) ? 0 : (listDimension.width - emptyBitmap.width) / 2);
940 bitmapPos.y = (listDimension.height - totalHeight) / 2;
942 textPos.x = ((listDimension.width == emptyText.width) ? 0 : (listDimension.width - emptyText.width) / 2);
943 textPos.y = bitmapPos.y + emptyBitmap.height;
947 if (__pEmptyBitmap != null)
949 bitmapPos.x = ((listDimension.width == emptyBitmap.width) ? 0 : (listDimension.width - emptyBitmap.width) / 2);
950 bitmapPos.y = ((listDimension.height == emptyBitmap.height) ? 0 : (listDimension.height - emptyBitmap.height) / 2);
953 if (__pEmptyText != null)
955 textPos.x = ((listDimension.width == emptyText.width) ? 0 : (listDimension.width - emptyText.width) / 2);
956 textPos.y = ((listDimension.height == emptyText.height) ? 0 : (listDimension.height - emptyText.height) / 2);
960 if (__pEmptyBitmap != null)
962 __pEmptyBitmap->SetPosition(bitmapPos);
964 if (__pEmptyText != null)
966 __pEmptyText->SetPosition(textPos);
969 CheckEmptyListShowState();
973 _GroupedListViewImpl::BeginReorderingMode(void)
975 SysTryReturn(NID_UI_CTRL, (GetCore().GetTableViewStyle() == TABLE_VIEW_STYLE_GROUPED), E_INVALID_OPERATION, E_INVALID_OPERATION,
976 "[E_INVALID_OPERATION] Reordering mode is supported only Indexed style.");
978 result r = GetCore().SetReorderModeEnabled(true);
980 SetLastResultReturn(r);
984 _GroupedListViewImpl::EndReorderingMode(void)
986 SysTryReturn(NID_UI_CTRL, (GetCore().GetTableViewStyle() == TABLE_VIEW_STYLE_GROUPED), E_INVALID_OPERATION, E_INVALID_OPERATION,
987 "[E_INVALID_OPERATION] Reordering mode is supported only Indexed style.");
989 result r = GetCore().SetReorderModeEnabled(false);
991 SetLastResultReturn(r);
995 _GroupedListViewImpl::IsInReorderingMode(void) const
997 return GetCore().IsReorderModeEnabled();
1001 _GroupedListViewImpl::OnListViewContextItemStateChanged(_Control& source, int groupIndex, int itemIndex, int elementId,
1002 ListContextItemStatus status)
1004 if (__pListItemEvent != null)
1006 GetCore().ResetSweepItem();
1008 __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
1010 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, elementId, 0, NOTIFY_TYPE_SELCTED_CONTEXT_ITEM);
1011 __pListItemEvent->Fire(*pArg);
1013 __pItemNeedsLazyDeletion = null;
1018 _GroupedListViewImpl::OnListViewItemLongPressed(_Control& source, int groupIndex, int itemIndex, int elementId)
1020 if (__pListItemEvent != null)
1022 __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
1024 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, elementId, 0, NOTIFY_TYPE_LONG_PRESSED_ITEM);
1025 __pListItemEvent->Fire(*pArg);
1027 __pItemNeedsLazyDeletion = null;
1032 _GroupedListViewImpl::OnGroupedTableViewGroupItemStateChanged(_TableView& tableView, int groupIndex, _TableViewItem* pItem,
1033 TableViewItemStatus status)
1035 FireListViewItemEvent(groupIndex, -1, pItem, status);
1039 _GroupedListViewImpl::OnGroupedTableViewItemStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pItem,
1040 TableViewItemStatus status)
1042 FireListViewItemEvent(groupIndex, itemIndex, pItem, status);
1046 _GroupedListViewImpl::OnGroupedTableViewContextItemActivationStateChanged(_TableView& tableView, int groupIndex, int itemIndex,
1047 _TableViewItem* pContextItem, bool activated)
1049 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
1051 if (pListViewItem != null)
1053 __pItemSwept = (activated ? pListViewItem : null);
1055 pListViewItem->SetContextItemActivationState(activated);
1060 _GroupedListViewImpl::OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom,
1061 int groupIndexTo, int itemIndexTo)
1063 if (__pListItemEvent != null)
1065 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndexFrom, itemIndexFrom, groupIndexTo, itemIndexTo,
1066 NOTIFY_TYPE_REORDERED_ITEM);
1067 __pListItemEvent->Fire(*pArg);
1072 _GroupedListViewImpl::OnSectionTableViewItemStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pItem,
1073 TableViewItemStatus status)
1075 FireListViewItemEvent(sectionIndex, itemIndex, pItem, status);
1079 _GroupedListViewImpl::OnSectionTableViewContextItemActivationStateChanged(_TableView& tableView, int sectionIndex, int itemIndex,
1080 _TableViewItem* pContextItem, bool activated)
1082 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(sectionIndex, itemIndex));
1084 if (pListViewItem != null)
1086 __pItemSwept = (activated ? pListViewItem : null);
1088 pListViewItem->SetContextItemActivationState(activated);
1093 _GroupedListViewImpl::OnTableViewItemSwept(_TableView& tableView, int groupIndex, int itemIndex, TableViewSweepDirection direction)
1095 if (__pListItemEvent != null)
1097 __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
1099 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, direction, 0, NOTIFY_TYPE_SWEPT_ITEM);
1100 __pListItemEvent->Fire(*pArg);
1102 __pItemNeedsLazyDeletion = null;
1107 _GroupedListViewImpl::FireListViewItemEvent(int groupIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1109 if (__pListItemEvent != null)
1111 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pItem);
1113 __pItemNeedsLazyDeletion = pListViewItem;
1115 if (pListViewItem != null)
1117 _ListViewItemStateChangedInfo itemInfo;
1118 pListViewItem->GetLastStateChangedInfo(itemInfo);
1120 if ((__pLinkEvent != null) && (itemInfo.pUiLinkInfo != null))
1122 IEventArg* pLinkEventArg = _PublicLinkEvent::CreateLinkEventArgN(itemInfo.pUiLinkInfo->textInfo,
1123 itemInfo.pUiLinkInfo->linkType,
1124 itemInfo.pUiLinkInfo->linkInfo);
1125 SysTryReturnVoidResult(NID_UI_CTRL, (pLinkEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg.");
1126 __pLinkEvent->Fire(*pLinkEventArg);
1131 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, itemInfo.elementId, 0,
1132 static_cast<NotifyType>(status));
1133 __pListItemEvent->Fire(*pArg);
1136 pListViewItem->ClearLastStateChangedInfo();
1139 __pItemNeedsLazyDeletion = null;
1144 _GroupedListViewImpl::OnScrollEndReached(_Control& source, ScrollEndEvent type)
1146 if (__pScrollEvent != null)
1148 _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), type);
1149 result r = GetLastResult();
1150 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1152 __pScrollEvent->Fire(*pEventArg);
1157 _GroupedListViewImpl::OnScrollPositionChanged(_Control& source, int scrollPos)
1159 if (__pScrollEvent != null)
1161 _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), scrollPos);
1162 result r = GetLastResult();
1163 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1165 __pScrollEvent->Fire(*pEventArg);
1170 _GroupedListViewImpl::OnScrollStopped(_Control& source)
1172 if (__pScrollEvent != null)
1174 _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic());
1175 result r = GetLastResult();
1176 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1178 __pScrollEvent->Fire(*pEventArg);
1182 _GroupedListViewImpl::OnUiFastScrollIndexSelected(_Control& source, _FastScrollIndex& index)
1184 if (__pFastScrollEvent != null)
1186 String* pIndexText = index.GetIndexText();
1187 if (pIndexText != null)
1189 _FastScrollEventArg* pEventArg = new (std::nothrow) _FastScrollEventArg(GetPublic(), *pIndexText);
1190 __pFastScrollEvent->Fire(*pEventArg);
1196 _GroupedListViewImpl::OnDraw(void)
1198 _ControlImpl::OnDraw();
1200 if (__redrawListView)
1202 CheckEmptyListShowState();
1203 __redrawListView = false;
1208 _GroupedListViewImpl::OnBoundsChanged(void)
1210 _ControlImpl::OnBoundsChanged();
1212 if (__pEmptyBitmap != null)
1214 SetBitmapOfEmptyList(__pEmptyBitmap->GetBackgroundBitmap());
1216 if (__pEmptyText != null)
1218 SetTextOfEmptyList(__pEmptyText->GetText());
1221 _GroupedListViewItemProviderAdaptor* pProviderAdaptor =
1222 static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
1224 if (pProviderAdaptor != null)
1226 int itemWidth = GetCore().GetBounds().width;
1228 if (GetCore().GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION)
1231 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin);
1233 itemWidth -= (margin * 2);
1236 pProviderAdaptor->SetListWidth(itemWidth);
1241 _GroupedListViewImpl::OnFontChanged(Font* pFont)
1243 String fontName = GetFont();
1244 _GroupedListViewItemProviderAdaptor* pProviderAdaptor =
1245 static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
1247 if (__pEmptyText != null)
1249 __pEmptyText->SetFont(fontName);
1250 SetTextOfEmptyList(__pEmptyText->GetText());
1253 if (pProviderAdaptor != null)
1255 pProviderAdaptor->SetItemFont(fontName);
1258 int firstGroup = -1;
1262 int currentItem = -1;
1263 int lastItemInGroup = -1;
1265 GetCore().GetFirstLoadedItemIndex(firstGroup, firstItem);
1266 GetCore().GetLastLoadedItemIndex(lastGroup, lastItem);
1268 for (int i = firstGroup; i <= lastGroup; i++)
1270 currentItem = ((i == firstGroup) ? firstItem : -1);
1271 lastItemInGroup = ((i == lastGroup) ? lastItem : GetCore().GetItemCountAt(i));
1273 for (; currentItem <= lastItemInGroup; currentItem++)
1275 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(i, currentItem));
1277 if (pListViewItem != null)
1279 pListViewItem->SetFont(fontName);
1286 _GroupedListViewImpl::OnFontInfoRequested(unsigned long& style, int& size)
1289 GET_SHAPE_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, textSize);
1291 style = FONT_STYLE_PLAIN;
1296 _GroupedListViewImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo)
1298 FirePublicTouchEvent(touchinfo);
1303 _GroupedListViewImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo)
1305 FirePublicTouchEvent(touchinfo);
1310 _GroupedListViewImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo)
1312 FirePublicTouchEvent(touchinfo);
1317 _GroupedListViewImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo)
1319 FirePublicTouchEvent(touchinfo);
1324 _GroupedListViewImpl::FirePublicTouchEvent(const _TouchInfo& touchInfo)
1326 _TouchManager* pTouchManager = _TouchManager::GetInstance();
1327 SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
1329 TouchEventInfo publicTouchInfo;
1331 _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
1332 SysTryReturnVoidResult(NID_UI, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1334 publicTouchInfo.Construct(*pEventArg);
1336 _Control* pDraggedControl = pTouchManager->GetTouchControlSource();
1338 IEnumeratorT<IEventListener*>* pEnumerator = GetTouchEventListener()->GetEnumeratorN();
1341 while (pEnumerator->MoveNext() == E_SUCCESS)
1343 IEventListener* pListener = null;
1344 pEnumerator->GetCurrent(pListener);
1346 ITouchEventListener* pTouchEventListener = dynamic_cast <ITouchEventListener*>(pListener);
1347 if (pTouchEventListener)
1349 FirePublicListener(*pTouchEventListener, publicTouchInfo);
1351 if (touchInfo.GetTouchStatus() == _TOUCH_RELEASED)
1353 if (pDraggedControl == null) //if exist dragged control, don't send focus event
1355 FireFocusListener(*pTouchEventListener, publicTouchInfo);
1358 else if (touchInfo.GetTouchStatus() == _TOUCH_MOVED)
1360 FireFocusListener(*pTouchEventListener, publicTouchInfo);
1372 _GroupedListViewImpl::FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
1374 switch (touchEventInfo.GetTouchStatus())
1377 listener.OnTouchPressed(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1379 case TOUCH_LONG_PRESSED:
1380 listener.OnTouchLongPressed(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1382 case TOUCH_RELEASED:
1383 listener.OnTouchReleased(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1386 listener.OnTouchMoved(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1388 case TOUCH_DOUBLE_PRESSED:
1389 listener.OnTouchDoublePressed(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1391 case TOUCH_FOCUS_IN:
1392 listener.OnTouchFocusIn(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1394 case TOUCH_FOCUS_OUT:
1395 listener.OnTouchFocusOut(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1397 case TOUCH_CANCELED:
1398 listener.OnTouchCanceled(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1406 _GroupedListViewImpl::FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
1408 _ControlManager* pControlManager = _ControlManager::GetInstance();
1409 SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
1411 _TouchManager* pTouchManager = _TouchManager::GetInstance();
1412 SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
1414 Point screenPoint(pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).x,
1415 pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).y);
1417 _Control* pTouchedControl = pControlManager->GetTopmostTouchedControl(screenPoint);
1418 SysTryReturnVoidResult(NID_UI, pTouchedControl, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pTouchedControl is null.");
1420 if (pTouchManager->GetFocusedControlSource() != pTouchedControl)
1422 if (&(GetCore()) != pTouchedControl)
1424 if (pTouchManager->GetFocusedControlSource() == &(GetCore()))
1426 listener.OnTouchFocusOut(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1431 listener.OnTouchFocusIn(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo);
1434 pTouchManager->SetFocusedControlSource(*pTouchedControl);
1439 _GroupedListViewImpl::GetTouchEventArgN(const _TouchInfo& touchInfo)
1443 _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(GetPublic(), touchInfo.GetTouchStatus());
1444 SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1446 _TouchManager* pTouchManager = _TouchManager::GetInstance();
1447 SysTryCatch(NID_UI, pTouchManager, , E_SYSTEM, "[E_SYSTEM] System error occurred.");
1449 startPoint.SetPosition(pTouchManager->GetStartPoint(touchInfo.GetPointId()).x - GetCore().GetAbsoluteBounds().x,
1450 pTouchManager->GetStartPoint(touchInfo.GetPointId()).y - GetCore().GetAbsoluteBounds().y);
1452 pEventArg->SetTouchPosition(touchInfo.GetPointId(), startPoint.x, startPoint.y,
1453 touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y);
1455 // need to flick distance setting
1464 class _GroupedListViewMaker
1465 : public _UiBuilderControlMaker
1468 _GroupedListViewMaker(_UiBuilder* uibuilder)
1469 : _UiBuilderControlMaker(uibuilder){};
1471 virtual ~_GroupedListViewMaker(){};
1473 static _UiBuilderControlMaker*
1474 GetInstance(_UiBuilder* uibuilder)
1476 _GroupedListViewMaker* pGroupedListViewMaker = new (std::nothrow) _GroupedListViewMaker(uibuilder);
1477 return pGroupedListViewMaker;
1480 virtual Tizen::Ui::Control*
1481 Make(_UiBuilderControl* pControl)
1483 result r = E_SYSTEM;
1484 _UiBuilderControlLayout* pControlProperty = null;
1485 GroupedListView* pGroupedListView = null;
1488 GroupedListViewStyle style = GROUPED_LIST_VIEW_STYLE_INDEXED;
1489 String elementString;
1490 bool itemDividerState = true;
1491 bool fastScrollState = false;
1493 bool sweepEnabledState = false;
1496 GetProperty(pControl, &pControlProperty);
1497 if (pControlProperty == null)
1502 pGroupedListView = new (std::nothrow) GroupedListView();
1503 if (pGroupedListView == null)
1508 rect = pControlProperty->GetRect();
1511 styleString = pControlProperty->GetStyle();
1513 if (styleString.Equals(L"GROUPED_LIST_VIEW_STYLE_SECTION", false))
1515 style = GROUPED_LIST_VIEW_STYLE_SECTION;
1519 style = GROUPED_LIST_VIEW_STYLE_INDEXED;
1523 if (pControl->GetElement(L"itemDivider", elementString))
1525 if (elementString.Equals(L"true", false))
1527 itemDividerState = true;
1531 itemDividerState = false;
1535 if (pControl->GetElement(L"fastScroll", elementString))
1537 if (elementString.Equals(L"true", false))
1539 fastScrollState = true;
1543 fastScrollState = false;
1547 r = pGroupedListView->Construct(rect, style, itemDividerState, fastScrollState);
1548 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1550 // Set BackgroundsBitmap
1551 if (pControl->GetElement("backgroundBitmapPath", elementString))
1553 Bitmap* pBackgroundBitmap = null;
1554 pBackgroundBitmap = LoadBitmapN(elementString);
1555 if (pBackgroundBitmap != null)
1557 r = pGroupedListView->SetBackgroundBitmap(pBackgroundBitmap);
1558 delete pBackgroundBitmap;
1559 pBackgroundBitmap = null;
1561 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1566 if (pControl->GetElement(L"textOfEmptyList", elementString))
1568 r = pGroupedListView->SetTextOfEmptyList(elementString);
1569 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1572 if (pControl->GetElement(L"colorOfEmptyListText", elementString))
1574 ConvertStringToColor(elementString, color);
1575 r = pGroupedListView->SetTextColorOfEmptyList(color);
1576 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1579 if (pControl->GetElement(L"bitmapPathOfEmptyList", elementString))
1581 Bitmap* pBackgroundBitmap = null;
1582 pBackgroundBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1583 if (pBackgroundBitmap != null)
1585 r = pGroupedListView->SetBitmapOfEmptyList(pBackgroundBitmap);
1586 delete pBackgroundBitmap;
1587 pBackgroundBitmap = null;
1589 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1593 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1595 Base::Integer::Parse(elementString, opacity);
1598 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1600 ConvertStringToColor32(elementString, opacity, color);
1601 r = pGroupedListView->SetBackgroundColor(color);
1602 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1605 if (pControl->GetElement(L"itemDividerColor", elementString))
1607 ConvertStringToColor(elementString, color);
1608 r = pGroupedListView->SetItemDividerColor(color);
1609 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1612 if (pControl->GetElement(L"sectionColor", elementString))
1614 ConvertStringToColor(elementString, color);
1615 r = pGroupedListView->SetSectionColor(color);
1616 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1619 if (pControl->GetElement(L"sweepEnabled", elementString))
1622 if (elementString.Equals(L"true", false))
1624 sweepEnabledState = true;
1628 sweepEnabledState = false;
1631 r = pGroupedListView->SetSweepEnabled(sweepEnabledState);
1632 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1635 return pGroupedListView;
1638 delete pGroupedListView;
1639 pGroupedListView = null;
1644 }; // _GroupedListViewMaker
1646 _GroupedListViewRegister::_GroupedListViewRegister()
1648 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1649 pUiBuilderControlTableManager->RegisterControl(L"GroupedListView", _GroupedListViewMaker::GetInstance);
1652 _GroupedListViewRegister::~_GroupedListViewRegister()
1654 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1655 pUiBuilderControlTableManager->UnregisterControl(L"GroupedListView");
1657 static _GroupedListViewRegister GroupedListViewRegisterToUIbuilder;
1658 }}} // Tizen::Ui::Controls