2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUiCtrlTab.cpp
20 * @brief This is the implementation file for Tab class.
22 * This file contains the implementation of Tab class.
25 #include <FUiCtrlTab.h>
26 #include "FUiCtrl_TabImpl.h"
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;
37 namespace Tizen { namespace Ui { namespace Controls
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Tab class Lifecycle
58 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
60 SysAssertf(pTabImpl == null,
61 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
63 pTabImpl = _TabImpl::CreateTabImplN(this);
65 SysTryReturn(NID_UI_CTRL, pTabImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
67 _pControlImpl = pTabImpl;
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Tab class Operation
75 Tab::AddActionEventListener(IActionEventListener& listener)
77 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
79 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
81 pTabImpl->AddActionEventListener(listener);
86 Tab::RemoveActionEventListener(IActionEventListener& listener)
88 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
90 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
92 pTabImpl->RemoveActionEventListener(listener);
96 Tab::AddItem(const String& text, int actionId)
98 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
99 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
101 return pTabImpl->AddItem(text, actionId);
105 Tab::AddItem(const Bitmap& titleIcon, const String& text, int actionId)
107 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
108 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
110 return pTabImpl->AddItem(titleIcon, text, actionId);
114 Tab::AddItem(const Bitmap& icon, int actionId)
116 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
117 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
119 return pTabImpl->AddItem(icon, actionId);
123 Tab::InsertItemAt(int index, const String& text, int actionId)
125 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
126 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
128 return pTabImpl->InsertItemAt(index, text, actionId);
132 Tab::InsertItemAt(int index, const Bitmap& titleIcon, const String& text, int actionId)
134 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
135 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
137 return pTabImpl->InsertItemAt(index, titleIcon, text, actionId);
141 Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
143 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
144 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
146 return pTabImpl->InsertItemAt(index, icon, actionId);
150 Tab::SetItemAt(int index, const String& text, int actionId)
152 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
153 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
155 return pTabImpl->SetItemAt(index, text, actionId);
159 Tab::SetItemAt(int index, const Bitmap& titleIcon, const String& text, int actionId)
161 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
162 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
164 return pTabImpl->SetItemAt(index, titleIcon, text, actionId);
168 Tab::SetItemAt(int index, const Bitmap& icon, int actionId)
170 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
171 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
173 return pTabImpl->SetItemAt(index, icon, actionId);
177 Tab::RemoveItemAt(int index)
179 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
180 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
182 return pTabImpl->RemoveItemAt(index);
187 Tab::RemoveAllItems(void)
189 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
190 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
192 return pTabImpl->RemoveAllItems();
197 Tab::SetBadgeIcon(int actionId, const Tizen::Graphics::Bitmap* pBadgeIcon)
199 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
200 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
202 return pTabImpl->SetBadgeIcon(actionId, pBadgeIcon);
206 Tab::GetItemCount(void) const
208 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
209 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
211 return pTabImpl->GetItemCount();
215 Tab::GetItemIndexFromActionId(int actionId) const
217 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
218 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
220 return pTabImpl->GetItemIndexFromActionId(actionId);
224 Tab::GetItemActionIdAt(int index) const
226 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
227 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
229 return pTabImpl->GetItemActionIdAt(index);
233 Tab::SetSelectedItem(int index)
235 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
236 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
238 pTabImpl->SetSelectedItem(index);
242 Tab::GetSelectedItemIndex(void) const
244 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
245 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
247 return pTabImpl->GetSelectedItemIndex();
251 Tab::SetEditModeEnabled(bool enable)
253 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
254 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
256 pTabImpl->SetEditModeEnabled(enable);
260 Tab::IsEditModeEnabled(void) const
262 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
263 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
265 return pTabImpl->IsEditModeEnabled();
269 Tab::SetBackgroundBitmap(const Bitmap& bitmap)
271 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
272 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
274 return pTabImpl->SetBackgroundBitmap(bitmap);
278 Tab::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap)
280 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
281 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
283 return pTabImpl->SetFocusedItemBackgroundBitmap(bitmap);
287 Tab::SetTextColor(const Color& color)
289 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
290 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
292 pTabImpl->SetTextColor(color);
296 Tab::GetTextColor(void) const
298 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
299 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
301 return pTabImpl->GetTextColor();
305 Tab::SetSelectedTextColor(const Color& color)
307 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
308 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
310 pTabImpl->SetSelectedTextColor(color);
314 Tab::GetSelectedTextColor(void) const
316 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
317 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
319 return pTabImpl->GetSelectedTextColor();
323 Tab::SetHighlightedTextColor(const Color& color)
325 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
326 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
328 pTabImpl->SetHighlightedTextColor(color);
332 Tab::GetHighlightedTextColor(void) const
334 const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
335 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
337 return pTabImpl->GetHighlightedTextColor();
341 Tab::SetHighlightedItemBackgroundBitmap (const Bitmap& bitmap)
343 _TabImpl* pTabImpl = _TabImpl::GetInstance(*this);
344 SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use.");
346 return pTabImpl->SetHighlightedItemBackgroundBitmap(bitmap);
349 }}} //Tizen::Ui::Controls