2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FUiCtrl_SplitPanelImpl.cpp
20 * @brief This is the implementation file for the _SplitPanelImpl class.
23 #include <FBaseInternalTypes.h>
24 #include <FApp_AppInfo.h>
25 #include <FBaseSysLog.h>
26 #include <FUiCtrlPanel.h>
27 #include <FUiCtrlScrollPanel.h>
28 #include <FUiCtrlForm.h>
29 #include "FUiCtrl_SplitPanelImpl.h"
30 #include "FUiCtrl_SplitPanel.h"
31 #include "FUi_UiBuilder.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::App;
39 namespace Tizen { namespace Ui { namespace Controls
43 _SplitPanelImpl::GetInstance(SplitPanel& pSplitPanel)
45 return static_cast<_SplitPanelImpl*> (pSplitPanel._pControlImpl);
48 const _SplitPanelImpl*
49 _SplitPanelImpl::GetInstance(const SplitPanel& pSplitPanel)
51 return static_cast<const _SplitPanelImpl*> (pSplitPanel._pControlImpl);
54 _SplitPanelImpl::_SplitPanelImpl(SplitPanel* pPublic, _SplitPanel* pCore)
55 : _ControlImpl(pPublic, pCore)
56 , __pSplitPanel(pCore)
57 , __pPublicSplitPanelEvent(null)
62 _SplitPanelImpl::~_SplitPanelImpl(void)
64 __pSplitPanel->RemoveSplitPanelEventListener(*this);
66 if(__pPublicSplitPanelEvent)
68 delete __pPublicSplitPanelEvent;
69 __pPublicSplitPanelEvent = null;
76 _SplitPanelImpl::CreateSplitPanelImplN(SplitPanel* pControl, const Rectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection)
81 _SplitPanel* pCore = _SplitPanel::CreateSplitPanelN(rect, splitPanelDividerStyle, splitPanelDividerDirection);
82 SysTryReturn(NID_UI_CTRL, pCore != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
84 _SplitPanelImpl* pImpl = new (std::nothrow) _SplitPanelImpl(pControl, pCore);
85 r = _ControlImpl::CheckConstruction(pCore, pImpl);
86 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
92 _SplitPanelImpl::Initialize(const Rectangle& rect)
98 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
100 __pPublicSplitPanelEvent = _PublicSplitPanelEvent::CreateInstanceN(GetPublic());
101 SysTryReturn(NID_UI_CTRL, __pPublicSplitPanelEvent, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
103 r = GetCore().AddSplitPanelEventListener(*this);
104 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
110 _SplitPanelImpl::GetPublicClassName(void) const
112 return "Tizen::Ui::Controls::SplitPanel";
116 _SplitPanelImpl::GetPublic(void) const
118 return static_cast <const SplitPanel&>(_ControlImpl::GetPublic());
122 _SplitPanelImpl::GetPublic(void)
124 return static_cast <SplitPanel&>(_ControlImpl::GetPublic());
128 _SplitPanelImpl::GetCore(void) const
130 return static_cast <const _SplitPanel&>(_ControlImpl::GetCore());
134 _SplitPanelImpl::GetCore(void)
136 return static_cast <_SplitPanel&>(_ControlImpl::GetCore());
140 _SplitPanelImpl::OnDividerPositionChanged(_SplitPanel& source, int position)
144 if (__pPublicSplitPanelEvent != null)
146 IEventArg* pEventArg = _PublicSplitPanelEvent::CreateSplitPanelEventArgN(SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE);
147 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
148 __pPublicSplitPanelEvent->Fire(*pEventArg);
153 _SplitPanelImpl::OnDividerDoublePressed(_SplitPanel& source)
157 if (__pPublicSplitPanelEvent != null)
159 IEventArg* pEventArg = _PublicSplitPanelEvent::CreateSplitPanelEventArgN(SPLIT_PANEL_EVENT_DIVIDER_DOUBLE_PRESSED);
160 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
161 __pPublicSplitPanelEvent->Fire(*pEventArg);
166 _SplitPanelImpl::AddSplitPanelEventListener(ISplitPanelEventListener& listener)
168 return __pPublicSplitPanelEvent->AddListener(listener);
172 _SplitPanelImpl::RemoveSplitPanelEventListener(ISplitPanelEventListener& listener)
174 return __pPublicSplitPanelEvent->RemoveListener(listener);
178 _SplitPanelImpl::SetPane(_ControlImpl* pControl, SplitPanelPaneOrder paneOrder)
180 result r = E_SUCCESS;
182 if (pControl == null)
184 r = GetCore().SetPane(null, paneOrder);
188 r = GetCore().SetPane(&(pControl->GetCore()), paneOrder);
191 SetLastResultReturn(r);
195 _SplitPanelImpl::GetPane(SplitPanelPaneOrder paneOrder) const
197 _Control* pControl = GetCore().GetPane(paneOrder);
198 if (pControl == null)
203 return static_cast<_ControlImpl*>(pControl->GetUserData());
207 _SplitPanelImpl::SetDividerPosition(int position)
209 result r = GetCore().SetDividerPosition(position);
210 SetLastResultReturn(r);
214 _SplitPanelImpl::GetDividerPosition(void) const
217 return GetCore().GetDividerPosition();
221 _SplitPanelImpl::SetMaximumDividerPosition(int position)
223 result r = GetCore().SetMaximumDividerPosition(position);
224 SetLastResultReturn(r);
228 _SplitPanelImpl::GetMaximumDividerPosition(void) const
231 return GetCore().GetMaximumDividerPosition();
235 _SplitPanelImpl::SetMinimumDividerPosition(int position)
237 result r = GetCore().SetMinimumDividerPosition(position);
238 SetLastResultReturn(r);
242 _SplitPanelImpl::GetMinimumDividerPosition(void) const
245 return GetCore().GetMinimumDividerPosition();
249 _SplitPanelImpl::MaximizePane(SplitPanelPaneOrder paneOrder)
251 result r = GetCore().MaximizePane(paneOrder);
252 SetLastResultReturn(r);
256 _SplitPanelImpl::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const
259 return GetCore().IsPaneMaximized(paneOrder);
263 _SplitPanelImpl::RestorePane(void)
265 result r = GetCore().RestorePane();
266 SetLastResultReturn(r);
269 class _SplitPanelMaker
270 : public _UiBuilderControlMaker
273 _SplitPanelMaker(_UiBuilder* uibuilder)
274 : _UiBuilderControlMaker(uibuilder){};
275 virtual ~_SplitPanelMaker(void){};
276 static _UiBuilderControlMaker*
277 GetInstance(_UiBuilder* uibuilder)
279 _SplitPanelMaker* pSplitPanelMaker = new (std::nothrow) _SplitPanelMaker(uibuilder);
281 return pSplitPanelMaker;
286 Make(_UiBuilderControl* pControl)
289 _UiBuilderControlLayout* pControlProperty = null;
290 SplitPanel* pSplitPanel = null;
291 Tizen::Graphics::Rectangle rect;
292 Tizen::Base::String elementString;
293 Tizen::Base::String xmlLink;
294 int minDividerPosition = 0;
295 int maxDividerPosition = 0;
296 int dividerPosition = 0;
298 SplitPanelDividerStyle splitPanelDividerStyle = SPLIT_PANEL_DIVIDER_STYLE_MOVABLE;
299 SplitPanelDividerDirection splitPanelDividerDirection = SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL;
301 GetProperty(pControl, &pControlProperty);
303 if (pControlProperty == null)
308 pSplitPanel = new (std::nothrow) SplitPanel();
309 SysTryReturn(NID_UI_CTRL, pSplitPanel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
311 rect = pControlProperty->GetRect();
314 if (pControl->GetElement("dividerStyle", elementString) || pControl->GetElement("DividerStyle", elementString))
316 if (elementString.Equals(L"SPLIT_PANEL_DIVIDER_STYLE_FIXED", false))
318 splitPanelDividerStyle = SPLIT_PANEL_DIVIDER_STYLE_FIXED;
320 if (elementString.Equals(L"SPLIT_PANEL_DIVIDER_STYLE_MOVABLE", false))
322 splitPanelDividerStyle = SPLIT_PANEL_DIVIDER_STYLE_MOVABLE;
326 if (pControl->GetElement("dividerDirection", elementString) || pControl->GetElement("DividerDirection", elementString))
328 if (elementString.Equals(L"SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL", false))
330 splitPanelDividerDirection = SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL;
332 if (elementString.Equals(L"SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL", false))
334 splitPanelDividerDirection = SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL;
339 r = pSplitPanel->Construct(rect, splitPanelDividerStyle, splitPanelDividerDirection);
343 SysLog(NID_UI_CTRL, "Failed to create SplitPanel.");
350 if (pControl->GetElement("minDividerPosition", elementString))
352 Base::Integer::Parse(elementString, minDividerPosition);
353 pSplitPanel->SetMinimumDividerPosition(minDividerPosition);
356 if (pControl->GetElement("maxDividerPosition", elementString))
358 Base::Integer::Parse(elementString, maxDividerPosition);
359 pSplitPanel->SetMaximumDividerPosition(maxDividerPosition);
362 if (pControl->GetElement("dividerPosition", elementString))
364 Base::Integer::Parse(elementString, dividerPosition);
365 pSplitPanel->SetDividerPosition(dividerPosition);
369 if (pControl->GetElement("firstPane", elementString))
371 if (pControl->GetElement("firstPaneXmlLink", xmlLink))
373 if (elementString.Equals(L"panel", false))
375 Panel* pFirstPanel = new (std::nothrow) Panel();
376 pFirstPanel->Construct(xmlLink);
377 pSplitPanel->SetPane(pFirstPanel, SPLIT_PANEL_PANE_ORDER_FIRST);
379 else if (elementString.Equals(L"form", false))
381 Form* pFirstForm = new (std::nothrow) Form();
382 pFirstForm->Construct(xmlLink);
383 pSplitPanel->SetPane(pFirstForm, SPLIT_PANEL_PANE_ORDER_FIRST);
385 else if (elementString.Equals(L"scrollpanel", false))
387 ScrollPanel* pFirstScrollPanel = new (std::nothrow) ScrollPanel();
388 pFirstScrollPanel->Construct(xmlLink);
389 pSplitPanel->SetPane(pFirstScrollPanel, SPLIT_PANEL_PANE_ORDER_FIRST);
394 if (pControl->GetElement("secondPane", elementString))
396 if (pControl->GetElement("secondPaneXmlLink", xmlLink))
398 if (elementString.Equals(L"panel", false))
400 Panel* pFirstPanel = new (std::nothrow) Panel();
401 pFirstPanel->Construct(xmlLink);
402 pSplitPanel->SetPane(pFirstPanel, SPLIT_PANEL_PANE_ORDER_SECOND);
404 else if (elementString.Equals(L"form", false))
406 Form* pFirstForm = new (std::nothrow) Form();
407 pFirstForm->Construct(xmlLink);
408 pSplitPanel->SetPane(pFirstForm, SPLIT_PANEL_PANE_ORDER_SECOND);
410 else if (elementString.Equals(L"scrollpanel", false))
412 ScrollPanel* pFirstScrollPanel = new (std::nothrow) ScrollPanel();
413 pFirstScrollPanel->Construct(xmlLink);
414 pSplitPanel->SetPane(pFirstScrollPanel, SPLIT_PANEL_PANE_ORDER_SECOND);
421 }; // _SplitPanelMaker
423 _SplitPanelRegister::_SplitPanelRegister(void)
425 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
426 pUiBuilderControlTableManager->RegisterControl(L"SplitPanel", _SplitPanelMaker::GetInstance);
428 _SplitPanelRegister::~_SplitPanelRegister(void)
430 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
431 pUiBuilderControlTableManager->UnregisterControl(L"SplitPanel");
433 static _SplitPanelRegister SplitPanelRegisterToUIbuilder;
434 }}} // Tizen::Ui::Controls