Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_PublicColorChangeEvent.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 /**
19  * @file                FUiCtrl_PublicColorChangeEvent.cpp
20  * @brief       This is the implementation for the _PublicColorChangeEvent class.
21  *
22  * This file contains the implementation of _PublicColorChangeEvent class. @n
23  */
24
25 #include <new>
26 #include <FBaseSysLog.h>
27 #include <FBaseErrors.h>
28 #include <FGrpColor.h>
29 #include <FUiIColorChangeEventListener.h>
30 #include "FUiCtrl_PublicColorChangeEvent.h"
31
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Runtime;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Ui;
36
37 namespace Tizen { namespace Ui { namespace Controls
38 {
39
40 class _OSP_EXPORT_ _PublicColorChangeEventArg
41         : public Tizen::Base::Runtime::IEventArg
42         , public Tizen::Base::Object
43 {
44 public:
45         _PublicColorChangeEventArg(const Color& color)
46                 : __color(color)
47         {
48         }
49
50         virtual ~_PublicColorChangeEventArg(void)
51         {
52         }
53
54         const Tizen::Graphics::Color GetColor(void) const
55         {
56                 return __color;
57         }
58
59 private:
60         Color __color;
61 }; // _PublicColorChangeEventArg
62
63 _PublicColorChangeEvent::_PublicColorChangeEvent(const Control& source)
64         : __pSource(null)
65 {
66         result r = _Event::Initialize();
67
68         // set event source
69         if (r == E_SUCCESS)
70         {
71                 __pSource = &source;
72         }
73 }
74
75 _PublicColorChangeEvent::~_PublicColorChangeEvent(void)
76 {
77 }
78
79 const Control*
80 _PublicColorChangeEvent::GetSource(void) const
81 {
82         return (__pSource);
83 }
84
85 void
86 _PublicColorChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
87 {
88         IColorChangeEventListener* pColorChangeListener = dynamic_cast <IColorChangeEventListener*>(&listener);
89         SysTryReturnVoidResult(NID_UI_CTRL, (pColorChangeListener != null), E_INVALID_ARG,
90                                 "[E_INVALID_ARG] The event argument is invalid type.\n.");
91
92         const _PublicColorChangeEventArg* pArg = dynamic_cast <const _PublicColorChangeEventArg*>(&arg);
93         SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG,
94                                 "[E_INVALID_ARG] The event argument is invalid type.\n.");
95
96         pColorChangeListener->OnColorChanged(*__pSource, Color(pArg->GetColor()));
97
98         return;
99 }
100
101 _PublicColorChangeEvent*
102 _PublicColorChangeEvent::CreateInstanceN(const Control& source)
103 {
104         _PublicColorChangeEvent* pCoreColorChangeEvent = new (std::nothrow) _PublicColorChangeEvent(source);
105         SysTryReturn(NID_UI_CTRL, (pCoreColorChangeEvent != null), null, E_OUT_OF_MEMORY,
106                                 "[E_OUT_OF_MEMORY] Memory allocation failed.");
107
108         if (IsFailed(GetLastResult()))
109         {
110                 goto CATCH;
111         }
112
113         return pCoreColorChangeEvent;
114
115 CATCH:
116         delete pCoreColorChangeEvent;
117         return null;
118
119 }
120
121 IEventArg*
122 _PublicColorChangeEvent::CreateColorChangeEventArgN(const Color& color)
123 {
124         _PublicColorChangeEventArg* pEventArg = new (std::nothrow) _PublicColorChangeEventArg(color);
125         SysTryReturn(NID_UI_CTRL, (pEventArg != null), null, E_OUT_OF_MEMORY,
126                                 "[E_OUT_OF_MEMORY] Memory allocation failed.");
127
128         return pEventArg;
129 }
130
131 }}} // Tizen::Ui::Controls