Nokia N97 SDK
Example Applications Guide

aknexpopfieldmanylinedialog.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : aknexpopfieldmanylinedialog.cpp
00004 *  Part of     : Popup-field example
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2004 - 2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include <eikenv.h>
00018 #include <aknpopupfield.h>
00019 #include <aknqueryvaluetext.h>
00020 #include <AknExPopField.rsg>
00021 
00022 #include "AknExPopField.hrh"
00023 #include "AknExPopFieldManyLineDialog.h"
00024 
00025 
00026 // ================= MEMBER FUNCTIONS =========================================
00027 
00028 // ----------------------------------------------------------------------------
00029 // CAknExPopFieldManyLineDialog* CAknExPopFieldManyLineDialog::NewLC()
00030 // Two-phased constructor.
00031 // ----------------------------------------------------------------------------
00032 //
00033 CAknExPopFieldManyLineDialog* CAknExPopFieldManyLineDialog::NewLC()
00034     {
00035     CAknExPopFieldManyLineDialog* self =
00036         new ( ELeave ) CAknExPopFieldManyLineDialog;
00037     CleanupStack::PushL( self );
00038     self->ConstructL();
00039     return self;
00040     }
00041 
00042 // ----------------------------------------------------------------------------
00043 // CAknExPopFieldManyLineDialog::~CAknExPopFieldManyLineDialog()
00044 // Destructor.
00045 // ----------------------------------------------------------------------------
00046 //
00047 CAknExPopFieldManyLineDialog::~CAknExPopFieldManyLineDialog()
00048     {
00049     DiscardTextArray();
00050     }
00051 
00052 // ----------------------------------------------------------------------------
00053 // CAknExPopFieldManyLineDialog::CAknExPopFieldManyLineDialog()
00054 // C++ default constructor can NOT contain any code, that might leave.
00055 // ----------------------------------------------------------------------------
00056 //
00057 CAknExPopFieldManyLineDialog::CAknExPopFieldManyLineDialog():  
00058                               iTextArray( NULL ),
00059                               iValueTextArray( NULL )
00060     {
00061 
00062     TInt index( KAknExPopFieldMLIndexInitialize );
00063     for ( index = KAknExPopFieldMLIndexInitialize;
00064           index < KAknExPopFieldMaxMLTextValueField; index++ )
00065         {
00066         iTextValues[ index ] = NULL;
00067         }
00068     }
00069 
00070 // ----------------------------------------------------------------------------
00071 // CAknExPopFieldManyLineDialog::DiscardTextArray()
00072 // Discard text array in popup field object.
00073 // ----------------------------------------------------------------------------
00074 //
00075 void CAknExPopFieldManyLineDialog::DiscardTextArray()
00076     {
00077     TInt index( KAknExPopFieldMLIndexInitialize );
00078     for ( index = KAknExPopFieldMLIndexInitialize;
00079           index < KAknExPopFieldMaxMLTextValueField; index++ )
00080         {
00081         if ( iTextValues[ index ] )
00082             {
00083             delete iTextValues[ index ];
00084             iTextValues[ index ] = NULL;
00085             }
00086         }
00087 
00088     if ( iValueTextArray )
00089         {
00090         delete iValueTextArray;
00091         iValueTextArray = NULL;
00092         }
00093 
00094     if ( iTextArray )
00095         {
00096         delete iTextArray;
00097         iTextArray = NULL;
00098         }
00099     }
00100 
00101 // ----------------------------------------------------------------------------
00102 // CAknExPopFieldManyLineDialog::ConfigurePopfieldValueL()
00103 // Configuration values (text) into Popup Fields.
00104 // ----------------------------------------------------------------------------
00105 //
00106 void CAknExPopFieldManyLineDialog::ConfigurePopfieldValueL()
00107     {
00108     // Discard textarray.
00109     DiscardTextArray();
00110 
00111     // Calculate number of pop-up field.
00112     TInt index( KAknExPopFieldMLIndexInitialize );
00113     TInt count( KAknExPopFieldMLCountInitialize );
00114     TInt controlId( KAknExPopFieldMLControlIdInitialize );
00115     CAknPopupField* popup[ KAknExPopFieldMaxMLTextValueField ];
00116     for ( index = KAknExPopFieldMLIndexInitialize;
00117           index < KAknExPopFieldMaxMLTextValueField; index++ )
00118         {
00119         popup[ index ] = NULL;
00120         controlId = EAknExPopFieldDlgCtrlIdPop01 + index;
00121         CCoeControl* control = ControlOrNull( controlId );
00122         if ( control )
00123             {
00124             popup[ count ] = static_cast<CAknPopupField*> ( control );
00125             count++;
00126             }
00127         }
00128 
00129     // Create textarray.
00130     iTextArray = iCoeEnv->ReadDesCArrayResourceL(
00131                             R_AKNEXPOPFIELD_TWELVE_TEXT_ARRAY );
00132 
00133     iValueTextArray = CAknQueryValueTextArray::NewL();
00134     iValueTextArray->SetArray( *iTextArray );
00135 
00136     // Set the same textarray into all the values, and initial value index.
00137     for ( index = KAknExPopFieldMLIndexInitialize; index < count; index++ )
00138         {
00139         iTextValues[ index ] = CAknQueryValueText::NewL();
00140         iTextValues[ index ]->SetArrayL( iValueTextArray );
00141         iTextValues[ index ]->SetCurrentValueIndex( NULL );
00142         iTextValues[ index ]->SetQueryCaption( R_AKNEXPOPFIELD_QUERY_PROMPT );
00143         }
00144 
00145     // Set values into popup fields.
00146     for ( index = KAknExPopFieldMLIndexInitialize; index < count; index++ )
00147         {
00148         popup[ index ]->SetQueryValueL( iTextValues[ index ] );
00149         }
00150     }
00151 
00152 // ----------------------------------------------------------------------------
00153 // CAknExPopFieldManyLineDialog::SaveFormDataL()
00154 // Save form data.
00155 // ----------------------------------------------------------------------------
00156 //
00157 TBool CAknExPopFieldManyLineDialog::SaveFormDataL()
00158     {
00159     for ( TInt i = KAknExPopFieldMLIndexInitialize;
00160               i < KAknExPopFieldMaxMLTextValueField; i++ )
00161         {
00162         if ( ControlOrNull( EAknExPopFieldDlgCtrlIdPop01+i ) )
00163             {
00164             iIndexValue[ i ] = iTextValues[ i ]->CurrentValueIndex();
00165             }
00166         }
00167 
00168     return ETrue;
00169     }
00170 
00171 // ----------------------------------------------------------------------------
00172 // CAknExPopFieldManyLineDialog::DoNotSaveFormDataL()
00173 // Does not save form data.
00174 // ----------------------------------------------------------------------------
00175 //
00176 void CAknExPopFieldManyLineDialog::DoNotSaveFormDataL()
00177     {
00178     for ( TInt i = KAknExPopFieldMLIndexInitialize;
00179               i < KAknExPopFieldMaxMLTextValueField; i++ )
00180         {
00181         if ( ControlOrNull( EAknExPopFieldDlgCtrlIdPop01+i ) )
00182             {
00183             iTextValues[ i ]->SetCurrentValueIndex( iIndexValue[ i ] );
00184             }
00185         }
00186     }
00187 
00188 // End of File

© Nokia 2009

Back to top