1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Widget control event handler interface. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef I_ALFWIDGETEVENTHANDLER_H |
|
20 #define I_ALFWIDGETEVENTHANDLER_H |
|
21 |
|
22 #include <alf/ialfinterfacebase.h> |
|
23 #include <alf/alftypes.h> |
|
24 |
|
25 |
|
26 class TAlfEvent; |
|
27 |
|
28 namespace duiuimodel |
|
29 { |
|
30 class DuiNode; |
|
31 } |
|
32 using namespace duiuimodel; |
|
33 |
|
34 namespace Alf |
|
35 { |
|
36 //FORWARD DECLARATIONS |
|
37 class CAlfWidgetControl; |
|
38 class AlfCustomInitDataBase; |
|
39 struct AlfWidgetEventHandlerInitData; |
|
40 |
|
41 |
|
42 namespace alfwidgeteventhandler |
|
43 { |
|
44 static const IfId ident = |
|
45 { |
|
46 0, "alfwidgeteventhandler" |
|
47 }; |
|
48 } |
|
49 |
|
50 /** |
|
51 * The interface for event handlers used by |
|
52 * widget controls. The event handlers are |
|
53 * used for handling any Alfred events, including |
|
54 * key events, pointer events and custom events. |
|
55 * Interfaces provided by the event handlers can |
|
56 * be accessed using IAlfInterfaceBase::MakeInterface(). |
|
57 * |
|
58 * @lib alfwidgetmodel.lib |
|
59 * @since S60 ?S60_version |
|
60 * @status Draft |
|
61 */ |
|
62 class IAlfWidgetEventHandler : public IAlfInterfaceBase |
|
63 { |
|
64 public: |
|
65 enum AlfEventHandlerType |
|
66 { |
|
67 /** |
|
68 * Presentation related event handlers. These will be deleted when the |
|
69 * presentation is destroyed. |
|
70 * @see: IAlfWigetControl::destroyPresentation |
|
71 * @see: IAlfWiget::setPresentation |
|
72 */ |
|
73 EPresentationEventHandler, |
|
74 /** |
|
75 * Logical event handlers. These event handlers are not presentation related and |
|
76 * will not be destroyed during the destruction of the presentation. |
|
77 */ |
|
78 ELogicalEventHandler, |
|
79 }; |
|
80 |
|
81 /** |
|
82 * Phase in which event handlers are executed. |
|
83 */ |
|
84 enum AlfEventHandlerExecutionPhase |
|
85 { |
|
86 /** |
|
87 * Tunneling event handlers are executed only in the tunnelling phase of the |
|
88 * event handling cycle. Tunnelling event handlers are executed before |
|
89 * IAlfWidgetControl::HandleEvent is executed. |
|
90 * @see IAlfWidgetControl::HandleEvent |
|
91 */ |
|
92 ETunnellingPhaseEventHandler, |
|
93 |
|
94 /** |
|
95 * Bubbling event handlers are executed only in the bubbling phase of the |
|
96 * event handling cycle. Bubbling event handlers are executed after |
|
97 * IAlfWidgetControl::HandleEvent is executed. |
|
98 * @see IAlfWidgetControl::HandleEvent |
|
99 */ |
|
100 EBubblingPhaseEventHandler, |
|
101 |
|
102 /** |
|
103 * These event handlers are executed both in the tunneling and bubbling phase |
|
104 * of the event handling cycle i.e both before and after IAlfWidgetControl::HandleEvent |
|
105 * is executed. |
|
106 * @see IAlfWidgetControl::HandleEvent |
|
107 */ |
|
108 ETunnellingAndBubblingPhaseEventHandler, |
|
109 }; |
|
110 |
|
111 static inline const IfId& type() |
|
112 { |
|
113 return alfwidgeteventhandler::ident; |
|
114 } |
|
115 |
|
116 virtual inline ~IAlfWidgetEventHandler() {} |
|
117 |
|
118 /** |
|
119 * Used to identify event handlers that are capable of handling |
|
120 * a specified key or custom event. Pointer event handlers cannot be |
|
121 * identified directly, since they are dependent on the presentation. |
|
122 * Therefore, pointer event handlers should be associated with |
|
123 * a custom event ID that can be used to simulate the actual pointer event. |
|
124 * |
|
125 * @since S60 ?S60_version |
|
126 * @param aEvent The event. |
|
127 * @return <code>ETrue</code> if the event can be processed. Otherwise <code>EFalse</code>. |
|
128 */ |
|
129 virtual bool accept( CAlfWidgetControl& aControl, const TAlfEvent& aEvent ) const = 0; |
|
130 |
|
131 /** |
|
132 * Called when an input event is being offered to this event handler. |
|
133 * The return value is used to indicate if the event was processed. |
|
134 * Processed events may not be offered to other event handlers. |
|
135 * |
|
136 * @since S60 ?S60_version |
|
137 * @param aControl The parent control of this event handler. |
|
138 * @param aEvent The event. |
|
139 * @return Result of event processing. See AlfEventStatus. |
|
140 */ |
|
141 virtual AlfEventStatus offerEvent( CAlfWidgetControl& aControl,const TAlfEvent& aEvent) = 0; |
|
142 |
|
143 /** |
|
144 * Defines the widget states, where the event handler is active. |
|
145 * By default, if this method is not called, the event handler is expected |
|
146 * to be active in all states. |
|
147 * |
|
148 * @param aStates A bitmask defining the widget states, where the event |
|
149 * handler is active. The low 16 bits are reserved for the states |
|
150 * defined by the framework in . The high 16 bits are |
|
151 * available for states defined by the client code. |
|
152 */ |
|
153 virtual void setActiveStates( unsigned int aStates ) = 0; |
|
154 |
|
155 /** |
|
156 * Sets AlfWidgetEventHandlerInitData to event handler. |
|
157 * |
|
158 * @param aData A data structure which contains for example id of the event |
|
159 * handler. |
|
160 */ |
|
161 virtual void setEventHandlerData( const AlfWidgetEventHandlerInitData& aData ) = 0; |
|
162 |
|
163 /** |
|
164 * Returns AlfWidgetEventHandlerInitData. |
|
165 * |
|
166 * @return A pointer to AlfWidgetEventHandlerInitData structure which contains |
|
167 * for example id of the event handler. |
|
168 */ |
|
169 virtual AlfWidgetEventHandlerInitData* eventHandlerData() = 0; |
|
170 |
|
171 /** |
|
172 * Returns the type of EventHandler. |
|
173 * @see IAlfWidgetEventHandler::AlfEventHandlerType |
|
174 * |
|
175 * @return The type of event handler. |
|
176 */ |
|
177 virtual AlfEventHandlerType eventHandlerType() = 0; |
|
178 |
|
179 /** |
|
180 * Returns information about the phase in the event handling cycle in |
|
181 * which the event hadler will be executed. |
|
182 * @see IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase |
|
183 * |
|
184 * @return Event handler execution phase. |
|
185 */ |
|
186 virtual AlfEventHandlerExecutionPhase eventExecutionPhase() = 0; |
|
187 }; |
|
188 |
|
189 /** |
|
190 * Placeholder for information required to instantiate an event handler |
|
191 * via the widget factory mechanism. |
|
192 * A pointer to this structure is casted to a void pointer and sent to the |
|
193 * factory plugin. |
|
194 * @lib alfwidgetmodel.lib |
|
195 * @since S60 ?S60_version |
|
196 */ |
|
197 struct AlfWidgetEventHandlerInitData |
|
198 { |
|
199 /** |
|
200 * Event handler instance ID.This uniquely identifies every event handler instance. |
|
201 */ |
|
202 char* mWidgetEventHandlerId; |
|
203 |
|
204 /** |
|
205 * Pointer to node in declaration containing information for the widget. |
|
206 */ |
|
207 DuiNode* mNode; |
|
208 |
|
209 /** |
|
210 * Pointer to custom data passed via factory mechanism |
|
211 * Not Owned. |
|
212 */ |
|
213 AlfCustomInitDataBase* mCustomData; |
|
214 }; |
|
215 |
|
216 } // namespace Alf |
|
217 |
|
218 #endif // I_ALFWIDGETEVENTHANDLER_H |
|
219 |
|
220 // End of File |
|