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: It is keyevent forwarder. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPHONEKEYEVENTFORWARDER_H |
|
20 #define CPHONEKEYEVENTFORWARDER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <bldvariant.hrh> //Feature flags |
|
24 #include <coecntrl.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class MPhoneStateMachine; |
|
28 class MPhoneKeyEventHandler; |
|
29 class MPhoneViewCommandHandle; |
|
30 class CPhoneTimer; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * It is keyevent forwarder. |
|
36 * |
|
37 */ |
|
38 class CPhoneKeyEventForwarder |
|
39 : public CCoeControl |
|
40 { |
|
41 public: // Constructors and destructor |
|
42 |
|
43 /** |
|
44 * Two-phased constructor. |
|
45 * |
|
46 * @param aRect rectangle of this control. |
|
47 * @param aStateMachine state machine |
|
48 * @param aViewCommandHandle View command handle |
|
49 * @return new instance. |
|
50 */ |
|
51 static CPhoneKeyEventForwarder* NewL( const TRect& aRect, |
|
52 MPhoneStateMachine* aStateMachine, |
|
53 MPhoneViewCommandHandle* aViewCommandHandle ); |
|
54 |
|
55 /** |
|
56 * Destructor. |
|
57 */ |
|
58 ~CPhoneKeyEventForwarder(); |
|
59 |
|
60 public: // New functions. |
|
61 |
|
62 public: // Functions from base classes |
|
63 |
|
64 /** |
|
65 * From CCoeControl, returns the amount of component controls. |
|
66 * |
|
67 * @return Returns the amount of component controls. |
|
68 */ |
|
69 TInt CountComponentControls() const; |
|
70 |
|
71 /** |
|
72 * From CCoeControl, returns a control by index. |
|
73 * |
|
74 * @param aIndex It is the index of the control. |
|
75 * @return Returns a control by index. |
|
76 */ |
|
77 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
78 |
|
79 /** |
|
80 * From CCoeControl, informs that the size is changed to update |
|
81 * the sizes of component controls appropriately. |
|
82 */ |
|
83 void SizeChanged(); |
|
84 |
|
85 /** |
|
86 * From CCoeControl, draws the contents of the view. |
|
87 * |
|
88 * @param aRect It is the area to be redrawn. |
|
89 */ |
|
90 void Draw( const TRect& aRect ) const; |
|
91 |
|
92 /** |
|
93 * From CCoeControl, offers a key event to the view. |
|
94 * |
|
95 * @param aKeyEvent It contains information about the key event. |
|
96 * @param aType It is the type of the event. |
|
97 * @return Returns information which indicates whether the keypress |
|
98 * was processed or not. |
|
99 */ |
|
100 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
101 TEventCode aType ); |
|
102 |
|
103 /** |
|
104 * This function should be called from AppUi, after framework has |
|
105 * Looped through CCoeControlStack |
|
106 * |
|
107 * @param aKeyEvent It contains information about the key event. |
|
108 * @param aType It is the type of the event. |
|
109 * @return Returns information which indicates whether the keypress |
|
110 * was processed or not. |
|
111 */ |
|
112 TKeyResponse OfferKeyEventAfterControlStackL( |
|
113 const TKeyEvent& aKeyEvent, |
|
114 TEventCode aType ); |
|
115 |
|
116 private: |
|
117 |
|
118 /** |
|
119 * C++ default constructor. |
|
120 */ |
|
121 CPhoneKeyEventForwarder( MPhoneStateMachine* aStateMachine, |
|
122 MPhoneViewCommandHandle* aViewCommandHandle ); |
|
123 |
|
124 /** |
|
125 * Symbian OS constructor. |
|
126 */ |
|
127 void ConstructL( const TRect& aRect ); |
|
128 |
|
129 /** |
|
130 * This function should be called before FEP or other components in |
|
131 * CCoeControl stack |
|
132 * |
|
133 * @param aKeyEvent It contains information about the key event. |
|
134 * @param aType It is the type of the event. |
|
135 * @return Returns information which indicates whether the keypress |
|
136 * was processed or not. |
|
137 */ |
|
138 TKeyResponse OfferKeyEventBeforeControlStackL( |
|
139 const TKeyEvent& aKeyEvent, |
|
140 TEventCode aType ); |
|
141 |
|
142 /** |
|
143 * Handle EEventKeyDown |
|
144 * @param aKeyEvent Tells which key was pressed. |
|
145 * @return tells whether the event was consumed or not. |
|
146 */ |
|
147 TKeyResponse HandleEventKeyDownBeforeControlStackL( const TKeyEvent& aKeyEvent ); |
|
148 |
|
149 /** |
|
150 * Handle EEventKey |
|
151 * @param aKeyEvent Tells which key was pressed. |
|
152 * @return tells whether the event was consumed or not. |
|
153 */ |
|
154 TKeyResponse HandleEventKeyBeforeControlStackL( const TKeyEvent& aKeyEvent ); |
|
155 |
|
156 /** |
|
157 * Handle EEventKeyUp |
|
158 * @param aKeyEvent Tells which key was pressed. |
|
159 * @return tells whether the event was consumed or not. |
|
160 */ |
|
161 TKeyResponse HandleEventKeyUpBeforeControlStackL( const TKeyEvent& aKeyEvent ); |
|
162 |
|
163 |
|
164 /** |
|
165 * Callback function for long press of a particular key |
|
166 */ |
|
167 static TInt DoHandleLongPressKeyEventCallbackL( TAny* aAny ); |
|
168 |
|
169 /** |
|
170 * Convert key code |
|
171 */ |
|
172 void ConvertKeyCode( TUint& aCode, const TKeyEvent& aKeyEvent ); |
|
173 |
|
174 /** |
|
175 * Handle key long press |
|
176 */ |
|
177 void HandleLongPressKeyEventL(); |
|
178 |
|
179 /** |
|
180 * Checks from the statemachine is the given keyevent |
|
181 * from one of the allowed characters |
|
182 */ |
|
183 TBool IsAlphaNumericKey( const TKeyEvent& aKeyEvent ); |
|
184 |
|
185 /** |
|
186 * Checks is the given key special character (*, 0, # ) from half-qwerty |
|
187 * keyboard and conver key code if needed. |
|
188 */ |
|
189 TBool ConvertHalfQwertySpecialChar( TUint& aCode, const TKeyEvent& aKeyEvent ); |
|
190 |
|
191 /** |
|
192 * Checks if key should be blocked from phone. |
|
193 * |
|
194 * @ return ETrue if alpha mode, EFalse otherwise. |
|
195 */ |
|
196 TBool IsKeyBlocked( const TKeyEvent& aKeyEvent ) const; |
|
197 |
|
198 private: // Data |
|
199 |
|
200 /** |
|
201 * State machine |
|
202 */ |
|
203 MPhoneStateMachine* iStateMachine; |
|
204 |
|
205 /** |
|
206 * Interface to view command handle |
|
207 */ |
|
208 MPhoneViewCommandHandle* iViewCommandHandle; |
|
209 |
|
210 /** |
|
211 * For long key press. Long press is handled within a |
|
212 * specific duration. |
|
213 */ |
|
214 CPhoneTimer* iLongPressKeyEventTimer; |
|
215 |
|
216 /** |
|
217 * Key press time |
|
218 */ |
|
219 TTime iKeyPressTime; |
|
220 |
|
221 /** |
|
222 * Key code |
|
223 */ |
|
224 TUint iKeyPressedDown; |
|
225 |
|
226 /** |
|
227 * Key scan code from EEventKey Updated in HandleEventKeyDownL. |
|
228 * Zeroed in HandleEventKeyUpL. |
|
229 */ |
|
230 TInt iScanCode; |
|
231 }; |
|
232 |
|
233 #endif // CPHONEKEYEVENTFORWARDER_H |
|
234 |
|
235 // End of File |
|