Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_ScrollEventArg.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 /**
19 * @file         FUiCtrl_ScrollEventArg.cpp
20 * @brief        This is the implementation for the _ScrollEventArg class.
21 */
22
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_ScrollEventArg.h"
25
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Runtime;
28
29 namespace Tizen { namespace Ui { namespace Controls
30 {
31
32 ////////////////////////////////////////////////////////////////////////////////
33 /// _ScrollEventArg class Lifecycle
34
35 _ScrollEventArg::_ScrollEventArg(_ScrollEventType eventType, const Control& source, int scrollPosition, ScrollEndEvent scrollType)
36         : __eventType(eventType)
37         , __pSource(const_cast <Control*>(&source))
38         , __scrollPosition(scrollPosition)
39         , __scrollType(scrollType)
40 {
41         // nothing
42 }
43
44 _ScrollEventArg::~_ScrollEventArg(void)
45 {
46         // nothing
47 }
48
49 _ScrollEventArg*
50 _ScrollEventArg::GetScrollEventArgN(const Control& source)
51 {
52         _ScrollEventArg* pEventArg = new (std::nothrow) _ScrollEventArg(SCROLL_EVENT_ON_SCROLL_STOPPED, source);
53         SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY));
54
55         return pEventArg;
56 }
57
58 _ScrollEventArg*
59 _ScrollEventArg::GetScrollEventArgN(const Control& source, int scrollPosition)
60 {
61         _ScrollEventArg* pEventArg = new (std::nothrow) _ScrollEventArg(SCROLL_EVENT_ON_SCROLL_POSITION_CHANGED, source, scrollPosition);
62         SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY));
63
64         return pEventArg;
65 }
66
67 _ScrollEventArg*
68 _ScrollEventArg::GetScrollEventArgN(const Control& source, ScrollEndEvent scrollType)
69 {
70         _ScrollEventArg* pEventArg = new (std::nothrow) _ScrollEventArg(SCROLL_EVENT_ON_SCROLL_END_REACHED, source, -1, scrollType);
71         SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY));
72
73         return pEventArg;
74 }
75
76 ////////////////////////////////////////////////////////////////////////////////
77 /// _ScrollEventArg class Access
78
79 _ScrollEventType
80 _ScrollEventArg::GetEventType(void) const
81 {
82         return __eventType;
83 }
84
85 Control*
86 _ScrollEventArg::GetSource(void) const
87 {
88         return __pSource;
89 }
90
91 int
92 _ScrollEventArg::GetScrollPosition(void) const
93 {
94         return __scrollPosition;
95 }
96
97 ScrollEndEvent
98 _ScrollEventArg::GetScrollType(void) const
99 {
100         return __scrollType;
101 }
102
103 }}}     // Tizen::Ui::Controls