|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "akncompagscontainer.h" |
|
20 #include "akncompagsmodel.h" |
|
21 #include "akncompags.hrh" |
|
22 |
|
23 #include <bldvariant.hrh> |
|
24 #include <akncompagsrsc.rsg> |
|
25 #include <aknlists.h> |
|
26 #include <StringLoader.h> |
|
27 #include <AknUtils.h> |
|
28 #include <cshelp/conset.hlp.hrh> |
|
29 #include <gsfwviewuids.h> |
|
30 #include <gslistbox.h> |
|
31 |
|
32 // -------------------------------------------------------------------------- |
|
33 // |
|
34 // -------------------------------------------------------------------------- |
|
35 void CAknCompaGSContainer::ConstructL( const TRect& aRect ) |
|
36 { |
|
37 iListBox = new( ELeave ) CAknSettingStyleListBox; |
|
38 |
|
39 BaseConstructL( aRect, R_AKNCOMPAGS_VIEW_TITLE, R_AKNCOMPAGS_LBX ); |
|
40 } |
|
41 |
|
42 |
|
43 // -------------------------------------------------------------------------- |
|
44 // |
|
45 // -------------------------------------------------------------------------- |
|
46 CAknCompaGSContainer::~CAknCompaGSContainer() |
|
47 { |
|
48 delete iListboxItemArray; |
|
49 delete iCompaModeStateItems; |
|
50 } |
|
51 |
|
52 // -------------------------------------------------------------------------- |
|
53 // Construct a list box |
|
54 // -------------------------------------------------------------------------- |
|
55 void CAknCompaGSContainer::ConstructListBoxL( TInt aResLbxId ) |
|
56 { |
|
57 iListBox->ConstructL( this, EAknListBoxSelectionList ); |
|
58 |
|
59 iListboxItemArray = CGSListBoxItemTextArray::NewL( aResLbxId, |
|
60 *iListBox, *iCoeEnv ); |
|
61 iListBox->Model()->SetItemTextArray( iListboxItemArray ); |
|
62 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
63 |
|
64 iCompaModeStateItems = iCoeEnv->ReadDesC16ArrayResourceL( |
|
65 R_AKNCOMPAGS_STATE_SETTING_PAGE_LBX ); |
|
66 |
|
67 CreateListBoxItemsL(); |
|
68 } |
|
69 |
|
70 // -------------------------------------------------------------------------- |
|
71 // Create list box items |
|
72 // -------------------------------------------------------------------------- |
|
73 void CAknCompaGSContainer::CreateListBoxItemsL() |
|
74 { |
|
75 MakeCompaModeStateItemL(); |
|
76 CAknCompaGSModel* model = CAknCompaGSModel::NewL(); |
|
77 CleanupStack::PushL(model); |
|
78 UpdateCompaModeStateItemL(model->CompaAppState()); |
|
79 CleanupStack::PopAndDestroy( model ); |
|
80 } |
|
81 |
|
82 |
|
83 // -------------------------------------------------------------------------- |
|
84 // Update list box item |
|
85 // -------------------------------------------------------------------------- |
|
86 void CAknCompaGSContainer::UpdateListBoxL( TInt aFeatureId, |
|
87 TInt aValue ) |
|
88 { |
|
89 switch( aFeatureId ) |
|
90 { |
|
91 case KCompaGSIdState: |
|
92 UpdateCompaModeStateItemL(aValue); |
|
93 break; |
|
94 default: |
|
95 break; |
|
96 } |
|
97 |
|
98 iListBox->HandleItemAdditionL(); |
|
99 } |
|
100 |
|
101 // -------------------------------------------------------------------------- |
|
102 // Make compa-mode setting visible |
|
103 // -------------------------------------------------------------------------- |
|
104 void CAknCompaGSContainer::MakeCompaModeStateItemL() |
|
105 { |
|
106 iListboxItemArray->SetItemVisibilityL( KCompaGSIdState, |
|
107 CGSListBoxItemTextArray::EVisible ); |
|
108 } |
|
109 |
|
110 // -------------------------------------------------------------------------- |
|
111 // Update compa-mode setting item on display |
|
112 // -------------------------------------------------------------------------- |
|
113 void CAknCompaGSContainer::UpdateCompaModeStateItemL(const TInt& aState) |
|
114 { |
|
115 HBufC* dynamicText = HBufC::NewLC( KGSBufSize128 ); |
|
116 TPtr ptrBuffer ( dynamicText->Des() ); |
|
117 |
|
118 ptrBuffer = ( *iCompaModeStateItems )[ aState ]; |
|
119 |
|
120 iListboxItemArray->SetDynamicTextL( KCompaGSIdState, ptrBuffer ); |
|
121 CleanupStack::PopAndDestroy( dynamicText ); |
|
122 |
|
123 iListboxItemArray->SetItemVisibilityL( KCompaGSIdState, |
|
124 CGSListBoxItemTextArray::EVisible ); |
|
125 } |
|
126 |
|
127 // -------------------------------------------------------------------------- |
|
128 // Return currently selected listbox feature id |
|
129 // -------------------------------------------------------------------------- |
|
130 TInt CAknCompaGSContainer::CurrentFeatureId( ) const |
|
131 { |
|
132 return iListboxItemArray->CurrentFeature( ); |
|
133 } |