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 * @brief This is the implementation file for Window class.
22 #include <FBaseSysLog.h>
23 #include <FUiWindow.h>
24 #include <FUiAnimDisplayContext.h>
25 #include <FSec_AccessController.h>
26 #include "FUi_WindowImpl.h"
27 #include "FUi_ErrorMessages.h"
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Ui::Animations;
31 using namespace Tizen::Security;
33 namespace Tizen { namespace Ui {
44 Window::Construct(const Rectangle& rect, bool resizable, bool movable)
47 SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
48 _WindowImpl* pImpl = _WindowImpl::CreateWindowImplN(this, rect, null, null, resizable, movable);
50 SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
52 _pControlImpl = pImpl;
58 Window::Construct(const Layout& layout, const Rectangle& rect, bool resizable, bool movable)
60 return Construct(layout, layout, rect, resizable, movable);
64 Window::Construct(const Layout& portraitLayout, const Layout& landscapeLayout,
65 const Rectangle& rect, bool resizable, bool movable)
68 SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
71 _WindowImpl::CreateWindowImplN(this, rect, &portraitLayout, &landscapeLayout, resizable, movable);
74 SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
77 _pControlImpl = pImpl;
87 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
88 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
96 Window::GetWindowState(void) const
98 const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
99 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
101 return pImpl->GetWindowState();
105 Window::GetDisplayContext(void) const
107 const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
108 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
110 return pImpl->GetDisplayContext();
114 Window::SetZOrderGroup(WindowZOrderGroup windowZOrderGroup)
116 result r = _AccessController::CheckUserPrivilege(_PRV_UIMANAGER);
117 SysTryReturnResult(NID_LOC, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
119 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
120 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
122 return pImpl->SetZOrderGroup(windowZOrderGroup);
126 Window::SetOwner(Tizen::Ui::Control *pControl)
128 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
129 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
131 pImpl->SetOwner(pControl);
135 Window::AddWindowEventListener(IWindowEventListener& listener)
137 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
138 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
140 pImpl->AddWindowEventListener(listener);
141 result r = GetLastResult();
142 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
146 Window::RemoveWindowEventListener(IWindowEventListener& listener)
148 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
149 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
151 pImpl->RemoveWindowEventListener(listener);
152 result r = GetLastResult();
153 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));