S60 3rd Edition SDK FP2 for Symbian OS CommonDialogsEx

- Main Page
- Classes
- Files

# CommonDialogsExAppUi.cpp

    00001 /*
    00002 * ============================================================================
    00003 *  Name        : commondialogsexappui.cpp
    00004 *  Part of     : CommonDialogsEx
    00005 *  Description : Implements CommonDialogsEx appui.
    00006 *  Version     :
    00007 *
    00008 *  Copyright (c) 2006 Nokia Corporation.
    00009 *  This material, including documentation and any related
    00010 *  computer programs, is protected by copyright controlled by
    00011 *  Nokia Corporation.
    00012 * ==============================================================================
    00013 */
    00014 #include <avkon.hrh>
    00015 #include <CAknMemorySelectionSettingPage.h>
    00016 #include <CAknFileSelectionDialog.h>
    00017 #include <CAknFileNamePromptDialog.h>
    00018 #include <CAknMemorySelectionDialogMultiDrive.h>
    00019 #include <CommonDialogsEx.rsg>
    00020 #include "CommonDialogsExAppUi.h"
    00021 #include "CommonDialogsExContainer.h"
    00022 #include "CommonDialogsEx.hrh"
    00023 #include "CommonDialogsExSettingsDialog.h"
    00024
    00025
    00026 _LIT( KCommonDialogsExSelected, "User selected" );
    00027 _LIT( KCommonDialogsExCanceled, "User canceled" );
    00028 _LIT( KCommonDialogsExSpace, " " );
    00029 _LIT( KCommonDialogsExMultiDrive, "Multi dvive: " );
    00030 _LIT( KCommonDialogsExPhoneMemoryName, "Phone memory" );
    00031 _LIT( KCommonDialogsExMemoryCardName,  "Memory card" );
    00032 _LIT( KCommonDialogsExDefaultSetting,  "Default setting" );
    00033 _LIT( KCommonDialogsExMultiSetting,  "Multi drive setting" );
    00034 _LIT( KCommonDialogsExFile,  " A file " );
    00035 _LIT( KCommonDialogsExFileName,  " Filename is OK " );
    00036 _LIT( KRootPath,                    "C:\\data\\Images\\" );
    00037 _LIT( KDefaultFileName,             "DynamicFilename.jpg" );
    00038
    00039 // ================= MEMBER FUNCTIONS =======================
    00040 //
    00041 // ----------------------------------------------------------
    00042 // CCommonDialogsExAppUi::ConstructL()
    00043 // Symbian 2nd phase constructor.
    00044 // ----------------------------------------------------------
    00045 //
    00046 void CCommonDialogsExAppUi::ConstructL()
    00047     {
    00048     BaseConstructL(EAknEnableSkin);
    00049     iAppContainer = new (ELeave) CCommonDialogsExContainer;
    00050     iAppContainer->ConstructL( ClientRect() );
    00051     AddToStackL( iAppContainer );
    00052     }
    00053
    00054 // ----------------------------------------------------
    00055 // CCommonDialogsExAppUi::~CCommonDialogsExAppUi()
    00056 // Destructor
    00057 // Frees reserved resources
    00058 // ----------------------------------------------------
    00059 //
    00060 CCommonDialogsExAppUi::~CCommonDialogsExAppUi()
    00061     {
    00062     RemoveFromStack( iAppContainer );
    00063     delete iAppContainer;
    00064     }
    00065
    00066 // ------------------------------------------------------------------------------
    00067 // CCommonDialogsExAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
    00068 //  This function is called by the EIKON framework just before it displays
    00069 //  a menu pane. Its default implementation is empty, and by overriding it,
    00070 //  the application can set the state of menu items dynamically according
    00071 //  to the state of application data.
    00072 // ------------------------------------------------------------------------------
    00073 //
    00074 void CCommonDialogsExAppUi::DynInitMenuPaneL(
    00075     TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
    00076     {
    00077     }
    00078
    00079 // ----------------------------------------------------
    00080 // CCommonDialogsExAppUi::HandleKeyEventL(
    00081 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
    00082 // From CEikAppUi, handles key events.
    00083 // ----------------------------------------------------
    00084 //
    00085 TKeyResponse CCommonDialogsExAppUi::HandleKeyEventL(
    00086     const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
    00087     {
    00088     return EKeyWasNotConsumed;
    00089     }
    00090
    00091 // ----------------------------------------------------
    00092 // CCommonDialogsExAppUi::HandleCommandL(TInt aCommand)
    00093 // Handles the commands.
    00094 // ----------------------------------------------------
    00095 //
    00096 void CCommonDialogsExAppUi::HandleCommandL(TInt aCommand)
    00097     {
    00098     TFileName rootFileName( KRootPath );
    00099     TFileName emptyFileName( KNullDesC );
    00100     TFileName defaultFileName( KDefaultFileName );
    00101     TFileName tempRootPath;
    00102     TFileName tempDefaultFolder;
    00103     TInt returnValue;
    00104
    00105     TBuf<32> textMain;
    00106     TBuf<64> textSub;
    00107
    00108     switch ( aCommand )
    00109         {
    00110         case EAknSoftkeyExit:
    00111         case EEikCmdExit:
    00112             {
    00113             Exit();
    00114             break;
    00115             }
    00116         //Memory selection (default)
    00117         case ECommonDialogsExCmd101:
    00118             {
    00119             CAknMemorySelectionDialog* dlg = CAknMemorySelectionDialog::NewL(
    00120                                                         ECFDDialogTypeNormal,
    00121                                                         ETrue );
    00122             CleanupStack::PushL( dlg );
    00123             returnValue = dlg->ExecuteL( iMemory );
    00124             if( returnValue )
    00125                 {
    00126                 textMain.Append( KCommonDialogsExSelected );
    00127                 if ( iMemory == CAknMemorySelectionSettingPage::EPhoneMemory )
    00128                     {
    00129                     textSub.Append( KCommonDialogsExPhoneMemoryName );
    00130                     }
    00131                 else
    00132                     {
    00133                     textSub.Append( KCommonDialogsExMemoryCardName );
    00134                     }
    00135                 }
    00136             else
    00137                 {
    00138                 textMain.Append( KCommonDialogsExCanceled );
    00139                 textSub.Append( KCommonDialogsExSpace );
    00140                 }
    00141             //set display text
    00142             iAppContainer->ShowTextL( textMain, textSub );
    00143             CleanupStack::PopAndDestroy();
    00144             break;
    00145             }
    00146
    00147         //Memory selection (Multi drive)
    00148         case ECommonDialogsExCmd102:
    00149             {
    00150             CAknMemorySelectionDialogMultiDrive* dlg =
    00151                 CAknMemorySelectionDialogMultiDrive::NewL(
    00152                         ECFDDialogTypeNormal, ETrue );
    00153             CleanupStack::PushL( dlg );
    00154             returnValue = dlg->ExecuteL( iDrive , &tempRootPath, NULL );
    00155
    00156             if( returnValue )
    00157                 {
    00158                 textMain.Append( KCommonDialogsExSelected );
    00159                 textSub.Append( KCommonDialogsExMultiDrive );
    00160                 textSub.Append( tempRootPath );
    00161                 }
    00162             else
    00163                 {
    00164                 textMain.Append( KCommonDialogsExCanceled );
    00165                 textSub.Append( KCommonDialogsExSpace );
    00166                 }
    00167
    00168             iAppContainer->ShowTextL( textMain, textSub );
    00169             CleanupStack::PopAndDestroy();
    00170
    00171             break;
    00172             }
    00173
    00174         //Memory setting (default)
    00175         case ECommonDialogsExCmd201:
    00176             {
    00177             CCommonDialogsExSettingsDialog* dlg =
    00178                           CCommonDialogsExSettingsDialog::NewL(0, EFalse);
    00179             dlg->ExecuteLD( R_COMMONDIALOGSEX_SETTINGS_DIALOG );
    00180             textMain.Append( KCommonDialogsExSelected );
    00181             textSub.Append( KCommonDialogsExDefaultSetting );
    00182             iAppContainer->ShowTextL( textMain, textSub );
    00183             break;
    00184             }
    00185
    00186         //Memory setting (Multi drive)
    00187         case ECommonDialogsExCmd202:
    00188             {
    00189             CCommonDialogsExSettingsDialog* dlg =
    00190                 CCommonDialogsExSettingsDialog::NewL(0, ETrue);
    00191             dlg->ExecuteLD( R_COMMONDIALOGSEX_SETTINGS_DIALOG );
    00192             textMain.Append( KCommonDialogsExSelected );
    00193             textSub.Append( KCommonDialogsExMultiSetting );
    00194             iAppContainer->ShowTextL( textMain, textSub );
    00195             break;
    00196             }
    00197
    00198         //File selection
    00199         case ECommonDialogsExCmd301:
    00200             {
    00201             CAknFileSelectionDialog* dlg =
    00202                        CAknFileSelectionDialog::NewL( ECFDDialogTypeSelect );
    00203             CleanupStack::PushL( dlg );
    00204             returnValue = dlg->ExecuteL( rootFileName );
    00205             if( returnValue )
    00206                 {
    00207                 textMain.Append( KCommonDialogsExSelected );
    00208                 textSub.Append( KCommonDialogsExFile );
    00209                 }
    00210             else
    00211                 {
    00212                 textMain.Append( KCommonDialogsExCanceled );
    00213                 textSub.Append( KCommonDialogsExSpace );
    00214                 }
    00215             iAppContainer->ShowTextL( textMain, textSub );
    00216             CleanupStack::PopAndDestroy();
    00217             break;
    00218             }
    00219
    00220         // Filename prompt
    00221         case ECommonDialogsExCmd401:
    00222             {
    00223             returnValue = CAknFileNamePromptDialog::RunDlgLD(
    00224                                   defaultFileName,
    00225                                   KRootPath );
    00226             if( returnValue )
    00227                 {
    00228                 textMain.Append( KCommonDialogsExSelected );
    00229                 textSub.Append( KCommonDialogsExFileName );
    00230                 }
    00231             else
    00232                 {
    00233                 textMain.Append( KCommonDialogsExCanceled );
    00234                 textSub.Append( KCommonDialogsExSpace );
    00235                 }
    00236             iAppContainer->ShowTextL( textMain, textSub );
    00237             break;
    00238             }
    00239
    00240         default:
    00241             {
    00242             break;
    00243             }
    00244         }
    00245     }

© Nokia 2007 |