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.
18 * @file FUiVerticalBoxLayout.cpp
19 * @brief This is the implementation file for VerticalBoxLayout class.
21 * This file contains the implementation of VerticalBoxLayout class.
24 #include <FUiVerticalBoxLayout.h>
25 #include <FUiControl.h>
26 #include <FApp_AppInfo.h>
27 #include "FUi_VerticalBoxLayoutImpl.h"
28 #include "FUi_CoordinateSystemUtils.h"
30 namespace Tizen { namespace Ui
33 VerticalBoxLayout::VerticalBoxLayout()
37 VerticalBoxLayout::~VerticalBoxLayout()
42 VerticalBoxLayout::Construct(VerticalDirection direction)
46 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
47 SysAssertf(pVerticalBoxLayoutImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
49 pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::CreateVerticalBoxLayoutImplN(this, direction);
50 result r = GetLastResult();
51 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
53 _LayoutImpl::SetLayoutImpl(this, pVerticalBoxLayoutImpl);
59 VerticalBoxLayout::GetLayoutType(void) const
61 return LAYOUT_VERTICAL_BOX;
65 VerticalBoxLayout::GetDirection(VerticalDirection& direction) const
69 const _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
70 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
72 result r = pVerticalBoxLayoutImpl->GetDirection(direction);
73 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
79 VerticalBoxLayout::SetHorizontalAlignment(Control& childControl, LayoutHorizontalAlignment alignment)
83 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
84 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
86 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
87 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
89 result r = pVerticalBoxLayoutImpl->SetHorizontalAlignment(*pControlImpl, alignment);
90 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
96 VerticalBoxLayout::SetSpacing(Control& childControl, int space)
100 SysTryReturn(NID_UI, space >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
102 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
103 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
105 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
106 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
108 result r = pVerticalBoxLayoutImpl->SetSpacing(*pControlImpl, _CoordinateSystemUtils::ConvertToFloat(space));
109 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
115 VerticalBoxLayout::SetSpacing(Control& childControl, float space)
119 SysTryReturn(NID_UI, space >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
121 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
122 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
124 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
125 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
127 result r = pVerticalBoxLayoutImpl->SetSpacing(*pControlImpl, space);
128 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
134 VerticalBoxLayout::SetHorizontalMargin(Control& childControl, int left, int right)
138 SysTryReturn(NID_UI, (left >= 0) && (right >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
140 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
141 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
143 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
144 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
146 float floatLeft = _CoordinateSystemUtils::ConvertToFloat(left);
147 float floatRight = _CoordinateSystemUtils::ConvertToFloat(right);
148 result r = pVerticalBoxLayoutImpl->SetHorizontalMargin(*pControlImpl, floatLeft, floatRight);
149 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
155 VerticalBoxLayout::SetHorizontalMargin(Control& childControl, float left, float right)
159 SysTryReturn(NID_UI, (left >= 0) && (right >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
161 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
162 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
164 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
165 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
167 result r = pVerticalBoxLayoutImpl->SetHorizontalMargin(*pControlImpl, left, right);
168 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
174 VerticalBoxLayout::SetWidth(Control& childControl, int width)
178 SysTryReturn(NID_UI, width >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
180 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
181 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
183 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
184 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
186 result r = pVerticalBoxLayoutImpl->SetWidth(*pControlImpl, _CoordinateSystemUtils::ConvertToFloat(width));
187 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
193 VerticalBoxLayout::SetWidth(Control& childControl, float width)
197 SysTryReturn(NID_UI, width >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
199 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
200 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
202 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
203 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
205 result r = pVerticalBoxLayoutImpl->SetWidth(*pControlImpl, width);
206 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
212 VerticalBoxLayout::SetHorizontalFitPolicy(Control& childControl, FitPolicy policy)
216 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
217 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
219 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
220 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
222 result r = pVerticalBoxLayoutImpl->SetItemHorizontalFitPolicy(*pControlImpl, policy);
223 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
229 VerticalBoxLayout::SetHeight(Control& childControl, int height)
233 SysTryReturn(NID_UI, height >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
235 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
236 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
238 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
239 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
241 result r = pVerticalBoxLayoutImpl->SetHeight(*pControlImpl, _CoordinateSystemUtils::ConvertToFloat(height));
242 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
248 VerticalBoxLayout::SetHeight(Control& childControl, float height)
252 SysTryReturn(NID_UI, height >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
254 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
255 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
257 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
258 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
260 result r = pVerticalBoxLayoutImpl->SetHeight(*pControlImpl, height);
261 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
267 VerticalBoxLayout::SetVerticalFitPolicy(Control& childControl, FitPolicy policy)
271 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
272 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
274 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
275 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
277 if (!Tizen::App::_AppInfo::IsOspCompat())
279 if (policy == FIT_POLICY_PARENT)
285 result r = pVerticalBoxLayoutImpl->SetItemVerticalFitPolicy(*pControlImpl, policy);
286 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
292 VerticalBoxLayout::SetWeight(Control& childControl, float weight)
296 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
297 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
299 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
300 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
302 SysTryReturn(NID_UI, weight >= 0.0f, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.\n")
304 result r = pVerticalBoxLayoutImpl->SetWeight(*pControlImpl, weight);
305 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));