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 FUiCtrlTabBar.cpp
19 * @brief This file contains implementation of TabBar class
22 #include <FUiCtrlTabBar.h>
23 #include <FUiCtrlTabBarItem.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_TabBarItemImpl.h"
26 #include "FUiCtrl_TabBarImpl.h"
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui::Controls;
31 namespace Tizen { namespace Ui { namespace Controls
45 TabBar::Construct(int x, int y, int width)
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.");
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));
55 _pControlImpl = pImpl;
61 TabBar::AddItem(const TabBarItem& item)
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");
68 return pImpl->AddItem(item.GetText(), item.GetActionId());
72 TabBar::InsertItemAt(int index, const TabBarItem& item)
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");
79 return pImpl->InsertItemAt(index, item.GetText(), item.GetActionId());
82 Tizen::Graphics::Color
83 TabBar::GetColor(void) const
85 const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
86 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
88 return pImpl->GetColor();
92 TabBar::GetItemCount(void) const
94 const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
95 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
97 return pImpl->GetItemCount();
100 Tizen::Graphics::Color
101 TabBar::GetSelectedItemColor(void) const
103 const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
104 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
106 return pImpl->GetSelectedItemColor();
109 Tizen::Graphics::Color
110 TabBar::GetItemTextColor(TabBarItemStatus status) const
112 const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
113 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
115 return pImpl->GetItemTextColor(status);
119 TabBar::GetSelectedItemIndex(void) const
121 const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
122 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
124 return pImpl->GetSelectedItemIndex();
128 TabBar::RemoveItemAt(int index)
130 _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
131 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
133 return pImpl->RemoveItemAt(index);
137 TabBar::RemoveAllItems(void)
139 _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
140 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
142 return pImpl->RemoveAllItems();
146 TabBar::SetColor(const Tizen::Graphics::Color& color)
148 _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
149 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
151 return pImpl->SetColor(color);
155 TabBar::SetItemAt(int index, const TabBarItem& item)
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");
162 return pImpl->SetItemAt(index, item.GetText(), item.GetActionId());
166 TabBar::SetItemSelected(int index)
168 _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
169 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
171 return pImpl->SetItemSelected(index);
175 TabBar::SetItemTextColor(TabBarItemStatus status, const Tizen::Graphics::Color& color)
177 _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
178 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
180 return pImpl->SetItemTextColor(status, color);
184 TabBar::SetSelectedItemColor(const Tizen::Graphics::Color& color)
186 _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
187 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
189 return pImpl->SetSelectedItemColor(color);
193 TabBar::SetWidth(int width)
195 _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
196 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
198 return pImpl->SetWidth(width);
202 TabBar::AddActionEventListener(Tizen::Ui::IActionEventListener& listener)
204 _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
205 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
207 pImpl->AddActionEventListener(listener);
212 TabBar::RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener)
214 _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this);
215 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
217 pImpl->RemoveActionEventListener(listener);
220 }}} // Tizen::Ui::Controls