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 FUiRelativeLayout.cpp
19 * @brief This is the implementation file for RelativeLayout class.
21 * This file contains the implementation of RelativeLayout class.
24 #include <FUiRelativeLayout.h>
25 #include <FUiControl.h>
26 #include "FUi_RelativeLayoutImpl.h"
28 namespace Tizen { namespace Ui
31 RelativeLayout::RelativeLayout()
35 RelativeLayout::~RelativeLayout()
40 RelativeLayout::Construct(void)
44 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
45 SysAssertf(pRelativeLayoutImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
47 pRelativeLayoutImpl = _RelativeLayoutImpl::CreateRelativeLayoutImplN(this);
48 result r = GetLastResult();
49 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
51 _LayoutImpl::SetLayoutImpl(this, pRelativeLayoutImpl);
57 RelativeLayout::GetLayoutType(void) const
59 return LAYOUT_RELATIVE;
63 RelativeLayout::SetRelation(Control& childControl, const Control& targetControl, RectangleEdgeRelation edgeRelation)
67 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
68 SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
70 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
71 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
73 _ControlImpl* pTargetControlImpl = const_cast<_ControlImpl*>(_ControlImpl::GetInstance(targetControl));
74 SysTryReturn(NID_UI, pTargetControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
78 r = pRelativeLayoutImpl->SetRelation(*pControlImpl, *pTargetControlImpl, edgeRelation);
79 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
85 RelativeLayout::ResetRelation(Control& childControl, RectangleEdgeType edgeType)
89 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
90 SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
92 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
93 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
95 result r = pRelativeLayoutImpl->ResetRelation(*pControlImpl, edgeType);
96 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
102 RelativeLayout::SetCenterAligned(Control& childControl, CenterAlignmentType alignment)
106 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
107 SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
109 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
110 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
112 result r = pRelativeLayoutImpl->SetCenterAligned(*pControlImpl, alignment);
113 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
119 RelativeLayout::ResetCenterAligned(Control& childControl, CenterAlignmentType alignment)
123 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
124 SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
126 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
127 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
129 result r = pRelativeLayoutImpl->ResetCenterAligned(*pControlImpl, alignment);
130 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
136 RelativeLayout::SetMargin(Control& childControl, int left, int right, int top, int bottom)
140 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
141 SysAssertf(pRelativeLayoutImpl != 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 result r = pRelativeLayoutImpl->SetItemMargin(*pControlImpl, left, right, top, bottom);
147 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
153 RelativeLayout::SetWidth(Control& childControl, int width)
157 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
158 SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
160 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
161 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
163 result r = pRelativeLayoutImpl->SetWidth(*pControlImpl, width);
164 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
170 RelativeLayout::SetHeight(Control& childControl, int height)
174 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
175 SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
177 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
178 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
180 result r = pRelativeLayoutImpl->SetHeight(*pControlImpl, height);
181 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
187 RelativeLayout::SetHorizontalFitPolicy(Control& childControl, FitPolicy policy)
191 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
192 SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
194 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
195 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
197 result r = pRelativeLayoutImpl->SetItemHorizontalFitPolicy(*pControlImpl, policy);
198 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
204 RelativeLayout::SetVerticalFitPolicy(Control& childControl, FitPolicy policy)
208 _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this);
209 SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use.");
211 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl);
212 SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed.");
214 result r = pRelativeLayoutImpl->SetItemVerticalFitPolicy(*pControlImpl, policy);
215 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));