Nokia N97 SDK
Example Applications Guide

CommonDialogsEx

1. About this Example
2. Architecture
3. Design and Implementation


1. About this Example

CommonDialogsEx example demonstrates the usage of Common Dialogs APIs. This example mainly demonstrates how to use normal and Multiple Drive CFD APIs. This example includes opening memory selection dialog, opening memory settings dialog, opening a file selection dialog,opening a file name prompt dialog.

1.1 APIs demonstrated

The CommonDialogsEx application mainly demonstrates the usage of the follow APIs:

The follow header files are included in the examples:

The CCommonDialogsExSettingsDialog class is inherited from the following classes:

The following functions have been implemented:

1.2 Prerequisites

This example requires a familiarity with the C++ programming language and S60 application structure.


2. Architecture

The CommonDialogsEx example application follows the standard S60 application framework. The application, document and view classes implement the framework and the actual example code is in the CCommonDialogsExAppUi class.

3. Design and Implementation

3.1 Capabilities

The CommonDialogsEx application needs ReadUserData and WriteUserData capabilities for creating, modifying and deleting contact(s).

3.2 Build and Installation

The CommonDialogsEx application has two .pkg files which will be used for making sis package for different target platforms. The whole project can be imported to codewarrior by mmp file. The project can be built inside codewarrior and also can be build on command line with the following commands.

 ..\group>bldmake bldfiles
 ..\group>abld build winscw udeb

3.3 Preparation

When the application is started, the CCommonDialogsExContainer class will be initialized by View class. Here are the steps done in CCommonDialogsExContainer's constructor.The labels are two components for display text;
   iLabel = new (ELeave) CEikLabel;
   iLabel->SetContainerWindowL( *this );
   iLabel->SetTextL( _L("Example View") );

   iToDoLabel = new (ELeave) CEikLabel;
   iToDoLabel->SetContainerWindowL( *this );
   iToDoLabel->SetTextL( _L("Press Options to start") );

Function ShowTextL(const TDesC& aText, const TDesC& aTextSub) Show text message on screen by using label

   iLabel->SetTextL(aText);
   iToDoLabel->SetTextL(aTextSub);

When the application is launched the CCommonDialogsExAppUi class is initialized by the AppUi class. Here are the steps done in the constructor.

 iAppContainer = new (ELeave) CCommonDialogsExContainer;
 iAppContainer->ConstructL( ClientRect() );

Class CCommonDialogsExSettingsDialog is inherited from class CEikDialog and MEikListBoxObserver. In this class you should implement function PreLayoutDynInitL() OkToExitL() ProcessCommandL() from CEikDialog, implement function HandleListBoxEventL() from MEikListBoxObserver.

Function PreLayoutDynInitL() Initializes the dialog's controls before the dialog is sized and layed out.

  CAknSettingStyleListBox* listBox =  static_cast< CAknSettingStyleListBox* >
                                                             ( Control( ECommonDialogsExSettingsListboxId ) );
   User::LeaveIfNull( listBox );

Create the memory selection item. If your current SDK support Multiple Drive APIs.

  if ( iMultiDriveSupport )
       {    
       settingItem = new( ELeave ) CAknMemorySelectionSettingItemMultiDrive(
                                            iResourceId, iDriveNumber );
       }
  else
       {
       settingItem = new( ELeave ) CAknMemorySelectionSettingItem(
                                           iResourceId, iMemory );
       }
   CleanupStack::PushL( settingItem );

Set memory selection item's title

   itemTitle = iCoeEnv->AllocReadResourceLC( R_STRING_COMMONDIALOGSEX_SET_MEMORY );
   settingItem->ConstructL( EFalse, 0, *itemTitle, NULL, 0,
                                                   EAknCtPopupSettingList );
   CleanupStack::PopAndDestroy();  // itemTitle

Add memo store item to the settings array

   iSettingItemArray.AppendL( settingItem );
   CleanupStack::Pop();    // settingItem

