Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlTab.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                FUiCtrlTab.cpp
20  * @brief               This is the implementation file for Tab class.
21  *
22  * This file contains the implementation of Tab class.
23  */
24
25 #include <FUiCtrlTab.h>
26 #include "FUiCtrl_TabImpl.h"
27
28 // using namespaces
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Base::Runtime;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35
36
37 namespace Tizen { namespace Ui { namespace Controls
38 {
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Tab class Lifecycle
41
42 Tab::Tab(void)
43 {
44
45 }
46
47 Tab::~Tab(void)
48 {
49
50 }
51
52
53 result
54 Tab::Construct(void)
55 {
56         result r = E_SUCCESS;
57
58         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
59
60         SysAssertf(pTabImpl == null,
61                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
62
63         pTabImpl = _TabImpl::CreateTabImplN(this);
64         r = GetLastResult();
65         SysTryReturn(NID_UI_CTRL, pTabImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
66
67         _pControlImpl = pTabImpl;
68
69         return E_SUCCESS;
70 }
71
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Tab class Operation
74 void
75 Tab::AddActionEventListener(IActionEventListener& listener)
76 {
77         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
78
79         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
80
81         pTabImpl->AddActionEventListener(listener);
82 }
83
84
85 void
86 Tab::RemoveActionEventListener(IActionEventListener& listener)
87 {
88         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
89
90         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
91
92         pTabImpl->RemoveActionEventListener(listener);
93 }
94
95 result
96 Tab::AddItem(const String& text, int actionId)
97 {
98         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
99         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
100
101         return pTabImpl->AddItem(text, actionId);
102 }
103
104 result
105 Tab::AddItem(const Bitmap& titleIcon, const String& text, int actionId)
106 {
107         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
108         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
109
110         return pTabImpl->AddItem(titleIcon, text, actionId);
111 }
112
113 result
114 Tab::AddItem(const Bitmap& icon, int actionId)
115 {
116         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
117         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
118
119         return pTabImpl->AddItem(icon, actionId);
120 }
121
122 result
123 Tab::InsertItemAt(int index, const String& text, int actionId)
124 {
125         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
126         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
127
128         return pTabImpl->InsertItemAt(index, text, actionId);
129 }
130
131 result
132 Tab::InsertItemAt(int index, const Bitmap& titleIcon, const String& text, int actionId)
133 {
134         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
135         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
136
137         return pTabImpl->InsertItemAt(index, titleIcon, text, actionId);
138 }
139
140 result
141 Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
142 {
143         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
144         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
145
146         return pTabImpl->InsertItemAt(index, icon, actionId);
147 }
148
149 result
150 Tab::SetItemAt(int index, const String& text, int actionId)
151 {
152         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
153         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
154
155         return pTabImpl->SetItemAt(index, text, actionId);
156 }
157
158 result
159 Tab::SetItemAt(int index, const Bitmap& titleIcon, const String& text, int actionId)
160 {
161         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
162         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
163
164         return pTabImpl->SetItemAt(index, titleIcon, text, actionId);
165 }
166
167 result
168 Tab::SetItemAt(int index, const Bitmap& icon, int actionId)
169 {
170         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
171         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
172
173         return pTabImpl->SetItemAt(index, icon, actionId);
174 }
175
176 result
177 Tab::RemoveItemAt(int index)
178 {
179         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
180         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
181
182         return pTabImpl->RemoveItemAt(index);
183 }
184
185
186 result
187 Tab::RemoveAllItems(void)
188 {
189         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
190         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
191
192         return pTabImpl->RemoveAllItems();
193 }
194
195
196 result
197 Tab::SetBadgeIcon(int actionId, const Tizen::Graphics::Bitmap* pBadgeIcon)
198 {
199         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
200         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
201
202         return pTabImpl->SetBadgeIcon(actionId, pBadgeIcon);
203 }
204
205 int
206 Tab::GetItemCount(void) const
207 {
208         const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
209         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
210
211         return pTabImpl->GetItemCount();
212 }
213
214 int
215 Tab::GetItemIndexFromActionId(int actionId) const
216 {
217         const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
218         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
219
220         return pTabImpl->GetItemIndexFromActionId(actionId);
221 }
222
223 int
224 Tab::GetItemActionIdAt(int index) const
225 {
226         const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
227         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
228
229         return pTabImpl->GetItemActionIdAt(index);
230 }
231
232 void
233 Tab::SetSelectedItem(int index)
234 {
235         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
236         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
237
238         pTabImpl->SetSelectedItem(index);
239 }
240
241 int
242 Tab::GetSelectedItemIndex(void) const
243 {
244         const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
245         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
246
247         return pTabImpl->GetSelectedItemIndex();
248 }
249
250 void
251 Tab::SetEditModeEnabled(bool enable)
252 {
253         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
254         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
255
256         pTabImpl->SetEditModeEnabled(enable);
257 }
258
259 bool
260 Tab::IsEditModeEnabled(void) const
261 {
262         const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
263         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
264
265         return pTabImpl->IsEditModeEnabled();
266 }
267
268 result
269 Tab::SetBackgroundBitmap(const Bitmap& bitmap)
270 {
271         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
272         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
273
274         return pTabImpl->SetBackgroundBitmap(bitmap);
275 }
276
277 result
278 Tab::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap)
279 {
280         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
281         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
282
283         return pTabImpl->SetFocusedItemBackgroundBitmap(bitmap);
284 }
285
286 void
287 Tab::SetTextColor(const Color& color)
288 {
289         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
290         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
291
292         pTabImpl->SetTextColor(color);
293 }
294
295 Color
296 Tab::GetTextColor(void) const
297 {
298         const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
299         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
300
301         return pTabImpl->GetTextColor();
302 }
303
304 void
305 Tab::SetSelectedTextColor(const Color& color)
306 {
307         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
308         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
309
310         pTabImpl->SetSelectedTextColor(color);
311 }
312
313 Color
314 Tab::GetSelectedTextColor(void) const
315 {
316         const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
317         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
318
319         return pTabImpl->GetSelectedTextColor();
320 }
321
322 void
323 Tab::SetHighlightedTextColor(const Color& color)
324 {
325         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
326         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
327
328         pTabImpl->SetHighlightedTextColor(color);
329 }
330
331 Color
332 Tab::GetHighlightedTextColor(void) const
333 {
334         const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
335         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
336
337         return pTabImpl->GetHighlightedTextColor();
338 }
339
340 result
341 Tab::SetHighlightedItemBackgroundBitmap (const Bitmap& bitmap)
342 {
343         _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
344         SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
345
346         return pTabImpl->SetHighlightedItemBackgroundBitmap(bitmap);
347 }
348
349 }}} //Tizen::Ui::Controls