Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_TableViewImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19 * @file         FUiCtrl_TableViewImpl.cpp
20 * @brief        This file contains implementation of _TableViewImpl class
21 */
22
23 #include <FUiCtrlIFastScrollListener.h>
24 #include <FUiCtrlITableViewItemEventListener.h>
25 #include <FUiCtrlIGroupedTableViewItemEventListener.h>
26 #include <FUiCtrlISectionTableViewItemEventListener.h>
27 #include <FUiCtrlITableViewItemProvider.h>
28 #include <FUiCtrlIGroupedTableViewItemProvider.h>
29 #include <FUiCtrlISectionTableViewItemProvider.h>
30 #include "FUiCtrl_TableViewImpl.h"
31 #include "FUiCtrl_TableViewItemEventArg.h"
32 #include "FUiCtrl_TableViewItemProvider.h"
33 #include "FUiCtrlTableViewItem.h"
34 #include "FUiCtrlTableViewGroupItem.h"
35 #include "FUiCtrlTableViewContextItem.h"
36 #include "FUiCtrl_FastScrollEvent.h"
37 #include "FUiCtrl_FastScrollEventArg.h"
38 #include "FUiCtrl_ScrollEvent.h"
39 #include "FUiCtrl_ScrollEventArg.h"
40 #include "FUi_UiBuilder.h"
41 #include "FUi_ResourceSizeInfo.h"
42 #include "FUi_ResourceManager.h"
43
44 using namespace Tizen::Ui;
45 using namespace Tizen::Base;
46 using namespace Tizen::Graphics;
47
48 namespace Tizen { namespace Ui { namespace Controls
49 {
50
51 Tizen::Graphics::Dimension
52 _TableViewImpl::TableViewSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const
53 {
54         result r = E_SUCCESS;
55         Tizen::Graphics::Dimension dimension(0, 0);
56         r = GET_DIMENSION_CONFIG(TABLEVIEW::MIN_SIZE, orientation, dimension);
57         SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] System Error", GetErrorMessage(r));
58         return dimension;
59 }
60
61 _TableViewImpl*
62 _TableViewImpl::GetInstance(TableView& tableView)
63 {
64         return static_cast <_TableViewImpl*>(tableView._pControlImpl);
65 }
66
67 const _TableViewImpl*
68 _TableViewImpl::GetInstance(const TableView& tableView)
69 {
70         return static_cast <const _TableViewImpl*>(tableView._pControlImpl);
71 }
72
73
74 _TableViewImpl*
75 _TableViewImpl::GetInstance(GroupedTableView& tableView)
76 {
77         return static_cast <_TableViewImpl*>(tableView._pControlImpl);
78 }
79
80 const _TableViewImpl*
81 _TableViewImpl::GetInstance(const GroupedTableView& tableView)
82 {
83         return static_cast <const _TableViewImpl*>(tableView._pControlImpl);
84 }
85
86
87 _TableViewImpl*
88 _TableViewImpl::GetInstance(SectionTableView& tableView)
89 {
90         return static_cast <_TableViewImpl*>(tableView._pControlImpl);
91 }
92
93 const _TableViewImpl*
94 _TableViewImpl::GetInstance(const SectionTableView& tableView)
95 {
96         return static_cast <const _TableViewImpl*>(tableView._pControlImpl);
97 }
98
99 _TableViewImpl::_TableViewImpl(Container* pTableView, _TableView* pCore)
100         : _ContainerImpl(pTableView, pCore)
101         , __pTableViewEvent(null)
102         , __pScrollEvent(null)
103         , __pFastScrollEvent(null)
104         , __useSearchIcon(false)
105         , __tableViewPublic()
106 {
107 }
108
109 _TableViewImpl::~_TableViewImpl()
110 {
111         if (__pScrollEvent != null)
112         {
113                 delete __pScrollEvent;
114                 __pScrollEvent = null;
115         }
116
117         if (__pFastScrollEvent != null)
118         {
119                 delete __pFastScrollEvent;
120                 __pFastScrollEvent = null;
121         }
122
123         if (__pTableViewEvent != null)
124         {
125                 delete __pTableViewEvent;
126                 __pTableViewEvent = null;
127         }
128 }
129
130 const char*
131 _TableViewImpl::GetPublicClassName(void) const
132 {
133         return "Tizen::Ui::Controls::TableView";
134 }
135
136 const _TableView&
137 _TableViewImpl::GetCore(void) const
138 {
139         return static_cast <const _TableView&>(_ControlImpl::GetCore());
140 }
141
142 _TableView&
143 _TableViewImpl::GetCore(void)
144 {
145         return static_cast <_TableView&>(_ControlImpl::GetCore());
146 }
147
148 _TableViewImpl*
149 _TableViewImpl::CreateTableViewImplN(Container* pPublic, Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle)
150 {
151         result r = E_SUCCESS;
152         ClearLastResult();
153
154         r = GET_SIZE_INFO(TableView).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
155         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
156
157         _TableView* pCore = _TableView::CreateTableViewN(style, itemDivider, scrollStyle);
158         SysTryReturn(NID_UI_CTRL, pCore, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
159
160         _TableViewImpl* pImpl = new (std::nothrow) _TableViewImpl(pPublic, pCore);
161         SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
162
163         pImpl->SetPublic(style, pPublic);
164
165         SetLastResult(r);
166
167         return pImpl;
168
169 CATCH:
170         delete pCore;
171
172         return null;
173 }
174
175 _TableViewImpl*
176 _TableViewImpl::CreateTableViewImplN(TableView* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle)
177 {
178         return _TableViewImpl::CreateTableViewImplN(static_cast<Container*>(pPublic), bounds, style, itemDivider, scrollStyle);
179 }
180 _TableViewImpl*
181 _TableViewImpl::CreateGroupedTableViewImplN(GroupedTableView* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle)
182 {
183         return _TableViewImpl::CreateTableViewImplN(static_cast<Container*>(pPublic), bounds, style, itemDivider, scrollStyle);
184 }
185 _TableViewImpl*
186 _TableViewImpl::CreateSectionTableViewImplN(SectionTableView* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle)
187 {
188         return _TableViewImpl::CreateTableViewImplN(static_cast<Container*>(pPublic), bounds, style, itemDivider, scrollStyle);
189 }
190
191
192 void
193 _TableViewImpl::SetPublic(TableViewStyle style, Container *pPublic)
194 {
195         __tableViewPublic.style = style;
196
197         if (style == TABLE_VIEW_STYLE_SIMPLE)
198         {
199                 __tableViewPublic.pTableView = static_cast <TableView*>(pPublic);
200         }
201         else if (style == TABLE_VIEW_STYLE_GROUPED)
202         {
203                 __tableViewPublic.pGroupedTableView = static_cast <GroupedTableView*>(pPublic);
204         }
205         else
206         {
207                 __tableViewPublic.pSectionTableView = static_cast <SectionTableView*>(pPublic);
208         }
209 }
210
211
212 result
213 _TableViewImpl::SetSimpleStyleItemProvider(ITableViewItemProvider* pProvider)
214 {
215         TableViewStyle style = GetCore().GetTableViewStyle();
216         SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SIMPLE");
217
218         _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
219         SysTryReturn(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
220
221         result r = pItemProvider->SetSimpleStyleItemProvider(pProvider);
222         if (r != E_SUCCESS)
223         {
224                 delete pItemProvider;
225                 SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
226         }
227
228         return GetCore().SetItemProvider(pItemProvider);
229 }
230
231 result
232 _TableViewImpl::SetGroupedStyleItemProvider(IGroupedTableViewItemProvider* pProvider)
233 {
234         TableViewStyle style = GetCore().GetTableViewStyle();
235         SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_STYLE_GROUPED, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_GROUPED");
236
237         _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
238         SysTryReturn(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
239
240         result r = pItemProvider->SetGroupedStyleItemProvider(pProvider);
241         if (r != E_SUCCESS)
242         {
243                 delete pItemProvider;
244                 SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
245         }
246
247         return GetCore().SetItemProvider(pItemProvider);
248 }
249 //
250 result
251 _TableViewImpl::SetSectionStyleItemProvider(ISectionTableViewItemProvider* pProvider)
252 {
253         TableViewStyle style = GetCore().GetTableViewStyle();
254         SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SECTION, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION");
255
256         _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
257         SysTryReturn(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
258
259         result r = pItemProvider->SetSectionStyleItemProvider(pProvider);
260         if (r != E_SUCCESS)
261         {
262                 delete pItemProvider;
263                 SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
264         }
265
266         return GetCore().SetItemProvider(pItemProvider);
267 }
268
269 result
270 _TableViewImpl::AddTableViewItemEventListener(ITableViewItemEventListener& listener)
271 {
272         result r = E_SUCCESS;
273
274         if (__pTableViewEvent == null)
275         {
276                 __pTableViewEvent = new (std::nothrow) _TableViewItemEvent();
277                 SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
278
279                 r = __pTableViewEvent->Construct(&GetPublic(), TABLE_VIEW_STYLE_SIMPLE);
280                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
281         }
282
283         r = __pTableViewEvent->AddListener(listener);
284         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
285
286         r = GetCore().AddTableViewItemEventListener(*this);
287         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
288
289         return r;
290 }
291
292 result
293 _TableViewImpl::RemoveTableViewItemEventListener(ITableViewItemEventListener& listener)
294 {
295         SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The listener is not found");
296
297         return __pTableViewEvent->RemoveListener(listener);
298 }
299
300 result
301 _TableViewImpl::AddGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener)
302 {
303         result r = E_SUCCESS;
304
305         if (__pTableViewEvent == null)
306         {
307                 __pTableViewEvent = new (std::nothrow) _TableViewItemEvent();
308                 SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
309
310                 r = __pTableViewEvent->Construct(&GetPublic(), TABLE_VIEW_STYLE_GROUPED);
311                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
312         }
313
314         r = __pTableViewEvent->AddListener(listener);
315         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
316
317         r = GetCore().AddGroupedTableViewItemEventListener(*this);
318         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
319
320         return r;
321 }
322
323 result
324 _TableViewImpl::RemoveGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener)
325 {
326         SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The listener is not found");
327
328         return __pTableViewEvent->RemoveListener(listener);
329 }
330
331 result
332 _TableViewImpl::AddSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener)
333 {
334         result r = E_SUCCESS;
335
336         if (__pTableViewEvent == null)
337         {
338                 __pTableViewEvent = new (std::nothrow) _TableViewItemEvent();
339                 SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
340
341                 r = __pTableViewEvent->Construct(&GetPublic(), TABLE_VIEW_STYLE_SECTION);
342                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
343         }
344
345         r = __pTableViewEvent->AddListener(listener);
346         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
347
348         r = GetCore().AddSectionTableViewItemEventListener(*this);
349         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
350
351         return r;
352 }
353
354 result
355 _TableViewImpl::RemoveSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener)
356 {
357         SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The listener is not found");
358
359         return __pTableViewEvent->RemoveListener(listener);
360 }
361
362 result
363 _TableViewImpl::AddFastScrollListener(IFastScrollListener& listener)
364 {
365         ClearLastResult();
366
367         TableViewScrollBarStyle style = GetCore().GetScrollStyle();
368         SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView scroll is not TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL");
369
370         if (__pFastScrollEvent == null)
371         {
372                 __pFastScrollEvent = new (std::nothrow) _FastScrollEvent();
373                 SysTryReturn(NID_UI_CTRL, __pFastScrollEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
374
375                 result r = __pFastScrollEvent->Construct(GetPublic());
376                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
377         }
378
379         __pFastScrollEvent->AddListener(listener);
380
381         return GetCore().AddFastScrollListener(*this);
382 }
383
384 result
385 _TableViewImpl::RemoveFastScrollListener(IFastScrollListener& listener)
386 {
387         ClearLastResult();
388
389         if (__pFastScrollEvent == null)
390         {
391                 return E_INVALID_OPERATION;
392         }
393
394         return __pFastScrollEvent->RemoveListener(listener);
395 }
396
397 result
398 _TableViewImpl::AddScrollEventListener(IScrollEventListener& listener)
399 {
400         ClearLastResult();
401
402         result r = E_SUCCESS;
403
404         if (__pScrollEvent == null)
405         {
406                 __pScrollEvent = new (std::nothrow) _ScrollEvent();
407                 SysTryReturn(NID_UI_CTRL, __pScrollEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
408
409                 r = __pScrollEvent->Construct(GetPublic());
410                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
411         }
412         r = __pScrollEvent->AddListener(listener);
413         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
414
415         GetCore().AddScrollEventListener(*this);
416
417         return GetLastResult();
418 }
419
420 result
421 _TableViewImpl::RemoveScrollEventListener(IScrollEventListener& listener)
422 {
423         ClearLastResult();
424
425         if (__pScrollEvent == null)
426         {
427                 return E_INVALID_OPERATION;
428         }
429
430         return __pScrollEvent->RemoveListener(listener);
431 }
432
433 result
434 _TableViewImpl::SetSweepEnabled(bool enable)
435 {
436         GetCore().SetSweepEnabled(enable);
437
438         return E_SUCCESS;
439 }
440
441 result
442 _TableViewImpl::SetFastScrollIndex(const String& text, bool useSearchIcon)
443 {
444         __useSearchIcon = useSearchIcon;
445
446         return GetCore().SetFastScrollIndex(text, useSearchIcon);
447 }
448
449 result
450 _TableViewImpl::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
451 {
452         return GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex);
453 }
454
455 result
456 _TableViewImpl::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
457 {
458         return GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
459 }
460
461 result
462 _TableViewImpl::ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment)
463 {
464         if (itemAlignment == TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP)
465         {
466                 return GetCore().SetTopDrawnItemIndex(groupIndex, itemIndex);
467         }
468         else if (itemAlignment == TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM)
469         {
470                 return GetCore().SetBottomDrawnItemIndex(groupIndex, itemIndex);
471         }
472
473         return E_OUT_OF_RANGE;
474 }
475
476 result
477 _TableViewImpl::ScrollByPixel(int scrollDistance)
478 {
479         return GetCore().ScrollByPixel(scrollDistance);
480 }
481
482 int
483 _TableViewImpl::GetCurrentScrollPosition(void) const
484 {
485         return GetCore().GetScrollPosition();
486 }
487
488 void
489 _TableViewImpl::SetScrollEnabled(bool enable)
490 {
491         GetCore().SetScrollEnabled(enable);
492 }
493
494 bool
495 _TableViewImpl::IsScrollEnabled(void) const
496 {
497         return GetCore().IsScrollEnabled();
498 }
499
500 result
501 _TableViewImpl::SetItemChecked(int groupIndex, int itemIndex, bool check)
502 {
503         return GetCore().SetItemChecked(groupIndex, itemIndex, check);
504 }
505
506 bool
507 _TableViewImpl::IsItemChecked(int groupIndex, int itemIndex) const
508 {
509         return GetCore().IsItemChecked(groupIndex, itemIndex);
510 }
511
512 result
513 _TableViewImpl::SetItemEnabled(int groupIndex, int itemIndex, bool enable)
514 {
515         return GetCore().SetItemEnabled(groupIndex, itemIndex, enable);
516 }
517
518 bool
519 _TableViewImpl::IsItemEnabled(int groupIndex, int itemIndex) const
520 {
521         return GetCore().IsItemEnabled(groupIndex, itemIndex);
522 }
523
524 int
525 _TableViewImpl::GetGroupCount(void) const
526 {
527         return GetCore().GetGroupCount();
528 }
529
530 int
531 _TableViewImpl::GetItemCountAt(int groupIndex) const
532 {
533         return GetCore().GetItemCountAt(groupIndex);
534 }
535
536 result
537 _TableViewImpl::RefreshTableView(int groupIndex, int itemIndex, TableViewRefreshType type)
538 {
539         return GetCore().RefreshTableView(groupIndex, itemIndex, type);
540 }
541
542 result
543 _TableViewImpl::UpdateTableView(void)
544 {
545         return GetCore().UpdateTableView();
546 }
547
548 result
549 _TableViewImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const
550 {
551         return GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex);
552 }
553
554 result
555 _TableViewImpl::SetSectionColor(const Color& color)
556 {
557         return GetCore().SetSectionColor(color);
558 }
559
560 Color
561 _TableViewImpl::GetSectionColor(void) const
562 {
563         return GetCore().GetSectionColor();
564 }
565
566 result
567 _TableViewImpl::SetItemDividerColor(const Color& color)
568 {
569         return GetCore().SetItemDividerColor(color);
570 }
571
572 Color
573 _TableViewImpl::GetItemDividerColor(void) const
574 {
575         return GetCore().GetItemDividerColor();
576 }
577
578 result
579 _TableViewImpl::SetBitmapOfEmptyTableView(const Bitmap* pBitmap)
580 {
581         return GetCore().SetBitmapOfEmptyTableView(pBitmap);
582 }
583
584 result
585 _TableViewImpl::SetTextOfEmptyTableView(const String& text)
586 {
587         return GetCore().SetTextOfEmptyTableView(text);
588 }
589
590 String
591 _TableViewImpl::GetTextOfEmptyTableView(void) const
592 {
593         return GetCore().GetTextOfEmptyTableView();
594 }
595
596 result
597 _TableViewImpl::SetTextColorOfEmptyTableView(const Color& color)
598 {
599         return GetCore().SetTextColorOfEmptyTableView(color);
600 }
601
602 Color
603 _TableViewImpl::GetTextColorOfEmptyTableView(void) const
604 {
605         return GetCore().GetTextColorOfEmptyTableView();
606 }
607
608 // Item Expand / Collapse
609 result
610 _TableViewImpl::ExpandGroup(int groupIndex)
611 {
612         return GetCore().ExpandGroup(groupIndex);
613 }
614
615 result
616 _TableViewImpl::CollapseGroup(int groupIndex)
617 {
618         return GetCore().CollapseGroup(groupIndex);
619 }
620
621 bool
622 _TableViewImpl::IsGroupExpanded(int groupIndex) const
623 {
624         return GetCore().IsGroupExpanded(groupIndex);
625 }
626
627 result
628 _TableViewImpl::ExpandAllGroup(void)
629 {
630         return GetCore().ExpandAllGroup(true);
631 }
632
633 result
634 _TableViewImpl::CollapseAllGroup(void)
635 {
636         return GetCore().CollapseAllGroup(true);
637 }
638
639 result
640 _TableViewImpl::SetGroupedLookEnabled(bool enable)
641 {
642         TableViewStyle style = GetCore().GetTableViewStyle();
643         SysTryReturn(NID_UI_CTRL, style != TABLE_VIEW_STYLE_SIMPLE, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SIMPLE");
644
645         GetCore().SetGroupedLookEnabled(enable);
646
647         return E_SUCCESS;
648 }
649
650 bool
651 _TableViewImpl::IsGroupedLookEnabled(void) const
652 {
653         return GetCore().IsGroupedLookEnabled();
654 }
655
656 result
657 _TableViewImpl::BeginReorderingMode(void)
658 {
659         TableViewStyle style = GetCore().GetTableViewStyle();
660         SysTryReturn(NID_UI_CTRL, style != TABLE_VIEW_STYLE_SECTION, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SECTION");
661
662         return GetCore().SetReorderModeEnabled(true);
663 }
664
665 result
666 _TableViewImpl::EndReorderingMode(void)
667 {
668         TableViewStyle style = GetCore().GetTableViewStyle();
669         SysTryReturn(NID_UI_CTRL, style != TABLE_VIEW_STYLE_SECTION, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SECTION");
670
671         return GetCore().SetReorderModeEnabled(false);
672 }
673
674 bool
675 _TableViewImpl::IsInReorderingMode(void) const
676 {
677         return GetCore().IsReorderModeEnabled();
678 }
679
680
681 void
682 _TableViewImpl::OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
683 {
684         if (__pTableViewEvent != null)
685         {
686                 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(itemIndex, 0, 0, 0, pItem, static_cast<TableViewNotifyType>(status));
687                 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
688                 __pTableViewEvent->Fire(*pArg);
689         }
690 }
691
692 void
693 _TableViewImpl::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated)
694 {
695         if (__pTableViewEvent != null)
696         {
697                 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(itemIndex, 0, 0, 0, pContextItem, TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION, activated);
698                 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
699                 __pTableViewEvent->Fire(*pArg);
700         }
701 }
702
703 void
704 _TableViewImpl::OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo)
705 {
706         if (__pTableViewEvent != null)
707         {
708                 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(itemIndexFrom, itemIndexTo, 0, 0, null, TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM);
709                 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
710                 __pTableViewEvent->Fire(*pArg);
711         }
712 }
713
714 void
715 _TableViewImpl::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
716 {
717         if (__pTableViewEvent != null)
718         {
719                 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, -1, 0, 0, pItem, static_cast<TableViewNotifyType>(status));
720                 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
721                 __pTableViewEvent->Fire(*pArg);
722         }
723 }
724
725 void
726 _TableViewImpl::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
727 {
728         if (__pTableViewEvent != null)
729         {
730                 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, 0, 0, pItem, static_cast<TableViewNotifyType>(status));
731                 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
732                 __pTableViewEvent->Fire(*pArg);
733         }
734 }
735
736 void
737 _TableViewImpl::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated)
738 {
739         if (__pTableViewEvent != null)
740         {
741                 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, 0, 0, pContextItem, TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION, activated);
742                 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
743                 __pTableViewEvent->Fire(*pArg);
744         }
745 }
746
747 void
748 _TableViewImpl::OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo)
749 {
750         if (__pTableViewEvent != null)
751         {
752                 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndexFrom, itemIndexFrom, groupIndexTo, itemIndexTo, null, TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM);
753                 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
754                 __pTableViewEvent->Fire(*pArg);
755         }
756 }
757
758
759 void
760 _TableViewImpl::OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
761 {
762         if (__pTableViewEvent != null)
763         {
764                 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(sectionIndex, itemIndex, 0, 0, pItem, static_cast<TableViewNotifyType>(status));
765                 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
766                 __pTableViewEvent->Fire(*pArg);
767         }
768 }
769
770 void
771 _TableViewImpl::OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated)
772 {
773         if (__pTableViewEvent != null)
774         {
775                 _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(sectionIndex, itemIndex, 0, 0, pContextItem, TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION, activated);
776                 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
777                 __pTableViewEvent->Fire(*pArg);
778         }
779 }
780
781 void
782 _TableViewImpl::OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& TableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction)
783 {
784         // It's not used public method.
785 }
786
787 void
788 _TableViewImpl::OnScrollEndReached(_Control& source, ScrollEndEvent type)
789 {
790         if (__pScrollEvent != null)
791         {
792                 _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), type);
793                 result r = GetLastResult();
794                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
795
796                 __pScrollEvent->Fire(*pEventArg);
797         }
798 }
799
800 void
801 _TableViewImpl::OnScrollPositionChanged(_Control& source, int scrollPosition)
802 {
803         if (__pScrollEvent != null)
804         {
805                 _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), scrollPosition);
806                 result r = GetLastResult();
807                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
808
809                 __pScrollEvent->Fire(*pEventArg);
810         }
811 }
812
813 void
814 _TableViewImpl::OnScrollStopped(_Control& source)
815 {
816         if (__pScrollEvent != null)
817         {
818                 _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic());
819                 result r = GetLastResult();
820                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
821
822                 __pScrollEvent->Fire(*pEventArg);
823         }
824 }
825
826 void
827 _TableViewImpl::OnUiFastScrollIndexSelected(_Control& source, Tizen::Ui::Controls::_FastScrollIndex& index)
828 {
829         if (__pFastScrollEvent != null)
830         {
831                 Tizen::Base::String* pIndexText = index.GetIndexText();
832                 if (pIndexText != null)
833                 {
834                         _FastScrollEventArg* pEventArg = new (std::nothrow) _FastScrollEventArg(GetPublic(), *pIndexText);
835                         SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create _FastScrollEventArg.");
836                         __pFastScrollEvent->Fire(*pEventArg);
837                 }
838         }
839 }
840
841 void
842 _TableViewImpl::SetScrollInputMode(ScrollInputMode mode)
843 {
844         GetCore().SetScrollInputMode(mode);
845 }
846
847 ScrollInputMode
848 _TableViewImpl::GetScrollInputMode(void) const
849 {
850         return GetCore().GetScrollInputMode();
851 }
852
853
854 class _TableViewMaker
855         : public _UiBuilderControlMaker
856 {
857 public:
858         _TableViewMaker(_UiBuilder* uibuilder)
859                 : _UiBuilderControlMaker(uibuilder){};
860         virtual ~_TableViewMaker(){};
861         static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
862         {
863                 _TableViewMaker* pTableViewMaker = new (std::nothrow) _TableViewMaker(uibuilder);
864                 SysTryReturn(NID_UI_CTRL, pTableViewMaker, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
865                 return pTableViewMaker;
866         };
867 protected:
868         virtual Control* Make(_UiBuilderControl* pControl)
869         {
870                 result r = E_SYSTEM;
871                 _UiBuilderControlLayout* pControlProperty = null;
872                 TableView* pTableView = null;
873                 Rectangle rect;
874
875                 Tizen::Base::String elementString;
876                 bool itemDividerState = true;
877                 TableViewScrollBarStyle scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT;
878                 int opacity = 100;
879                 Color color;
880
881                 GetProperty(pControl, &pControlProperty);
882                 if (pControlProperty == null)
883                 {
884                         return null;
885                 }
886
887                 pTableView = new (std::nothrow) TableView();
888                 SysTryReturn(NID_UI_CTRL, pTableView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
889
890                 rect = pControlProperty->GetRect();
891
892                 //Construct
893                 if (pControl->GetElement("itemDivider", elementString))
894                 {
895                         if (elementString.Equals(L"true", false))
896                         {
897                                 itemDividerState = true;
898                         }
899                         else
900                         {
901                                 itemDividerState = false;
902                         }
903                 }
904
905                 if (pControl->GetElement("scrollBarStyle", elementString))
906                 {
907                         if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT", false))
908                         {
909                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT;
910                         }
911                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FIXED", false))
912                         {
913                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED;
914                         }
915                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP", false))
916                         {
917                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP;
918                         }
919                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_THUMB", false))
920                         {
921                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB;
922                         }
923                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL", false))
924                         {
925                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL;
926                         }
927                         else
928                         {
929                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE;
930                         }
931                 }
932
933                 r = pTableView->Construct(rect, itemDividerState, scrollStyle);
934                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
935
936                 if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL)
937                 {
938                         Tizen::Base::String fastScrollIndex;
939                         bool useSearchIcon = false;
940
941                         if (pControl->GetElement("fastScrollIndex", elementString))
942                         {
943                                 fastScrollIndex = elementString;
944                         }
945
946                         if (pControl->GetElement("useSearchIcon", elementString))
947                         {
948                                 if (elementString.Equals(L"true", false))
949                                 {
950                                         useSearchIcon = true;
951                                 }
952                         }
953
954                         r = pTableView->SetFastScrollIndex(fastScrollIndex, useSearchIcon);
955                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
956                 }
957
958                 if (pControl->GetElement("backgroundColorOpacity", elementString))
959                 {
960                         Base::Integer::Parse(elementString, opacity);
961                 }
962
963                 if (pControl->GetElement("backgroundColor", elementString))
964                 {
965                         ConvertStringToColor32(elementString, opacity, color);
966                         pTableView->SetBackgroundColor(color);
967                 }
968
969                 if (pControl->GetElement("itemDividerColor", elementString))
970                 {
971                         ConvertStringToColor(elementString, color);
972                         pTableView->SetItemDividerColor(color);
973                 }
974
975                 if (pControl->GetElement("scrollInputMode", elementString))
976                 {
977                         ScrollInputMode scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION;
978
979                         if (elementString.Equals(L"SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION", false))
980                         {
981                                 scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION;
982                         }
983                         else if (elementString.Equals(L"SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION", false))
984                         {
985                                 scrollInputMode = SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION;
986                         }
987
988                         pTableView->SetScrollInputMode(scrollInputMode);
989                 }
990
991                 return pTableView;
992
993         CATCH:
994                 delete pTableView;
995
996                 return null;
997         }
998
999 };      // _TableViewMaker
1000
1001 class _GroupedTableViewMaker
1002         : public _UiBuilderControlMaker
1003 {
1004 public:
1005         _GroupedTableViewMaker(_UiBuilder* uibuilder)
1006                 : _UiBuilderControlMaker(uibuilder){};
1007         virtual ~_GroupedTableViewMaker(){};
1008         static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1009         {
1010                 _GroupedTableViewMaker* pTableViewMaker = new (std::nothrow) _GroupedTableViewMaker(uibuilder);
1011                 SysTryReturn(NID_UI_CTRL, pTableViewMaker, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1012                 return pTableViewMaker;
1013         };
1014 protected:
1015         virtual Control* Make(_UiBuilderControl* pControl)
1016         {
1017                 result r = E_SYSTEM;
1018                 _UiBuilderControlLayout* pControlProperty = null;
1019                 GroupedTableView* pTableView = null;
1020                 Rectangle rect;
1021
1022                 Tizen::Base::String elementString;
1023                 bool itemDividerState = true;
1024                 TableViewScrollBarStyle scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT;
1025                 int opacity = 100;
1026                 Color color;
1027
1028                 GetProperty(pControl, &pControlProperty);
1029                 if (pControlProperty == null)
1030                 {
1031                         return null;
1032                 }
1033
1034                 pTableView = new (std::nothrow) GroupedTableView();
1035                 SysTryReturn(NID_UI_CTRL, pTableView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1036
1037                 rect = pControlProperty->GetRect();
1038
1039                 //Construct
1040                 if (pControl->GetElement("itemDivider", elementString))
1041                 {
1042                         if (elementString.Equals(L"true", false))
1043                         {
1044                                 itemDividerState = true;
1045                         }
1046                         else
1047                         {
1048                                 itemDividerState = false;
1049                         }
1050                 }
1051
1052                 if (pControl->GetElement("scrollBarStyle", elementString))
1053                 {
1054                         if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT", false))
1055                         {
1056                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT;
1057                         }
1058                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FIXED", false))
1059                         {
1060                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED;
1061                         }
1062                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP", false))
1063                         {
1064                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP;
1065                         }
1066                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_THUMB", false))
1067                         {
1068                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB;
1069                         }
1070                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL", false))
1071                         {
1072                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL;
1073                         }
1074                         else
1075                         {
1076                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE;
1077                         }
1078                 }
1079
1080                 r = pTableView->Construct(rect, itemDividerState, scrollStyle);
1081                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1082
1083                 if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL)
1084                 {
1085                         Tizen::Base::String fastScrollIndex;
1086                         bool useSearchIcon = false;
1087
1088                         if (pControl->GetElement("fastScrollIndex", elementString))
1089                         {
1090                                 fastScrollIndex = elementString;
1091                         }
1092
1093                         if (pControl->GetElement("useSearchIcon", elementString))
1094                         {
1095                                 if (elementString.Equals(L"true", false))
1096                                 {
1097                                         useSearchIcon = true;
1098                                 }
1099                                 else
1100                                 {
1101                                         useSearchIcon = false;
1102                                 }
1103                         }
1104
1105                         r = pTableView->SetFastScrollIndex(fastScrollIndex, useSearchIcon);
1106                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1107                 }
1108
1109                 if (pControl->GetElement("backgroundColorOpacity", elementString))
1110                 {
1111                         Base::Integer::Parse(elementString, opacity);
1112                 }
1113
1114                 if (pControl->GetElement("backgroundColor", elementString))
1115                 {
1116                         ConvertStringToColor32(elementString, opacity, color);
1117                         pTableView->SetBackgroundColor(color);
1118                 }
1119
1120                 if (pControl->GetElement("itemDividerColor", elementString))
1121                 {
1122                         ConvertStringToColor(elementString, color);
1123                         pTableView->SetItemDividerColor(color);
1124                 }
1125
1126                 if (pControl->GetElement("groupedLookEnabled", elementString))
1127                 {
1128                         bool groupedLookEnabled = false;
1129
1130                         if (elementString.Equals(L"true", false))
1131                         {
1132                                 groupedLookEnabled = true;
1133                         }
1134
1135                         pTableView->SetGroupedLookEnabled(groupedLookEnabled);
1136                 }
1137
1138                 if (pControl->GetElement("collapseByPinchEnabled", elementString))
1139                 {
1140                         bool collapseByPinchEnabled = false;
1141
1142                         if (elementString.Equals(L"true", false))
1143                         {
1144                                 collapseByPinchEnabled = true;
1145                         }
1146
1147                         pTableView->SetCollapseByPinchGestureEnabled(collapseByPinchEnabled);
1148                 }
1149
1150                 if (pControl->GetElement("scrollInputMode", elementString))
1151                 {
1152                         ScrollInputMode scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION;
1153
1154                         if (elementString.Equals(L"SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION", false))
1155                         {
1156                                 scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION;
1157                         }
1158                         else if (elementString.Equals(L"SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION", false))
1159                         {
1160                                 scrollInputMode = SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION;
1161                         }
1162
1163                         pTableView->SetScrollInputMode(scrollInputMode);
1164                 }
1165
1166                 return pTableView;
1167
1168         CATCH:
1169                 delete pTableView;
1170
1171                 return null;
1172         }
1173
1174 };      // _GroupedTableViewMaker
1175
1176 class _SectionTableViewMaker
1177         : public _UiBuilderControlMaker
1178 {
1179 public:
1180         _SectionTableViewMaker(_UiBuilder* uibuilder)
1181                 : _UiBuilderControlMaker(uibuilder){};
1182         virtual ~_SectionTableViewMaker(){};
1183         static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1184         {
1185                 _SectionTableViewMaker* pTableViewMaker = new (std::nothrow) _SectionTableViewMaker(uibuilder);
1186                 SysTryReturn(NID_UI_CTRL, pTableViewMaker, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1187                 return pTableViewMaker;
1188         };
1189 protected:
1190         virtual Control* Make(_UiBuilderControl* pControl)
1191         {
1192                 result r = E_SYSTEM;
1193                 _UiBuilderControlLayout* pControlProperty = null;
1194                 SectionTableView* pTableView = null;
1195                 Rectangle rect;
1196
1197                 Tizen::Base::String elementString;
1198                 bool itemDividerState = true;
1199                 TableViewScrollBarStyle scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT;
1200                 int opacity = 100;
1201                 Color color;
1202
1203                 GetProperty(pControl, &pControlProperty);
1204                 if (pControlProperty == null)
1205                 {
1206                         return null;
1207                 }
1208
1209                 pTableView = new (std::nothrow) SectionTableView();
1210                 SysTryReturn(NID_UI_CTRL, pTableView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1211
1212                 rect = pControlProperty->GetRect();
1213
1214                 //Construct
1215                 if (pControl->GetElement("itemDivider", elementString))
1216                 {
1217                         if (elementString.Equals(L"true", false))
1218                         {
1219                                 itemDividerState = true;
1220                         }
1221                         else
1222                         {
1223                                 itemDividerState = false;
1224                         }
1225                 }
1226
1227                 if (pControl->GetElement("scrollBarStyle", elementString))
1228                 {
1229                         if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT", false))
1230                         {
1231                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT;
1232                         }
1233                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FIXED", false))
1234                         {
1235                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED;
1236                         }
1237                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP", false))
1238                         {
1239                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP;
1240                         }
1241                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_THUMB", false))
1242                         {
1243                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB;
1244                         }
1245                         else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL", false))
1246                         {
1247                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL;
1248                         }
1249                         else
1250                         {
1251                                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE;
1252                         }
1253                 }
1254
1255                 r = pTableView->Construct(rect, itemDividerState, scrollStyle);
1256                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1257
1258                 if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL)
1259                 {
1260                         Tizen::Base::String fastScrollIndex;
1261                         bool useSearchIcon = false;
1262
1263                         if (pControl->GetElement("fastScrollIndex", elementString))
1264                         {
1265                                 fastScrollIndex = elementString;
1266                         }
1267
1268                         if (pControl->GetElement("useSearchIcon", elementString))
1269                         {
1270                                 if (elementString.Equals(L"true", false))
1271                                 {
1272                                         useSearchIcon = true;
1273                                 }
1274                                 else
1275                                 {
1276                                         useSearchIcon = false;
1277                                 }
1278                         }
1279
1280                         r = pTableView->SetFastScrollIndex(fastScrollIndex, useSearchIcon);
1281                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1282                 }
1283
1284                 if (pControl->GetElement("backgroundColorOpacity", elementString))
1285                 {
1286                         Base::Integer::Parse(elementString, opacity);
1287                 }
1288
1289                 if (pControl->GetElement("backgroundColor", elementString))
1290                 {
1291                         ConvertStringToColor32(elementString, opacity, color);
1292                         pTableView->SetBackgroundColor(color);
1293                 }
1294
1295                 if (pControl->GetElement("itemDividerColor", elementString))
1296                 {
1297                         ConvertStringToColor(elementString, color);
1298                         pTableView->SetItemDividerColor(color);
1299                 }
1300
1301                 if (pControl->GetElement("groupedLookEnabled", elementString))
1302                 {
1303                         bool groupedLookEnabled = false;
1304
1305                         if (elementString.Equals(L"true", false))
1306                         {
1307                                 groupedLookEnabled = true;
1308                         }
1309
1310                         pTableView->SetGroupedLookEnabled(groupedLookEnabled);
1311                 }
1312
1313                 if (pControl->GetElement("sectionColor", elementString))
1314                 {
1315                         ConvertStringToColor(elementString, color);
1316                         pTableView->SetSectionColor(color);
1317                 }
1318
1319                 if (pControl->GetElement("scrollInputMode", elementString))
1320                 {
1321                         ScrollInputMode scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION;
1322
1323                         if (elementString.Equals(L"SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION", false))
1324                         {
1325                                 scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION;
1326                         }
1327                         else if (elementString.Equals(L"SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION", false))
1328                         {
1329                                 scrollInputMode = SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION;
1330                         }
1331
1332                         pTableView->SetScrollInputMode(scrollInputMode);
1333                 }
1334
1335                 return pTableView;
1336
1337         CATCH:
1338                 delete pTableView;
1339
1340                 return null;
1341         }
1342
1343 };      // _SectionTableViewMaker
1344
1345
1346 _TableViewRegister::_TableViewRegister()
1347 {
1348         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1349         pUiBuilderControlTableManager->RegisterControl(L"TableView", _TableViewMaker::GetInstance);
1350 }
1351 _TableViewRegister::~_TableViewRegister()
1352 {
1353         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1354         pUiBuilderControlTableManager->UnregisterControl(L"TableView");
1355 }
1356
1357 _GroupedTableViewRegister::_GroupedTableViewRegister()
1358 {
1359         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1360         pUiBuilderControlTableManager->RegisterControl(L"GroupedTableView", _GroupedTableViewMaker::GetInstance);
1361 }
1362 _GroupedTableViewRegister::~_GroupedTableViewRegister()
1363 {
1364         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1365         pUiBuilderControlTableManager->UnregisterControl(L"GroupedTableView");
1366 }
1367
1368 _SectionTableViewRegister::_SectionTableViewRegister()
1369 {
1370         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1371         pUiBuilderControlTableManager->RegisterControl(L"SectionTableView", _SectionTableViewMaker::GetInstance);
1372 }
1373 _SectionTableViewRegister::~_SectionTableViewRegister()
1374 {
1375         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1376         pUiBuilderControlTableManager->UnregisterControl(L"SectionTableView");
1377 }
1378
1379
1380 static _TableViewRegister TableViewRegisterToUiBuilder;
1381 static _GroupedTableViewRegister GroupedTableViewRegisterToUiBuilder;
1382 static _SectionTableViewRegister SectionTableViewRegisterToUiBuilder;
1383
1384
1385 }}} // Tizen::Ui::Controls