S60 3rd Edition SDK FP2 for Symbian OS CommonDialogsEx |
00001 /* 00002 * ============================================================================ 00003 * Name : commondialogsexsettingsdialog.cpp 00004 * Part of : CommonDialogsEx 00005 * Description : For settings dialog. 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 00015 #include <AknLists.h> 00016 #include <CAknMemorySelectionSettingItem.h> 00017 #include <CAknMemorySelectionSettingItemMultiDrive.h> 00018 #include <CommonDialogsEx.rsg> 00019 00020 #include "CommonDialogsEx.hrh" 00021 #include "CommonDialogsExSettingsDialog.h" 00022 00023 00024 CCommonDialogsExSettingsDialog::~CCommonDialogsExSettingsDialog() 00025 { 00026 iSettingItemArray.ResetAndDestroy(); 00027 } 00028 00029 CCommonDialogsExSettingsDialog* CCommonDialogsExSettingsDialog::NewL(TInt aResId, TBool aMultiDriveSupport) 00030 { 00031 CCommonDialogsExSettingsDialog* self = new( ELeave ) CCommonDialogsExSettingsDialog; 00032 CleanupStack::PushL( self ); 00033 self->iResourceId = aResId; 00034 self->iMultiDriveSupport = aMultiDriveSupport; 00035 CleanupStack::Pop(); 00036 return self; 00037 } 00038 00039 TBool CCommonDialogsExSettingsDialog::OkToExitL( TInt aButtonId ) 00040 { 00041 if ( aButtonId == EAknSoftkeySelect ) 00042 { 00043 ProcessCommandL( aButtonId ); 00044 return EFalse; 00045 } 00046 return ETrue; 00047 } 00048 00049 void CCommonDialogsExSettingsDialog::PreLayoutDynInitL() 00050 { 00051 iMemory = CAknMemorySelectionSettingPage::EPhoneMemory; 00052 iDriveNumber = EDriveC; 00053 00054 CAknSettingStyleListBox* listBox = 00055 static_cast< CAknSettingStyleListBox* > 00056 ( Control( ECommonDialogsExSettingsListboxId ) ); 00057 User::LeaveIfNull( listBox ); 00058 00059 CAknSettingItem* settingItem; 00060 HBufC* itemTitle; 00061 00062 // Create the memory selection item 00063 if ( iMultiDriveSupport ) 00064 { 00065 settingItem = 00066 new( ELeave ) CAknMemorySelectionSettingItemMultiDrive( 00067 iResourceId, iDriveNumber ); 00068 } 00069 else 00070 { 00071 settingItem = 00072 new( ELeave ) CAknMemorySelectionSettingItem( 00073 iResourceId, iMemory ); 00074 } 00075 CleanupStack::PushL( settingItem ); 00076 00077 // Set memory selection item's title 00078 itemTitle = iCoeEnv->AllocReadResourceLC( R_STRING_COMMONDIALOGSEX_SET_MEMORY ); 00079 settingItem->ConstructL( EFalse, 0, *itemTitle, NULL, 0, 00080 EAknCtPopupSettingList ); 00081 CleanupStack::PopAndDestroy(); // itemTitle 00082 00083 // Add memo store item to the settings array 00084 iSettingItemArray.AppendL( settingItem ); 00085 CleanupStack::Pop(); // settingItem 00086 00087 CTextListBoxModel* model = listBox->Model(); 00088 model->SetItemTextArray( &iSettingItemArray ); 00089 // Ownership retained by us 00090 model->SetOwnershipType( ELbmDoesNotOwnItemArray ); 00091 00092 iSettingItemArray.RecalculateVisibleIndicesL(); 00093 listBox->CreateScrollBarFrameL( ETrue ); 00094 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( 00095 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); 00096 listBox->HandleItemAdditionL(); 00097 listBox->SetListBoxObserver( this ); 00098 listBox->UpdateScrollBarsL(); 00099 } 00100 00101 void CCommonDialogsExSettingsDialog::HandleListBoxEventL( CEikListBox* aListBox, 00102 TListBoxEvent aEventType ) 00103 { 00104 TInt index( aListBox->CurrentItemIndex() ); 00105 if ( index >=0 ) // index is -1 if there are no items in the list 00106 { 00107 iSettingItemArray.At( index )->EditItemL( 00108 aEventType == EEventEditingStarted ); 00109 aListBox->DrawItem( index ); 00110 } 00111 } 00112 00113 void CCommonDialogsExSettingsDialog::ProcessCommandL( TInt aCommandId ) 00114 { 00115 switch ( aCommandId ) 00116 { 00117 case EAknSoftkeySelect: 00118 { 00119 CEikListBox* listBox = static_cast< CEikListBox* > 00120 ( Control( ECommonDialogsExSettingsListboxId ) ); 00121 HandleListBoxEventL( listBox, EEventEditingStarted ); 00122 break; 00123 } 00124 default: 00125 { 00126 CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId ); 00127 break; 00128 } 00129 } 00130 }
© Nokia 2007 |