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.
20 * @brief This is the implementation file for Window class.
23 #include <FBaseSysLog.h>
24 #include <FUiWindow.h>
25 #include <FUiAnimDisplayContext.h>
26 #include <FSec_AccessController.h>
27 #include "FUi_WindowImpl.h"
28 #include "FUi_ErrorMessages.h"
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Ui::Animations;
32 using namespace Tizen::Security;
34 namespace Tizen { namespace Ui {
45 Window::Construct(const Rectangle& rect, bool resizable, bool movable)
48 SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
49 _WindowImpl* pImpl = _WindowImpl::CreateWindowImplN(this, rect, null, null, resizable, movable);
51 SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
53 _pControlImpl = pImpl;
59 Window::Construct(const FloatRectangle& rect, bool resizable, bool movable)
62 SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
63 _WindowImpl* pImpl = _WindowImpl::CreateWindowImplN(this, rect, null, null, resizable, movable);
65 SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
67 _pControlImpl = pImpl;
73 Window::Construct(const Layout& layout, const Rectangle& rect, bool resizable, bool movable)
75 return Construct(layout, layout, rect, resizable, movable);
79 Window::Construct(const Layout& layout, const FloatRectangle& rect, bool resizable, bool movable)
81 return Construct(layout, layout, rect, resizable, movable);
85 Window::Construct(const Layout& portraitLayout, const Layout& landscapeLayout,
86 const Rectangle& rect, bool resizable, bool movable)
89 SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
92 _WindowImpl::CreateWindowImplN(this, rect, &portraitLayout, &landscapeLayout, resizable, movable);
95 SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
98 _pControlImpl = pImpl;
104 Window::Construct(const Layout& portraitLayout, const Layout& landscapeLayout,
105 const FloatRectangle& rect, bool resizable, bool movable)
107 result r = E_SUCCESS;
108 SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
111 _WindowImpl::CreateWindowImplN(this, rect, &portraitLayout, &landscapeLayout, resizable, movable);
114 SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
117 _pControlImpl = pImpl;
125 result r = E_SUCCESS;
127 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
128 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
136 Window::GetWindowState(void) const
138 const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
139 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
141 return pImpl->GetWindowState();
145 Window::GetDisplayContext(void) const
147 const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
148 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
150 return pImpl->GetDisplayContext();
154 Window::SetZOrderGroup(WindowZOrderGroup windowZOrderGroup)
156 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
157 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
159 return pImpl->SetZOrderGroup(windowZOrderGroup);
163 Window::SetOwner(Tizen::Ui::Control *pControl)
165 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
166 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
168 pImpl->SetOwner(pControl);
172 Window::GetOwner(void) const
174 const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
175 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
177 return pImpl->GetOwner();
181 Window::AddWindowEventListener(IWindowEventListener& listener)
183 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
184 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
186 pImpl->AddWindowEventListener(listener);
187 result r = GetLastResult();
188 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
192 Window::RemoveWindowEventListener(IWindowEventListener& listener)
194 _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
195 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
197 pImpl->RemoveWindowEventListener(listener);
198 result r = GetLastResult();
199 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));