Changed indicator bg color.
[platform/framework/native/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 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  *      @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 result
80 Frame::Construct(const FloatRectangle& rect)
81 {
82         SysAssertf(_FrameImpl::GetInstance(*this) == null,
83                                 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
84
85         result r = E_SUCCESS;
86
87         _FrameImpl* pImpl = _FrameImpl::CreateFrameImplN(this);
88         r = GetLastResult();
89         SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
90
91         _pControlImpl = pImpl;
92
93         pImpl->SetFloatingBounds(rect);
94
95         return r;
96 }
97
98 void
99 Frame::AddOrientationEventListener(IOrientationEventListener& listener)
100 {
101         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
102         SysAssertf(pImpl != null,
103                                 "Not yet constructed. Construct() should be called before use.");
104
105         pImpl->AddOrientationEventListener(listener);
106 }
107
108 void
109 Frame::AddFrameEventListener(IFrameEventListener& listener)
110 {
111         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
112         SysAssertf(pImpl != null,
113                                 "Not yet constructed. Construct() should be called before use.");
114
115         pImpl->AddFrameEventListener(listener);
116 }
117
118 void
119 Frame::RemoveOrientationEventListener(IOrientationEventListener& listener)
120 {
121         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
122         SysAssertf(pImpl != null,
123                                 "Not yet constructed. Construct() should be called before use.");
124
125         pImpl->RemoveOrientationEventListener(listener);
126 }
127
128 void
129 Frame::RemoveFrameEventListener(IFrameEventListener& listener)
130 {
131         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
132         SysAssertf(pImpl != null,
133                                 "Not yet constructed. Construct() should be called before use.");
134
135         pImpl->RemoveFrameEventListener(listener);
136
137         return;
138 }
139
140 Form*
141 Frame::GetCurrentForm(void) const
142 {
143         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
144         SysAssertf(pImpl != null,
145                                 "Not yet constructed. Construct() should be called before use.");
146
147         _FormImpl* pFormImpl = pImpl->GetCurrentForm();
148         SysTryReturn(NID_UI_CTRL, pFormImpl, null, E_INVALID_STATE, "[E_INVALID_STATE] The current Form does not exist.");
149
150         return &pFormImpl->GetPublic();
151 }
152
153 result
154 Frame::SetCurrentForm(const Form& form)
155 {
156         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
157         SysAssertf(pImpl != null,
158                                 "Not yet constructed. Construct() should be called before use.");
159
160         result r = pImpl->SetCurrentForm(*_FormImpl::GetInstance(form));
161         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
162
163         return E_SUCCESS;
164 }
165
166 result
167 Frame::SetCurrentForm(Form* pForm)
168 {
169         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
170         SysAssertf(pImpl != null,
171                                 "Not yet constructed. Construct() should be called before use.");
172
173         result r = pImpl->SetCurrentForm(_FormImpl::GetInstance(*pForm));
174         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
175
176         return E_SUCCESS;
177 }
178
179
180 Color
181 Frame::GetBackgroundColor(void) const
182 {
183         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
184         SysAssertf(pImpl != null,
185                                 "Not yet constructed. Construct() should be called before use.");
186
187         return pImpl->GetBackgroundColor();
188 }
189
190 void
191 Frame::SetBackgroundColor(const Color& color)
192 {
193         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
194         SysAssertf(pImpl != null,
195                                 "Not yet constructed. Construct() should be called before use.");
196
197         pImpl->SetBackgroundColor(color);
198 }
199
200 void
201 Frame::SetOrientation(Orientation orientation)
202 {
203         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
204         SysAssertf(pImpl != null,
205                                 "Not yet constructed. Construct() should be called before use.");
206
207         pImpl->SetOrientation(orientation);
208 }
209
210 Orientation
211 Frame::GetOrientation(void) const
212 {
213         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
214         SysAssertf(pImpl != null,
215                                 "Not yet constructed. Construct() should be called before use.");
216
217         return pImpl->GetOrientation();
218 }
219
220 OrientationStatus
221 Frame::GetOrientationStatus(void) const
222 {
223         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
224         SysAssertf(pImpl != null,
225                                 "Not yet constructed. Construct() should be called before use.");
226
227         return pImpl->GetOrientationStatus();
228 }
229
230 FrameAnimator*
231 Frame::GetFrameAnimator(void) const
232 {
233         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
234         SysAssertf(pImpl != null,
235                                 "Not yet constructed. Construct() should be called before use.");
236
237         return pImpl->GetFrameAnimator();
238 }
239
240 result
241 Frame::SetShowMode(FrameShowMode mode)
242 {
243         _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
244         SysAssertf(pImpl != null,
245                                 "Not yet constructed. Construct() should be called before use.");
246
247         return pImpl->SetShowMode(mode);
248 }
249
250 FrameShowMode
251 Frame::GetShowMode(void) const
252 {
253         const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this);
254         SysAssertf(pImpl != null,
255                                 "Not yet constructed. Construct() should be called before use.");
256
257         return pImpl->GetShowMode();
258 }
259
260 }}} // Tizen::Ui::Constrols