Changed indicator bg color.
[platform/framework/native/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 Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
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 #include "FUi_CoordinateSystemUtils.h"
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 TableViewItem::TableViewItem(void)
35         : TableViewItemBase()
36 {
37         // empty statement
38 }
39
40 TableViewItem::~TableViewItem(void)
41 {
42         // empty statement
43 }
44
45 result
46 TableViewItem::Construct(const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style)
47 {
48         return Construct(_CoordinateSystemUtils::ConvertToFloat(itemSize), style);
49 }
50
51 result
52 TableViewItem::Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style)
53 {
54         return Construct(layout, layout, _CoordinateSystemUtils::ConvertToFloat(itemSize), style);
55 }
56
57 result
58 TableViewItem::Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style)
59 {
60         return Construct(portraitLayout, landscapeLayout, _CoordinateSystemUtils::ConvertToFloat(itemSize), style);
61 }
62
63 result
64 TableViewItem::Construct(const Tizen::Graphics::FloatDimension& itemSize, TableViewAnnexStyle style)
65 {
66         result r = E_SUCCESS;
67         _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this);
68         SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
69
70         pImpl = _TableViewItemImpl::CreateTableViewItemImplN(this, itemSize, style);
71         r = GetLastResult();
72         SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
73
74         _pControlImpl = pImpl;
75
76         return r;
77 }
78
79 result
80 TableViewItem::Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::FloatDimension& itemSize, TableViewAnnexStyle style)
81 {
82         return Construct(layout, layout, itemSize, style);
83 }
84
85 result
86 TableViewItem::Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::FloatDimension& itemSize, TableViewAnnexStyle style)
87 {
88         result r = E_SUCCESS;
89         _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this);
90         SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
91
92         pImpl = _TableViewItemImpl::CreateTableViewItemImplN(this, itemSize, style, &(const_cast <Layout&>(portraitLayout)), &(const_cast <Layout&>(landscapeLayout)));
93         r = GetLastResult();
94         SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
95
96         _pControlImpl = pImpl;
97
98         return r;
99 }
100
101 void
102 TableViewItem::SetContextItem(const TableViewContextItem* pItem)
103 {
104         _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this);
105         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
106
107         _TableViewItemImpl* pItemImpl = null;
108         if (pItem != null)
109         {
110                 pItemImpl = const_cast<_TableViewItemImpl*>(_TableViewItemImpl::GetInstance(*pItem));
111         }
112
113         pImpl->SetContextItem(pItemImpl);
114 }
115
116 int
117 TableViewItem::GetAnnexWidth(TableViewAnnexStyle style)
118 {
119         return _CoordinateSystemUtils::ConvertToInteger(_TableViewItemImpl::GetAnnexWidth(style));
120 }
121
122 float
123 TableViewItem::GetAnnexWidthF(TableViewAnnexStyle style)
124 {
125         return _TableViewItemImpl::GetAnnexWidth(style);
126 }
127
128 }}} // Tizen::Ui::Controls