Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_AnimationEvent.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 * @file         FUiCtrl_AnimationEvent.cpp
19 * @brief        This is the implementation for the AnimationEvent class.
20 */
21
22 #include <new>
23 #include <FBaseErrors.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_IAnimationEventListener.h"
26 #include "FUiCtrl_AnimationEvent.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Runtime;
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 class _OSP_EXPORT_ _AnimationEventArg
35         : public IEventArg
36         , public Object
37 {
38 public:
39         _AnimationEventArg(void);
40         virtual ~_AnimationEventArg(void);
41
42 };  // _AnimationEventArg
43
44 _AnimationEventArg::_AnimationEventArg(void)
45 {
46 }
47
48 _AnimationEventArg::~_AnimationEventArg(void)
49 {
50 }
51
52
53 _AnimationEvent::_AnimationEvent(const _Control& source)
54         : __pSource(null)
55 {
56         result r = _Event::Initialize();
57
58         if (r == E_SUCCESS)
59         {
60                 __pSource = &source;
61         }
62 }
63
64 _AnimationEvent::~_AnimationEvent(void)
65 {
66 }
67
68 _AnimationEvent*
69 _AnimationEvent::CreateInstanceN(const _Control& source)
70 {
71         _AnimationEvent* pAnimationEvent = new (std::nothrow) _AnimationEvent(source);
72         SysTryReturn(NID_UI_CTRL, pAnimationEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
73
74         if (IsFailed(GetLastResult()))
75         {
76                 delete pAnimationEvent;
77                 pAnimationEvent = null;
78
79                 return null;
80         }
81
82         return pAnimationEvent;
83 }
84
85 const _Control*
86 _AnimationEvent::GetSource(void) const
87 {
88         return __pSource;
89 }
90
91 void
92 _AnimationEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
93 {
94         _IAnimationEventListener* pAnimationListener = dynamic_cast <_IAnimationEventListener*>(&listener);
95         SysTryReturnVoidResult(NID_UI_CTRL, pAnimationListener != null, E_INVALID_ARG,
96                                 "[E_INVALID_ARG] Invalid argument(s) is used. The _IAnimationEventListener instance is null.");
97
98         pAnimationListener->OnAnimationStopped(*__pSource);
99
100         SetLastResult(E_SUCCESS);
101         return;
102 }
103
104 IEventArg*
105 _AnimationEvent::CreateAnimationEventArgN(void)
106 {
107         _AnimationEventArg* pEventArg = new (std::nothrow) _AnimationEventArg();
108         SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
109
110         SetLastResult(E_SUCCESS);
111         return pEventArg;
112 }
113
114 }}} // Tizen::Ui::Controls