Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_PublicTextBlockEvent.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_PublicTextBlockEvent.cpp
20 * @brief        This is the implementation for the _PublicTextBlockEvent class.
21 *
22 * This file contains implementation of _PublicTextBlockEvent class.
23 */
24
25 // includes
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28 #include <new>
29 #include <FUiITextBlockEventListener.h>
30 #include "FUiCtrl_PublicTextBlockEvent.h"
31
32
33 // using namespace
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Runtime;
36
37 namespace Tizen { namespace Ui { namespace Controls
38 {
39
40 /**
41  * @class       _PublicTextBlockEventArg
42  * @brief       This class is used as the argument to change event listener.
43  *
44  * This class is used as the argument to change event listener. When an change event is generated
45  * (such as when a button is pressed) the TextBlockEvent calls TextBlockEventListener's OnTextd
46  * with an instance of this class as an argument.
47  *
48  * From this class, one can find out, the (event) source object and the change ID.
49  */
50 class _OSP_EXPORT_ _PublicTextBlockEventArg
51         : public IEventArg
52         , public Object
53 {
54 // Lifecycle
55 public:
56         /**
57          * This is the default class constructor.
58          *
59          */
60         _PublicTextBlockEventArg(int start, int end);
61
62         /**
63          * This is the class destructor.
64          *
65          */
66         virtual ~_PublicTextBlockEventArg(void);
67
68
69 // Access
70 public:
71         /**
72          * Gets the start position of text block.
73          *
74          * @return      the start position of text block.
75          */
76         const int GetStartPosition(void) const;
77
78         /**
79          * Gets the end position of text block.
80          *
81          * @return      the end position of text block.
82          */
83         const int GetEndPosition(void) const;
84
85 // Attribute
86 private:
87         /**
88         * Start position.
89         */
90         int __start;
91
92         /**
93         * End position.
94         */
95         int __end;
96 }; // _PublicTextBlockEventArg
97
98 ////////////////////////////////////////////////////////////////////////////////
99 /// _PublicTextBlockEventArg class Lifecycle
100
101 _PublicTextBlockEventArg::_PublicTextBlockEventArg(int start, int end)
102         : __start(start)
103         , __end(end)
104 {
105         // Nothing
106 }
107
108 _PublicTextBlockEventArg::~_PublicTextBlockEventArg(void)
109 {
110         // Nothing.
111 }
112
113 const int
114 _PublicTextBlockEventArg::GetStartPosition(void) const
115 {
116         return __start;
117 }
118
119 const int
120 _PublicTextBlockEventArg::GetEndPosition(void) const
121 {
122         return __end;
123 }
124
125 ////////////////////////////////////////////////////////////////////////////////
126 /// _PublicTextBlockEvent class Lifecycle
127 _PublicTextBlockEvent::_PublicTextBlockEvent(const Control& source)
128         : __pSource(null)
129 {
130         result r = _Event::Initialize();
131
132         // Set event source
133         if (r == E_SUCCESS)
134         {
135                 __pSource = &source;
136         }
137 }
138
139 _PublicTextBlockEvent::~_PublicTextBlockEvent(void)
140 {
141         // Nothing.
142 }
143
144 _PublicTextBlockEvent*
145 _PublicTextBlockEvent::CreateInstanceN(const Control& source)
146 {
147         _PublicTextBlockEvent* pPublicTextBlockEvent = new (std::nothrow) _PublicTextBlockEvent(source);
148         SysTryReturn(NID_UI_CTRL, pPublicTextBlockEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
149
150         return pPublicTextBlockEvent;
151 }
152
153 // Accessors
154
155 const Control*
156 _PublicTextBlockEvent::GetSource(void) const
157 {
158         return __pSource;
159 }
160
161 // Operations
162
163 void
164 _PublicTextBlockEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
165 {
166         ITextBlockEventListener* pTextBlockEventListener = dynamic_cast <ITextBlockEventListener*>(&listener);
167         SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n");
168
169         const _PublicTextBlockEventArg* pTextBlockEventArg = dynamic_cast <const _PublicTextBlockEventArg*>(&arg);
170         SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n");
171
172         pTextBlockEventListener->OnTextBlockSelected(const_cast <Control&>(*__pSource),
173                                                                                                  pTextBlockEventArg->GetStartPosition(), pTextBlockEventArg->GetEndPosition());
174
175         SetLastResult(E_SUCCESS);
176
177         return;
178 }
179
180 IEventArg*
181 _PublicTextBlockEvent::CreateTextBlockEventArgN(int start, int end)
182 {
183         _PublicTextBlockEventArg* pEventArg = new (std::nothrow) _PublicTextBlockEventArg(start, end);
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