2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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_PublicSplitPanelEvent.cpp
20 * @brief This is the implementation for the _PublicSplitPanelEvent class.
26 #include <FBaseErrors.h>
27 #include <FBaseRtIEventListener.h>
28 #include <FUiCtrlSplitPanel.h>
29 #include <FBaseSysLog.h>
30 #include "FUiCtrl_PublicSplitPanelEvent.h"
31 #include "FUiCtrl_SplitPanelImpl.h"
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Runtime;
38 namespace Tizen { namespace Ui { namespace Controls
42 * @class _PublicSplitPanelEventArg
43 * @brief This class is used as the argument to change event listener.
45 * This class is used as the argument to change event listener. When an change event is generated
46 * (such as when a button is pressed) the SplitPanelEvent calls SplitPanelEventListener's OnTextd
47 * with an instance of this class as an argument.
49 * From this class, one can find out, the (event) source object and the change ID.
51 class _OSP_EXPORT_ _PublicSplitPanelEventArg
52 : public Tizen::Base::Runtime::IEventArg
53 , public Tizen::Base::Object
58 * This is the default class constructor.
62 _PublicSplitPanelEventArg(SplitPanelEventStatus status);
65 * This is the class destructor.
68 virtual ~_PublicSplitPanelEventArg(void);
73 SplitPanelEventStatus GetStatus(void) const;
80 SplitPanelEventStatus __status;
81 }; // _PublicSplitPanelEventArg
83 ////////////////////////////////////////////////////////////////////////////////
84 /// _PublicSplitPanelEventArg class Lifecycle
86 _PublicSplitPanelEventArg::_PublicSplitPanelEventArg(SplitPanelEventStatus status)
92 _PublicSplitPanelEventArg::~_PublicSplitPanelEventArg(void)
98 _PublicSplitPanelEventArg::GetStatus(void) const
103 ////////////////////////////////////////////////////////////////////////////////
104 /// _PublicSplitPanelEvent class Lifecycle
105 _PublicSplitPanelEvent::_PublicSplitPanelEvent(const SplitPanel& source)
108 //result r = Event::Construct();
109 result r = _Event::Initialize();
118 _PublicSplitPanelEvent::~_PublicSplitPanelEvent(void)
123 _PublicSplitPanelEvent*
124 _PublicSplitPanelEvent::CreateInstanceN(const SplitPanel& source)
126 _PublicSplitPanelEvent* pPublicSplitPanelEvent = new (std::nothrow) _PublicSplitPanelEvent(source);
127 SysTryReturn(NID_UI_CTRL, pPublicSplitPanelEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
129 return pPublicSplitPanelEvent;
135 _PublicSplitPanelEvent::GetSource(void) const
143 _PublicSplitPanelEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
145 // cast to IActionEventListener
146 ISplitPanelEventListener* pSplitPanelEventListener = dynamic_cast <ISplitPanelEventListener*>(&listener);
147 ISplitPanelEventListenerF* pSplitPanelEventListenerF = dynamic_cast <ISplitPanelEventListenerF*>(&listener);
148 SysTryReturnVoidResult(NID_UI_CTRL, pSplitPanelEventListener != null || pSplitPanelEventListenerF != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given.");
150 // cast to _PublicSplitPanelEventArg
151 const _PublicSplitPanelEventArg* pArg = dynamic_cast <const _PublicSplitPanelEventArg*>(&arg);
152 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.");
154 SplitPanel* pSource = null;
155 pSource = const_cast <SplitPanel*>(__pSource);
157 // call cursor change event listener method
158 SplitPanelEventStatus status = pArg->GetStatus();
159 if (status == SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE)
161 if (pSplitPanelEventListener)
163 pSplitPanelEventListener->OnDividerPositionChanged(*pSource, pSource->GetDividerPosition());
166 if (pSplitPanelEventListenerF)
168 pSplitPanelEventListenerF->OnDividerPositionChanged(*pSource, pSource->GetDividerPositionF());
173 if (pSplitPanelEventListener)
175 pSplitPanelEventListener->OnDividerDoublePressed(*pSource);
178 if (pSplitPanelEventListenerF)
180 pSplitPanelEventListenerF->OnDividerDoublePressed(*pSource);
186 _PublicSplitPanelEvent::CreateSplitPanelEventArgN(SplitPanelEventStatus status)
188 _PublicSplitPanelEventArg* pEventArg = new (std::nothrow) _PublicSplitPanelEventArg(status);
189 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
194 }}} // Tizen::Ui::Controls