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 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"
29 namespace Tizen { namespace Ui
32 VerticalBoxLayout::VerticalBoxLayout()
36 VerticalBoxLayout::~VerticalBoxLayout()
41 VerticalBoxLayout::Construct(VerticalDirection direction)
45 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
46 SysAssertf(pVerticalBoxLayoutImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
48 pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::CreateVerticalBoxLayoutImplN(this, direction);
49 result r = GetLastResult();
50 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
52 _LayoutImpl::SetLayoutImpl(this, pVerticalBoxLayoutImpl);
58 VerticalBoxLayout::GetLayoutType(void) const
60 return LAYOUT_VERTICAL_BOX;
64 VerticalBoxLayout::GetDirection(VerticalDirection& direction) const
68 const _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
69 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
71 result r = pVerticalBoxLayoutImpl->GetDirection(direction);
72 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
78 VerticalBoxLayout::SetHorizontalAlignment(Control& childControl, LayoutHorizontalAlignment alignment)
82 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
83 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
85 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
86 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
88 result r = pVerticalBoxLayoutImpl->SetHorizontalAlignment(*pControlImpl, alignment);
89 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
95 VerticalBoxLayout::SetSpacing(Control& childControl, int space)
99 SysTryReturn(NID_UI, space >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
101 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
102 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
104 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
105 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
107 result r = pVerticalBoxLayoutImpl->SetSpacing(*pControlImpl, space);
108 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
114 VerticalBoxLayout::SetHorizontalMargin(Control& childControl, int left, int right)
118 SysTryReturn(NID_UI, (left >= 0) && (right >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
120 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
121 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
123 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
124 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
126 result r = pVerticalBoxLayoutImpl->SetHorizontalMargin(*pControlImpl, left, right);
127 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
133 VerticalBoxLayout::SetWidth(Control& childControl, int width)
137 SysTryReturn(NID_UI, width >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
139 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
140 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
142 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
143 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
145 result r = pVerticalBoxLayoutImpl->SetWidth(*pControlImpl, width);
146 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
152 VerticalBoxLayout::SetHorizontalFitPolicy(Control& childControl, FitPolicy policy)
156 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
157 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
159 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
160 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
162 result r = pVerticalBoxLayoutImpl->SetItemHorizontalFitPolicy(*pControlImpl, policy);
163 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
169 VerticalBoxLayout::SetHeight(Control& childControl, int height)
173 SysTryReturn(NID_UI, height >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.");
175 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
176 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
178 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
179 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
181 result r = pVerticalBoxLayoutImpl->SetHeight(*pControlImpl, height);
182 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
188 VerticalBoxLayout::SetVerticalFitPolicy(Control& childControl, FitPolicy policy)
192 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
193 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
195 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
196 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
198 if (!Tizen::App::_AppInfo::IsOspCompat())
200 if (policy == FIT_POLICY_PARENT)
206 result r = pVerticalBoxLayoutImpl->SetItemVerticalFitPolicy(*pControlImpl, policy);
207 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
213 VerticalBoxLayout::SetWeight(Control& childControl, float weight)
217 _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this);
218 SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
220 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
221 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
223 SysTryReturn(NID_UI, weight >= 0.0f, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.\n")
225 result r = pVerticalBoxLayoutImpl->SetWeight(*pControlImpl, weight);
226 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));