Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_UiScrollEventArg.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_UiScrollEventArg.cpp
20 * @brief        This is the implementation for the _UiScrollEventArg class.
21 */
22
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_UiScrollEventArg.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 /// _UiScrollEventArg class Lifecycle
34
35 _UiScrollEventArg::_UiScrollEventArg(_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 _UiScrollEventArg::~_UiScrollEventArg(void)
45 {
46         // nothing
47 }
48
49 _UiScrollEventArg*
50 _UiScrollEventArg::GetScrollEventArgN(const _Control& source)
51 {
52         _UiScrollEventArg* pEventArg = new (std::nothrow) _UiScrollEventArg(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 _UiScrollEventArg*
59 _UiScrollEventArg::GetScrollEventArgN(const _Control& source, int scrollPosition)
60 {
61         _UiScrollEventArg* pEventArg = new (std::nothrow) _UiScrollEventArg(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 _UiScrollEventArg*
68 _UiScrollEventArg::GetScrollEventArgN(const _Control& source, ScrollEndEvent scrollType)
69 {
70         _UiScrollEventArg* pEventArg = new (std::nothrow) _UiScrollEventArg(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 /// _UiScrollEventArg class Access
78 _ScrollEventType
79 _UiScrollEventArg::GetEventType(void) const
80 {
81         ClearLastResult();
82         return __eventType;
83 }
84
85 _Control*
86 _UiScrollEventArg::GetSource(void) const
87 {
88         ClearLastResult();
89         return __pSource;
90 }
91
92 ScrollEndEvent
93 _UiScrollEventArg::GetScrollType(void) const
94 {
95         ClearLastResult();
96         return __scrollType;
97 }
98
99 int
100 _UiScrollEventArg::GetScrollPosition(void) const
101 {
102         ClearLastResult();
103         return __scrollPosition;
104 }
105
106 }}}     // Tizen::Ui::Controls