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 FUiCtrlPanel.cpp
20 * @brief This is the implementation file for %Panel class.
24 #include <unique_ptr.h>
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
27 #include <FUiCtrlPanel.h>
28 #include "FUi_CoordinateSystemUtils.h"
29 #include "FUi_UiBuilder.h"
30 #include "FUiCtrl_PanelImpl.h"
31 #include "FUiCtrl_Panel.h"
34 using namespace Tizen::Graphics;
36 namespace Tizen { namespace Ui { namespace Controls
51 Panel::Construct(const Rectangle& rect, GroupStyle groupStyle)
53 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
54 SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
56 FloatRectangle floatRect = _CoordinateSystemUtils::ConvertToFloat(rect);
57 pImpl = _PanelImpl::CreatePanelImplN(this, floatRect, groupStyle);
58 result r = GetLastResult();
59 SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] A specified input parameter is invalid.", GetErrorMessage(r));
60 SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r));
61 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
63 _pControlImpl = pImpl;
76 Panel::Construct(const FloatRectangle& rect, GroupStyle groupStyle)
78 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
79 SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
81 pImpl = _PanelImpl::CreatePanelImplN(this, rect, groupStyle);
82 result r = GetLastResult();
83 SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] A specified input parameter is invalid.", GetErrorMessage(r));
84 SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r));
85 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
87 _pControlImpl = pImpl;
100 Panel::Construct(const Tizen::Base::String& resourceId)
104 // Parse UiBuilder XML file
105 unique_ptr<_UiBuilder> pBuilder(new _UiBuilder());
106 SysTryReturn(NID_UI_CTRL, pBuilder, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY));
107 result r = pBuilder->Construct(resourceId, this);
108 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
109 r = pBuilder->Parse();
110 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
116 Panel::Construct(const Layout& layout, const Rectangle& rect, GroupStyle groupStyle)
118 return Construct(layout, layout, rect, groupStyle);
122 Panel::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, const Rectangle& rect, GroupStyle groupStyle)
124 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
125 SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
127 FloatRectangle floatRect = _CoordinateSystemUtils::ConvertToFloat(rect);
128 pImpl = _PanelImpl::CreatePanelImplN(this, floatRect, groupStyle, &(const_cast <Layout&>(portraitLayout)), &(const_cast <Layout&>(landscapeLayout)));
129 result r = GetLastResult();
130 SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] A specified input parameter is invalid.", GetErrorMessage(r));
131 SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r));
132 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
134 _pControlImpl = pImpl;
146 Panel::Construct(const Layout& layout, const FloatRectangle& rect, GroupStyle groupStyle)
148 return Construct(layout, layout, rect, groupStyle);
152 Panel::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, const FloatRectangle& rect, GroupStyle groupStyle)
154 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
155 SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
157 pImpl = _PanelImpl::CreatePanelImplN(this, rect, groupStyle, &(const_cast <Layout&>(portraitLayout)), &(const_cast <Layout&>(landscapeLayout)));
158 result r = GetLastResult();
159 SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] A specified input parameter is invalid.", GetErrorMessage(r));
160 SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r));
161 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
163 _pControlImpl = pImpl;
175 Panel::GetBackgroundColor(void) const
177 const _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
178 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
180 Color color = pImpl->GetBackgroundColor();
181 result r = GetLastResult();
182 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(0, 0, 0, 0), E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
188 Panel::SetBackgroundColor(const Color& color)
190 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
191 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
193 pImpl->SetBackgroundColor(color);
194 result r = GetLastResult();
195 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
199 Panel::SetCompositeEnabled(bool composite)
201 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
202 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
204 result r = pImpl->SetCompositeEnabled(composite);
205 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
211 Panel::IsCompositeEnabled(void) const
213 const _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
214 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
216 return pImpl->IsCompositeEnabled();
220 Panel::GetDataBindingContextN(void) const
222 const _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
223 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
225 return pImpl->GetDataBindingContextN();
229 }}} //Tizen::Ui::Controls