|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : aknexpopfieldattribsetdialog.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 <aknutils.h> // for Font Change 00019 #include <avkon.hrh> 00020 #include <avkon.rsg> 00021 #include <aknpopupfield.h> 00022 #include <aknqueryvaluetext.h> 00023 #include <AknExPopField.rsg> 00024 00025 #include "AknExPopField.hrh" 00026 #include "AknExPopFieldAttribSetDialog.h" 00027 00028 00029 // ================= MEMBER FUNCTIONS ========================================= 00030 00031 // ---------------------------------------------------------------------------- 00032 // CAknExPopFieldAttribSetDialog::CAknExPopFieldAttribSetDialog() 00033 // C++ default constructor can NOT contain any code, that might leave. 00034 // ---------------------------------------------------------------------------- 00035 // 00036 CAknExPopFieldAttribSetDialog::CAknExPopFieldAttribSetDialog() 00037 { 00038 for ( TInt index( KAknExPopFieldAttribSetIndexInitialize ); 00039 index < KAknExPopFieldAttribSetControlCount; ++index ) 00040 { 00041 iTextValues[ index ] = NULL; 00042 iTextEmptyArray[ index ] = NULL; 00043 iValueTextArrayWithNoElements[ index ] = NULL; 00044 } 00045 } 00046 00047 // ---------------------------------------------------------------------------- 00048 // CAknExPopFieldAttribSetDialog* CAknExPopFieldAttribSetDialog::NewLC() 00049 // Two-phased constructor. 00050 // ---------------------------------------------------------------------------- 00051 // 00052 CAknExPopFieldAttribSetDialog* CAknExPopFieldAttribSetDialog::NewLC() 00053 { 00054 CAknExPopFieldAttribSetDialog* self = 00055 new ( ELeave ) CAknExPopFieldAttribSetDialog; 00056 CleanupStack::PushL( self ); 00057 self->ConstructL(); 00058 return self; 00059 } 00060 00061 // ---------------------------------------------------------------------------- 00062 // CAknExPopFieldAttribSetDialog::~CAknExPopFieldAttribSetDialog() 00063 // Destructor. 00064 // ---------------------------------------------------------------------------- 00065 // 00066 CAknExPopFieldAttribSetDialog::~CAknExPopFieldAttribSetDialog() 00067 { 00068 DiscardTextArray(); 00069 } 00070 00071 00072 // ---------------------------------------------------------------------------- 00073 // CAknExPopFieldAttribSetDialog::DiscardTextArray() 00074 // Discard text array in popup field object. 00075 // ---------------------------------------------------------------------------- 00076 // 00077 void CAknExPopFieldAttribSetDialog::DiscardTextArray() 00078 { 00079 for ( TInt index( KAknExPopFieldAttribSetIndexInitialize ); 00080 index < KAknExPopFieldAttribSetControlCount; ++index ) 00081 { 00082 if ( iTextValues[index] ) 00083 { 00084 delete iTextValues[ index ]; 00085 iTextValues[ index ] = NULL; 00086 } 00087 if ( iValueTextArrayWithNoElements[ index ] ) 00088 { 00089 delete iValueTextArrayWithNoElements[ index ]; 00090 iValueTextArrayWithNoElements[ index ] = NULL; 00091 } 00092 if ( iTextEmptyArray[ index ] ) 00093 { 00094 delete iTextEmptyArray[ index ]; 00095 iTextEmptyArray[ index ] = NULL; 00096 } 00097 } // for 00098 } 00099 00100 // ---------------------------------------------------------------------------- 00101 // CAknExPopFieldAttribSetDialog::SetIsSaveMenu() 00102 // Set flag to indicate if we are in the save menu. 00103 // ---------------------------------------------------------------------------- 00104 // 00105 void CAknExPopFieldAttribSetDialog::SetIsSaveMenu( TBool aVal ) 00106 { 00107 iIsSaveMenuFlag = aVal; 00108 } 00109 00110 // ---------------------------------------------------------------------------- 00111 // CAknExPopFieldAttribSetDialog::IsSaveMenu() 00112 // Check if we are in the save menu. 00113 // ---------------------------------------------------------------------------- 00114 // 00115 TBool CAknExPopFieldAttribSetDialog::IsSaveMenu() 00116 { 00117 return iIsSaveMenuFlag; 00118 } 00119 00120 // ---------------------------------------------------------------------------- 00121 // CAknExPopFieldAttribSetDialog::DynInitMenuPaneL() 00122 // Add menu item to menupane. 00123 // ---------------------------------------------------------------------------- 00124 // 00125 void CAknExPopFieldAttribSetDialog::DynInitMenuPaneL( TInt aResourceId, 00126 CEikMenuPane* aMenuPane ) 00127 { 00128 00129 CAknExPopFieldBaseDialog::DynInitMenuPaneL( aResourceId, aMenuPane ); 00130 if ( aResourceId == R_AVKON_FORM_MENUPANE && IsSaveMenu() ) 00131 { 00132 aMenuPane->AddMenuItemsL( R_AKNEXPOPFIELD_EXTRA_MENU, 00133 EAknFormCmdSave, ETrue ); 00134 } 00135 } 00136 00137 // ---------------------------------------------------------------------------- 00138 // CAknExPopFieldAttribSetDialog::ProcessCommandL() 00139 // Overridden to supply a location for calls to PopupField APIs. 00140 // ---------------------------------------------------------------------------- 00141 // 00142 void CAknExPopFieldAttribSetDialog::ProcessCommandL( TInt aCommandId ) 00143 { 00144 switch ( aCommandId ) 00145 { 00146 case EAknExPopFieldCmdEditEntry: 00147 { 00148 TInt ctrlId = IdOfFocusControl(); 00149 // Don't call ActiveSelectionList on an empty list, 00150 // or panic incurred! 00151 if( ctrlId == EAknExPopFieldDlgCtrlIdAttribSet02 ) 00152 { 00153 CAknPopupField* popup; 00154 popup = static_cast<CAknPopupField*> (ControlOrNull( ctrlId ) ); 00155 if ( popup ) 00156 { 00157 popup->ActivateSelectionListL(); 00158 } 00159 } 00160 break; 00161 } 00162 case EAknFormCmdEdit: 00163 { 00164 SetIsSaveMenu( ETrue ); 00165 break; 00166 } 00167 case EAknFormCmdSave: 00168 { 00169 SetIsSaveMenu( EFalse ); 00170 break; 00171 } 00172 } 00173 CAknExPopFieldBaseDialog::ProcessCommandL( aCommandId ); 00174 } 00175 00176 // ---------------------------------------------------------------------------- 00177 // CAknExPopFieldAttribSetDialog::OkToExitL() 00178 // From CAknDialog, OkToExitL. 00179 // ---------------------------------------------------------------------------- 00180 // 00181 TBool CAknExPopFieldAttribSetDialog::OkToExitL( TInt aButtonId ) 00182 { 00183 if ( aButtonId == EAknSoftkeyBack && IsSaveMenu() ) 00184 { 00185 SetIsSaveMenu( EFalse ); 00186 } 00187 return CAknExPopFieldBaseDialog::OkToExitL( aButtonId ); 00188 } 00189 00190 // ---------------------------------------------------------------------------- 00191 // CAknExPopFieldAttribSetDialog::ConfigurePopfieldValueL() 00192 // Configuration values (text) into Popup Fields and call CAknPopupField APIs 00193 // ---------------------------------------------------------------------------- 00194 // 00195 void CAknExPopFieldAttribSetDialog::ConfigurePopfieldValueL() 00196 { 00197 // Discard textarray. 00198 DiscardTextArray(); 00199 00200 // Control container. 00201 CAknPopupField* popup[ KAknExPopFieldAttribSetControlCount ]; 00202 00203 for ( TInt index( KAknExPopFieldAttribSetIndexInitialize ) ; 00204 index < KAknExPopFieldAttribSetControlCount; ++index ) 00205 { 00206 // Get PopFieldAttribSet controls. 00207 00208 popup[ index ] = static_cast<CAknPopupField*> 00209 (ControlOrNull( EAknExPopFieldDlgCtrlIdAttribSet01 + index ) ); 00210 00211 __ASSERT_ALWAYS( popup[ index ]!=NULL, User::Leave( KErrNotFound ) ); 00212 00213 // Fill the arrays with empty array instances. 00214 iTextEmptyArray[index] = new ( ELeave ) CDesCArrayFlat( 00215 KAknExPopFieldGranularityForEmptyArray ); // Granularity of 16 00216 00217 // Set iValueTextValueArray with the empty arrays. 00218 iValueTextArrayWithNoElements[ index ] = 00219 CAknQueryValueTextArray::NewL(); 00220 iValueTextArrayWithNoElements[ index ]-> 00221 SetArray( *iTextEmptyArray[index] ); 00222 00223 // Set the same textarray into all the values, and initial value index, and 00224 // make calls onto the CAknPopfield APIs 00225 iTextValues[ index ] = CAknQueryValueText::NewL(); 00226 iTextValues[ index ]-> 00227 SetArrayL( iValueTextArrayWithNoElements[ index ] ); 00228 iTextValues[ index ]->SetQueryCaption( R_AKNEXPOPFIELD_QUERY_PROMPT ); 00229 00230 // Set values into popup fields. 00231 popup[ index ]->SetQueryValueL( iTextValues[ index ] ); 00232 popup[ index ]->SetFont( LatinPlain12() ); 00233 popup[ index ]->SetMaxNumberOfLinesPermitted( 00234 KAknExPopFieldMaxNumberLines ); 00235 00236 if ( !index ) // Call APIs specific to the control. 00237 { 00238 popup[ index ]-> 00239 SetEmptyListNoteL( R_AKNEXPOPFIELD_EMPTY_LIST_NOTE ); 00240 TBuf16<KAknExPopFieldReplacementTextBufLength> replacementString01; 00241 iEikonEnv->ReadResource( replacementString01, 00242 R_AKNEXPOPFIELD_EMPTY_TEXT_RAPLACEMENT ); 00243 popup[ index ]->SetEmptyTextL( replacementString01 ); 00244 } 00245 else 00246 { 00247 popup[ index ]->SetAllowsUserDefinedEntry( ETrue ); 00248 00249 // Set the Other text replacement in attribset02 00250 TBuf16<KAknExPopFieldReplacementTextBufLength> replacementString02; 00251 iEikonEnv->ReadResource( replacementString02, 00252 R_AKNEXPOPFIELD_OTHER_TEXT_RAPLACEMENT ); 00253 popup[ index ]->SetOtherTextL( replacementString02 ); 00254 00255 // Set the Empty text replacement in attribset02 00256 TBuf16<KAknExPopFieldReplacementTextBufLength> replacementString03; 00257 iEikonEnv->ReadResource( replacementString03, 00258 R_AKNEXPOPFIELD_EMPTY_TEXT_RAPLACEMENT ); 00259 popup[ index ]->SetEmptyTextL( replacementString03 ); 00260 } 00261 } // for 00262 } 00263 00264 // ---------------------------------------------------------------------------- 00265 // CAknExPopFieldAttribSetDialog::SaveFormDataL() 00266 // Save form data. 00267 // ---------------------------------------------------------------------------- 00268 // 00269 TBool CAknExPopFieldAttribSetDialog::SaveFormDataL() 00270 { 00271 for ( TInt i = KAknExPopFieldAttribSetIndexInitialize; 00272 i < KAknExPopFieldAttribSetControlCount; i++ ) 00273 { 00274 if ( ControlOrNull( EAknExPopFieldDlgCtrlIdPop01+i ) ) 00275 { 00276 iIndexValue[ i ] = iTextValues[ i ]->CurrentValueIndex(); 00277 } 00278 } 00279 00280 return ETrue; 00281 } 00282 00283 // ---------------------------------------------------------------------------- 00284 // CAknExPopFieldAttribSetDialog::DoNotSaveFormDataL() 00285 // Does not save form data. 00286 // ---------------------------------------------------------------------------- 00287 // 00288 void CAknExPopFieldAttribSetDialog::DoNotSaveFormDataL() 00289 { 00290 for ( TInt i = KAknExPopFieldAttribSetIndexInitialize; 00291 i < KAknExPopFieldAttribSetControlCount; i++ ) 00292 { 00293 if ( ControlOrNull( EAknExPopFieldDlgCtrlIdPop01+i ) ) 00294 { 00295 iTextValues[ i ]->SetCurrentValueIndex( iIndexValue[ i ] ); 00296 } 00297 } 00298 } 00299 00300 // End of File
|
© Nokia 2009 |