Tizen 2.1 base
[framework/osp/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 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 /**
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::SetPane(Control* pControl, SplitPanelPaneOrder paneOrder)
71 {
72         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
73         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
74
75         return pSplitPanelImpl->SetPane(const_cast <_ControlImpl*>(_ControlImpl::GetInstance(*pControl)), paneOrder);
76 }
77
78 Control*
79 SplitPanel::GetPane(SplitPanelPaneOrder paneOrder) const
80 {
81         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
82         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
83
84         _ControlImpl* pSplitPaneImpl = pSplitPanelImpl->GetPane(paneOrder);
85         result r = GetLastResult();
86         SysTryReturn(NID_UI_CTRL, pSplitPaneImpl, null, r, "[%s] Propagating.", GetErrorMessage(r));
87         return &(pSplitPaneImpl->GetPublic());
88 }
89
90 result
91 SplitPanel::SetDividerPosition(int position)
92 {
93         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
94         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
95
96         return pSplitPanelImpl->SetDividerPosition(position);
97 }
98
99 int
100 SplitPanel::GetDividerPosition(void) const
101 {
102         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
103         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
104
105         return pSplitPanelImpl->GetDividerPosition();
106 }
107
108 result
109 SplitPanel::SetMaximumDividerPosition(int position)
110 {
111         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
112         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
113
114         return pSplitPanelImpl->SetMaximumDividerPosition(position);
115 }
116
117 int
118 SplitPanel::GetMaximumDividerPosition(void) const
119 {
120         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
121         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
122
123         return pSplitPanelImpl->GetMaximumDividerPosition();
124 }
125
126 result
127 SplitPanel::SetMinimumDividerPosition(int position)
128 {
129         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
130         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
131
132         return pSplitPanelImpl->SetMinimumDividerPosition(position);
133 }
134
135 int
136 SplitPanel::GetMinimumDividerPosition(void) const
137 {
138         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
139         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
140
141         return pSplitPanelImpl->GetMinimumDividerPosition();
142 }
143
144 result
145 SplitPanel::MaximizePane(SplitPanelPaneOrder paneOrder)
146 {
147         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
148         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
149
150         return pSplitPanelImpl->MaximizePane(paneOrder);
151 }
152
153 bool
154 SplitPanel::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const
155 {
156         const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
157         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
158
159         return pSplitPanelImpl->IsPaneMaximized(paneOrder);
160 }
161
162 result
163 SplitPanel::RestorePane(void)
164 {
165         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
166         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
167
168         return pSplitPanelImpl->RestorePane();
169 }
170
171 result
172 SplitPanel::AddSplitPanelEventListener(ISplitPanelEventListener& listener)
173 {
174         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
175         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
176
177         return pSplitPanelImpl->AddSplitPanelEventListener(listener);
178 }
179
180 result
181 SplitPanel::RemoveSplitPanelEventListener(ISplitPanelEventListener& listener)
182 {
183         _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this);
184         SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use.");
185
186         return pSplitPanelImpl->RemoveSplitPanelEventListener(listener);
187 }
188
189 }}} // Tizen::Ui::Controls
190