epoc32/include/mw/aknsfld.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002 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: 
    15 *  Search Field support. 
    16 *
    17 *
    18 */
    19 
    20 
    21 #ifndef __AKNSFLD_H__
    22 #define __AKNSFLD_H__
    23 
    24 // INCLUDES
    25 #include <AknControl.h>
    26 #include <gulicon.h>
    27 #include <eikgted.h>
    28 #include <aknappui.h>
    29 #include <e32property.h>  // for subscriber/publisher
    30 
    31 // FORWARD DECLARATIONS
    32 class CEikEdwin;
    33 class CGlobalText;
    34 class CAknInputFrame;
    35 class CAknSearchFieldIndicator;
    36 class CAknsListBoxBackgroundControlContext;
    37 class CAknsFrameBackgroundControlContext;
    38 class CEikListBox;
    39 class CAknAdaptiveSearch;
    40 class MAdaptiveSearchTextObserver; 
    41 class CAknSearchField;
    42 class CHwKbSubscriber;
    43 
    44 /** 
    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.  
    50  * 
    51  * @since 5.0 
    52  */ 
    53 class MAdaptiveSearchTextObserver 
    54     { 
    55     public: 
    56        /** 
    57         * Notification and handling of an adaptive search text change. 
    58         * 
    59         * @param aSearchField The source search field of this message. 
    60         */ 
    61         virtual void AdaptiveSearchTextChanged( CAknSearchField* aSearchField ) = 0; 
    62     }; 
    63 
    64  
    65 // CLASS DECLARATION
    66 
    67 /**
    68  * The CAknSearchField class implements a Search field control. There are 
    69  * different styles for the search field defined by a TSearchFieldStyle.
    70  *
    71  * @since Series 60 0.9
    72  */
    73 NONSHARABLE_CLASS(CAknSearchField) : public CAknControl,
    74 		                             public MCoeControlObserver,			
    75                 		             public MEikCommandObserver
    76 {
    77 public:
    78    /**
    79     * Search field style.
    80     */
    81     enum TSearchFieldStyle 
    82         {
    83         /** Use only ESearch in Series 60 */
    84         ESearch,
    85         /** (Not used) */        
    86         EInput,
    87         /** (Not used) */
    88         EUrl,  
    89         /** (Not used) */
    90         EPhone,
    91         /** (Not used) */
    92         EPlain,
    93         /** Use as popup search field. */
    94         EPopup,         
    95         /** Use as pinb search field. */
    96         EPinb,          
    97         /** For Clock application/list_single_heading_pane. */
    98         EClockApp,      
    99         /** Same as ESearch, but using CreateWindowL(). */
   100         EFixed,         
   101         /** Layout where no line is used. */
   102         ESearchWithoutLine, 
   103         /** Popup window layout. */
   104         EPopupWindow,
   105 	    /** For adaptive search grid */
   106 	    /** @since 5.0 */
   107 	    EAdaptiveSearch,
   108 	    /** For adaptive search grid */
   109 	    /** Same as EAdaptiveSearch, but using CreateWindowL(). */
   110 	    /** @since 5.0 */
   111 	    EAdaptive,
   112         /** For adaptive search grid */
   113 	    /** Same as EAdaptiveSearch, but using popup find pane. */
   114 	    /** @since 5.0 */
   115 	    EPopupAdaptiveSearch,
   116         /** For adaptive search grid */
   117 	    /** Popup window layout */
   118 	    /** @since 5.0 */
   119 	    EPopupAdaptiveSearchWindow
   120         };
   121   
   122 public:
   123 
   124    /**
   125     * Destructor.
   126     */
   127     IMPORT_C ~CAknSearchField();
   128 
   129    /**
   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.
   137     */
   138     IMPORT_C static CAknSearchField* NewL( const CCoeControl& aParent, TSearchFieldStyle aFieldStyle, CGulIcon* aIcon, TInt aTextLimit );
   139 
   140 public:                 // for search string manipulation
   141    /**
   142     * Returns the length of search text.
   143     * @return The length of search text.
   144     */
   145     IMPORT_C TInt TextLength() const;
   146 
   147    /**
   148     * Returns the text of search field by writing it into the 
   149     * buffer aSearchTxt.
   150     * @param aSearchTxt Reference to the text buffer. Buffer size must be same
   151     *                   or greater than maximum text length, which is given in 
   152     *                   constructor.
   153     */
   154     IMPORT_C void GetSearchText( TDes& aSearchTxt ) const;
   155 
   156    /**
   157     * Sets text into search field.
   158     * @param aSearchTxt Reference to the text buffer.
   159     */
   160     IMPORT_C void SetSearchTextL( const TDesC& aSearchTxt );
   161 
   162    /**
   163     * Selects the whole search text.
   164     */
   165     IMPORT_C void SelectSearchTextL();
   166 
   167    /**
   168     * Clears text in the search field.
   169     */
   170     IMPORT_C void ResetL();
   171 
   172    /**
   173     * Sets additional info text to the search field.
   174     * @param aText Reference to the text buffer.
   175     */
   176     IMPORT_C void SetInfoTextL( const TDesC& aText );
   177 
   178    /**
   179     * Calls editor's @c ClipboardL() function.
   180     * @param aClipboardFunc Clipboard function.
   181     */
   182     IMPORT_C void ClipboardL( CEikEdwin::TClipboardFunc aClipboardFunc );
   183 
   184    /**
   185     * Return search field style
   186     * @since 5.0
   187     * @return style of search field 
   188     */   
   189     IMPORT_C CAknSearchField::TSearchFieldStyle SearchFieldStyle() const;
   190 
   191 public: // new methods for Avkon Skins support
   192 
   193    /**
   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.
   198     */
   199     IMPORT_C void SetSkinEnabledL( const TBool aEnabled );
   200 
   201 public: // from MCoeControlObserver
   202 
   203    /**
   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. 
   210     */
   211     void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType );
   212 
   213 public: // From CCoeControl
   214 
   215    /**
   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.
   220     */
   221     IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType );
   222 
   223    /**
   224     * From @c CCoeControl, Handles pointer event.
   225     * @since 5.0
   226     * @param aPointerEvent The pointer event. 
   227     *	Invert adaptive search grid by tapping search field.    
   228     */
   229     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
   230 
   231    /**
   232     * From @c CCoeControl, Returns minimum size. Minimum size depends on 
   233     * zoom factor. 
   234     * @return Minimum size.
   235     */
   236     IMPORT_C TSize MinimumSize();
   237 
   238    /**
   239     * Sets this control as visible or invisible.
   240     *
   241     * @since S60 3.2
   242     * @param aVisible ETrue to make the control visible, EFalse to make
   243     *                 it invisible.
   244     */
   245     IMPORT_C void MakeVisible( TBool aVisible );
   246     
   247     /**
   248      * From @c CCoeControl, Resource change handling.
   249      *
   250      * @param aType Message type.
   251      */
   252     void HandleResourceChange( TInt aType );
   253 
   254 public:
   255 
   256    /**
   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
   260     */
   261     IMPORT_C void SetLinePos( TInt aLinePos );
   262 
   263    /**
   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.
   267     */
   268     IMPORT_C CEikEdwin& Editor() const;
   269 
   270    /**
   271     * Set adaptive search grid characters.
   272     * @since 5.0
   273     * @param aGridChars The characters for adaptive search grid.
   274     */
   275     IMPORT_C void SetAdaptiveGridChars( const TDesC& aGridChars ) const;
   276 
   277    /**
   278     * Show adaptive search grid. 
   279     * Application can activate adaptive search grid from the option menu.
   280     * @since 5.0
   281     */
   282     IMPORT_C void ShowAdaptiveSearchGrid() const;   
   283     
   284    /**
   285     * Set column filter flag for adaptive search grid  
   286     * @since 5.0
   287     * @param aFlag The bit flag shows which columns take into account
   288     * during filtering.
   289     */
   290     IMPORT_C void SetListColumnFilterFlags( const TBitFlags32 aFlag );
   291 
   292    /**
   293     * Send column filter flag for adaptive search grid  
   294     * @since 5.0
   295     * @return aFlag The bit flag shows which columns take into account
   296     * during filtering.
   297     */
   298     IMPORT_C TBitFlags32 ListColumnFilterFlags() const;
   299 
   300    /** 
   301     * Adds an adaptive search text observer. Duplicates are not checked 
   302     * (i.e. adding the same observer multiple times is not prevented). 
   303     * @since 5.0 
   304     * @param aObserver Must be non-NULL. 
   305     */ 
   306     IMPORT_C void AddAdaptiveSearchTextObserverL( MAdaptiveSearchTextObserver* aObserver );
   307 
   308    /** 
   309     * Removes an adaptive search text observer. 
   310     * @since 5.0 
   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). 
   314     */ 
   315     IMPORT_C TBool RemoveAdaptiveSearchTextObserver( MAdaptiveSearchTextObserver* aObserver );
   316 
   317    /** 
   318     * Returns information whether adaptive search is enabled or not
   319     * @since 5.0   
   320     * @return ETrue if adaptive search is enabled, EFalse otherwise.
   321     */ 
   322     IMPORT_C TBool AdaptiveSearchEnabled();
   323 
   324    /** 
   325     * Notify client if input language changed in settings, for adaptive search
   326     * @since 5.0       
   327     * @return ETrue if language has changed, EFalse otherwise.
   328     */
   329     IMPORT_C TBool LanguageChanged() const;
   330 
   331 private: // from MObjectProvider
   332     TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
   333 private:
   334     TInt CountComponentControls() const;
   335     CCoeControl* ComponentControl( TInt aIndex ) const;
   336     void SizeChanged();
   337     void FocusChanged( TDrawNow aDrawNow );
   338 private:
   339     void ConstructL( const CCoeControl& aParent, TSearchFieldStyle aFieldStyle, CGulIcon* aIcon, TInt aTextLimit );
   340     CAknSearchField(); 
   341 private:
   342     void ZoomEditorL();
   343 private: // from MEikCommandObserver
   344     IMPORT_C void ProcessCommandL( TInt aCommandId );
   345 private:
   346     void UpdatePopupCBAL();
   347     void RestorePopupCBA();
   348     void SetupSkinContextL();
   349 public:
   350 
   351    /**
   352     * Sets a list box for this control.
   353     * @since Series 60 2.6
   354     * @param aListBox A pointer to a list box object.
   355     */
   356     void SetListbox( CEikListBox* aListBox );
   357 
   358    /**
   359     * Sets the parent control for this control.
   360     * @since Series 60 2.6
   361     * @param aParent A pointer to the parent control.
   362     */
   363     void SetParentCtrl( CCoeControl* aParent );
   364 
   365    /**
   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.
   369     */
   370     TBool IsPopup();
   371 
   372    /**
   373     * Sets index, where listbox focus should return when popup findbox is
   374     * canceled.
   375     * @since Series 60 3.1
   376     * @internal
   377     */
   378     void SetOldItemIndex( TInt aOldItemIndex );
   379 
   380    /**
   381     * Returns index, where listbox focus should return when popup findbox is
   382     * canceled
   383     * @since Series 60 3.1
   384     * @internal
   385     */
   386     TInt OldItemIndex();
   387 
   388    /** 
   389     * Set the language changed flag, for adaptive search
   390     * @since 5.0       
   391     * @param aLanguageChanged ETrue if language has changed, EFalse otherwise.
   392     */
   393     void SetLanguageChangedFlag( TBool aLanguageChanged );
   394     
   395     /**
   396      * Handle HW keyboard active/deactive event.
   397      * @since 5.0
   398      */
   399     void HandleHWKeyboardModeChangeL();
   400 
   401     /**
   402      * A helper methord used in ContructL().
   403      * Get Adaptive Search setting and subscribe hardware 
   404      * keyboard layout changing.
   405      *
   406      * @param aShowIndicator, ETrue if indicator need be shown
   407      * @return ETrue if Adaptive is enabled in cenrep/
   408      * @since 5.0
   409      */
   410     TBool GetASStatusAndSubKbLayoutL( TBool& aShowIndicator );
   411 
   412 private:	
   413     // The bit flag shows which collumns take into account during filltering  
   414     TBitFlags32 iColumnFlag;
   415     CEikEdwin* iEditor;   
   416     CGlobalText* iGlobalText;
   417     CAknInputFrame* iInputFrame;
   418     CAknSearchFieldIndicator* iIndicator; 
   419     CAknsListBoxBackgroundControlContext* iSkinContext;
   420     TInt iFlags;  
   421     TInt iLinePos;
   422     CAknsFrameBackgroundControlContext* iInputContext;
   423     TBool iIsPopup;
   424     TBool iCBAObserverUpdated;
   425     CEikListBox *iListBox; // not owned
   426     CCoeControl *iParent; // not owned
   427     CEikButtonGroupContainer *iCba; // this is only for checking whether cba changed 
   428     TInt iOldItemIndex;
   429     CAknAppUi* iBackedAppUi;
   430     CAknAdaptiveSearch* iAdaptiveSearch; 
   431     TSearchFieldStyle iStyle;    
   432     TBool iLanguageChanged; // flag shows was input language changed or not
   433 
   434     // For hybird keyborad
   435     RProperty iHwKeyboardPro;
   436     CHwKbSubscriber* iHwKbSub;
   437     };
   438  
   439 #endif
   440 
   441