Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_SplitPanel.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                FUiCtrl_SplitPanel.cpp
20  * @brief               This is the implementation file for the _SplitPanel class.
21  */
22
23 #include <FBaseErrorDefine.h>
24 #include <FBaseString.h>
25 #include <FBaseSysLog.h>
26 #include <FGrp_BitmapImpl.h>
27 #include <FGrp_CoordinateSystemUtils.h>
28 #include "FUi_ResourceManager.h"
29 #include "FUi_UiTouchEvent.h"
30 #include "FUi_TouchTapGestureDetector.h"
31 #include "FUiCtrl_SplitPanel.h"
32 #include "FUiCtrl_SplitPanelPresenter.h"
33
34 using namespace Tizen::Ui;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Ui::Animations;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Runtime;
39
40 namespace Tizen { namespace Ui { namespace Controls
41 {
42
43 _SplitPanel::_SplitPanel()
44         : __pSplitPanelPresenter(null)
45         , __pTapGesture(null)
46         , __pFirstPaneParent(null)
47         , __pSecondPaneParent(null)
48         , __pFirstPane(null)
49         , __pSecondPane(null)
50         , __splitPanelDividerDirection(SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
51         , __pSplitPanelEvent(null)
52         , __dividerTapCount(0)
53         , __pDividerVisualElement(null)
54 {
55         for (int i=0; i < _SPLIT_PANEL_DIVIDER_STATE; i++)
56         {
57                 __dividerPosition[i] = 0.0f;
58                 __minimumDividerPosition[i] = 0.0f;
59                 __maximumDividerPosition[i] = 0.0f;
60         }
61 }
62
63 _SplitPanel*
64 _SplitPanel::CreateSplitPanelN(const FloatRectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection)
65 {
66         result r = E_SUCCESS;
67         float dividerThickness = 0.0f;
68         _SplitPanel* pSplitPanel = null;
69         _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
70
71         pSplitPanel = new (std::nothrow) _SplitPanel;
72         SysTryReturn(NID_UI_CTRL, pSplitPanel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
73
74         r = pSplitPanel->Construct(splitPanelDividerStyle, splitPanelDividerDirection);
75         if (r != E_SUCCESS)
76         {
77                 delete pSplitPanel;
78                 pSplitPanel = null;
79                 return null;
80         }
81         pSplitPanel->AcquireHandle();
82         pSplitPanel->SetDividerDirection(splitPanelDividerDirection);
83
84         orientation = _ControlManager::GetInstance()->GetOrientation();
85
86         if (splitPanelDividerStyle == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
87         {
88                 GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, dividerThickness);
89         }
90         else
91         {
92                 GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, dividerThickness);
93         }
94
95         pSplitPanel->__maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = rect.width - dividerThickness;
96         pSplitPanel->__maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = rect.width - dividerThickness;
97         pSplitPanel->__maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = rect.height - dividerThickness;
98         pSplitPanel->__maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = rect.width - dividerThickness;
99
100         pSplitPanel->__dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = rect.width / 2.0f;
101         pSplitPanel->__dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = rect.width / 2.0f;
102         pSplitPanel->__dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] =  rect.height / 2.0f;
103         pSplitPanel->__dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = rect.height / 2.0f;
104
105         pSplitPanel->__pTapGesture = new (std::nothrow) _TouchTapGestureDetector;
106         SysTryCatch(NID_UI_CTRL, pSplitPanel->__pTapGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
107
108         pSplitPanel->AddGestureDetector(*(pSplitPanel->__pTapGesture));
109         r = pSplitPanel->__pTapGesture->AddGestureListener(*pSplitPanel);
110         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
111
112         pSplitPanel->SetFocusable(false);
113         pSplitPanel->SetBackgroundColor(Color(0,0,0,0));
114
115         return pSplitPanel;
116
117 CATCH:
118         if (pSplitPanel->__pTapGesture != null)
119         {
120                 pSplitPanel->__pTapGesture->RemoveGestureListener(*pSplitPanel);
121                 pSplitPanel->RemoveGestureDetector(*pSplitPanel->__pTapGesture);
122
123                 delete pSplitPanel->__pTapGesture;
124                 pSplitPanel->__pTapGesture = null;
125         }
126
127         delete pSplitPanel;
128         return null;
129 }
130
131 result
132 _SplitPanel::Construct(SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection)
133 {
134         result r = E_SUCCESS;
135
136         __pDividerVisualElement = new (std::nothrow) VisualElement();
137         SysTryReturnResult(NID_UI_CTRL, __pDividerVisualElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
138         r = __pDividerVisualElement->Construct();
139         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct divider visual element.", GetErrorMessage(r));
140
141         __pDividerVisualElement->SetShowState(true);
142         __pDividerVisualElement->SetImplicitAnimationEnabled(false);
143         __pDividerVisualElement->SetClipChildrenEnabled(false);
144
145         r = GetVisualElement()->AttachChild(*__pDividerVisualElement);
146         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach divider visual element.", GetErrorMessage(r));
147
148         __pSplitPanelPresenter = new (std::nothrow) _SplitPanelPresenter;
149         SysTryCatch(NID_UI_CTRL, __pSplitPanelPresenter != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
150
151         r = __pSplitPanelPresenter->Construct(*this, splitPanelDividerStyle, splitPanelDividerDirection);
152         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct presenter.", GetErrorMessage(r));
153
154         __pFirstPaneParent = _Control::CreateControlN();
155         r = GetLastResult();
156         SysTryCatch(NID_UI_CTRL, __pFirstPaneParent != null, , r, "[%s] Propagating.", GetErrorMessage(r));
157
158         __pSecondPaneParent = _Control::CreateControlN();
159         r = GetLastResult();
160         SysTryCatch(NID_UI_CTRL, __pSecondPaneParent != null, , r, "[%s] Propagating.", GetErrorMessage(r));
161
162         __pFirstPaneParent->SetFocusable(false);
163         __pSecondPaneParent->SetFocusable(false);
164
165         __pFirstPaneParent->SetBackgroundColor(Color(0,0,0,0));
166         __pSecondPaneParent->SetBackgroundColor(Color(0,0,0,0));
167
168         r = AttachChild(*__pFirstPaneParent);
169         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
170
171         r = AttachChild(*__pSecondPaneParent);
172         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
173
174         return r;
175
176 CATCH:
177
178         if (__pDividerVisualElement)
179         {
180                 __pDividerVisualElement->Destroy();
181                 __pDividerVisualElement = null;
182         }
183
184         if (__pSplitPanelPresenter)
185         {
186                 delete __pSplitPanelPresenter;
187                 __pSplitPanelPresenter = null;
188         }
189
190         if (__pFirstPaneParent)
191         {
192                 DetachChild(*__pFirstPaneParent);
193
194                 delete __pFirstPaneParent;
195                 __pFirstPaneParent = null;
196         }
197
198         if (__pSecondPaneParent)
199         {
200                 DetachChild(*__pSecondPaneParent);
201
202                 delete __pSecondPaneParent;
203                 __pSecondPaneParent = null;
204         }
205
206         return r;
207 }
208
209 _SplitPanel::~_SplitPanel(void)
210 {
211         if (__pSplitPanelPresenter)
212         {
213                 delete __pSplitPanelPresenter;
214                 __pSplitPanelPresenter = null;
215         }
216
217         if (__pSplitPanelEvent)
218         {
219                 delete __pSplitPanelEvent;
220                 __pSplitPanelEvent = null;
221         }
222
223         if (__pTapGesture)
224         {
225                 __pTapGesture->RemoveGestureListener(*this);
226                 RemoveGestureDetector(*__pTapGesture);
227
228                 delete __pTapGesture;
229                 __pTapGesture = null;
230         }
231
232         if (__pDividerVisualElement)
233         {
234                 GetVisualElement()->DetachChild(*__pDividerVisualElement);
235
236                 __pDividerVisualElement->Destroy();
237                 __pDividerVisualElement = null;
238         }
239
240         if (__pFirstPaneParent)
241         {
242                 DetachChild(*__pFirstPaneParent);
243
244                 delete __pFirstPaneParent;
245                 __pFirstPaneParent = null;
246         }
247
248         if (__pSecondPaneParent)
249         {
250                 DetachChild(*__pSecondPaneParent);
251
252                 delete __pSecondPaneParent;
253                 __pSecondPaneParent = null;
254         }
255
256         ClearLastResult();
257 }
258
259 result
260 _SplitPanel::SetPresenter(const _SplitPanelPresenter& splitPanelPresenter)
261 {
262         __pSplitPanelPresenter = const_cast<_SplitPanelPresenter*>(&splitPanelPresenter);
263         return E_SUCCESS;
264 }
265
266 result
267 _SplitPanel::AddSplitPanelEventListener(const _ISplitPanelEventListener& listener)
268 {
269         result r = E_SUCCESS;
270
271         if (__pSplitPanelEvent == null)
272         {
273                 __pSplitPanelEvent = _SplitPanelEvent::CreateInstanceN(*this);
274                 r = GetLastResult();
275                 SysTryReturn(NID_UI_CTRL, __pSplitPanelEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
276
277                 __pSplitPanelEvent->AddListener(listener);
278         }
279
280         return r;
281 }
282
283 result
284 _SplitPanel::RemoveSplitPanelEventListener(const _ISplitPanelEventListener& listener)
285 {
286         SysTryReturn(NID_UI_CTRL, __pSplitPanelEvent, E_SYSTEM, E_SYSTEM,
287                                 "[E_SYSTEM] System error occurred.");
288
289         __pSplitPanelEvent->RemoveListener(listener);
290
291         return E_SUCCESS;
292 }
293
294 void
295 _SplitPanel::OnDraw(void)
296 {
297         __pSplitPanelPresenter->Draw();
298
299         return;
300 }
301
302 void
303 _SplitPanel::OnChangeLayout(_ControlOrientation orientation)
304 {
305         __pSplitPanelPresenter->OnChangeLayout(orientation);
306
307         return;
308 }
309
310 void
311 _SplitPanel::OnBoundsChanged(void)
312 {
313         FloatRectangle bounds = GetBoundsF();
314         float dividerThickness = 0.0f;
315         _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
316
317         orientation = _ControlManager::GetInstance()->GetOrientation();
318
319         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, dividerThickness);
320
321         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
322         {
323                 if (GetMaximumDividerPosition() > (bounds.width - dividerThickness))
324                 {
325                         SetMaximumDividerPosition(bounds.width - dividerThickness);
326                 }
327         }
328         else
329         {
330                 if (GetMaximumDividerPosition() > (bounds.height - dividerThickness))
331                 {
332                         SetMaximumDividerPosition(bounds.height - dividerThickness);
333                 }
334         }
335
336         __pSplitPanelPresenter->OnBoundsChanged();
337
338         return;
339 }
340
341 _UiTouchEventDelivery
342 _SplitPanel::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
343 {
344         if (__pSplitPanelPresenter->OnTouchPressed(source, touchinfo) == true)
345         {
346                 return _UI_TOUCH_EVENT_DELIVERY_NO;
347         }
348
349         return _UI_TOUCH_EVENT_DELIVERY_YES;
350 }
351
352 _UiTouchEventDelivery
353 _SplitPanel::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
354 {
355         if (__pSplitPanelPresenter->OnTouchReleased(source, touchinfo) == true)
356         {
357                 return _UI_TOUCH_EVENT_DELIVERY_NO;
358         }
359
360         return _UI_TOUCH_EVENT_DELIVERY_YES;
361 }
362
363 _UiTouchEventDelivery
364 _SplitPanel::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
365 {
366         if (__pSplitPanelPresenter->OnTouchMoved(source, touchinfo) == true)
367         {
368                 return _UI_TOUCH_EVENT_DELIVERY_NO;
369         }
370
371         return _UI_TOUCH_EVENT_DELIVERY_YES;
372 }
373
374 _UiTouchEventDelivery
375 _SplitPanel::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
376 {
377         if (__pSplitPanelPresenter->OnTouchCanceled(source, touchinfo) == true)
378         {
379                 return _UI_TOUCH_EVENT_DELIVERY_NO;
380         }
381
382         return _UI_TOUCH_EVENT_DELIVERY_YES;
383 }
384
385 bool
386 _SplitPanel::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
387 {
388         if (&source != this)
389         {
390                 return false;
391         }
392         return __pSplitPanelPresenter->OnTouchPressed(source, touchinfo);
393 }
394
395 bool
396 _SplitPanel::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
397 {
398         if (&source != this)
399         {
400                 return false;
401         }
402         return __pSplitPanelPresenter->OnTouchReleased(source, touchinfo);
403 }
404
405 bool
406 _SplitPanel::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
407 {
408         if (&source != this)
409         {
410                 return false;
411         }
412         return __pSplitPanelPresenter->OnTouchMoved(source, touchinfo);
413 }
414
415 bool
416 _SplitPanel::OnTouchCanceled(const _Control & source, const _TouchInfo & touchinfo)
417 {
418         return __pSplitPanelPresenter->OnTouchCanceled(source, touchinfo);
419 }
420
421 bool
422 _SplitPanel::OnTapGestureDetected(_TouchTapGestureDetector& gesture)
423 {
424         if (__pSplitPanelPresenter == null)
425         {
426                 return true;
427         }
428
429         return __pSplitPanelPresenter->OnTapGestureDetected(gesture);
430 }
431
432 bool
433 _SplitPanel::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
434 {
435         return __pSplitPanelPresenter->OnTapGestureCanceled(gesture);
436 }
437
438 result
439 _SplitPanel::SetPane(_Control* pControl, SplitPanelPaneOrder paneOrder)
440 {
441         result r = E_SUCCESS;
442
443         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
444         {
445                 if (pControl != null)
446                 {
447                         r = __pFirstPaneParent->AttachChild(*pControl);
448                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
449                 }
450
451                 __pFirstPane = pControl;
452         }
453         else
454         {
455                 if (pControl != null)
456                 {
457                         r = __pSecondPaneParent->AttachChild(*pControl);
458                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
459                 }
460
461                 __pSecondPane = pControl;
462         }
463
464          __pSplitPanelPresenter->RecalcSplitPanel();
465
466         return E_SUCCESS;
467 }
468
469 _Control*
470 _SplitPanel::GetPane(SplitPanelPaneOrder paneOrder) const
471 {
472         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
473         {
474                 return const_cast <_Control*>(__pFirstPane);
475         }
476
477         return const_cast <_Control*>(__pSecondPane);
478 }
479
480 _Control*
481 _SplitPanel::GetPaneParent(SplitPanelPaneOrder paneOrder) const
482 {
483         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
484         {
485                 return const_cast <_Control*>(__pFirstPaneParent);
486         }
487
488         return const_cast <_Control*>(__pSecondPaneParent);
489 }
490
491 result
492 _SplitPanel::SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle)
493 {
494         __pSplitPanelPresenter->SetDividerStyle(splitPanelDividerStyle);
495
496         return E_SUCCESS;
497 }
498
499 SplitPanelDividerStyle
500 _SplitPanel::GetDividerStyle(void) const
501 {
502         return __pSplitPanelPresenter->GetDividerStyle();
503 }
504
505 result
506 _SplitPanel::SetDividerPosition(float position)
507 {
508         const float width = GetBoundsF().width;
509         const float height = GetBoundsF().height;
510         int configValue = 0;
511         float margin = 0.0f;
512         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
513
514         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
515         {
516                 GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, configValue);
517         }
518         else
519         {
520                 GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, configValue);
521         }
522
523         margin = _CoordinateSystemUtils::ConvertToFloat(configValue);
524
525         if ((0.0f > position) ||
526                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) && ((width - margin) < position)) ||
527                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL) && ((height - margin) < position)))
528         {
529                 return E_OUT_OF_RANGE;
530         }
531
532         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
533         {
534                 if ((GetMinimumDividerPosition() > position) || (GetMaximumDividerPosition() < position))
535                 {
536                         return E_OUT_OF_RANGE;
537                 }
538         }
539
540         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
541         {
542                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
543                 {
544                         __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
545                 }
546                 else
547                 {
548                         __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
549                 }
550         }
551         else
552         {
553                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
554                 {
555                         __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
556                 }
557                 else
558                 {
559                         __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
560                 }
561         }
562
563         __pSplitPanelPresenter->RecalcSplitPanel();
564
565         return E_SUCCESS;
566 }
567
568 float
569 _SplitPanel::GetDividerPosition(void) const
570 {
571         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
572
573         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
574         {
575                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
576                 {
577                         return __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE];
578                 }
579                 else
580                 {
581                         return __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE];
582                 }
583         }
584         else
585         {
586                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
587                 {
588                         return __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT];
589                 }
590                 else
591                 {
592                         return __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT];
593                 }
594         }
595 }
596
597 result
598 _SplitPanel::SetMaximumDividerPosition(float position)
599 {
600         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED)
601         {
602                 SysLog(NID_UI_CTRL, "[E_SYSTEM] System error occurred. This functionality is not supported for divider style fixed.");
603                 return E_SUCCESS;
604         }
605
606         const float width = GetBoundsF().width;
607         const float height = GetBoundsF().height;
608         int configValue = 0;
609         float margin = 0.0f;
610         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
611
612         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
613         {
614                 GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, configValue);
615         }
616         else
617         {
618                 GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, configValue);
619         }
620
621         margin = _CoordinateSystemUtils::ConvertToFloat(configValue);
622
623         if ((0.0f > position) ||
624                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) && ((width - margin) < position)) ||
625                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL) && ((height - margin) < position)) ||
626                         (position < GetMinimumDividerPosition()))
627         {
628                 return E_OUT_OF_RANGE;
629         }
630
631         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
632         {
633                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
634                 {
635                         __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
636                 }
637                 else
638                 {
639                         __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
640                 }
641         }
642         else
643         {
644                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
645                 {
646                         __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
647                 }
648                 else
649                 {
650                         __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
651                 }
652         }
653
654         if (GetDividerPosition() > position)
655         {
656                 SetDividerPosition(position);
657         }
658
659         return E_SUCCESS;
660 }
661
662 float
663 _SplitPanel::GetMaximumDividerPosition(void) const
664 {
665         if (GetDividerStyle() != SPLIT_PANEL_DIVIDER_STYLE_FIXED)
666         {
667                 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
668
669                 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
670                 {
671                         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
672                         {
673                                 return __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE];
674                         }
675                         else
676                         {
677                                 return __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE];
678                         }
679                 }
680                 else
681                 {
682                         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
683                         {
684                                 return __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT];
685                         }
686                         else
687                         {
688                                 return __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT];
689                         }
690                 }
691
692         }
693
694         return GetBounds().width;
695 }
696
697 result
698 _SplitPanel::SetMinimumDividerPosition(float position)
699 {
700         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED)
701         {
702                 SysLog(NID_UI_CTRL, "[E_SYSTEM] System error occurred. This functionality is not supported for divider style fixed");
703                 return E_SUCCESS;
704         }
705
706         const float width = GetBoundsF().width;
707         const float height = GetBoundsF().height;
708         int configValue = 0;
709         float margin = 0.0f;
710         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
711
712         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
713         {
714                 GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, configValue);
715         }
716         else
717         {
718                 GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, configValue);
719         }
720
721         margin = _CoordinateSystemUtils::ConvertToFloat(configValue);
722
723         if ((0.0f > position) ||
724                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) && ((width - margin) < position)) ||
725                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL) && ((height - margin) < position)) ||
726                         (position > GetMaximumDividerPosition()))
727         {
728                 return E_OUT_OF_RANGE;
729         }
730
731         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
732         {
733                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
734                 {
735                         __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
736                 }
737                 else
738                 {
739                         __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
740                 }
741         }
742         else
743         {
744                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
745                 {
746                         __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
747                 }
748                 else
749                 {
750                         __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
751                 }
752         }
753
754         if (GetDividerPosition() < position)
755         {
756                 SetDividerPosition(position);
757         }
758
759         return E_SUCCESS;
760 }
761
762 float
763 _SplitPanel::GetMinimumDividerPosition(void) const
764 {
765         if (GetDividerStyle() != SPLIT_PANEL_DIVIDER_STYLE_FIXED)
766         {
767                 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
768
769                 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
770                 {
771                         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
772                         {
773                                 return __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE];
774                         }
775                         else
776                         {
777                                 return __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE];
778                         }
779                 }
780                 else
781                 {
782                         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
783                         {
784                                 return __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT];
785                         }
786                         else
787                         {
788                                 return __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT];
789                         }
790                 }
791
792         }
793
794         return 0;
795 }
796
797 void
798 _SplitPanel::SetDividerDirection(SplitPanelDividerDirection dividerDirection)
799 {
800         __splitPanelDividerDirection = dividerDirection;
801
802         return;
803 }
804
805 SplitPanelDividerDirection
806 _SplitPanel::GetDividerDirection(void) const
807 {
808         SetLastResult(E_SUCCESS);
809
810         return __splitPanelDividerDirection;
811 }
812
813 result
814 _SplitPanel::MaximizePane(SplitPanelPaneOrder paneOrder)
815 {
816         return __pSplitPanelPresenter->MaximizePane(paneOrder);
817 }
818
819 bool
820 _SplitPanel::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const
821 {
822         return __pSplitPanelPresenter->IsPaneMaximized(paneOrder);
823 }
824
825 result
826 _SplitPanel::RestorePane(void)
827 {
828         return __pSplitPanelPresenter->RestorePane();
829 }
830
831 result
832 _SplitPanel::SendSplitPanelEvent(_SplitPanelEventStatus status)
833 {
834         result r = E_SUCCESS;
835         IEventArg* pEventArg = null;
836
837         if (__pSplitPanelEvent)
838         {
839                 pEventArg = _SplitPanelEvent::CreateSplitPanelEventArgN(status);
840                 r = GetLastResult();
841                 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
842
843                 __pSplitPanelEvent->Fire(*pEventArg);
844         }
845
846         return r;
847 }
848
849 void
850 _SplitPanel::SetTapCount(int count)
851 {
852         __dividerTapCount = count;
853
854         return;
855 }
856
857 int
858 _SplitPanel::GetTapCount(void) const
859 {
860         return __dividerTapCount;
861 }
862
863 VisualElement*
864 _SplitPanel::GetDividerVisualElement(void)
865 {
866         return __pDividerVisualElement;
867 }
868
869 void
870 _SplitPanel::SetDividerVisualElementBounds(Tizen::Graphics::FloatRectangle& bounds)
871 {
872         if (__pDividerVisualElement)
873         {
874                 __pDividerVisualElement->SetBounds(bounds);
875         }
876
877         return;
878 }
879
880 }}} // Tizen::Ui::Controls
881