Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrlAnimationFrame.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        FUiCtrlAnimationFrame.cpp
19  * @brief       This is the implementation file for AnimationFrame class.
20  */
21
22 #include <FUiCtrlAnimationFrame.h>
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_AnimationFrameImpl.h"
25
26 using namespace Tizen::Graphics;
27
28 namespace Tizen { namespace Ui { namespace Controls
29 {
30
31 AnimationFrame::AnimationFrame(void)
32         : __pAnimationFrameImpl(null)
33 {
34         ClearLastResult();
35
36         __pAnimationFrameImpl = new (std::nothrow) _AnimationFrameImpl();
37         SysTryReturnVoidResult(NID_UI_CTRL, __pAnimationFrameImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
38 }
39
40 AnimationFrame::AnimationFrame(const Bitmap& frame, long duration)
41         : __pAnimationFrameImpl(null)
42 {
43         ClearLastResult();
44
45         __pAnimationFrameImpl = new (std::nothrow) _AnimationFrameImpl(frame, duration);
46         SysTryReturnVoidResult(NID_UI_CTRL, __pAnimationFrameImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
47 }
48
49 AnimationFrame::~AnimationFrame(void)
50 {
51         delete __pAnimationFrameImpl;
52         __pAnimationFrameImpl = null;
53 }
54
55 void
56 AnimationFrame::SetFrame(const Bitmap& frame)
57 {
58         SysAssertf(__pAnimationFrameImpl != null, "Not yet constructed. Construct() should be called before use.");
59
60         result r = __pAnimationFrameImpl->SetFrame(frame);
61         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
62
63         SetLastResult(E_SUCCESS);
64         return;
65 }
66
67 const Bitmap*
68 AnimationFrame::GetFrame(void) const
69 {
70         ClearLastResult();
71
72         SysAssertf(__pAnimationFrameImpl != null, "Not yet constructed. Construct() should be called before use.");
73
74         return __pAnimationFrameImpl->GetFrame();
75 }
76
77 void
78 AnimationFrame::SetDuration(long duration)
79 {
80         SysAssertf(__pAnimationFrameImpl != null, "Not yet constructed. Construct() should be called before use.");
81
82         result r = __pAnimationFrameImpl->SetDuration(duration);
83         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
84
85         SetLastResult(E_SUCCESS);
86         return;
87 }
88
89 long
90 AnimationFrame::GetDuration(void) const
91 {
92         ClearLastResult();
93
94         SysAssertf(__pAnimationFrameImpl != null, "Not yet constructed. Construct() should be called before use.");
95
96         return __pAnimationFrameImpl->GetDuration();
97 }
98
99 }}} // Tizen::Ui::Controls