epoc32/include/mw/caknfileselectiondialog.h
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
     1.1 --- a/epoc32/include/mw/caknfileselectiondialog.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/mw/caknfileselectiondialog.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,251 @@
     1.4 -caknfileselectiondialog.h
     1.5 +/*
     1.6 +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description:  Dialog used to select target file or directory
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#ifndef CAKNFILESELECTIONDIALOG_H
    1.24 +#define CAKNFILESELECTIONDIALOG_H
    1.25 +
    1.26 +// INCLUDES
    1.27 +#include <CAknCommonDialogsBase.h>
    1.28 +
    1.29 +// FORWARD DECLARATIONS
    1.30 +class CAknFileSelectionModel;
    1.31 +class CAknFileSelectionEventHandler;
    1.32 +class MAknFileSelectionObserver;
    1.33 +class MAknFileFilter;
    1.34 +
    1.35 +//  CLASS DEFINITION
    1.36 +/**
    1.37 +*  A class that launches a popup dialog for file selection or directory browsing.
    1.38 +*
    1.39 +*  @lib CommonDialogs.lib
    1.40 +*  @since 1.2
    1.41 +*/
    1.42 +NONSHARABLE_CLASS(CAknFileSelectionDialog) : public CAknCommonDialogsBase
    1.43 +    {
    1.44 +    public:     // Constructors and destructors
    1.45 +        /**
    1.46 +        * Static constructor.
    1.47 +        * @param aDialogType Type of the dialog for reading correct default values.
    1.48 +        * @return Returns a pointer to an instance of itself.
    1.49 +        */
    1.50 +        IMPORT_C static CAknFileSelectionDialog* NewL(
    1.51 +            TCommonDialogType aDialogType );
    1.52 +
    1.53 +        /**
    1.54 +        * Static constructor.
    1.55 +        * @param aDialogType Type of the dialog for reading correct default values.
    1.56 +        * @param aResourceId A resource id (FILESELECTIONDIALOG).
    1.57 +        * @return Returns a pointer to an instance of itself.
    1.58 +        */
    1.59 +        IMPORT_C static CAknFileSelectionDialog* NewL(
    1.60 +            TCommonDialogType aDialogType, TInt aResourceId );
    1.61 +
    1.62 +        IMPORT_C ~CAknFileSelectionDialog();
    1.63 +
    1.64 +    public: // New functions
    1.65 +
    1.66 +        /**
    1.67 +        * Sets an observer which is asked if the selected item can be selected.
    1.68 +        * @param aObserver A pointer to an observer.
    1.69 +        */
    1.70 +        IMPORT_C void SetObserver( MAknFileSelectionObserver* aObserver );
    1.71 +
    1.72 +        /**
    1.73 +        * Adds a filter to list of filters owned by the engine.
    1.74 +        * Note! The ownership of the filter is transferred to the engine.
    1.75 +        * @param aFilter A pointer to a filter that is derived from MAknFileFilter.
    1.76 +        */
    1.77 +        IMPORT_C void AddFilterL( MAknFileFilter* aFilter );
    1.78 +
    1.79 +        /**
    1.80 +        * Sets the default folder that browsing is started from.
    1.81 +        * @param aDefaultFolder A folder that is relative to the root path,
    1.82 +        *        e.g. root path = "C:\" so the default folder could be
    1.83 +        *        "Nokia\Images\".
    1.84 +        */
    1.85 +        IMPORT_C void SetDefaultFolderL( const TDesC& aDefaultFolder );
    1.86 +
    1.87 +        /**
    1.88 +        * Sets title to the pop-up dialog.
    1.89 +        * @param aText Title text.
    1.90 +        */
    1.91 +        IMPORT_C void SetTitleL( const TDesC& aText );
    1.92 +
    1.93 +        /**
    1.94 +        * Sets the text used for left softkey when a file is focused.
    1.95 +        * @param aText The text for softkey.
    1.96 +        */
    1.97 +        IMPORT_C void SetLeftSoftkeyFileL( const TDesC& aText );
    1.98 +
    1.99 +        /**
   1.100 +        * Sets the text used for left softkey when a folder is focused.
   1.101 +        * @param aText The text for softkey.
   1.102 +        */
   1.103 +        IMPORT_C void SetLeftSoftkeyFolderL( const TDesC& aText );
   1.104 +
   1.105 +        /**
   1.106 +        * Sets the text used for right softkey when user is in the root folder.
   1.107 +        * @param aText The text used for right softkey when user is in the root folder.
   1.108 +        */
   1.109 +        IMPORT_C void SetRightSoftkeyRootFolderL( const TDesC& aText );
   1.110 +
   1.111 +        /**
   1.112 +        * Sets the text used for right softkey when user is in a subfolder.
   1.113 +        * @param aText The text used for right softkey when user is in a subfolder.
   1.114 +        */
   1.115 +        IMPORT_C void SetRightSoftkeySubfolderL( const TDesC& aText );
   1.116 +
   1.117 +        /**
   1.118 +        * Executes the file selection dialog.
   1.119 +        * @param aFileName Contains the root path.
   1.120 +        *        If an item is selected, the selected item will be set to the
   1.121 +        *        parameter with full path.
   1.122 +        * @return Returns ETrue if user has selected an item and EFalse
   1.123 +        *         if user hits cancel.
   1.124 +        */
   1.125 +        IMPORT_C TBool ExecuteL( TDes& aFileName );
   1.126 +
   1.127 +        /**
   1.128 +        * A static method that launches a file selection dialog.
   1.129 +        * @see RunL()
   1.130 +        */
   1.131 +        IMPORT_C static TBool RunDlgLD( TDes& aFileName,
   1.132 +            const TDesC& aDefaultFolder,
   1.133 +            MAknFileSelectionObserver* aObserver = NULL );
   1.134 +
   1.135 +        /**
   1.136 +        * A static method that launches a file selection dialog.
   1.137 +        * @see RunL()
   1.138 +        */
   1.139 +        IMPORT_C static TBool RunDlgLD( TDes& aFileName,
   1.140 +            const TDesC& aDefaultFolder,
   1.141 +            const TDesC& aTitle,
   1.142 +            MAknFileSelectionObserver* aObserver = NULL );
   1.143 +
   1.144 +        /**
   1.145 +        * A static method that launches a file selection dialog.
   1.146 +        * @see RunL()
   1.147 +        */
   1.148 +        IMPORT_C static TBool RunDlgLD( TDes& aFileName,
   1.149 +            const TDesC& aDefaultFolder,
   1.150 +            TInt aResourceId,
   1.151 +            MAknFileSelectionObserver* aObserver = NULL );
   1.152 +
   1.153 +    private:    // New functions
   1.154 +
   1.155 +        /**
   1.156 +        * A static method for launching a file selection dialog.
   1.157 +        * Creates, constructs, runs and deletes a file selection dialog with
   1.158 +        * different parameters.
   1.159 +        * @param aResourceId An id of a resource. If zero, default resource is used.
   1.160 +        * @param aFileName A reference to a filename. Must contain the root path
   1.161 +        *        to start browsing from (if the root path is not defined in
   1.162 +        *        resource). If user accepts a selection, the whole path + current
   1.163 +        *        filename is set to aFileName.
   1.164 +        * @param aDefaultFolder A descriptor that contains one or more folders
   1.165 +        *        that are relative to the root path. Browsing is started from
   1.166 +        *        the default folder and user can browse folders up all the way
   1.167 +        *        to the root folder.
   1.168 +        * @param aTitle A title for file selection dialog.
   1.169 +        * @param aObserver An observer which is asked if the selected item
   1.170 +        *        can be selected. Implemented in application.
   1.171 +        * @return Returns true if user has selected an item and false
   1.172 +        *         if user hits cancel.
   1.173 +        */
   1.174 +        static TBool RunL(
   1.175 +            TInt aResourceId,
   1.176 +            TDes& aFileName,
   1.177 +            const TDesC& aDefaultFolder,
   1.178 +            const TDesC& aTitle,
   1.179 +            MAknFileSelectionObserver* aObserver );
   1.180 +
   1.181 +        /**
   1.182 +        * Initialization method that must be called before executing the dialog.
   1.183 +        * Initializes the engine and event handler with correct values.
   1.184 +        * Decides if the dialog should be shown or not.
   1.185 +        * Called in ExecuteL.
   1.186 +        * @param aFileName The root path.
   1.187 +        * @return Returns EFalse if the dialog cannot be executed.
   1.188 +        */
   1.189 +        TBool PrepareL( const TDesC& aFileName );
   1.190 +
   1.191 +        /**
   1.192 +        * Sets id to a default CFD resource depending on dialog type.
   1.193 +        * @param aResourceId Resource id variable to be modified.
   1.194 +        * @param aType Dialog type.
   1.195 +        */
   1.196 +        void SetResourceId( TInt& aResourceId, TCommonDialogType aType ) const;
   1.197 +
   1.198 +        /**
   1.199 +        * Reads settings from resource.
   1.200 +        * @param aResourceId Resource id.
   1.201 +        */
   1.202 +        void ReadFromResourceL( TInt aResourceId );
   1.203 +
   1.204 +    private:    // Constructors and destructors
   1.205 +
   1.206 +        CAknFileSelectionDialog( TCommonDialogType aDialogType );
   1.207 +
   1.208 +        /**
   1.209 +         * Second phase construct. Constructs itself from a resource.
   1.210 +         * @param aResourceId A resource id (FILESELECTIONDIALOG).
   1.211 +         */
   1.212 +        void ConstructFromResourceL( TInt aResourceId );
   1.213 +
   1.214 +    private:    // Data
   1.215 +
   1.216 +        // Own: Dialog type
   1.217 +        TCommonDialogType iDialogType;
   1.218 +
   1.219 +        // Own: Model
   1.220 +        CAknFileSelectionModel* iModel;
   1.221 +
   1.222 +        // Own: Event handler
   1.223 +        CAknFileSelectionEventHandler* iEventHandler;
   1.224 +
   1.225 +        // Ref: Observer
   1.226 +        MAknFileSelectionObserver* iObserver;
   1.227 +
   1.228 +        // Own: Title
   1.229 +        HBufC* iTitle;
   1.230 +
   1.231 +        // Own: Left softkey when file focused
   1.232 +        HBufC* iLeftSoftkeyFile;
   1.233 +
   1.234 +        // Own: Left softkey when folder focused
   1.235 +        HBufC* iLeftSoftkeyFolder;
   1.236 +
   1.237 +        // Own: Right softkey when in root folder
   1.238 +        HBufC* iRightSoftkeyRootFolder;
   1.239 +
   1.240 +        // Own: Right softkey when in subfolder
   1.241 +        HBufC* iRightSoftkeySubfolder;
   1.242 +
   1.243 +        // Own: Root path
   1.244 +        HBufC* iRootPath;
   1.245 +
   1.246 +        // Own: Default folder
   1.247 +        HBufC* iDefaultFolder;
   1.248 +
   1.249 +        // Own: Boolean value that tells if the dialog has been executed already.
   1.250 +        TBool iExecuted;
   1.251 +    };
   1.252 +
   1.253 +#endif // CAKNFILESELECTIONDIALOG_H
   1.254 +
   1.255 +// End of File