Fork for IVI: mesa fixing
[profile/ivi/uifw.git] / src / ui / controls / FUiCtrlTabBar.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 * @file         FUiCtrlTabBar.cpp
19 * @brief        This file contains implementation of TabBar class
20 */
21
22 #include <FUiCtrlTabBar.h>
23 #include <FUiCtrlTabBarItem.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_TabBarItemImpl.h"
26 #include "FUiCtrl_TabBarImpl.h"
27
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui::Controls;
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 TabBar::TabBar(void)
35 {
36 }
37
38
39 TabBar::~TabBar(void)
40 {
41 }
42
43
44 result
45 TabBar::Construct(int x, int y, int width)
46 {
47         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
48         SysAssertf(pImpl == null,
49                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
50
51         pImpl = _TabBarImpl::CreateTabBarImplN(this, Rectangle(x, y, width, 0));
52         result r = GetLastResult();
53         SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
54
55         _pControlImpl = pImpl;
56
57         return r;
58 }
59
60 result
61 TabBar::AddItem(const TabBarItem& item)
62 {
63         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
64         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
65         SysTryReturn(NID_UI_CTRL, item.__pTabBarItemImpl != null, E_INVALID_ARG, E_INVALID_ARG,
66                         "[E_INVALID_ARG] Input TabBarItem is not constructed.\n");
67
68         return pImpl->AddItem(item.GetText(), item.GetActionId());
69 }
70
71 result
72 TabBar::InsertItemAt(int index, const TabBarItem& item)
73 {
74         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
75         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
76         SysTryReturn(NID_UI_CTRL, item.__pTabBarItemImpl != null, E_INVALID_ARG, E_INVALID_ARG,
77                         "[E_INVALID_ARG] Input TabBarItem is not constructed.\n");
78
79         return pImpl->InsertItemAt(index, item.GetText(), item.GetActionId());
80 }
81
82 Tizen::Graphics::Color
83 TabBar::GetColor(void) const
84 {
85         const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
86         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
87
88         return pImpl->GetColor();
89 }
90
91 int
92 TabBar::GetItemCount(void) const
93 {
94         const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
95         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
96
97         return pImpl->GetItemCount();
98 }
99
100 Tizen::Graphics::Color
101 TabBar::GetSelectedItemColor(void) const
102 {
103         const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
104         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
105
106         return pImpl->GetSelectedItemColor();
107 }
108
109 Tizen::Graphics::Color
110 TabBar::GetItemTextColor(TabBarItemStatus status) const
111 {
112         const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
113         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
114
115         return pImpl->GetItemTextColor(status);
116 }
117
118 int
119 TabBar::GetSelectedItemIndex(void) const
120 {
121         const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
122         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
123
124         return pImpl->GetSelectedItemIndex();
125 }
126
127 result
128 TabBar::RemoveItemAt(int index)
129 {
130         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
131         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
132
133         return pImpl->RemoveItemAt(index);
134 }
135
136 result
137 TabBar::RemoveAllItems(void)
138 {
139         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
140         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
141
142         return pImpl->RemoveAllItems();
143 }
144
145 result
146 TabBar::SetColor(const Tizen::Graphics::Color& color)
147 {
148         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
149         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
150
151         return pImpl->SetColor(color);
152 }
153
154 result
155 TabBar::SetItemAt(int index, const TabBarItem& item)
156 {
157         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
158         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
159         SysTryReturn(NID_UI_CTRL, item.__pTabBarItemImpl != null, E_INVALID_ARG, E_INVALID_ARG,
160                         "[E_INVALID_ARG] Input TabBarItem is not constructed.\n");
161
162         return pImpl->SetItemAt(index, item.GetText(), item.GetActionId());
163 }
164
165 result
166 TabBar::SetItemSelected(int index)
167 {
168         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
169         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
170
171         return pImpl->SetItemSelected(index);
172 }
173
174 result
175 TabBar::SetItemTextColor(TabBarItemStatus status, const Tizen::Graphics::Color& color)
176 {
177         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
178         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
179
180         return pImpl->SetItemTextColor(status, color);
181 }
182
183 result
184 TabBar::SetSelectedItemColor(const Tizen::Graphics::Color& color)
185 {
186         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
187         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
188
189         return pImpl->SetSelectedItemColor(color);
190 }
191
192 result
193 TabBar::SetWidth(int width)
194 {
195         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
196         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
197
198         return pImpl->SetWidth(width);
199 }
200
201 void
202 TabBar::AddActionEventListener(Tizen::Ui::IActionEventListener& listener)
203 {
204         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
205         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
206
207         pImpl->AddActionEventListener(listener);
208 }
209
210
211 void
212 TabBar::RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener)
213 {
214         _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
215         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
216
217         pImpl->RemoveActionEventListener(listener);
218 }
219
220 }}} // Tizen::Ui::Controls