Fork for IVI: mesa fixing
[profile/ivi/uifw.git] / src / ui / controls / FUiCtrl_ScrollPanelEvent.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_ScrollPanelEvent.cpp
20 * @brief        This is the implementation for the _ScrollPanelEvent class.
21 * @version      1.0
22 */
23
24 // includes
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
27 #include <new>
28 #include "FUiCtrl_IScrollPanelEventListener.h"
29 #include "FUiCtrl_ScrollPanelEvent.h"
30
31 // using namespace
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Runtime;
34
35 namespace Tizen { namespace Ui { namespace Controls
36 {
37
38 /**
39  * @class       _ScrollPanelEventArg
40  * @brief       This class is used as the argument to change event listener.
41  *
42  * This class is used as the argument to change event listener. When an change event is generated
43  * (such as when a button is pressed) the ScrollPanelEvent calls ScrollPanelEventListener's OnTextd
44  * with an instance of this class as an argument.
45  *
46  * From this class, one can find out, the (event) source object and the change ID.
47  */
48 class _ScrollPanelEventArg
49         : public Tizen::Base::Runtime::IEventArg
50         , public Tizen::Base::Object
51 {
52 // Lifecycle
53 public:
54         /**
55          * This is the default class constructor.
56          *
57          */
58         _ScrollPanelEventArg(CoreScrollPanelStatus status);
59
60         /**
61          * This is the class destructor.
62          *
63          */
64         virtual ~_ScrollPanelEventArg(void);
65
66
67 // Access
68 public:
69         CoreScrollPanelStatus GetStatus(void) const;
70
71 // Attribute
72 private:
73         /**
74         * Status
75         */
76         CoreScrollPanelStatus __status;
77 }; // _ScrollPanelEventArg
78
79 ////////////////////////////////////////////////////////////////////////////////
80 /// _ScrollPanelEventArg class Lifecycle
81
82 _ScrollPanelEventArg::_ScrollPanelEventArg(CoreScrollPanelStatus status)
83         : __status(status)
84 {
85         // Nothing
86 }
87
88 _ScrollPanelEventArg::~_ScrollPanelEventArg(void)
89 {
90         // Nothing.
91 }
92
93 CoreScrollPanelStatus
94 _ScrollPanelEventArg::GetStatus(void) const
95 {
96         return __status;
97 }
98
99 ////////////////////////////////////////////////////////////////////////////////
100 /// _ScrollPanelEvent class Lifecycle
101 _ScrollPanelEvent::_ScrollPanelEvent(const Tizen::Ui::_Control& source)
102         : __pSource(null)
103 {
104         result r = _Event::Initialize();
105
106         // Set event source
107         if (r == E_SUCCESS)
108         {
109                 __pSource = &source;
110         }
111 }
112
113 _ScrollPanelEvent::~_ScrollPanelEvent(void)
114 {
115         // Nothing.
116 }
117
118 _ScrollPanelEvent*
119 _ScrollPanelEvent::CreateScrollPanelEventN(const Tizen::Ui::_Control& source)
120 {
121         _ScrollPanelEvent* pCoreScrollPanelEvent = new (std::nothrow) _ScrollPanelEvent(source);
122         SysTryReturn(NID_UI_CTRL, pCoreScrollPanelEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
123
124         if (IsFailed(GetLastResult()))
125         {
126                 goto CATCH;
127         }
128
129         return pCoreScrollPanelEvent;
130
131 CATCH:
132         delete pCoreScrollPanelEvent;
133         return null;
134 }
135
136 // Accessors
137
138 const Tizen::Ui::_Control*
139 _ScrollPanelEvent::GetSource(void) const
140 {
141         return __pSource;
142 }
143
144 // Operations
145
146 void
147 _ScrollPanelEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
148 {
149         _IScrollPanelEventListener* pScrollPanelEventListener = dynamic_cast <_IScrollPanelEventListener*>(&listener);
150         SysTryReturnVoidResult(NID_UI_CTRL, pScrollPanelEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n");
151
152         const _ScrollPanelEventArg* pScrollPanelEventArg = dynamic_cast <const _ScrollPanelEventArg*>(&arg);
153         SysTryReturnVoidResult(NID_UI_CTRL, pScrollPanelEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n");
154
155         switch (pScrollPanelEventArg->GetStatus())
156         {
157         case CORE_OVERLAY_CONTROL_CREATED:
158                 // notify listener
159                 pScrollPanelEventListener->OnOverlayControlCreated(*GetSource());
160                 break;
161
162         case CORE_OVERLAY_CONTROL_OPENED:
163                 pScrollPanelEventListener->OnOverlayControlOpened(*GetSource());
164                 break;
165
166         case CORE_OVERLAY_CONTROL_CLOSED:
167                 pScrollPanelEventListener->OnOverlayControlClosed(*GetSource());
168                 break;
169
170         case CORE_OTHER_CONTROL_SELECTED:
171                 pScrollPanelEventListener->OnOtherControlSelected(*GetSource());
172                 break;
173         }
174
175         SetLastResult(E_SUCCESS);
176
177         return;
178 }
179
180 IEventArg*
181 _ScrollPanelEvent::CreateScrollPanelEventArgN(CoreScrollPanelStatus status)
182 {
183         _ScrollPanelEventArg* pEventArg = new (std::nothrow) _ScrollPanelEventArg(status);
184         SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
185
186         return pEventArg;
187 }
188
189 }}} // Tizen::Ui::Controls