2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
18 * @file FUiCtrlTab.cpp
19 * @brief This is the implementation file for Tab class.
21 * This file contains the implementation of Tab class.
24 #include <FUiCtrlTab.h>
25 #include "FUiCtrl_TabImpl.h"
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;
36 namespace Tizen { namespace Ui { namespace Controls
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Tab class Lifecycle
57 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
59 SysAssertf(pTabImpl == null,
60 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
62 pTabImpl = _TabImpl::CreateTabImplN(this);
64 SysTryReturn(NID_UI_CTRL, pTabImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
66 _pControlImpl = pTabImpl;
71 ////////////////////////////////////////////////////////////////////////////////
72 /// Tab class Operation
74 Tab::AddActionEventListener(IActionEventListener& listener)
76 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
78 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
80 pTabImpl->AddActionEventListener(listener);
85 Tab::RemoveActionEventListener(IActionEventListener& listener)
87 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
89 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
91 pTabImpl->RemoveActionEventListener(listener);
95 Tab::AddItem(const String& text, int actionId)
97 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
98 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
100 return pTabImpl->AddItem(text, actionId);
104 Tab::AddItem(const Bitmap& titleIcon, const String& text, int actionId)
106 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
107 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
109 return pTabImpl->AddItem(titleIcon, text, actionId);
113 Tab::AddItem(const Bitmap& icon, int actionId)
115 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
116 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
118 return pTabImpl->AddItem(icon, actionId);
122 Tab::InsertItemAt(int index, const String& text, int actionId)
124 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
125 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
127 return pTabImpl->InsertItemAt(index, text, actionId);
131 Tab::InsertItemAt(int index, const Bitmap& titleIcon, const String& text, int actionId)
133 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
134 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
136 return pTabImpl->InsertItemAt(index, titleIcon, text, actionId);
140 Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
142 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
143 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
145 return pTabImpl->InsertItemAt(index, icon, actionId);
149 Tab::SetItemAt(int index, const String& text, int actionId)
151 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
152 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
154 return pTabImpl->SetItemAt(index, text, actionId);
158 Tab::SetItemAt(int index, const Bitmap& titleIcon, const String& text, int actionId)
160 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
161 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
163 return pTabImpl->SetItemAt(index, titleIcon, text, actionId);
167 Tab::SetItemAt(int index, const Bitmap& icon, int actionId)
169 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
170 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
172 return pTabImpl->SetItemAt(index, icon, actionId);
176 Tab::RemoveItemAt(int index)
178 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
179 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
181 return pTabImpl->RemoveItemAt(index);
186 Tab::RemoveAllItems(void)
188 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
189 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
191 return pTabImpl->RemoveAllItems();
196 Tab::SetBadgeIcon(int actionId, const Tizen::Graphics::Bitmap* pBadgeIcon)
198 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
199 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
201 return pTabImpl->SetBadgeIcon(actionId, pBadgeIcon);
205 Tab::GetItemCount(void) const
207 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
208 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
210 return pTabImpl->GetItemCount();
214 Tab::GetItemIndexFromActionId(int actionId) const
216 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
217 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
219 return pTabImpl->GetItemIndexFromActionId(actionId);
223 Tab::GetItemActionIdAt(int index) const
225 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
226 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
228 return pTabImpl->GetItemActionIdAt(index);
232 Tab::SetSelectedItem(int index)
234 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
235 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
237 pTabImpl->SetSelectedItem(index);
241 Tab::GetSelectedItemIndex(void) const
243 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
244 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
246 return pTabImpl->GetSelectedItemIndex();
250 Tab::SetEditModeEnabled(bool enable)
252 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
253 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
255 pTabImpl->SetEditModeEnabled(enable);
259 Tab::IsEditModeEnabled(void) const
261 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
262 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
264 return pTabImpl->IsEditModeEnabled();
268 Tab::SetBackgroundBitmap(const Bitmap& bitmap)
270 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
271 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
273 return pTabImpl->SetBackgroundBitmap(bitmap);
277 Tab::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap)
279 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
280 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
282 return pTabImpl->SetFocusedItemBackgroundBitmap(bitmap);
286 Tab::SetTextColor(const Color& color)
288 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
289 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
291 pTabImpl->SetTextColor(color);
295 Tab::GetTextColor(void) const
297 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
298 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
300 return pTabImpl->GetTextColor();
304 Tab::SetSelectedTextColor(const Color& color)
306 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
307 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
309 pTabImpl->SetSelectedTextColor(color);
313 Tab::GetSelectedTextColor(void) const
315 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
316 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
318 return pTabImpl->GetSelectedTextColor();
322 Tab::SetHighlightedTextColor(const Color& color)
324 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
325 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
327 pTabImpl->SetHighlightedTextColor(color);
331 Tab::GetHighlightedTextColor(void) const
333 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
334 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
336 return pTabImpl->GetHighlightedTextColor();
340 Tab::SetHighlightedItemBackgroundBitmap (const Bitmap& bitmap)
342 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
343 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
345 return pTabImpl->SetHighlightedItemBackgroundBitmap(bitmap);
348 }}} //Tizen::Ui::Controls