Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrlFrame.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
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  *      @file           FUiCtrlFrame.cpp
19  *      @brief          This is the implementation for the Frame class.
20  */
21
22 // Includes
23 #include <FUiCtrlFrame.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_FrameImpl.h"
26 #include "FUiCtrl_FormImpl.h"
27
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Ui::Animations;
31
32 namespace Tizen { namespace Ui { namespace Controls
33 {
34
35 Frame::Frame(void)
36 {
37 }
38
39 Frame::~Frame(void)
40 {
41 }
42
43 result
44 Frame::Construct(void)
45 {
46         SysAssertf(_FrameImpl::GetInstance(*this) == null,
47                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
48
49         result r = E_SUCCESS;
50
51         _FrameImpl* pImpl = _FrameImpl::CreateFrameImplN(this);
52         r = GetLastResult();
53         SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
54
55         _pControlImpl = pImpl;
56
57         return r;
58 }
59
60 result
61 Frame::Construct(const Rectangle& rect)
62 {
63         SysAssertf(_FrameImpl::GetInstance(*this) == null,
64                                 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
65
66         result r = E_SUCCESS;
67
68         _FrameImpl* pImpl = _FrameImpl::CreateFrameImplN(this);
69         r = GetLastResult();
70         SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
71
72         _pControlImpl = pImpl;
73
74         pImpl->SetFloatingBounds(rect);
75
76         return r;
77 }
78
79 void
80 Frame::AddOrientationEventListener(IOrientationEventListener& listener)
81 {
82         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
83         SysAssertf(pImpl != null,
84                                 "Not yet constructed. Construct() should be called before use.");
85
86         pImpl->AddOrientationEventListener(listener);
87 }
88
89 void
90 Frame::AddFrameEventListener(IFrameEventListener& listener)
91 {
92         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
93         SysAssertf(pImpl != null,
94                                 "Not yet constructed. Construct() should be called before use.");
95
96         pImpl->AddFrameEventListener(listener);
97 }
98
99 void
100 Frame::RemoveOrientationEventListener(IOrientationEventListener& listener)
101 {
102         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
103         SysAssertf(pImpl != null,
104                                 "Not yet constructed. Construct() should be called before use.");
105
106         pImpl->RemoveOrientationEventListener(listener);
107 }
108
109 void
110 Frame::RemoveFrameEventListener(IFrameEventListener& listener)
111 {
112         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
113         SysAssertf(pImpl != null,
114                                 "Not yet constructed. Construct() should be called before use.");
115
116         pImpl->RemoveFrameEventListener(listener);
117
118         return;
119 }
120
121 Form*
122 Frame::GetCurrentForm(void) const
123 {
124         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
125         SysAssertf(pImpl != null,
126                                 "Not yet constructed. Construct() should be called before use.");
127
128         _FormImpl* pFormImpl = pImpl->GetCurrentForm();
129         SysTryReturn(NID_UI_CTRL, pFormImpl, null, E_INVALID_STATE, "[E_INVALID_STATE] The current Form does not exist.");
130
131         return &pFormImpl->GetPublic();
132 }
133
134 result
135 Frame::SetCurrentForm(const Form& form)
136 {
137         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
138         SysAssertf(pImpl != null,
139                                 "Not yet constructed. Construct() should be called before use.");
140
141         result r = pImpl->SetCurrentForm(*_FormImpl::GetInstance(form));
142         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
143
144         return E_SUCCESS;
145 }
146
147 Color
148 Frame::GetBackgroundColor(void) const
149 {
150         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
151         SysAssertf(pImpl != null,
152                                 "Not yet constructed. Construct() should be called before use.");
153
154         return pImpl->GetBackgroundColor();
155 }
156
157 void
158 Frame::SetBackgroundColor(const Color& color)
159 {
160         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
161         SysAssertf(pImpl != null,
162                                 "Not yet constructed. Construct() should be called before use.");
163
164         pImpl->SetBackgroundColor(color);
165 }
166
167 void
168 Frame::SetOrientation(Orientation orientation)
169 {
170         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
171         SysAssertf(pImpl != null,
172                                 "Not yet constructed. Construct() should be called before use.");
173
174         pImpl->SetOrientation(orientation);
175 }
176
177 Orientation
178 Frame::GetOrientation(void) const
179 {
180         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
181         SysAssertf(pImpl != null,
182                                 "Not yet constructed. Construct() should be called before use.");
183
184         return pImpl->GetOrientation();
185 }
186
187 OrientationStatus
188 Frame::GetOrientationStatus(void) const
189 {
190         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
191         SysAssertf(pImpl != null,
192                                 "Not yet constructed. Construct() should be called before use.");
193
194         return pImpl->GetOrientationStatus();
195 }
196
197 FrameAnimator*
198 Frame::GetFrameAnimator(void) const
199 {
200         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
201         SysAssertf(pImpl != null,
202                                 "Not yet constructed. Construct() should be called before use.");
203
204         return pImpl->GetFrameAnimator();
205 }
206
207 result
208 Frame::SetShowMode(FrameShowMode mode)
209 {
210         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
211         SysAssertf(pImpl != null,
212                                 "Not yet constructed. Construct() should be called before use.");
213
214         return pImpl->SetShowMode(mode);
215 }
216
217 FrameShowMode
218 Frame::GetShowMode(void) const
219 {
220         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
221         SysAssertf(pImpl != null,
222                                 "Not yet constructed. Construct() should be called before use.");
223
224         return pImpl->GetShowMode();
225 }
226
227 }}} // Tizen::Ui::Constrols