commonuis/CommonDialogs/src/CAknFileSelectionEventHandler.h
changeset 0 2f259fa3e83a
child 15 08e69e956a8c
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  The event handler to handle events of list box in dialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_AKNFILESELECTIONEVENTHANDLER_H
       
    20 #define C_AKNFILESELECTIONEVENTHANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <cstack.h>
       
    24 #include <f32file.h>
       
    25 
       
    26 #include "MAknCommonDialogsEventObserver.h"
       
    27 #include "CAknCommonDialogsBase.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class MAknFileSelectionObserver;
       
    31 class CAknFileSelectionModel;
       
    32 
       
    33 // CLASS DEFINITION
       
    34 /**
       
    35 *  A class that handles events reported from an UI class in file selection.
       
    36 *
       
    37 *  @lib CommonDialogs.lib
       
    38 *  @since 1.2
       
    39 */
       
    40 NONSHARABLE_CLASS(CAknFileSelectionEventHandler) : public CBase, public MAknCommonDialogsEventObserver
       
    41     {
       
    42     public:     // Constructors and destructors
       
    43 
       
    44         /**
       
    45         * Static constructor.
       
    46         * @param aCoeEnv A pointer to control environment.
       
    47         * @param aModel A pointer to file selection model.
       
    48         * @param aDialogType Type of the dialog.
       
    49         * @param aObserver A reference to a pointer to an observer which is
       
    50         *        asked if the selected item can be selected.
       
    51         * @param aLeftSoftkeyFile Left softkey text when a file is focused.
       
    52         * @param aLeftSoftkeyFolder Left softkey text when a folder is focused.
       
    53         * @param aRightSoftkeyRootFolder Right softkey text when user browses
       
    54         *        in the root folder.
       
    55         * @param aRightSoftkeySubfolder Right softkey text when user browses
       
    56         *        in a subdirectory.
       
    57         * @return Returns a pointer to an instance of itself.
       
    58         */
       
    59         static CAknFileSelectionEventHandler* NewL(
       
    60             CCoeEnv* aCoeEnv,
       
    61             CAknFileSelectionModel* aModel,
       
    62             const TCommonDialogType& aDialogType,
       
    63             MAknFileSelectionObserver*& aObserver,
       
    64             const HBufC*& aLeftSoftkeyFile,
       
    65             const HBufC*& aLeftSoftkeyFolder,
       
    66             const HBufC*& aRightSoftkeyRootFolder,
       
    67             const HBufC*& aRightSoftkeySubfolder );
       
    68 
       
    69         ~CAknFileSelectionEventHandler();
       
    70 
       
    71     public:     // New methods
       
    72 
       
    73         /**
       
    74         * Pushes listbox indices to stack.
       
    75         * @param aTopIndex Index of the topmost item in the listbox window.
       
    76         * @param aFocus Index of the item focused.
       
    77         */
       
    78         void PushIndicesL( TInt aTopIndex, TInt aFocus );
       
    79 
       
    80         /**
       
    81         * Pops listbox indexes from stack. Sets values to 0 if stack is empty.
       
    82         * @param aTopIndex Index of the topmost item in the listbox window.
       
    83         * @param aFocus Index of the item focused.
       
    84         */
       
    85         void PopIndices( TInt& aTopIndex, TInt& aFocus );
       
    86 
       
    87         /**
       
    88         * Resets current softkeys to EFirstTime.
       
    89         */
       
    90         void ResetSoftkeyStatus();
       
    91 
       
    92         /**
       
    93         * Updates softkey texts if they need to be changed.
       
    94         * @param aCurrentItemIndex Index of the currently selected item.
       
    95         * @param aContainer A pointer to a button group container to update buttons.
       
    96         */
       
    97         void UpdateSoftkeysL( TInt aCurrentItemIndex, CEikButtonGroupContainer* aContainer );
       
    98 
       
    99     public:     // Functions from base classes
       
   100 
       
   101         /**
       
   102         * From MAknCommonDialogsEventObserver
       
   103         */
       
   104         TAction HandleEventL(
       
   105             TEvent aEvent,
       
   106             TInt& aFocusedItemIndex,
       
   107             TInt& aTopItemIndex,
       
   108             CEikButtonGroupContainer* aContainer );
       
   109 
       
   110     private:    // Enumerations
       
   111 
       
   112         /**
       
   113         * Enumerations for softkey statuses.
       
   114         * If softkey status has changed the text must be redrawn.
       
   115         */
       
   116         enum TSoftkeyStatus
       
   117             {
       
   118             EFirstTime = -1,
       
   119             ESKNotVisible,
       
   120             ESKFileFocused,
       
   121             ESKFolderFocused,
       
   122             ESKInRootFolder,
       
   123             ESKInSubfolder
       
   124             };
       
   125 
       
   126         /**
       
   127         * A small container class.
       
   128         */
       
   129         class TFocusItem
       
   130             {
       
   131             public:
       
   132                 inline TFocusItem( TInt aTopIndex, TInt aFocus );
       
   133                 TInt iTopIndex; // Index of the first item in listbox view.
       
   134                 TInt iFocus; // Index of the focused item.
       
   135             };
       
   136 
       
   137     private:    // Constructors and destructors
       
   138 
       
   139         void ConstructL();
       
   140 
       
   141         /**
       
   142         * Constructor.
       
   143         * @param aCoeEnv A pointer to control environment.
       
   144         * @param aModel A pointer to file selection model.
       
   145         * @param aDialogType Type of the dialog.
       
   146         * @param aObserver A reference to a pointer to an observer which is
       
   147         *        asked if the selected item can be selected.
       
   148         * @param aLeftSoftkeyFile Left softkey text when a file is focused.
       
   149         * @param aLeftSoftkeyFolder Left softkey text when a folder is focused.
       
   150         * @param aRightSoftkeyRootFolder Right softkey text when user browses
       
   151         *        in the root folder.
       
   152         * @param aRightSoftkeySubfolder Right softkey text when user browses
       
   153         *        in a subdirectory.
       
   154         */
       
   155         CAknFileSelectionEventHandler(
       
   156             CCoeEnv* aCoeEnv,
       
   157             CAknFileSelectionModel* aModel,
       
   158             const TCommonDialogType& aType,
       
   159             MAknFileSelectionObserver*& aObserver,
       
   160             const HBufC*& aLeftSoftkeyFile,
       
   161             const HBufC*& aLeftSoftkeyFolder,
       
   162             const HBufC*& aRightSoftkeyRootFolder,
       
   163             const HBufC*& aRightSoftkeySubfolder );
       
   164 
       
   165     private:    // Data
       
   166 
       
   167         // Own: Left softkey status
       
   168         TSoftkeyStatus iCurrentLeftSoftkey;
       
   169 
       
   170         // Own Right softkey status.
       
   171         TSoftkeyStatus iCurrentRightSoftkey;
       
   172 
       
   173         // Own: Stack for listbox focuses.
       
   174         CStack<TFocusItem, ETrue> iStack;
       
   175 
       
   176         // Ref: Pointer to control environment
       
   177         CCoeEnv* iCoeEnv;
       
   178 
       
   179         // Ref: Pointer to file selection engine
       
   180         CAknFileSelectionModel* iModel;
       
   181 
       
   182         TEntry  iEntry;
       
   183 
       
   184         // Ref: Dialog type
       
   185         const TCommonDialogType& iDialogType;
       
   186 
       
   187         // Ref: File selection observer
       
   188         MAknFileSelectionObserver*& iObserver;
       
   189 
       
   190         // Ref: Softkey text
       
   191         const HBufC*& iLeftSoftkeyFile;
       
   192 
       
   193         // Ref: Softkey text
       
   194         const HBufC*& iLeftSoftkeyFolder;
       
   195 
       
   196         // Ref: Softkey text
       
   197         const HBufC*& iRightSoftkeyRootFolder;
       
   198 
       
   199         // Ref: Softkey text
       
   200         const HBufC*& iRightSoftkeySubfolder;
       
   201     };
       
   202 
       
   203 
       
   204 // Constructor for TFocusItem object
       
   205 
       
   206 inline CAknFileSelectionEventHandler::TFocusItem::TFocusItem(
       
   207     TInt aTopIndex,
       
   208     TInt aFocus )
       
   209     :   iTopIndex( aTopIndex ),
       
   210         iFocus( aFocus )
       
   211     {
       
   212     }
       
   213 
       
   214 #endif // C_AKNFILESELECTIONEVENTHANDLER_H