Revert " modify license, permission and remove ^M char"
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_PublicAdjustmentEvent.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                FUiCtrl_PublicAdjustmentEvent.cpp
20  * @brief               This is the implementation for the _AdjustmentEvent class.
21  *
22  * This file contains the implementation of _AdjustmentEvent class. @n
23  */
24
25 #include <new>
26 #include <FBaseSysLog.h>
27 #include <FBaseErrors.h>
28 #include <FUiIAdjustmentEventListener.h>
29 #include "FUiCtrl_PublicAdjustmentEvent.h"
30
31 using namespace Tizen::Ui;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Runtime;
34
35 namespace Tizen { namespace Ui { namespace Controls
36 {
37
38 class _OSP_EXPORT_ _PublicAdjustmentEventArg
39         : public IEventArg
40         , public Object
41 {
42 // Lifecycle
43 public:
44         _PublicAdjustmentEventArg(int adjustment);
45         virtual ~_PublicAdjustmentEventArg(void);
46
47 // Access
48 public:
49         int GetAdjustment(void) const;
50
51 // Attribute
52 private:
53         int __adjustment;
54
55 }; // _PublicAdjustmentEventArg
56
57 _PublicAdjustmentEventArg::_PublicAdjustmentEventArg(int adjustment)
58         : __adjustment(adjustment)
59 {
60 }
61
62 _PublicAdjustmentEventArg::~_PublicAdjustmentEventArg(void)
63 {
64 }
65
66 int
67 _PublicAdjustmentEventArg::GetAdjustment(void) const
68 {
69         return __adjustment;
70 }
71
72
73 _PublicAdjustmentEvent::_PublicAdjustmentEvent(const Control& source)
74         : __pSource(null)
75 {
76         result r = _Event::Initialize();
77
78         // set event source
79         if (r == E_SUCCESS)
80         {
81                 __pSource = &source;
82         }
83 }
84
85 _PublicAdjustmentEvent::~_PublicAdjustmentEvent(void)
86 {
87 }
88
89 _PublicAdjustmentEvent*
90 _PublicAdjustmentEvent::CreateInstanceN(const Control& source)
91 {
92         _PublicAdjustmentEvent* pPublicAdjustmentEvent = new (std::nothrow) _PublicAdjustmentEvent(source);
93         SysTryReturn(NID_UI_CTRL, pPublicAdjustmentEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
94
95         if (IsFailed(GetLastResult()))
96         {
97                 goto CATCH;
98         }
99
100         return pPublicAdjustmentEvent;
101
102 CATCH:
103         delete pPublicAdjustmentEvent;
104         pPublicAdjustmentEvent = null;
105
106         return null;
107 }
108
109 const Control*
110 _PublicAdjustmentEvent::GetSource(void) const
111 {
112         return __pSource;
113 }
114
115 void
116 _PublicAdjustmentEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
117 {
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.");
122
123         // cast to _PublicAdjustmentEventArg
124         const _PublicAdjustmentEventArg* pAdjustmentEventArg = dynamic_cast <const _PublicAdjustmentEventArg*>(&arg);
125         SysTryReturnVoidResult(NID_UI_CTRL, pAdjustmentEventArg != null, E_INVALID_ARG,
126                                 "[E_INVALID_ARG] The invalid Event Argument was given.");
127
128         // call cursor change event listener method
129         pAdjustmentListener->OnAdjustmentValueChanged(*__pSource, pAdjustmentEventArg->GetAdjustment());
130         SetLastResult(E_SUCCESS);
131         return;
132 }
133
134 IEventArg*
135 _PublicAdjustmentEvent::CreateAdjustmentEventArgN(int adjustment)
136 {
137         _PublicAdjustmentEventArg* pEventArg = new (std::nothrow) _PublicAdjustmentEventArg(adjustment);
138         SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
139
140         return pEventArg;
141 }
142
143 }}} // Tizen::Ui::Controls