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_AnimationImpl.cpp
20 * @brief This is the implementation file for the _AnimationImpl class.
23 #include <FUiCtrlAnimation.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_AnimationImpl.h"
26 #include "FUiCtrl_Animation.h"
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Base::Runtime;
31 namespace Tizen { namespace Ui { namespace Controls
35 _AnimationImpl::GetInstance(Animation& animation)
37 return static_cast<_AnimationImpl*> (animation._pControlImpl);
41 _AnimationImpl::GetInstance(const Animation& animation)
43 return static_cast<const _AnimationImpl*> (animation._pControlImpl);
46 _AnimationImpl::_AnimationImpl(Animation* pPublic, _Animation* pCore)
47 : _ControlImpl(pPublic, pCore)
48 , __pPublicAnimationEvent(null)
50 SetFocusableChangable(false);
53 _AnimationImpl::~_AnimationImpl(void)
55 if (__pPublicAnimationEvent != null)
57 delete __pPublicAnimationEvent;
58 __pPublicAnimationEvent = null;
63 _AnimationImpl::CreateAnimationImplN(Animation* pControl)
69 _Animation* pCore = _Animation::CreateAnimationN();
71 SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
73 _AnimationImpl* pImpl = new (std::nothrow) _AnimationImpl(pControl, pCore);
75 r = CheckConstruction(pCore, pImpl);
76 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
78 pImpl->__pPublicAnimationEvent = _PublicAnimationEvent::CreateInstanceN(*pControl);
80 SysTryCatch(NID_UI_CTRL, pImpl->__pPublicAnimationEvent != null, , r, "[%s] Propagating.", GetErrorMessage(r));
82 r = pCore->AddAnimationEventListener(*pImpl);
83 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
95 _AnimationImpl::SetAnimationFrames(const IList& animationFrames)
99 return GetCore().SetAnimationFrames(animationFrames);
103 _AnimationImpl::SetImageCount(int imageCount)
105 GetCore().SetImageCount(imageCount);
111 _AnimationImpl::AddAnimationEventListener(IAnimationEventListener& listener)
115 SysTryReturnResult(NID_UI_CTRL, __pPublicAnimationEvent, E_SYSTEM, "A system error has occurred. The _PublicAnimationEvent instance is null");
117 result r = __pPublicAnimationEvent->AddListener(listener);
118 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.");
124 _AnimationImpl::RemoveAnimationEventListener(IAnimationEventListener& listener)
128 SysTryReturnResult(NID_UI_CTRL, __pPublicAnimationEvent, E_SYSTEM, "A system error has occurred. The _PublicAnimationEvent instance is null");
130 result r = __pPublicAnimationEvent->RemoveListener(listener);
131 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.");
137 _AnimationImpl::SetRepeatCount(int count)
141 Variant repeatCount(count);
143 return GetCore().SetPropertyRepeatCount(repeatCount);
147 _AnimationImpl::GetRepeatCount(void) const
151 return GetCore().GetPropertyRepeatCount().ToInt();
155 _AnimationImpl::GetCurrentRepeatedCount(void) const
159 return GetCore().GetCurrentRepeatedCount();
163 _AnimationImpl::GetImageCount(void) const
167 return GetCore().GetImageCount();
171 _AnimationImpl::Play(void)
175 return GetCore().Play();
179 _AnimationImpl::Stop(void)
183 return GetCore().Stop();
187 _AnimationImpl::Pause(void)
191 return GetCore().Pause();
195 _AnimationImpl::GetStatus(void) const
197 return GetCore().GetStatus();
201 _AnimationImpl::OnAnimationStopped(const _Control& source)
203 IEventArg* pEventArg = _PublicAnimationEvent::CreateAnimationEventArgN();
204 result r = GetLastResult();
205 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
207 r = __pPublicAnimationEvent->Fire(*pEventArg);
209 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
211 SetLastResult(E_SUCCESS);
216 _AnimationImpl::GetPublicClassName(void) const
218 return "Tizen::Ui::Controls::Animation";
222 _AnimationImpl::GetPublic(void) const
224 return static_cast <const Animation&>(_ControlImpl::GetPublic());
228 _AnimationImpl::GetPublic(void)
230 return static_cast <Animation&>(_ControlImpl::GetPublic());
234 _AnimationImpl::GetCore(void) const
236 return static_cast <const _Animation&>(_ControlImpl::GetCore());
240 _AnimationImpl::GetCore(void)
242 return static_cast <_Animation&>(_ControlImpl::GetCore());
245 }}} // Tizen::Ui::Controls