2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Search Field support.
25 #include <AknControl.h>
29 #include <e32property.h> // for subscriber/publisher
31 // FORWARD DECLARATIONS
35 class CAknSearchFieldIndicator;
36 class CAknsListBoxBackgroundControlContext;
37 class CAknsFrameBackgroundControlContext;
39 class CAknAdaptiveSearch;
40 class MAdaptiveSearchTextObserver;
41 class CAknSearchField;
42 class CHwKbSubscriber;
45 * Adaptive search text observer will be notified when adaptive search
46 * text/language are changed. Notify about text changing when adaptive search
47 * grid is opened for the first time (empty search text is generated) or when
48 * user taps the grid so that new character is inputted. Notify about language
49 * chnging when got information from CenRep.
53 class MAdaptiveSearchTextObserver
57 * Notification and handling of an adaptive search text change.
59 * @param aSearchField The source search field of this message.
61 virtual void AdaptiveSearchTextChanged( CAknSearchField* aSearchField ) = 0;
68 * The CAknSearchField class implements a Search field control. There are
69 * different styles for the search field defined by a TSearchFieldStyle.
71 * @since Series 60 0.9
73 NONSHARABLE_CLASS(CAknSearchField) : public CAknControl,
74 public MCoeControlObserver,
75 public MEikCommandObserver
81 enum TSearchFieldStyle
83 /** Use only ESearch in Series 60 */
93 /** Use as popup search field. */
95 /** Use as pinb search field. */
97 /** For Clock application/list_single_heading_pane. */
99 /** Same as ESearch, but using CreateWindowL(). */
101 /** Layout where no line is used. */
103 /** Popup window layout. */
105 /** For adaptive search grid */
108 /** For adaptive search grid */
109 /** Same as EAdaptiveSearch, but using CreateWindowL(). */
112 /** For adaptive search grid */
113 /** Same as EAdaptiveSearch, but using popup find pane. */
115 EPopupAdaptiveSearch,
116 /** For adaptive search grid */
117 /** Popup window layout */
119 EPopupAdaptiveSearchWindow
127 IMPORT_C ~CAknSearchField();
130 * Two-phased constructor.
131 * @param aParent Reference to parent control.
132 * @param aFieldStyle Defines the UI style.
133 * @param aIcon A pointer to the icon to be shown in the search box frame.
134 * Takes ownerships. Can be @c NULL.
135 * @param aTextLimit Defines the maximum text length.
136 * @return A pointer to contructed @c CAknSearchField object.
138 IMPORT_C static CAknSearchField* NewL( const CCoeControl& aParent, TSearchFieldStyle aFieldStyle, CGulIcon* aIcon, TInt aTextLimit );
140 public: // for search string manipulation
142 * Returns the length of search text.
143 * @return The length of search text.
145 IMPORT_C TInt TextLength() const;
148 * Returns the text of search field by writing it into the
150 * @param aSearchTxt Reference to the text buffer. Buffer size must be same
151 * or greater than maximum text length, which is given in
154 IMPORT_C void GetSearchText( TDes& aSearchTxt ) const;
157 * Sets text into search field.
158 * @param aSearchTxt Reference to the text buffer.
160 IMPORT_C void SetSearchTextL( const TDesC& aSearchTxt );
163 * Selects the whole search text.
165 IMPORT_C void SelectSearchTextL();
168 * Clears text in the search field.
170 IMPORT_C void ResetL();
173 * Sets additional info text to the search field.
174 * @param aText Reference to the text buffer.
176 IMPORT_C void SetInfoTextL( const TDesC& aText );
179 * Calls editor's @c ClipboardL() function.
180 * @param aClipboardFunc Clipboard function.
182 IMPORT_C void ClipboardL( CEikEdwin::TClipboardFunc aClipboardFunc );
185 * Return search field style
187 * @return style of search field
189 IMPORT_C CAknSearchField::TSearchFieldStyle SearchFieldStyle() const;
191 public: // new methods for Avkon Skins support
194 * Sets whether skins are enabled on this control. The default value is
195 * determined from global setting from @c CAknAppUi.
196 * @since Series 60 2.0
197 * @param aEnabled @c ETrue if skins are enabled, @c EFalse if not.
199 IMPORT_C void SetSkinEnabledL( const TBool aEnabled );
201 public: // from MCoeControlObserver
204 * From @c MCoeControlObserver, Acts upon changes in the hosted control's state.
205 * This class's implementation is trivial and should be able to be safely
206 * re-implemented in directly client-derived classes. For non-base setting
207 * page classes, a call to the base class should be made.
208 * @param aControl Control that caused the event. (not used in default implementation)
209 * @param aEventType Type of the event.
211 void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType );
213 public: // From CCoeControl
216 * From @c CCoeControl, Handles key event.
217 * @param aKeyEvent The key event.
218 * @param aType The type of the event.
219 * @return Indicates whether the key event was used by this control or not.
221 IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType );
224 * From @c CCoeControl, Handles pointer event.
226 * @param aPointerEvent The pointer event.
227 * Invert adaptive search grid by tapping search field.
229 void HandlePointerEventL( const TPointerEvent& aPointerEvent );
232 * From @c CCoeControl, Returns minimum size. Minimum size depends on
234 * @return Minimum size.
236 IMPORT_C TSize MinimumSize();
239 * Sets this control as visible or invisible.
242 * @param aVisible ETrue to make the control visible, EFalse to make
245 IMPORT_C void MakeVisible( TBool aVisible );
248 * From @c CCoeControl, Resource change handling.
250 * @param aType Message type.
252 void HandleResourceChange( TInt aType );
257 * Sets position of the line on main pane.
258 * @since Series 60 2.0
259 * @param aLinePos The position as defined in @c TAknSeparatorLinePos
261 IMPORT_C void SetLinePos( TInt aLinePos );
264 * Access to the edwin owned by the search field.
265 * @since Series 60 2.6
266 * @return Reference to the edwin owned by the search field.
268 IMPORT_C CEikEdwin& Editor() const;
271 * Set adaptive search grid characters.
273 * @param aGridChars The characters for adaptive search grid.
275 IMPORT_C void SetAdaptiveGridChars( const TDesC& aGridChars ) const;
278 * Show adaptive search grid.
279 * Application can activate adaptive search grid from the option menu.
282 IMPORT_C void ShowAdaptiveSearchGrid() const;
285 * Set column filter flag for adaptive search grid
287 * @param aFlag The bit flag shows which columns take into account
290 IMPORT_C void SetListColumnFilterFlags( const TBitFlags32 aFlag );
293 * Send column filter flag for adaptive search grid
295 * @return aFlag The bit flag shows which columns take into account
298 IMPORT_C TBitFlags32 ListColumnFilterFlags() const;
301 * Adds an adaptive search text observer. Duplicates are not checked
302 * (i.e. adding the same observer multiple times is not prevented).
304 * @param aObserver Must be non-NULL.
306 IMPORT_C void AddAdaptiveSearchTextObserverL( MAdaptiveSearchTextObserver* aObserver );
309 * Removes an adaptive search text observer.
311 * @param aObserver The observer to be removed.
312 * @return ETrue if removal ok, EFalse if observer was not removed (not
313 * found from the list of observers).
315 IMPORT_C TBool RemoveAdaptiveSearchTextObserver( MAdaptiveSearchTextObserver* aObserver );
318 * Returns information whether adaptive search is enabled or not
320 * @return ETrue if adaptive search is enabled, EFalse otherwise.
322 IMPORT_C TBool AdaptiveSearchEnabled();
325 * Notify client if input language changed in settings, for adaptive search
327 * @return ETrue if language has changed, EFalse otherwise.
329 IMPORT_C TBool LanguageChanged() const;
331 private: // from MObjectProvider
332 TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
334 TInt CountComponentControls() const;
335 CCoeControl* ComponentControl( TInt aIndex ) const;
337 void FocusChanged( TDrawNow aDrawNow );
339 void ConstructL( const CCoeControl& aParent, TSearchFieldStyle aFieldStyle, CGulIcon* aIcon, TInt aTextLimit );
343 private: // from MEikCommandObserver
344 IMPORT_C void ProcessCommandL( TInt aCommandId );
346 void UpdatePopupCBAL();
347 void RestorePopupCBA();
348 void SetupSkinContextL();
352 * Sets a list box for this control.
353 * @since Series 60 2.6
354 * @param aListBox A pointer to a list box object.
356 void SetListbox( CEikListBox* aListBox );
359 * Sets the parent control for this control.
360 * @since Series 60 2.6
361 * @param aParent A pointer to the parent control.
363 void SetParentCtrl( CCoeControl* aParent );
366 * Indicates that is the control popup or not.
367 * @since Series 60 2.6
368 * @return @c ETrue if it is a popup, @c EFalse if not.
373 * Sets index, where listbox focus should return when popup findbox is
375 * @since Series 60 3.1
378 void SetOldItemIndex( TInt aOldItemIndex );
381 * Returns index, where listbox focus should return when popup findbox is
383 * @since Series 60 3.1
389 * Set the language changed flag, for adaptive search
391 * @param aLanguageChanged ETrue if language has changed, EFalse otherwise.
393 void SetLanguageChangedFlag( TBool aLanguageChanged );
396 * Handle HW keyboard active/deactive event.
399 void HandleHWKeyboardModeChangeL();
402 * A helper methord used in ContructL().
403 * Get Adaptive Search setting and subscribe hardware
404 * keyboard layout changing.
406 * @param aShowIndicator, ETrue if indicator need be shown
407 * @return ETrue if Adaptive is enabled in cenrep/
410 TBool GetASStatusAndSubKbLayoutL( TBool& aShowIndicator );
413 // The bit flag shows which collumns take into account during filltering
414 TBitFlags32 iColumnFlag;
416 CGlobalText* iGlobalText;
417 CAknInputFrame* iInputFrame;
418 CAknSearchFieldIndicator* iIndicator;
419 CAknsListBoxBackgroundControlContext* iSkinContext;
422 CAknsFrameBackgroundControlContext* iInputContext;
424 TBool iCBAObserverUpdated;
425 CEikListBox *iListBox; // not owned
426 CCoeControl *iParent; // not owned
427 CEikButtonGroupContainer *iCba; // this is only for checking whether cba changed
429 CAknAppUi* iBackedAppUi;
430 CAknAdaptiveSearch* iAdaptiveSearch;
431 TSearchFieldStyle iStyle;
432 TBool iLanguageChanged; // flag shows was input language changed or not
434 // For hybird keyborad
435 RProperty iHwKeyboardPro;
436 CHwKbSubscriber* iHwKbSub;