modify license, permission and remove ^M char
[platform/framework/native/uifw.git] / src / ui / FUiWindow.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17
18 /**
19  * @file        FUiWindow.cpp
20  * @brief       This is the implementation file for Window class.
21  */
22
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"
29
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Ui::Animations;
32 using namespace Tizen::Security;
33
34 namespace Tizen { namespace Ui {
35
36 Window::Window()
37 {
38 }
39
40 Window::~Window(void)
41 {
42 }
43
44 result
45 Window::Construct(const Rectangle& rect, bool resizable, bool movable)
46 {
47         result r = E_SUCCESS;
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);
50         r = GetLastResult();
51         SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
52
53         _pControlImpl = pImpl;
54
55         return E_SUCCESS;
56 }
57
58 result
59 Window::Construct(const FloatRectangle& rect, bool resizable, bool movable)
60 {
61         result r = E_SUCCESS;
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);
64         r = GetLastResult();
65         SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
66
67         _pControlImpl = pImpl;
68
69         return E_SUCCESS;
70 }
71
72 result
73 Window::Construct(const Layout& layout, const Rectangle& rect, bool resizable, bool movable)
74 {
75         return Construct(layout, layout, rect, resizable, movable);
76 }
77
78 result
79 Window::Construct(const Layout& layout, const FloatRectangle& rect, bool resizable, bool movable)
80 {
81         return Construct(layout, layout, rect, resizable, movable);
82 }
83
84 result
85 Window::Construct(const Layout& portraitLayout, const Layout& landscapeLayout,
86                                                          const Rectangle& rect, bool resizable, bool movable)
87 {
88         result r = E_SUCCESS;
89         SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
90
91         _WindowImpl* pImpl =
92                 _WindowImpl::CreateWindowImplN(this, rect, &portraitLayout, &landscapeLayout, resizable, movable);
93
94         r = GetLastResult();
95         SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
96
97
98         _pControlImpl = pImpl;
99
100         return E_SUCCESS;
101 }
102
103 result
104 Window::Construct(const Layout& portraitLayout, const Layout& landscapeLayout,
105                                                          const FloatRectangle& rect, bool resizable, bool movable)
106 {
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.");
109
110         _WindowImpl* pImpl =
111                 _WindowImpl::CreateWindowImplN(this, rect, &portraitLayout, &landscapeLayout, resizable, movable);
112
113         r = GetLastResult();
114         SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
115
116
117         _pControlImpl = pImpl;
118
119         return E_SUCCESS;
120 }
121
122 result
123 Window::Show(void)
124 {
125         result r = E_SUCCESS;
126
127         _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
128         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
129
130         r = pImpl->Open();
131
132         return r;
133 }
134
135 WindowState
136 Window::GetWindowState(void) const
137 {
138         const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
139         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
140
141         return pImpl->GetWindowState();
142 }
143
144 DisplayContext*
145 Window::GetDisplayContext(void) const
146 {
147         const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
148         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
149
150         return pImpl->GetDisplayContext();
151 }
152
153 result
154 Window::SetZOrderGroup(WindowZOrderGroup windowZOrderGroup)
155 {
156         _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
157         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
158
159         return pImpl->SetZOrderGroup(windowZOrderGroup);
160 }
161
162 void
163 Window::SetOwner(Tizen::Ui::Control *pControl)
164 {
165         _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
166         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
167
168         pImpl->SetOwner(pControl);
169 }
170
171 Control*
172 Window::GetOwner(void) const
173 {
174         const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
175         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
176
177         return pImpl->GetOwner();
178 }
179
180 void
181 Window::AddWindowEventListener(IWindowEventListener& listener)
182 {
183         _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
184         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
185
186         pImpl->AddWindowEventListener(listener);
187         result r = GetLastResult();
188         SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
189 }
190
191 void
192 Window::RemoveWindowEventListener(IWindowEventListener& listener)
193 {
194         _WindowImpl* pImpl = _WindowImpl::GetInstance(*this);
195         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
196
197         pImpl->RemoveWindowEventListener(listener);
198         result r = GetLastResult();
199         SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
200 }
201
202 }} // Tizen::Ui