fep/aknfep/UiPlugins/AknFepUiInterface/AvkonImpl/inc/AknFepAvkonCandidatePopup.h
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     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:             Avkon implementation of non-focusing popup menu to show word candidates.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 #ifndef __AKN_FEP_AVKON_CANDIDATE_POPUP_H
       
    30 #define __AKN_FEP_AVKON_CANDIDATE_POPUP_H
       
    31 
       
    32 #include "AknFepCandidatePopup.h"
       
    33 #include "AknFepCandidatePopupCallback.h"
       
    34 #include <aknPopup.h>
       
    35 #include <PtiDefs.h>
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class TAknPopupLayouts;
       
    39 class TRect;
       
    40 
       
    41 
       
    42 // CLASS DECLARATION
       
    43 class CAknFepAvkonCandidatePopup : public CAknPopupList, public MAknFepCandidatePopup
       
    44     {
       
    45 public: // construction and destruction
       
    46 
       
    47     /**
       
    48     * Two-phased constructor
       
    49     * @param    aOwner  Reference to the owner of the popup which provides 
       
    50     *                   the candidates to be shown
       
    51     * @return   A new instance of the class.
       
    52     */
       
    53     static CAknFepAvkonCandidatePopup* NewL( MAknFepCandidatePopupCallback& aOwner );
       
    54     
       
    55     /**
       
    56     * Destructor
       
    57     */
       
    58     ~CAknFepAvkonCandidatePopup();
       
    59     
       
    60 public: // methods
       
    61 
       
    62     /**
       
    63     * Getter for the currently active word
       
    64     * @return   The currently active word as pointer descriptor
       
    65     */
       
    66     TPtrC ActiveWord() const;
       
    67     
       
    68     /**
       
    69     * Getter for the exact word (the word with ordinal 0)
       
    70     * @return   The exact word as pointer descriptor.
       
    71     */
       
    72     TPtrC ExactWord() const;
       
    73     
       
    74     /**
       
    75     * Makes the pop-up selection list visible and blocks until the dialog has been dismissed.
       
    76     * @param    aInlineEditorRect    Tells the place of the inline editor. If possible, the popup is opened
       
    77     *                                so that it does not hide the inline editor.
       
    78     * @param    aSelectedIdx         Output argument for the selected index.
       
    79     * @param    aLastKeyEvent        The last key event received by the popup. On return this is the event
       
    80     *                                which closed the popup.
       
    81     * @param    aRightToLeftLanguage Direction of the candidate language.ETrue is right to left. EFalse otherwise
       
    82     * @param    aKeyboard            Type of keyboard in use.
       
    83     * 
       
    84     * @return   The command id used to close the window. EAknFepSoftkeySpell, EAknSoftkeyCancel, or EAknSoftkeySelect
       
    85     */
       
    86     TInt ExecutePopupL( const TRect& aInlineEditorRect, TInt& aSelectedIdx, TKeyEvent& aLastKeyEvent, TBool aRightToLeftLanguage, TInt aKeyboard );
       
    87     
       
    88     /**
       
    89     * Function called when the dialog is dismissed. Among other things, this hides the dialog
       
    90     * and deblocks the thread. Unlike in the base class, the instance is not destroyed here. 
       
    91     * The same popup instance can be reused by calling ExecutePopupL() again. 
       
    92     * @param    aAccept     EFalse  if the dialog was cancelled.
       
    93     *                       ETrue   otherwise.
       
    94     */
       
    95     void AttemptExitL(TBool aAccept); 
       
    96     /**
       
    97     * Function called when there is a change of resource, typically when there is a layout switch.
       
    98     * Overidden the base implementation for the same. This is because the position of the popup
       
    99     * also chnages when there is a layout change.
       
   100     * @param    aType : Specifies the type of layout switch.
       
   101     */
       
   102     void HandleResourceChange(TInt aType); 
       
   103 
       
   104     /**
       
   105     * Removes the focus from the candidate list and makes the editor to be in focus.
       
   106     */
       
   107     void UnFocus();
       
   108     /**
       
   109     * Changes the position where the candidate list is shown. The position of the candidate list is choosen by the
       
   110     * candidate list itself but can be controlled by the inline text rectangle.
       
   111     * @param    aRect  The inline text rect.
       
   112     */
       
   113     void ShowAtNewPosition(TRect aRect);
       
   114     
       
   115     /**
       
   116      * Reduce the candidate pop up control priority and add it to stack.
       
   117      * Basically, this function is called,if after void UnFocus();
       
   118      * 
       
   119      * Whenever layout Change is happen opencandidate list, then candidatelist priority
       
   120      * should be reduce, otherwise updated inline rect 
       
   121      */
       
   122     void SetFocusAddStackReducePriorityL();
       
   123    
       
   124 protected: // methods
       
   125     
       
   126     /**
       
   127     * Handler for key evemts.
       
   128     * @param    aKeyEvent   The key event to be handled.
       
   129     * @param    aType       The type of the key event to be handled.
       
   130     * @return   EKeyWasConsumed     If the offered key event is consumed.
       
   131     *           EKeyWasNotConsumed  Otherwise.
       
   132     */
       
   133     virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
       
   134 
       
   135     /**
       
   136     * Processing of the CBA commands
       
   137     * @param  aCommandId  The command to be handled.
       
   138     */
       
   139     virtual void ProcessCommandL(TInt aCommandId);
       
   140 
       
   141     /**
       
   142     * Calculates the position for the popup window and places it there
       
   143     * @param    aInlineEditorRect   The placement of the inline editor is used as reference.
       
   144     *                               The inline editor is not hidden behind the popup if possible.
       
   145     *                               The preferred location for the popup is under the inline editor.
       
   146     *                               The next best place is on the right side of the inline editor,
       
   147     *                               then on the top of the editor and last on the left side of the editor.
       
   148     */
       
   149     virtual void SetupWindowLocation( const TRect& aInlineEditorRect );
       
   150     
       
   151     /**
       
   152     * Sets up the layout of the popup window.
       
   153     * Modified from CAknPopupList::SetupWindowLayout()
       
   154     */
       
   155     virtual void SetupWindowLayout( AknPopupLayouts::TAknPopupLayouts aType );
       
   156 
       
   157     /**
       
   158     * Calculates the width of the popup window based on the candidates available on the list. 
       
   159     * The with is always set to as small as possible without truncation. 
       
   160     * The client application area is used as reference to ensure that the popup is never wider
       
   161     * than the application area.
       
   162     * @param    aClientRect The client application area.
       
   163     * @return   The window widt in pixels.
       
   164     */    
       
   165     TInt CalculateWindowWidth( const TRect& aClientRect );
       
   166     
       
   167     /**
       
   168     * Updates the popup window layout.
       
   169     * Modified from AknPopupLayouts::HandleSizeChanged()
       
   170     */
       
   171     void HandleSizeChanged( TAknPopupWindowLayoutDef &aDef,
       
   172                             AknPopupLayouts::TAknPopupLayouts aLayout_1,
       
   173                             TAknPopupLayoutsNode *aNode );
       
   174     
       
   175     /**
       
   176     * The C++ constructor
       
   177     * @param    aOwner  Reference to the owner of the popup which provides 
       
   178     *                   the candidates to be shown 
       
   179     */
       
   180     CAknFepAvkonCandidatePopup( MAknFepCandidatePopupCallback& aOwner );
       
   181 
       
   182     /**
       
   183     * Second phase constructor.
       
   184     */
       
   185     void ConstructL();
       
   186     
       
   187     
       
   188     static TInt HandleChrKeyMonitorCallback(TAny* aParam);
       
   189 
       
   190 private: // data
       
   191 
       
   192     //! Owner of this popup. Provides the candidates.
       
   193     MAknFepCandidatePopupCallback& iOwner;
       
   194 
       
   195     //! The listbox embedded into this popup
       
   196     CEikFormattedCellListBox* iList;
       
   197     
       
   198     //! Array of candidates shown in the popup list
       
   199     CDesCArray* iCandidates;
       
   200     
       
   201     //! Pointer to variable containing the index of currently selected word.
       
   202     TInt* iSelectedIdx;         // not owned
       
   203     
       
   204     //! Pointer to variable containing the last received key event.
       
   205     TKeyEvent* iLastKeyEvent;   // not owned
       
   206     
       
   207     //! Last received command. EAknSoftkeySelect, EAknSoftkeySpell, or EAknSoftkeyCancel.
       
   208     TInt iLastCommandId;
       
   209     
       
   210     //! Candidate Language direction.
       
   211     TBool iRightToLeftCandidate;
       
   212     //! Keyboard type in use.
       
   213     TPtiKeyboardType iKeyboard;
       
   214     
       
   215     CPeriodic*     iChrKeypressMonitor;
       
   216     //The inline text rectangle that is used as a reference for showing the candidate list.
       
   217     TRect iInlineTextRect;
       
   218     };
       
   219     
       
   220 
       
   221 #endif // __AKN_FEP_AVKON_CANDIDATE_POPUP_H   
       
   222