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