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