|
1 /* |
|
2 * Copyright (c) 2008 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: Class that implements Search Field feature. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMPXCOMMONCONTAINERSEARCHFIELD_H |
|
20 #define CMPXCOMMONCONTAINERSEARCHFIELD_H |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <coecntrl.h> |
|
24 #include <eikedwin.h> |
|
25 #include <Avkon.mbg> |
|
26 |
|
27 // FORWARD DECLARATION |
|
28 class CAknInputFrame; |
|
29 class CMPXCommonContainerSearchField; |
|
30 class CMPXCommonContainerSearchFieldWrapper; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * Class for handling key events. Has higher priority than FEP, |
|
36 * to be able to catch up/down key event and forward them to Search |
|
37 * Field's editor. |
|
38 */ |
|
39 NONSHARABLE_CLASS( CMPXCommonContainerSearchFieldKeyHandler ) : |
|
40 public CCoeControl, |
|
41 public MEikEdwinObserver |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * public constructor. |
|
47 * |
|
48 * @param aSearchField Reference to Search Field that key events are controlled. |
|
49 */ |
|
50 CMPXCommonContainerSearchFieldKeyHandler( CMPXCommonContainerSearchField& aSearchField ); |
|
51 |
|
52 /** |
|
53 * Catches key events before FEP could do it. |
|
54 * |
|
55 * @param aKeyEvent Key event. |
|
56 * @param aType Key event type. |
|
57 * @return Response whether key was handled or not. |
|
58 */ |
|
59 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
60 |
|
61 /** |
|
62 * Catches EEventTextUpdate event. |
|
63 * |
|
64 * @param aEdwin Pointer to editor. |
|
65 * @param aEventType Editor event type. |
|
66 */ |
|
67 void HandleEdwinEventL( CEikEdwin* aEdwin, TEdwinEvent aEventType ); |
|
68 |
|
69 /** |
|
70 * Put control to control stack or remove it from there. |
|
71 * |
|
72 * @param aEnable ETrue puts control to the control stack with higher |
|
73 * priority than FEP has. EFalse removes control from the stack. |
|
74 */ |
|
75 void EnableL( TBool aEnable ); |
|
76 |
|
77 /** |
|
78 * Resets key handling situation by setting iFirstKeyEvent to ETrue. |
|
79 */ |
|
80 void Reset(); |
|
81 |
|
82 /** |
|
83 * Get LeftRightEvent. |
|
84 */ |
|
85 TBool IsLeftRightEvent(); |
|
86 |
|
87 /** |
|
88 * SetFirstKey. |
|
89 */ |
|
90 void SetFirstKeyEvent( TBool aFirstKeyEvent ); |
|
91 |
|
92 protected: |
|
93 |
|
94 /** |
|
95 * Key event catching enable flag. |
|
96 */ |
|
97 TBool iEnabled; |
|
98 |
|
99 /** |
|
100 * Only first key event is catched. |
|
101 */ |
|
102 TBool iFirstKeyEvent; |
|
103 |
|
104 /** |
|
105 * Flag for LeftRightEvent. |
|
106 */ |
|
107 TBool iLeftRightEvent; |
|
108 |
|
109 /** |
|
110 * Search Field control of which key events are catched. |
|
111 */ |
|
112 CMPXCommonContainerSearchField& iSearchField; |
|
113 }; |
|
114 |
|
115 /** |
|
116 * Search Field class for component. |
|
117 * |
|
118 */ |
|
119 NONSHARABLE_CLASS( CMPXCommonContainerSearchField ) : public CCoeControl, |
|
120 public MCoeControlObserver, |
|
121 public MCoeFepObserver |
|
122 { |
|
123 public: |
|
124 |
|
125 /** |
|
126 * Two-phased constructor. Leaves on failure. |
|
127 * |
|
128 * @param aParent Parent control. |
|
129 * @param aFindKeywordMode ETrue if the pane is a find keyword pane. |
|
130 * @return The constructed Search Field control. |
|
131 */ |
|
132 static CMPXCommonContainerSearchField* NewL( CMPXCommonContainerSearchFieldWrapper* aParent, |
|
133 TBool aFindKeywordMode = ETrue ); |
|
134 |
|
135 /** |
|
136 * Destructor. |
|
137 */ |
|
138 virtual ~CMPXCommonContainerSearchField(); |
|
139 |
|
140 /** |
|
141 * Shows or hides to Search Field. |
|
142 * |
|
143 * @param ETrue to set visible |
|
144 */ |
|
145 void MakeVisibleL( TBool aVisible ); |
|
146 |
|
147 /** |
|
148 * Non-leaving version of MakeVisibleL. |
|
149 * |
|
150 * @param ETrue to set visible |
|
151 */ |
|
152 void MakeVisible( TBool aVisible ); |
|
153 |
|
154 /** |
|
155 * Called to handle change in Search Field size. |
|
156 */ |
|
157 void HandleFindSizeChanged(); |
|
158 |
|
159 /** |
|
160 * Enable key event handler. |
|
161 * |
|
162 * @param aEnable ETrue to enable. |
|
163 */ |
|
164 void EnableKeyEventHandlerL( TBool aEnable ); |
|
165 |
|
166 public: // From MCoeControlObserver |
|
167 |
|
168 /** |
|
169 * Handle control event. |
|
170 * |
|
171 * @param aControl The control. |
|
172 * @param aEventType Event type. |
|
173 */ |
|
174 void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); |
|
175 |
|
176 public: // From CCoeControl |
|
177 |
|
178 /** |
|
179 * Handles key event. |
|
180 * |
|
181 * @param aKeyEvent The key event. |
|
182 * @param aType Key event type. |
|
183 * @return Response whether event was consumed. |
|
184 */ |
|
185 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
186 |
|
187 /** |
|
188 * HandlePointerEventL, from CCoeControl. |
|
189 * |
|
190 * @param aPointerEvent Pointer event. |
|
191 */ |
|
192 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
193 |
|
194 /** |
|
195 * Count component controls. |
|
196 * |
|
197 * @return Number of component controls |
|
198 */ |
|
199 TInt CountComponentControls() const; |
|
200 |
|
201 /** |
|
202 * Get a component control by index. |
|
203 * |
|
204 * @param aIndex Index of component control to be returned |
|
205 * @return Component control or NULL |
|
206 */ |
|
207 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
208 |
|
209 /** |
|
210 * Sets the OrdinalPosition of Search Field. |
|
211 * |
|
212 * @param aPos The OrdinalPosition |
|
213 */ |
|
214 void SetOrdinalPosition( TInt aPos ); |
|
215 |
|
216 public: // Text manipulation. |
|
217 |
|
218 /** |
|
219 * Lengt of the text in the editor. |
|
220 * |
|
221 * @return The text length |
|
222 */ |
|
223 TInt TextLength() const; |
|
224 |
|
225 /** |
|
226 * Get text from the editor. |
|
227 * |
|
228 * @return text from the editor |
|
229 */ |
|
230 HBufC* GetTextLC() const; |
|
231 |
|
232 /** |
|
233 * Set text. |
|
234 * |
|
235 * @param aTxt Text to set, appended if needed. |
|
236 */ |
|
237 void SetTextL( const TDesC& aTxt ); |
|
238 |
|
239 /** |
|
240 * Selects all text in the editor, see CEikEdwin's SelectAllL(). |
|
241 */ |
|
242 void SelectAllL(); |
|
243 |
|
244 /** |
|
245 * Set info text. |
|
246 * |
|
247 * @param aText Text to be displayed as info |
|
248 */ |
|
249 void SetInfoTextL( const TDesC& aText ); |
|
250 |
|
251 /** |
|
252 * Perform clipboard functionality. |
|
253 * |
|
254 * @param aClipboardFunc Function to perform. |
|
255 */ |
|
256 void ClipboardL( CEikEdwin::TClipboardFunc aClipboardFunc ); |
|
257 |
|
258 /** |
|
259 * Returns editor control of Search Field. |
|
260 * |
|
261 * @return Editor control. |
|
262 */ |
|
263 CEikEdwin* Editor() const; |
|
264 |
|
265 /** |
|
266 * Checks if client's keyword needs updating, and updates if needed. |
|
267 */ |
|
268 void UpdateFindKeywordL(); |
|
269 |
|
270 public: // Observer support. |
|
271 |
|
272 /** |
|
273 * Handles resource change. |
|
274 * |
|
275 * @param aType Type of resource change. |
|
276 */ |
|
277 void HandleResourceChange( TInt aType ); |
|
278 |
|
279 /** |
|
280 * Handles the completion of a FEP transaction. |
|
281 */ |
|
282 void HandleCompletionOfTransactionL(); |
|
283 |
|
284 /** |
|
285 * Handles the start of a FEP transaction. |
|
286 */ |
|
287 void HandleStartOfTransactionL(); |
|
288 |
|
289 protected: // Construction. |
|
290 |
|
291 /** |
|
292 * Constructor. |
|
293 * |
|
294 * @param aFindKeywordMode ETrue if the pane is a find keyword pane. |
|
295 */ |
|
296 CMPXCommonContainerSearchField( TBool aFindKeywordMode ); |
|
297 |
|
298 /** |
|
299 * Second-phase constructor. Leaves on failure. |
|
300 * |
|
301 * @param aParent Parent control. |
|
302 */ |
|
303 void ConstructL( CMPXCommonContainerSearchFieldWrapper* aParent ); |
|
304 |
|
305 protected: // From CCoeControl. |
|
306 |
|
307 /** |
|
308 * Handle size change, layout and draw components. |
|
309 */ |
|
310 void SizeChanged(); |
|
311 |
|
312 /** |
|
313 * Handle focus change. |
|
314 * |
|
315 * @param aDrawNow ETrue if immediate draw is needed. |
|
316 */ |
|
317 void FocusChanged( TDrawNow aDrawNow ); |
|
318 |
|
319 private: |
|
320 |
|
321 /** |
|
322 * Set the text and redraw. |
|
323 * |
|
324 * @param aTxt Text to set. |
|
325 */ |
|
326 void DoSetTextL( const TDesC& aTxt ); |
|
327 |
|
328 /** |
|
329 * Activates virtual keyboard. |
|
330 */ |
|
331 void ActivateVkbL(); |
|
332 |
|
333 protected: // Data. |
|
334 |
|
335 /** |
|
336 * Pointer to parent (control). |
|
337 * Not own. |
|
338 */ |
|
339 CMPXCommonContainerSearchFieldWrapper* iParent; |
|
340 |
|
341 /** |
|
342 * If the control is in find keyword pane mode. |
|
343 */ |
|
344 TBool iFindKeywordMode; |
|
345 |
|
346 /** |
|
347 * HandleFEPFind. |
|
348 */ |
|
349 TBool iHandleFEPFind; |
|
350 |
|
351 /** |
|
352 * The previously typed text into iEditor. |
|
353 */ |
|
354 HBufC* iPrevKeyword; |
|
355 |
|
356 /** |
|
357 * Editor. |
|
358 * Own. |
|
359 */ |
|
360 CEikEdwin* iEditor; |
|
361 |
|
362 /** |
|
363 * Input frame. |
|
364 * Own. |
|
365 */ |
|
366 CAknInputFrame* iInputFrame; |
|
367 |
|
368 /** |
|
369 * Key handler. |
|
370 * Own. |
|
371 */ |
|
372 CMPXCommonContainerSearchFieldKeyHandler *iSearchFieldKeyHandler; |
|
373 }; |
|
374 |
|
375 #endif // CMPXCOMMONCONTAINERSEARCHFIELD_H |