Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlSplitPanel.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         FUiCtrlSplitPanel.cpp
20 * @brief        This file contains implementation of SplitPanel class
21 */
22
23 // Includes
24 #include <FUiCtrlSplitPanel.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_SplitPanelImpl.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 SplitPanel::SplitPanel(void)
35 {
36
37 }
38
39 SplitPanel::~SplitPanel(void)
40 {
41
42 }
43
44 result
45 SplitPanel::Construct(const Tizen::Graphics::Rectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection)
46 {
47         result r = E_SUCCESS;
48         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
49
50         SysAssertf(pSplitPanelImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
51
52         pSplitPanelImpl = _SplitPanelImpl::CreateSplitPanelImplN(this, rect, splitPanelDividerStyle, splitPanelDividerDirection);
53         SysTryReturnResult(NID_UI_CTRL, pSplitPanelImpl, GetLastResult(), "Propagating.");
54
55         _pControlImpl = pSplitPanelImpl;
56
57         r = pSplitPanelImpl->Initialize(rect);
58         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
59
60         return r;
61
62 CATCH:
63         delete pSplitPanelImpl;
64         _pControlImpl = null;
65
66         return r;
67 }
68
69 result
70 SplitPanel::Construct(const Tizen::Graphics::FloatRectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection)
71 {
72         result r = E_SUCCESS;
73         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
74
75         SysAssertf(pSplitPanelImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
76
77         pSplitPanelImpl = _SplitPanelImpl::CreateSplitPanelImplFN(this, rect, splitPanelDividerStyle, splitPanelDividerDirection);
78         SysTryReturnResult(NID_UI_CTRL, pSplitPanelImpl, GetLastResult(), "Propagating.");
79
80         _pControlImpl = pSplitPanelImpl;
81
82         r = pSplitPanelImpl->InitializeF(rect);
83         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
84
85         return r;
86
87 CATCH:
88         delete pSplitPanelImpl;
89         _pControlImpl = null;
90
91         return r;
92 }
93
94 result
95 SplitPanel::SetPane(Control* pControl, SplitPanelPaneOrder paneOrder)
96 {
97         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
98         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
99
100         if (pControl ==  null)
101         {
102                 return pSplitPanelImpl->SetPane(null, paneOrder);
103         }
104
105         _ControlImpl* pImpl = _ControlImpl::GetInstance(*pControl);
106         SysAssertf(pImpl != null, "Parameter pControl is not yet constructed. Construct() should be called before use.");
107
108         return pSplitPanelImpl->SetPane(pImpl, paneOrder);
109 }
110
111 Control*
112 SplitPanel::GetPane(SplitPanelPaneOrder paneOrder) const
113 {
114         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
115         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
116
117         _ControlImpl* pSplitPaneImpl = pSplitPanelImpl->GetPane(paneOrder);
118         result r = GetLastResult();
119         SysTryReturn(NID_UI_CTRL, pSplitPaneImpl, null, r, "[%s] Propagating.", GetErrorMessage(r));
120         return &(pSplitPaneImpl->GetPublic());
121 }
122
123 result
124 SplitPanel::SetDividerPosition(int position)
125 {
126         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
127         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
128
129         return pSplitPanelImpl->SetDividerPosition(position);
130 }
131
132 result
133 SplitPanel::SetDividerPosition(float position)
134 {
135         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
136         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
137
138         return pSplitPanelImpl->SetDividerPosition(position);
139 }
140
141 int
142 SplitPanel::GetDividerPosition(void) const
143 {
144         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
145         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
146
147         return pSplitPanelImpl->GetDividerPosition();
148 }
149
150 float
151 SplitPanel::GetDividerPositionF(void) const
152 {
153         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
154         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
155
156         return pSplitPanelImpl->GetDividerPositionF();
157 }
158
159 result
160 SplitPanel::SetMaximumDividerPosition(int position)
161 {
162         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
163         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
164
165         return pSplitPanelImpl->SetMaximumDividerPosition(position);
166 }
167
168 result
169 SplitPanel::SetMaximumDividerPosition(float position)
170 {
171         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
172         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
173
174         return pSplitPanelImpl->SetMaximumDividerPosition(position);
175 }
176
177 int
178 SplitPanel::GetMaximumDividerPosition(void) const
179 {
180         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
181         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
182
183         return pSplitPanelImpl->GetMaximumDividerPosition();
184 }
185
186 float
187 SplitPanel::GetMaximumDividerPositionF(void) const
188 {
189         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
190         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
191
192         return pSplitPanelImpl->GetMaximumDividerPositionF();
193 }
194
195 result
196 SplitPanel::SetMinimumDividerPosition(int position)
197 {
198         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
199         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
200
201         return pSplitPanelImpl->SetMinimumDividerPosition(position);
202 }
203
204 result
205 SplitPanel::SetMinimumDividerPosition(float position)
206 {
207         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
208         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
209
210         return pSplitPanelImpl->SetMinimumDividerPosition(position);
211 }
212
213 int
214 SplitPanel::GetMinimumDividerPosition(void) const
215 {
216         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
217         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
218
219         return pSplitPanelImpl->GetMinimumDividerPosition();
220 }
221
222 float
223 SplitPanel::GetMinimumDividerPositionF(void) const
224 {
225         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
226         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
227
228         return pSplitPanelImpl->GetMinimumDividerPositionF();
229 }
230
231 result
232 SplitPanel::MaximizePane(SplitPanelPaneOrder paneOrder)
233 {
234         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
235         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
236
237         return pSplitPanelImpl->MaximizePane(paneOrder);
238 }
239
240 bool
241 SplitPanel::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const
242 {
243         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
244         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
245
246         return pSplitPanelImpl->IsPaneMaximized(paneOrder);
247 }
248
249 result
250 SplitPanel::RestorePane(void)
251 {
252         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
253         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
254
255         return pSplitPanelImpl->RestorePane();
256 }
257
258 result
259 SplitPanel::AddSplitPanelEventListener(ISplitPanelEventListener& listener)
260 {
261         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
262         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
263
264         return pSplitPanelImpl->AddSplitPanelEventListener(listener);
265 }
266
267 result
268 SplitPanel::AddSplitPanelEventListener(ISplitPanelEventListenerF& listener)
269 {
270         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
271         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
272
273         return pSplitPanelImpl->AddSplitPanelEventListener(listener);
274 }
275
276 result
277 SplitPanel::RemoveSplitPanelEventListener(ISplitPanelEventListener& listener)
278 {
279         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
280         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
281
282         return pSplitPanelImpl->RemoveSplitPanelEventListener(listener);
283 }
284
285 result
286 SplitPanel::RemoveSplitPanelEventListener(ISplitPanelEventListenerF& listener)
287 {
288         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
289         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
290
291         return pSplitPanelImpl->RemoveSplitPanelEventListener(listener);
292 }
293
294 }}} // Tizen::Ui::Controls
295