2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
18 * @file FUiCtrl_AnimationImpl.cpp
19 * @brief This is the implementation file for the _AnimationImpl class.
22 #include <FUiCtrlAnimation.h>
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_AnimationImpl.h"
25 #include "FUiCtrl_Animation.h"
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::Base::Runtime;
30 namespace Tizen { namespace Ui { namespace Controls
34 _AnimationImpl::GetInstance(Animation& animation)
36 return static_cast<_AnimationImpl*> (animation._pControlImpl);
40 _AnimationImpl::GetInstance(const Animation& animation)
42 return static_cast<const _AnimationImpl*> (animation._pControlImpl);
45 _AnimationImpl::_AnimationImpl(Animation* pPublic, _Animation* pCore)
46 : _ControlImpl(pPublic, pCore)
47 , __pPublicAnimationEvent(null)
49 SetFocusableChangable(false);
52 _AnimationImpl::~_AnimationImpl(void)
54 if (__pPublicAnimationEvent != null)
56 delete __pPublicAnimationEvent;
57 __pPublicAnimationEvent = null;
62 _AnimationImpl::CreateAnimationImplN(Animation* pControl)
68 _Animation* pCore = _Animation::CreateAnimationN();
70 SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
72 _AnimationImpl* pImpl = new (std::nothrow) _AnimationImpl(pControl, pCore);
74 r = CheckConstruction(pCore, pImpl);
75 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
77 pImpl->__pPublicAnimationEvent = _PublicAnimationEvent::CreateInstanceN(*pControl);
79 SysTryCatch(NID_UI_CTRL, pImpl->__pPublicAnimationEvent != null, , r, "[%s] Propagating.", GetErrorMessage(r));
81 r = pCore->AddAnimationEventListener(*pImpl);
82 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
94 _AnimationImpl::SetAnimationFrames(const IList& animationFrames)
98 return GetCore().SetAnimationFrames(animationFrames);
102 _AnimationImpl::SetImageCount(int imageCount)
104 GetCore().SetImageCount(imageCount);
110 _AnimationImpl::AddAnimationEventListener(IAnimationEventListener& listener)
114 SysTryReturnResult(NID_UI_CTRL, __pPublicAnimationEvent, E_SYSTEM, "A system error has occurred. The _PublicAnimationEvent instance is null");
116 result r = __pPublicAnimationEvent->AddListener(listener);
117 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "A system error has occurred. The IAnimationEventListener instance already exists in the event listener list.");
123 _AnimationImpl::RemoveAnimationEventListener(IAnimationEventListener& listener)
127 SysTryReturnResult(NID_UI_CTRL, __pPublicAnimationEvent, E_SYSTEM, "A system error has occurred. The _PublicAnimationEvent instance is null");
129 result r = __pPublicAnimationEvent->RemoveListener(listener);
130 SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "A system error has occurred. The IAnimationEventListener instance does not exist in the event listener list.");
136 _AnimationImpl::SetRepeatCount(int count)
140 Variant repeatCount(count);
142 return GetCore().SetPropertyRepeatCount(repeatCount);
146 _AnimationImpl::GetRepeatCount(void) const
150 return GetCore().GetPropertyRepeatCount().ToInt();
154 _AnimationImpl::GetCurrentRepeatedCount(void) const
158 return GetCore().GetCurrentRepeatedCount();
162 _AnimationImpl::GetImageCount(void) const
166 return GetCore().GetImageCount();
170 _AnimationImpl::Play(void)
174 return GetCore().Play();
178 _AnimationImpl::Stop(void)
182 return GetCore().Stop();
186 _AnimationImpl::Pause(void)
190 return GetCore().Pause();
194 _AnimationImpl::GetStatus(void) const
196 return GetCore().GetStatus();
200 _AnimationImpl::OnAnimationStopped(const _Control& source)
202 IEventArg* pEventArg = _PublicAnimationEvent::CreateAnimationEventArgN();
203 result r = GetLastResult();
204 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
206 r = __pPublicAnimationEvent->Fire(*pEventArg);
208 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
210 SetLastResult(E_SUCCESS);
215 _AnimationImpl::GetPublicClassName(void) const
217 return "Tizen::Ui::Controls::Animation";
221 _AnimationImpl::GetPublic(void) const
223 return static_cast <const Animation&>(_ControlImpl::GetPublic());
227 _AnimationImpl::GetPublic(void)
229 return static_cast <Animation&>(_ControlImpl::GetPublic());
233 _AnimationImpl::GetCore(void) const
235 return static_cast <const _Animation&>(_ControlImpl::GetCore());
239 _AnimationImpl::GetCore(void)
241 return static_cast <_Animation&>(_ControlImpl::GetCore());
244 }}} // Tizen::Ui::Controls