Set listBox.

   CTextListBoxModel* model = listBox->Model();
   model->SetItemTextArray( &iSettingItemArray );
   model->SetOwnershipType( ELbmDoesNotOwnItemArray );
   iSettingItemArray.RecalculateVisibleIndicesL();
   listBox->CreateScrollBarFrameL( ETrue );
   listBox->ScrollBarFrame()->SetScrollBarVisibilityL(
                       CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
   listBox->HandleItemAdditionL();
   listBox->SetListBoxObserver( this );
   listBox->UpdateScrollBarsL();

3.5 Execution

There are total 6 cases for this example: opening memory selection dialog, opening Multiple Drive memory selection dialog ,opening memory settings dialog, opening Multiple Drive memory settings dialog, opening file selection dialog, opening file name prompt dialog

a) Creating memory selection dialogs with case ECommonDialogsExCmd101

           CAknMemorySelectionDialog* dlg = CAknMemorySelectionDialog::NewL( 
                                                       ECFDDialogTypeNormal, 
                                                       ETrue );
           CleanupStack::PushL( dlg );
           returnValue = dlg->ExecuteL( iMemory );

Then set the display text.

           if( returnValue )
               {
               textMain.Append( KCommonDialogsExSelected );
               if ( iMemory == CAknMemorySelectionSettingPage::EPhoneMemory )
                   {
                   textSub.Append( KCommonDialogsExPhoneMemoryName );
                   }
               else
                   {
                   textSub.Append( KCommonDialogsExMemoryCardName );
                   }
               }
           else
               {
               textMain.Append( KCommonDialogsExCanceled );
               textSub.Append( KCommonDialogsExSpace );
               }
           iAppContainer->ShowTextL( textMain, textSub );
           CleanupStack::PopAndDestroy(); //dlg

b) Creating Multiple Drive memory selection dialogs with case ECommonDialogsExCmd102

If your current SDK support Multiple Drive APIs, the dialog will display.

           CAknMemorySelectionDialogMultiDrive* dlg =
               CAknMemorySelectionDialogMultiDrive::NewL(
                       ECFDDialogTypeNormal, ETrue );
           CleanupStack::PushL( dlg );
           returnValue = dlg->ExecuteL( iDrive , &tempRootPath, NULL );
           ......
           CleanupStack::PopAndDestroy();

c) Creating memory settings dialog with case ECommonDialogsExCmd201

           CCommonDialogsExSettingsDialog* dlg = 
                         CCommonDialogsExSettingsDialog::NewL(0, EFalse);
           dlg->ExecuteLD( R_COMMONDIALOGSEX_SETTINGS_DIALOG );
           textMain.Append( KCommonDialogsExSelected );
           textSub.Append( KCommonDialogsExDefaultSetting );
           iAppContainer->ShowTextL( textMain, textSub );

d) Creating Multiple Drive memory settings dialog with case ECommonDialogsExCmd202

            CCommonDialogsExSettingsDialog* dlg =
                CCommonDialogsExSettingsDialog::NewL(0, ETrue);
            dlg->ExecuteLD( R_COMMONDIALOGSEX_SETTINGS_DIALOG );
            textMain.Append( KCommonDialogsExSelected );
            textSub.Append( KCommonDialogsExMultiSetting );
            iAppContainer->ShowTextL( textMain, textSub );

e) Creating file selection dialog with case ECommonDialogsExCmd301

           CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL( ECFDDialogTypeSelect );
           CleanupStack::PushL( dlg );
           returnValue = dlg->ExecuteL( rootFileName );
           ......
           iAppContainer->ShowTextL( textMain, textSub );
           CleanupStack::PopAndDestroy();

f) Creating file name prompt dialog with case ECommonDialogsExCmd401

           returnValue = CAknFileNamePromptDialog::RunDlgLD( 
                                 defaultFileName, 
                                 KRootPath );
           ......
           iAppContainer->ShowTextL( textMain, textSub );



© Nokia 2009

Back to top