|
1 /* |
|
2 * Copyright (c) 2007 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: Softkey UI feature implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <cvtengmodel.h> |
|
20 #include <mvtengcamerapreferences.h> |
|
21 #include <eikenv.h> |
|
22 #include <cvtlogger.h> |
|
23 #include <avkon.hrh> |
|
24 |
|
25 #include "cvtuiprefsettinglistbase.h" |
|
26 #include "CVtUiAppUi.h" |
|
27 #include "cvtuitransparentsettingpage.h" |
|
28 #include "CVtUiMainControl.h" |
|
29 #include "CVtUiContextControl.h" |
|
30 #include "cvtuifeaturemanager.h" |
|
31 #include "VtUiLayout.h" |
|
32 |
|
33 #include <layoutmetadata.cdl.h> |
|
34 |
|
35 // constants |
|
36 static const TInt KMaxNumberOfArrayItems = 5; |
|
37 static const TInt KMaxNumberOfActiveItems = 5; |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CVtUiPrefSettingListBase::~CVtUiPrefSettingListBase |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CVtUiPrefSettingListBase::~CVtUiPrefSettingListBase() |
|
44 { |
|
45 __VTPRINTENTER( "CVtUiPrefSettingListBase.~CVtUiPrefSettingListBase" ) |
|
46 delete iViewfinderBitmap; |
|
47 delete iSettingPage; |
|
48 iActiveItems.Close(); |
|
49 __VTPRINTEXIT( "CVtUiPrefSettingListBase.~CVtUiPrefSettingListBase" ) |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CVtUiPrefSettingListBase::InitFeatureL |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 void CVtUiPrefSettingListBase::InitFeatureL() |
|
57 { |
|
58 __VTPRINTENTER( "CVtUiPrefSettingListBase.InitFeatureL" ) |
|
59 ResizeBackroundBitmapRect(); |
|
60 __VTPRINTEXIT( "CVtUiPrefSettingListBase.InitFeatureL" ) |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CVtUiPrefSettingListBase::IsPendingCmd |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 TBool CVtUiPrefSettingListBase::IsPendingCmd() |
|
68 { |
|
69 return iPendingSettingChangeCmd; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CVtUiPrefSettingListBase::HandlePendingCmd |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CVtUiPrefSettingListBase::HandlePendingCmdL() |
|
77 { |
|
78 SettingPageItemChangedL( iOriginalSelection ); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CVtUiPrefSettingListBase::HandleSettingPageEventL |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CVtUiPrefSettingListBase::HandleSettingPageEventL( |
|
86 CAknSettingPage* /*aSettingPage*/, TAknSettingPageEvent aEventType ) |
|
87 { |
|
88 __VTPRINTENTER( "CVtUiPrefSettingListBase.HandleSettingPageEventL" ) |
|
89 const TInt currentItem = iSettingPage->ListBoxControl()->CurrentItemIndex(); |
|
90 switch ( aEventType ) |
|
91 { |
|
92 case EEventSettingCancelled: |
|
93 { |
|
94 if ( iOriginalSelection != currentItem ) |
|
95 { |
|
96 // Set back to orginal selection |
|
97 SettingPageItemChangedL( iOriginalSelection ); |
|
98 iCurrentSelection = iOriginalSelection; |
|
99 } |
|
100 Stop(); |
|
101 break; |
|
102 } |
|
103 case EEventSettingChanged: |
|
104 { |
|
105 SettingPageItemChangedL( currentItem ); |
|
106 iOriginalSelection = currentItem; |
|
107 Stop(); |
|
108 break; |
|
109 } |
|
110 case EEventSettingOked: |
|
111 { |
|
112 // Check if the current selection has changed |
|
113 if ( iOriginalSelection != currentItem ) |
|
114 { |
|
115 SettingPageItemChangedL( currentItem ); |
|
116 iOriginalSelection = currentItem; |
|
117 iCurrentSelection = currentItem; |
|
118 } |
|
119 Stop(); |
|
120 break; |
|
121 } |
|
122 default: |
|
123 break; |
|
124 } |
|
125 __VTPRINTEXIT( "CVtUiPrefSettingListBase.HandleSettingPageEventL" ) |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CVtUiPrefSettingListBase::ListStateChangedL |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void CVtUiPrefSettingListBase::ListStateChangedL() |
|
133 { |
|
134 __VTPRINTENTER( "CVtUiPrefSettingListBase.ListStateChangedL" ) |
|
135 // Check if new item is focused in the selection list |
|
136 |
|
137 const TInt currentItem = iSettingPage->ListBoxControl()->CurrentItemIndex(); |
|
138 if ( iCurrentSelection != currentItem ) |
|
139 { |
|
140 // Update current selection |
|
141 iCurrentSelection = currentItem; |
|
142 // Adjust frame |
|
143 SettingPageItemChangedL( currentItem ); |
|
144 } |
|
145 __VTPRINTEXIT( "CVtUiPrefSettingListBase.ListStateChangedL" ) |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CVtUiPrefSettingListBase::StartSettingPageL |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 void CVtUiPrefSettingListBase::StartSettingPageL() |
|
153 { |
|
154 __VTPRINTENTER( "CVtUiPrefSettingListBase.StartSettingPageL" ) |
|
155 // Swap image places if needed |
|
156 iAppUi.SwitchViewFinderToMainPaneL(); |
|
157 |
|
158 // Get context control's window priority and position |
|
159 iWindowPriority = iAppUi.ContextControl().DrawableWindow() |
|
160 ->OrdinalPriority(); |
|
161 iWindowPosition = iAppUi.ContextControl().DrawableWindow() |
|
162 ->OrdinalPosition(); |
|
163 |
|
164 // Rise context control's window priority othwerwise setting page will be |
|
165 // drawn partially over the context control window. |
|
166 iAppUi.ContextControl().DrawableWindow()->SetOrdinalPosition( |
|
167 iWindowPosition, iWindowPriority + 1 ); |
|
168 |
|
169 // Creates setting page |
|
170 CreateSettingPageL(); |
|
171 // Launch setting page. |
|
172 iSettingPage->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted, EFalse ); |
|
173 iSettingPage = NULL; |
|
174 __VTPRINTEXIT( "CVtUiPrefSettingListBase.StartSettingPageL" ) |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CVtUiPrefSettingListBase::StopSettingPageL |
|
179 // |
|
180 // |
|
181 void CVtUiPrefSettingListBase::StopSettingPageL() |
|
182 { |
|
183 __VTPRINTENTER( "CVtUiPrefSettingListBase.StopSettingPageL" ) |
|
184 // Swap image places if needed |
|
185 iAppUi.RestoreViewFinderL(); |
|
186 |
|
187 if ( iSettingPage) |
|
188 { |
|
189 // Cancell the setting page |
|
190 TKeyEvent keyEvent; |
|
191 keyEvent.iCode = EKeyEscape; |
|
192 iSettingPage->OfferKeyEventL( keyEvent, EEventKey ); |
|
193 } |
|
194 |
|
195 // Set contex control's window priority and position back to orginal value. |
|
196 iAppUi.ContextControl().DrawableWindow()->SetOrdinalPosition( |
|
197 iWindowPosition, iWindowPriority ); |
|
198 __VTPRINTEXIT( "CVtUiPrefSettingListBase.StopSettingPageL" ) |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // CVtUiPrefSettingListBase::SizeChanged |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void CVtUiPrefSettingListBase::SizeChanged() |
|
206 { |
|
207 __VTPRINTENTER( "CVtUiPrefSettingListBase.SizeChanged" ) |
|
208 ResizeBackroundBitmapRect(); |
|
209 // Set new coordinates and size |
|
210 iSettingPage->SetBitmapPositionAndClipRect( iBitmapTopLeftCorner, |
|
211 iBitmapClippingRect ); |
|
212 iSettingPage->HandleLayoutChangeL(); |
|
213 __VTPRINTEXIT( "CVtUiPrefSettingListBase.SizeChanged" ) |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // CVtUiPrefSettingListBase::UpdateBackground |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 void CVtUiPrefSettingListBase::UpdateBackground( CFbsBitmap* aFrame ) |
|
221 { |
|
222 __VTPRINTENTER( "CVtUiPrefSettingListBase.UpdateBackground" ) |
|
223 if ( aFrame ) |
|
224 { |
|
225 // aFrame is valid only in this callback, the bitmap |
|
226 // must be copied for use as the setting page background |
|
227 iViewfinderBitmap->Duplicate( aFrame->Handle() ); |
|
228 if ( iSettingPage ) |
|
229 { |
|
230 // Update background |
|
231 iSettingPage->ChangeBackground( iViewfinderBitmap ); |
|
232 } |
|
233 } |
|
234 __VTPRINTEXIT( "CVtUiPrefSettingListBase.UpdateBackground" ) |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // CVtUiPrefSettingListBase::UpdateSettingL |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 void CVtUiPrefSettingListBase::UpdateSettingL() |
|
242 { |
|
243 // if no active items do nothing |
|
244 if ( iActiveItems.Count() > 0 ) |
|
245 { |
|
246 // user change the focuse in the list but not |
|
247 // select it indeed |
|
248 if( iOriginalSelection != iCurrentSelection ) |
|
249 SettingPageItemChangedL( iCurrentSelection ); |
|
250 else |
|
251 // yes,user has tapped down the OK button to choose a item |
|
252 SettingPageItemChangedL( iOriginalSelection ); |
|
253 } |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // CVtUiPrefSettingListBase::CVtUiPrefSettingListBase |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 CVtUiPrefSettingListBase::CVtUiPrefSettingListBase( CVtUiFeatureManager& |
|
261 aFeatureManager, TVtUiFeatureId aFeatureId ) : CVtUiFeatureBase( |
|
262 aFeatureId, aFeatureManager ), iActiveItems( KMaxNumberOfActiveItems ), |
|
263 iBitmapTopLeftCorner( 0, 0 ), iAppUi( aFeatureManager.AppUi() ),iPendingSettingChangeCmd( EFalse ) |
|
264 { |
|
265 __VTPRINTENTER( "CVtUiPrefSettingListBase.CVtUiPrefSettingListBase" ) |
|
266 __VTPRINTEXIT( "CVtUiPrefSettingListBase.CVtUiPrefSettingListBase" ) |
|
267 } |
|
268 |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // CVtUiPrefSettingListBase::ConstructL |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 void CVtUiPrefSettingListBase::ConstructL() |
|
275 { |
|
276 __VTPRINTENTER( "CVtUiPrefSettingListBase.ConstructL" ) |
|
277 BaseConstructL(); |
|
278 // Get camera preferences extension. |
|
279 iCameraPref = static_cast<MVtEngCameraPreferences*> (iFeatureManager. |
|
280 AppUi().Model().Extension( KVtEngExtensionCameraPreferences ) ); |
|
281 // Create backgound bitmap |
|
282 iViewfinderBitmap = new ( ELeave ) CFbsBitmap(); |
|
283 __VTPRINTEXIT( "CVtUiPrefSettingListBase.ConstructL" ) |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CVtUiPrefSettingListBase::ReadAndAppendItemL |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 void CVtUiPrefSettingListBase::ReadAndAppendItemL( CDesCArray& aItems, |
|
291 TInt aResId ) |
|
292 { |
|
293 __VTPRINTENTER( "CVtUiPrefSettingListBase.ReadAndAppendItemL" ) |
|
294 HBufC* text = iAppUi.GetEikonEnv()->AllocReadResourceLC( aResId ); |
|
295 aItems.AppendL( *text ); |
|
296 CleanupStack::PopAndDestroy(); // text |
|
297 __VTPRINTEXIT( "CVtUiPrefSettingListBase.ReadAndAppendItemL" ) |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // CVtUiPrefSettingListBase::CreateSettingPageL |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 void CVtUiPrefSettingListBase::CreateSettingPageL() |
|
305 { |
|
306 __VTPRINTENTER( "CVtUiPrefSettingListBase.CreateSettingPageL" ) |
|
307 CDesCArray* selectionArray = new ( ELeave ) |
|
308 CDesCArraySeg( KMaxNumberOfArrayItems ); |
|
309 CleanupStack::PushL( selectionArray ); |
|
310 // Set items must be called before CurrentSelection function |
|
311 // Otherwise iActiveItems array is not populated |
|
312 iActiveItems.Reset(); |
|
313 SetItemsL( *selectionArray ); |
|
314 TInt resourceId = SettingPageResId(); |
|
315 |
|
316 // Current selection is needed when a new item is focused in the list |
|
317 iCurrentSelection = iOriginalSelection; |
|
318 TInt current( CurrentSelection() ); |
|
319 if ( !iSettingPage ) |
|
320 { |
|
321 iSettingPage = new ( ELeave ) CVtUiTransparentSettingPage( resourceId, |
|
322 iCurrentSelection, selectionArray ); |
|
323 iSettingPage->ConstructL(); |
|
324 iSettingPage->SetSettingPageObserver( this ); |
|
325 iSettingPage->SetSettingPageEventStateObserver( this ); |
|
326 } |
|
327 CleanupStack::PopAndDestroy(); // selectionArray |
|
328 ResizeBackroundBitmapRect(); |
|
329 iSettingPage->SetBitmapPositionAndClipRect( iBitmapTopLeftCorner, |
|
330 iBitmapClippingRect ); |
|
331 __VTPRINTEXIT( "CVtUiPrefSettingListBase.CreateSettingPageL" ) |
|
332 } |
|
333 |
|
334 // --------------------------------------------------------------------------- |
|
335 // CVtUiPrefSettingListBase::ShrinkBackroundBitmapRect |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 void CVtUiPrefSettingListBase::ResizeBackroundBitmapRect() |
|
339 { |
|
340 __VTPRINTENTER( "CVtUiPrefSettingListBase.ResizeBackroundBitmapRect" ) |
|
341 TRect parent( iAppUi.MainControl().Size() ); |
|
342 TAknWindowLineLayout rect; |
|
343 TAknLayoutRect iStreamLayout; |
|
344 VtUiLayout::GetSecondWindowStreamLayout( rect, ETrue ); |
|
345 iStreamLayout.LayoutRect( parent, rect ); |
|
346 |
|
347 // In landscape rect from layout doesn't work |
|
348 // for some reason |
|
349 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
350 { |
|
351 iBitmapClippingRect = parent; |
|
352 } |
|
353 else |
|
354 { |
|
355 iBitmapClippingRect = iStreamLayout.Rect(); |
|
356 } |
|
357 |
|
358 iBitmapTopLeftCorner = iStreamLayout.Rect().iTl; |
|
359 __VTPRINTEXIT( "CVtUiPrefSettingListBase.ResizeBackroundBitmapRect" ) |
|
360 } |