Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrlTableViewItem.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         FUiCtrlTableViewItem.cpp
20 * @brief        This file contains implementation of TableViewItem class
21 */
22
23
24 //includes
25 #include <FUiCtrlTableViewItem.h>
26 #include <FUiCtrlTableViewContextItem.h>
27 #include "FUiCtrl_TableViewItemImpl.h"
28 #include "FUiCtrl_ListItemBaseImpl.h"
29
30 namespace Tizen { namespace Ui { namespace Controls
31 {
32
33 TableViewItem::TableViewItem(void)
34         : TableViewItemBase()
35 {
36         // empty statement
37 }
38
39 TableViewItem::~TableViewItem(void)
40 {
41         // empty statement
42 }
43
44 result
45 TableViewItem::Construct(const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style)
46 {
47         result r = E_SUCCESS;
48         _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this);
49         SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
50
51         pImpl = _TableViewItemImpl::CreateTableViewItemImplN(this, itemSize, style);
52         r = GetLastResult();
53         SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
54
55         _pControlImpl = pImpl;
56
57         return r;
58 }
59
60 result
61 TableViewItem::Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style)
62 {
63         return Construct(layout, layout, itemSize, style);
64 }
65
66 result
67 TableViewItem::Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style)
68 {
69         result r = E_SUCCESS;
70         _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this);
71         SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
72
73         pImpl = _TableViewItemImpl::CreateTableViewItemImplN(this, itemSize, style, &(const_cast <Layout&>(portraitLayout)), &(const_cast <Layout&>(landscapeLayout)));
74         r = GetLastResult();
75         SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
76
77         _pControlImpl = pImpl;
78
79         return r;
80 }
81
82 void
83 TableViewItem::SetContextItem(const TableViewContextItem* pItem)
84 {
85         _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this);
86         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
87
88         _TableViewItemImpl* pItemImpl = null;
89         if (pItem != null)
90         {
91                 pItemImpl = const_cast<_TableViewItemImpl*>(_TableViewItemImpl::GetInstance(*pItem));
92         }
93
94         pImpl->SetContextItem(pItemImpl);
95 }
96
97 int
98 TableViewItem::GetAnnexWidth(TableViewAnnexStyle style)
99 {
100         return _TableViewItemImpl::GetAnnexWidth(style);
101 }
102
103 }}} // Tizen::Ui::Controls