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_AdjustmentEvent.cpp
20 * @brief This is the implementation for the _AdjustmentEvent class.
22 * This file contains the implementation of _AdjustmentEvent class. @n
26 #include <FBaseSysLog.h>
27 #include <FBaseErrors.h>
28 #include "FUiCtrl_IAdjustmentEventListener.h"
29 #include "FUiCtrl_AdjustmentEvent.h"
31 using namespace Tizen::Ui;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Runtime;
35 namespace Tizen { namespace Ui { namespace Controls
38 class _OSP_EXPORT_ _AdjustmentEventArg
44 _AdjustmentEventArg(int adjustment);
45 virtual ~_AdjustmentEventArg(void);
49 int GetAdjustment(void) const;
55 }; // _AdjustmentEventArg
57 _AdjustmentEventArg::_AdjustmentEventArg(int adjustment)
58 : __adjustment(adjustment)
62 _AdjustmentEventArg::~_AdjustmentEventArg(void)
67 _AdjustmentEventArg::GetAdjustment(void) const
73 _AdjustmentEvent::_AdjustmentEvent(const _Control& source)
76 result r = _Event::Initialize();
85 _AdjustmentEvent::~_AdjustmentEvent(void)
90 _AdjustmentEvent::CreateInstanceN(const _Control& source)
92 _AdjustmentEvent* pAdjustmentEvent = new (std::nothrow) _AdjustmentEvent(source);
93 SysTryReturn(NID_UI_CTRL, pAdjustmentEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
95 if (IsFailed(GetLastResult()))
100 return pAdjustmentEvent;
103 delete pAdjustmentEvent;
104 pAdjustmentEvent = null;
110 _AdjustmentEvent::GetSource(void) const
116 _AdjustmentEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
118 // cast to _IAdjustmentEventListener
119 _IAdjustmentEventListener* pAdjustmentListener = dynamic_cast <_IAdjustmentEventListener*>(&listener);
120 SysTryReturnVoidResult(NID_UI_CTRL, pAdjustmentListener != null, E_INVALID_ARG,
121 "[E_INVALID_ARG] The invalid listener was given.\n");
123 // cast to _AdjustmentEventArg
124 const _AdjustmentEventArg* pAdjustmentEventArg = dynamic_cast <const _AdjustmentEventArg*>(&arg);
125 SysTryReturnVoidResult(NID_UI_CTRL, pAdjustmentEventArg != null, E_INVALID_ARG,
126 "[E_INVALID_ARG] The invalid Event Argument was given.\n");
128 // call cursor change event listener method
129 pAdjustmentListener->OnAdjustmentValueChanged(*__pSource, pAdjustmentEventArg->GetAdjustment());
130 SetLastResult(E_SUCCESS);
135 _AdjustmentEvent::CreateAdjustmentEventArgN(int adjustment)
137 _AdjustmentEventArg* pEventArg = new (std::nothrow) _AdjustmentEventArg(adjustment);
138 SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
143 }}} // Tizen::Ui::Controls