1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * Base container for GS some views. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <gsbasecontainer.h> |
|
22 |
|
23 #include <akncontext.h> |
|
24 #include <aknlists.h> |
|
25 #include <aknnavi.h> |
|
26 #include <akntitle.h> |
|
27 #include <AknUtils.h> |
|
28 #include <avkon.hrh> |
|
29 #include <avkon.mbg> |
|
30 #include <avkon.rsg> |
|
31 #include <barsread.h> |
|
32 #include <calslbs.h> |
|
33 #include <e32def.h> |
|
34 #include <eikbtgpc.h> |
|
35 #include <eikclbd.h> |
|
36 #include <eikenv.h> |
|
37 #include <eikfrlbd.h> |
|
38 #include <eiklbx.h> |
|
39 #include <eikslb.h> |
|
40 #include <gulicon.h> |
|
41 |
|
42 // ================= MEMBER FUNCTIONS ======================= |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CGSBaseContainer::BaseConstructL |
|
46 // |
|
47 // |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 EXPORT_C void CGSBaseContainer::BaseConstructL( const TRect& aRect, |
|
51 TInt aResTitleId, |
|
52 TInt aResLbxId ) |
|
53 { |
|
54 CEikStatusPane* sp = iAvkonAppUi->StatusPane(); |
|
55 |
|
56 CAknTitlePane* title = |
|
57 static_cast<CAknTitlePane*> ( |
|
58 sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
59 |
|
60 TResourceReader rReader; |
|
61 iCoeEnv->CreateResourceReaderLC( rReader, aResTitleId ); |
|
62 title->SetFromResourceL( rReader ); |
|
63 CleanupStack::PopAndDestroy(); // rReader |
|
64 |
|
65 |
|
66 CreateWindowL(); // Makes the control a window-owning control |
|
67 |
|
68 // Set iListBox to be contained in this container: |
|
69 iListBox->SetContainerWindowL( *this ); |
|
70 |
|
71 ConstructListBoxL( aResLbxId ); |
|
72 |
|
73 iListBox->CreateScrollBarFrameL( ETrue ); |
|
74 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
75 CEikScrollBarFrame::EOff, |
|
76 CEikScrollBarFrame::EAuto ); |
|
77 |
|
78 SetRect( aRect ); |
|
79 ActivateL(); |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CGSBaseContainer::CGSBaseContainer |
|
85 // Constructor |
|
86 // |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 EXPORT_C CGSBaseContainer::CGSBaseContainer() |
|
90 { |
|
91 iElaf = ( AknLayoutUtils::Variant() == EEuropeanVariant ); |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CGSBaseContainer::~CGSBaseContainer |
|
97 // Destructor |
|
98 // |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C CGSBaseContainer::~CGSBaseContainer() |
|
102 { |
|
103 if ( iListBox ) |
|
104 { |
|
105 delete iListBox; |
|
106 } |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CGSBaseContainer::ConstructListBoxL |
|
112 // |
|
113 // Construct's ListBox from Resource ID |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 void CGSBaseContainer::ConstructListBoxL( TInt aResLbxId ) |
|
117 { |
|
118 TResourceReader rReader; |
|
119 iCoeEnv->CreateResourceReaderLC( rReader, aResLbxId ); |
|
120 |
|
121 // Construct's iListBox from resource file |
|
122 iListBox->ConstructFromResourceL( rReader ); |
|
123 CleanupStack::PopAndDestroy(); // rReader |
|
124 } |
|
125 |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // CGSBaseContainer::SizeChanged |
|
129 // called by framwork when the view size is changed |
|
130 // |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 EXPORT_C void CGSBaseContainer::SizeChanged() |
|
134 { |
|
135 if ( iListBox ) |
|
136 { |
|
137 iListBox->SetRect( Rect() ); |
|
138 } |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CGSBaseContainer::CountComponentControls |
|
144 // |
|
145 // |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 EXPORT_C TInt CGSBaseContainer::CountComponentControls() const |
|
149 { |
|
150 return 1; |
|
151 } |
|
152 |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CGSBaseContainer::ComponentControl |
|
156 // |
|
157 // |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C CCoeControl* CGSBaseContainer::ComponentControl( TInt /*aIndex*/ ) |
|
161 const |
|
162 { |
|
163 return iListBox; |
|
164 } |
|
165 |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CGSMainContainer::TKeyResponse OfferKeyEventL |
|
169 // Called when a key is pressed. |
|
170 // |
|
171 // --------------------------------------------------------------------------- |
|
172 |
|
173 EXPORT_C TKeyResponse CGSBaseContainer::OfferKeyEventL( |
|
174 const TKeyEvent& aKeyEvent, |
|
175 TEventCode aType ) |
|
176 { |
|
177 switch ( aKeyEvent.iCode ) |
|
178 { |
|
179 case EKeyLeftArrow: |
|
180 case EKeyRightArrow: |
|
181 // Listbox takes all event even if it doesn't use them: |
|
182 return EKeyWasNotConsumed; |
|
183 default: |
|
184 break; |
|
185 } |
|
186 |
|
187 // Now it's iListBox's job to process the key event |
|
188 return iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
189 } |
|
190 |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // CGSMainContainer::HandleResourceChange |
|
194 // |
|
195 // --------------------------------------------------------------------------- |
|
196 EXPORT_C void CGSBaseContainer::HandleResourceChange( TInt aType ) |
|
197 { |
|
198 CCoeControl::HandleResourceChange( aType ); |
|
199 if ( aType == KAknsMessageSkinChange || |
|
200 aType == KEikDynamicLayoutVariantSwitch ) |
|
201 { |
|
202 TRect mainPaneRect; |
|
203 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
204 mainPaneRect); |
|
205 SetRect( mainPaneRect ); |
|
206 } |
|
207 } |
|
208 |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CGSBaseContainer::SetSelectedItem() |
|
212 // |
|
213 // |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 EXPORT_C void CGSBaseContainer::SetSelectedItem( TInt aIndex ) |
|
217 { |
|
218 if( iListBox && aIndex >= 0 ) |
|
219 { |
|
220 iListBox->SetCurrentItemIndexAndDraw( aIndex ); |
|
221 } |
|
222 } |
|
223 |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CGSBaseContainer::SelectedItem() |
|
227 // |
|
228 // |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 EXPORT_C TInt CGSBaseContainer::SelectedItem() |
|
232 { |
|
233 TInt selectedItem = 0; |
|
234 if( iListBox ) |
|
235 { |
|
236 selectedItem = iListBox->CurrentItemIndex(); |
|
237 } |
|
238 return selectedItem; |
|
239 } |
|
240 |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CGSContainer::FocusChanged |
|
244 // |
|
245 // Set focus on the selected listbox. For animated skins feature. |
|
246 // --------------------------------------------------------------------------- |
|
247 EXPORT_C void CGSBaseContainer::FocusChanged( TDrawNow /*aDrawNow*/ ) |
|
248 { |
|
249 if( iListBox ) |
|
250 { |
|
251 iListBox->SetFocus( IsFocused() ); |
|
252 } |
|
253 } |
|
254 |
|
255 // End of File |
|