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.
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_UiBuilder.h"
29 #include "FUiCtrl_PanelImpl.h"
30 #include "FUiCtrl_Panel.h"
33 using namespace Tizen::Graphics;
35 namespace Tizen { namespace Ui { namespace Controls
50 Panel::Construct(const Rectangle& rect, GroupStyle groupStyle)
52 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
53 SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
55 pImpl = _PanelImpl::CreatePanelImplN(this, rect, groupStyle);
56 result r = GetLastResult();
57 SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] A specified input parameter is invalid.", GetErrorMessage(r));
58 SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r));
59 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
61 _pControlImpl = pImpl;
74 Panel::Construct(const Tizen::Base::String& resourceId)
78 // Parse UiBuilder XML file
79 unique_ptr<_UiBuilder> pBuilder(new _UiBuilder());
80 SysTryReturn(NID_UI_CTRL, pBuilder, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY));
81 result r = pBuilder->Construct(resourceId, this);
82 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
83 r = pBuilder->Parse();
84 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
90 Panel::Construct(const Layout& layout, const Rectangle& rect, GroupStyle groupStyle)
92 return Construct(layout, layout, rect, groupStyle);
96 Panel::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, const Rectangle& rect, GroupStyle groupStyle)
98 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
99 SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
101 pImpl = _PanelImpl::CreatePanelImplN(this, rect, groupStyle, &(const_cast <Layout&>(portraitLayout)), &(const_cast <Layout&>(landscapeLayout)));
102 result r = GetLastResult();
103 SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] A specified input parameter is invalid.", GetErrorMessage(r));
104 SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r));
105 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
107 _pControlImpl = pImpl;
119 Panel::GetBackgroundColor(void) const
121 const _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
122 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
124 Color color = pImpl->GetBackgroundColor();
125 result r = GetLastResult();
126 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(0, 0, 0, 0), E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
132 Panel::SetBackgroundColor(const Color& color)
134 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
135 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
137 pImpl->SetBackgroundColor(color);
138 result r = GetLastResult();
139 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
143 Panel::SetCompositeEnabled(bool composite)
145 _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
146 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
148 result r = pImpl->SetCompositeEnabled(composite);
149 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM));
155 Panel::IsCompositeEnabled(void) const
157 const _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
158 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
160 return pImpl->IsCompositeEnabled();
164 Panel::GetDataBindingContextN(void) const
166 const _PanelImpl* pImpl = _PanelImpl::GetInstance(*this);
171 return pImpl->GetDataBindingContextN();
175 }}} //Tizen::Ui::Controls