Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_SplitPanelEvent.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
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 #include <new>
19 #include <FBaseErrors.h>
20 #include <FBaseSysLog.h>
21 #include "FUiCtrl_ISplitPanelEventListener.h"
22 #include "FUiCtrl_SplitPanelEvent.h"
23 #include "FUiCtrl_SplitPanel.h"
24
25 // using namespace
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Runtime;
28
29 namespace Tizen { namespace Ui { namespace Controls
30 {
31
32 /**
33  * @class       _SplitPanelEventArg
34  * @brief       This class is used as the argument to action event listener.
35  *
36  * This class is used as the argument to splitpanel event listener. When an splitpanel event is generated
37  * (such as when a splitpanel is pressed) the SplitPanelEvent calls SplitPanelEventListener's OnActionPerformed
38  * with an instance of this class as an argument.
39  *
40  * From this class, one can find out, the (event) source object and the action ID.
41  */
42 class _OSP_EXPORT_ _SplitPanelEventArg
43         : public IEventArg
44         , public Object
45 {
46 // Lifecycle
47 public:
48         /**
49          * This is the default class constructor.
50          *
51          * @param[in] status
52          */
53         _SplitPanelEventArg(_SplitPanelEventStatus status);
54
55         /**
56          * This is the class destructor.
57          *
58          */
59         virtual ~_SplitPanelEventArg(void);
60
61
62 // Access
63 public:
64         /**
65         * This method returns the status which the event initially occurred.
66         *
67         * @return       See the comment above.
68         */
69         _SplitPanelEventStatus GetStatus(void) const;
70
71
72 // Attribute
73 private:
74         /**
75         * Event status.
76         */
77         _SplitPanelEventStatus __status;
78 };
79
80 _SplitPanelEventArg::_SplitPanelEventArg(_SplitPanelEventStatus status)
81         : __status(status)
82 {
83
84 }
85
86 _SplitPanelEventArg::~_SplitPanelEventArg(void)
87 {
88
89 }
90
91 _SplitPanelEventStatus
92 _SplitPanelEventArg::GetStatus(void) const
93 {
94         return __status;
95 }
96
97 _SplitPanelEvent::_SplitPanelEvent(const _SplitPanel& source)
98         : __pSource(null)
99 {
100         result r = _Event::Initialize();
101
102         // set event source
103         if (r == E_SUCCESS)
104         {
105                 __pSource = &source;
106         }
107 }
108
109 _SplitPanelEvent::~_SplitPanelEvent(void)
110 {
111
112 }
113
114 _SplitPanelEvent*
115 _SplitPanelEvent::CreateInstanceN(const _SplitPanel& source)
116 {
117         _SplitPanelEvent* pSplitPanelEvent = new (std::nothrow) _SplitPanelEvent(source);
118         SysTryReturn(NID_UI_CTRL, pSplitPanelEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
119
120         if (IsFailed(GetLastResult()))
121         {
122                 goto CATCH;
123         }
124
125         return pSplitPanelEvent;
126
127 CATCH:
128         delete pSplitPanelEvent;
129         return null;
130 }
131
132 const _SplitPanel*
133 _SplitPanelEvent::GetSource(void) const
134 {
135         return __pSource;
136 }
137
138 void
139 _SplitPanelEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
140 {
141         // cast to _IActionEventListener
142         _ISplitPanelEventListener* pSplitPanelListner = dynamic_cast <_ISplitPanelEventListener*>(&listener);
143         SysTryReturnVoidResult(NID_UI_CTRL, pSplitPanelListner != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given.\n");
144
145         // cast to _SplitPanelEventArg
146         const _SplitPanelEventArg* pArg = dynamic_cast <const _SplitPanelEventArg*>(&arg);
147         SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n");
148
149         _SplitPanel* pSource = null;
150         pSource = const_cast <_SplitPanel*>(__pSource);
151         SysTryReturnVoidResult(NID_UI_CTRL, pSource != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n");
152
153         // call cursor change event listener method
154         _SplitPanelEventStatus status= pArg->GetStatus();
155
156         if (status == _SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE)
157         {
158                 pSplitPanelListner->OnDividerPositionChanged(*pSource, pSource->GetDividerPosition());
159         }
160         else
161         {
162                 pSplitPanelListner->OnDividerDoublePressed(*pSource);
163         }
164 }
165
166 IEventArg*
167 _SplitPanelEvent::CreateSplitPanelEventArgN(_SplitPanelEventStatus status)
168 {
169         _SplitPanelEventArg* pEventArg = new (std::nothrow) _SplitPanelEventArg(status);
170         SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
171
172         return pEventArg;
173 }
174
175 }}} // Tizen::Ui::Controls