add patch
[framework/osp/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 != null)
179         {
180                 __pDividerVisualElement->Destroy();
181                 __pDividerVisualElement = null;
182         }
183
184         delete __pSplitPanelPresenter;
185         __pSplitPanelPresenter = null;
186
187         if (__pFirstPaneParent != null)
188         {
189                 DetachChild(*__pFirstPaneParent);
190
191                 delete __pFirstPaneParent;
192                 __pFirstPaneParent = null;
193         }
194
195         if (__pSecondPaneParent != null)
196         {
197                 DetachChild(*__pSecondPaneParent);
198
199                 delete __pSecondPaneParent;
200                 __pSecondPaneParent = null;
201         }
202
203         return r;
204 }
205
206 _SplitPanel::~_SplitPanel(void)
207 {
208         delete __pSplitPanelPresenter;
209         __pSplitPanelPresenter = null;
210
211         delete __pSplitPanelEvent;
212         __pSplitPanelEvent = null;
213
214         if (__pTapGesture != null)
215         {
216                 __pTapGesture->RemoveGestureListener(*this);
217                 RemoveGestureDetector(*__pTapGesture);
218
219                 delete __pTapGesture;
220                 __pTapGesture = null;
221         }
222
223         if (__pDividerVisualElement != null)
224         {
225                 GetVisualElement()->DetachChild(*__pDividerVisualElement);
226
227                 __pDividerVisualElement->Destroy();
228                 __pDividerVisualElement = null;
229         }
230
231         if (__pFirstPaneParent != null)
232         {
233                 DetachChild(*__pFirstPaneParent);
234
235                 delete __pFirstPaneParent;
236                 __pFirstPaneParent = null;
237         }
238
239         if (__pSecondPaneParent != null)
240         {
241                 DetachChild(*__pSecondPaneParent);
242
243                 delete __pSecondPaneParent;
244                 __pSecondPaneParent = null;
245         }
246
247         ClearLastResult();
248 }
249
250 result
251 _SplitPanel::SetPresenter(const _SplitPanelPresenter& splitPanelPresenter)
252 {
253         __pSplitPanelPresenter = const_cast<_SplitPanelPresenter*>(&splitPanelPresenter);
254         return E_SUCCESS;
255 }
256
257 result
258 _SplitPanel::AddSplitPanelEventListener(const _ISplitPanelEventListener& listener)
259 {
260         result r = E_SUCCESS;
261
262         if (__pSplitPanelEvent == null)
263         {
264                 __pSplitPanelEvent = _SplitPanelEvent::CreateInstanceN(*this);
265                 r = GetLastResult();
266                 SysTryReturn(NID_UI_CTRL, __pSplitPanelEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
267
268                 __pSplitPanelEvent->AddListener(listener);
269         }
270
271         return r;
272 }
273
274 result
275 _SplitPanel::RemoveSplitPanelEventListener(const _ISplitPanelEventListener& listener)
276 {
277         SysTryReturn(NID_UI_CTRL, __pSplitPanelEvent, E_SYSTEM, E_SYSTEM,
278                                 "[E_SYSTEM] System error occurred.");
279
280         __pSplitPanelEvent->RemoveListener(listener);
281
282         return E_SUCCESS;
283 }
284
285 void
286 _SplitPanel::OnDraw(void)
287 {
288         __pSplitPanelPresenter->Draw();
289
290         return;
291 }
292
293 void
294 _SplitPanel::OnChangeLayout(_ControlOrientation orientation)
295 {
296         __pSplitPanelPresenter->OnChangeLayout(orientation);
297
298         return;
299 }
300
301 void
302 _SplitPanel::OnBoundsChanged(void)
303 {
304         FloatRectangle bounds = GetBoundsF();
305         float dividerThickness = 0.0f;
306         _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
307
308         orientation = _ControlManager::GetInstance()->GetOrientation();
309
310         GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, dividerThickness);
311
312         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
313         {
314                 if (GetMaximumDividerPosition() > (bounds.width - dividerThickness))
315                 {
316                         SetMaximumDividerPosition(bounds.width - dividerThickness);
317                 }
318         }
319         else
320         {
321                 if (GetMaximumDividerPosition() > (bounds.height - dividerThickness))
322                 {
323                         SetMaximumDividerPosition(bounds.height - dividerThickness);
324                 }
325         }
326
327         __pSplitPanelPresenter->OnBoundsChanged();
328
329         return;
330 }
331
332 _UiTouchEventDelivery
333 _SplitPanel::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
334 {
335         if (__pSplitPanelPresenter->OnTouchPressed(source, touchinfo))
336         {
337                 return _UI_TOUCH_EVENT_DELIVERY_NO;
338         }
339
340         return _UI_TOUCH_EVENT_DELIVERY_YES;
341 }
342
343 _UiTouchEventDelivery
344 _SplitPanel::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
345 {
346         if (__pSplitPanelPresenter->OnTouchReleased(source, touchinfo))
347         {
348                 return _UI_TOUCH_EVENT_DELIVERY_NO;
349         }
350
351         return _UI_TOUCH_EVENT_DELIVERY_YES;
352 }
353
354 _UiTouchEventDelivery
355 _SplitPanel::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
356 {
357         if (__pSplitPanelPresenter->OnTouchMoved(source, touchinfo))
358         {
359                 return _UI_TOUCH_EVENT_DELIVERY_NO;
360         }
361
362         return _UI_TOUCH_EVENT_DELIVERY_YES;
363 }
364
365 _UiTouchEventDelivery
366 _SplitPanel::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
367 {
368         if (__pSplitPanelPresenter->OnTouchCanceled(source, touchinfo))
369         {
370                 return _UI_TOUCH_EVENT_DELIVERY_NO;
371         }
372
373         return _UI_TOUCH_EVENT_DELIVERY_YES;
374 }
375
376 bool
377 _SplitPanel::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
378 {
379         if (&source != this)
380         {
381                 return false;
382         }
383         return __pSplitPanelPresenter->OnTouchPressed(source, touchinfo);
384 }
385
386 bool
387 _SplitPanel::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
388 {
389         if (&source != this)
390         {
391                 return false;
392         }
393         return __pSplitPanelPresenter->OnTouchReleased(source, touchinfo);
394 }
395
396 bool
397 _SplitPanel::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
398 {
399         if (&source != this)
400         {
401                 return false;
402         }
403         return __pSplitPanelPresenter->OnTouchMoved(source, touchinfo);
404 }
405
406 bool
407 _SplitPanel::OnTouchCanceled(const _Control & source, const _TouchInfo & touchinfo)
408 {
409         return __pSplitPanelPresenter->OnTouchCanceled(source, touchinfo);
410 }
411
412 bool
413 _SplitPanel::OnTapGestureDetected(_TouchTapGestureDetector& gesture)
414 {
415         if (__pSplitPanelPresenter == null)
416         {
417                 return true;
418         }
419
420         return __pSplitPanelPresenter->OnTapGestureDetected(gesture);
421 }
422
423 bool
424 _SplitPanel::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
425 {
426         return __pSplitPanelPresenter->OnTapGestureCanceled(gesture);
427 }
428
429 result
430 _SplitPanel::SetPane(_Control* pControl, SplitPanelPaneOrder paneOrder)
431 {
432         result r = E_SUCCESS;
433
434         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
435         {
436                 if (pControl != null)
437                 {
438                         r = __pFirstPaneParent->AttachChild(*pControl);
439                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
440                 }
441
442                 __pFirstPane = pControl;
443         }
444         else
445         {
446                 if (pControl != null)
447                 {
448                         r = __pSecondPaneParent->AttachChild(*pControl);
449                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
450                 }
451
452                 __pSecondPane = pControl;
453         }
454
455          __pSplitPanelPresenter->RecalcSplitPanel();
456
457         return E_SUCCESS;
458 }
459
460 _Control*
461 _SplitPanel::GetPane(SplitPanelPaneOrder paneOrder) const
462 {
463         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
464         {
465                 return const_cast <_Control*>(__pFirstPane);
466         }
467
468         return const_cast <_Control*>(__pSecondPane);
469 }
470
471 _Control*
472 _SplitPanel::GetPaneParent(SplitPanelPaneOrder paneOrder) const
473 {
474         if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST)
475         {
476                 return const_cast <_Control*>(__pFirstPaneParent);
477         }
478
479         return const_cast <_Control*>(__pSecondPaneParent);
480 }
481
482 result
483 _SplitPanel::SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle)
484 {
485         __pSplitPanelPresenter->SetDividerStyle(splitPanelDividerStyle);
486
487         return E_SUCCESS;
488 }
489
490 SplitPanelDividerStyle
491 _SplitPanel::GetDividerStyle(void) const
492 {
493         return __pSplitPanelPresenter->GetDividerStyle();
494 }
495
496 result
497 _SplitPanel::SetDividerPosition(float position)
498 {
499         const float width = GetBoundsF().width;
500         const float height = GetBoundsF().height;
501         int configValue = 0;
502         float margin = 0.0f;
503         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
504
505         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
506         {
507                 GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, configValue);
508         }
509         else
510         {
511                 GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, configValue);
512         }
513
514         margin = _CoordinateSystemUtils::ConvertToFloat(configValue);
515
516         if ((0.0f > position) ||
517                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) && ((width - margin) < position)) ||
518                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL) && ((height - margin) < position)))
519         {
520                 return E_OUT_OF_RANGE;
521         }
522
523         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
524         {
525                 if ((GetMinimumDividerPosition() > position) || (GetMaximumDividerPosition() < position))
526                 {
527                         return E_OUT_OF_RANGE;
528                 }
529         }
530
531         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
532         {
533                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
534                 {
535                         __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
536                 }
537                 else
538                 {
539                         __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
540                 }
541         }
542         else
543         {
544                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
545                 {
546                         __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
547                 }
548                 else
549                 {
550                         __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
551                 }
552         }
553
554         __pSplitPanelPresenter->RecalcSplitPanel();
555
556         return E_SUCCESS;
557 }
558
559 float
560 _SplitPanel::GetDividerPosition(void) const
561 {
562         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
563
564         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
565         {
566                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
567                 {
568                         return __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE];
569                 }
570                 else
571                 {
572                         return __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE];
573                 }
574         }
575         else
576         {
577                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
578                 {
579                         return __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT];
580                 }
581                 else
582                 {
583                         return __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT];
584                 }
585         }
586 }
587
588 result
589 _SplitPanel::SetMaximumDividerPosition(float position)
590 {
591         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED)
592         {
593                 SysLog(NID_UI_CTRL, "[E_SYSTEM] System error occurred. This functionality is not supported for divider style fixed.");
594                 return E_SUCCESS;
595         }
596
597         const float width = GetBoundsF().width;
598         const float height = GetBoundsF().height;
599         int configValue = 0;
600         float margin = 0.0f;
601         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
602
603         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
604         {
605                 GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, configValue);
606         }
607         else
608         {
609                 GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, configValue);
610         }
611
612         margin = _CoordinateSystemUtils::ConvertToFloat(configValue);
613
614         if ((0.0f > position) ||
615                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) && ((width - margin) < position)) ||
616                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL) && ((height - margin) < position)) ||
617                         (position < GetMinimumDividerPosition()))
618         {
619                 return E_OUT_OF_RANGE;
620         }
621
622         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
623         {
624                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
625                 {
626                         __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
627                 }
628                 else
629                 {
630                         __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
631                 }
632         }
633         else
634         {
635                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
636                 {
637                         __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
638                 }
639                 else
640                 {
641                         __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
642                 }
643         }
644
645         if (GetDividerPosition() > position)
646         {
647                 SetDividerPosition(position);
648         }
649
650         return E_SUCCESS;
651 }
652
653 float
654 _SplitPanel::GetMaximumDividerPosition(void) const
655 {
656         if (GetDividerStyle() != SPLIT_PANEL_DIVIDER_STYLE_FIXED)
657         {
658                 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
659
660                 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
661                 {
662                         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
663                         {
664                                 return __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE];
665                         }
666                         else
667                         {
668                                 return __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE];
669                         }
670                 }
671                 else
672                 {
673                         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
674                         {
675                                 return __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT];
676                         }
677                         else
678                         {
679                                 return __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT];
680                         }
681                 }
682
683         }
684
685         return GetBounds().width;
686 }
687
688 result
689 _SplitPanel::SetMinimumDividerPosition(float position)
690 {
691         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED)
692         {
693                 SysLog(NID_UI_CTRL, "[E_SYSTEM] System error occurred. This functionality is not supported for divider style fixed");
694                 return E_SUCCESS;
695         }
696
697         const float width = GetBoundsF().width;
698         const float height = GetBoundsF().height;
699         int configValue = 0;
700         float margin = 0.0f;
701         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
702
703         if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE)
704         {
705                 GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, configValue);
706         }
707         else
708         {
709                 GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, configValue);
710         }
711
712         margin = _CoordinateSystemUtils::ConvertToFloat(configValue);
713
714         if ((0.0f > position) ||
715                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) && ((width - margin) < position)) ||
716                         ((GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL) && ((height - margin) < position)) ||
717                         (position > GetMaximumDividerPosition()))
718         {
719                 return E_OUT_OF_RANGE;
720         }
721
722         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
723         {
724                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
725                 {
726                         __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
727                 }
728                 else
729                 {
730                         __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position;
731                 }
732         }
733         else
734         {
735                 if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
736                 {
737                         __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
738                 }
739                 else
740                 {
741                         __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position;
742                 }
743         }
744
745         if (GetDividerPosition() < position)
746         {
747                 SetDividerPosition(position);
748         }
749
750         return E_SUCCESS;
751 }
752
753 float
754 _SplitPanel::GetMinimumDividerPosition(void) const
755 {
756         if (GetDividerStyle() != SPLIT_PANEL_DIVIDER_STYLE_FIXED)
757         {
758                 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
759
760                 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
761                 {
762                         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
763                         {
764                                 return __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE];
765                         }
766                         else
767                         {
768                                 return __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE];
769                         }
770                 }
771                 else
772                 {
773                         if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL)
774                         {
775                                 return __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT];
776                         }
777                         else
778                         {
779                                 return __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT];
780                         }
781                 }
782
783         }
784
785         return 0;
786 }
787
788 void
789 _SplitPanel::SetDividerDirection(SplitPanelDividerDirection dividerDirection)
790 {
791         __splitPanelDividerDirection = dividerDirection;
792
793         return;
794 }
795
796 SplitPanelDividerDirection
797 _SplitPanel::GetDividerDirection(void) const
798 {
799         SetLastResult(E_SUCCESS);
800
801         return __splitPanelDividerDirection;
802 }
803
804 result
805 _SplitPanel::MaximizePane(SplitPanelPaneOrder paneOrder)
806 {
807         return __pSplitPanelPresenter->MaximizePane(paneOrder);
808 }
809
810 bool
811 _SplitPanel::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const
812 {
813         return __pSplitPanelPresenter->IsPaneMaximized(paneOrder);
814 }
815
816 result
817 _SplitPanel::RestorePane(void)
818 {
819         return __pSplitPanelPresenter->RestorePane();
820 }
821
822 result
823 _SplitPanel::SendSplitPanelEvent(_SplitPanelEventStatus status)
824 {
825         result r = E_SUCCESS;
826         IEventArg* pEventArg = null;
827
828         if (__pSplitPanelEvent != null)
829         {
830                 pEventArg = _SplitPanelEvent::CreateSplitPanelEventArgN(status);
831                 r = GetLastResult();
832                 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
833
834                 __pSplitPanelEvent->Fire(*pEventArg);
835         }
836
837         return r;
838 }
839
840 void
841 _SplitPanel::SetTapCount(int count)
842 {
843         __dividerTapCount = count;
844
845         return;
846 }
847
848 int
849 _SplitPanel::GetTapCount(void) const
850 {
851         return __dividerTapCount;
852 }
853
854 VisualElement*
855 _SplitPanel::GetDividerVisualElement(void)
856 {
857         return __pDividerVisualElement;
858 }
859
860 void
861 _SplitPanel::SetDividerVisualElementBounds(Tizen::Graphics::FloatRectangle& bounds)
862 {
863         if (__pDividerVisualElement != null)
864         {
865                 __pDividerVisualElement->SetBounds(bounds);
866         }
867
868         return;
869 }
870
871 }}} // Tizen::Ui::Controls
872