1 /* |
|
2 * Copyright (c) 2007-2010 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: Implements the location settings for image settings* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <gscamerapluginrsc.rsg> |
|
22 #include <barsread.h> |
|
23 #include <AknQueryValue.h> |
|
24 #include <AknIconUtils.h> |
|
25 #include <akntitle.h> // CAknTitlePane |
|
26 #include <aknappui.h> |
|
27 #include <AknsUtils.h> |
|
28 #include <AknsDrawUtils.h> |
|
29 #include <StringLoader.h> |
|
30 #include <cameraapp.mbg> |
|
31 #include <aknlayoutscalable_apps.cdl.h> |
|
32 #include <layoutmetadata.cdl.h> |
|
33 #include <touchfeedback.h> |
|
34 |
|
35 #include "CamLocationSettingContainer.h" |
|
36 #include "CamUtility.h" |
|
37 #include "CamCaptureSetupListBox.h" |
|
38 #include "CamCaptureSetupListBoxModel.h" |
|
39 #include "CamPanic.h" |
|
40 #include "camuiconstants.h" |
|
41 #include "camuidconstants.h" |
|
42 #include "CamAppUiBase.h" |
|
43 #include "CamStaticSettingsModel.h" |
|
44 #include "GSCamcorderPlugin.h" |
|
45 |
|
46 // ============================ MEMBER FUNCTIONS =============================== |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CCamLocationSettingContainer::CCamLocationSettingContainer |
|
50 // C++ default constructor can NOT contain any code, that |
|
51 // might leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CCamLocationSettingContainer::CCamLocationSettingContainer( MCamAppController& aController, |
|
55 TCamCameraMode aMode, |
|
56 CCoeControl* aParent ) |
|
57 : iParent( aParent ), |
|
58 iController( aController ), |
|
59 iMode( aMode ), |
|
60 iActivateOnTouchRelease( EFalse ) |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CCamLocationSettingContainer::ConstructL |
|
66 // Symbian 2nd phase constructor can leave. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CCamLocationSettingContainer::ConstructL() |
|
70 { |
|
71 PRINT(_L("Camera => CCamLocationSettingContainer::ConstructL") ) |
|
72 PRINT(_L("Camera <= CCamLocationSettingContainer::ConstructL") ) |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CCamLocationSettingContainer::NewL |
|
77 // Two-phased constructor. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CCamLocationSettingContainer* |
|
81 CCamLocationSettingContainer::NewL( MCamAppController& aController, |
|
82 TCamCameraMode aMode, |
|
83 CCoeControl* aParent ) |
|
84 { |
|
85 CCamLocationSettingContainer* self = |
|
86 new( ELeave ) CCamLocationSettingContainer( aController, aMode, aParent ); |
|
87 CleanupStack::PushL( self ); |
|
88 self->ConstructL(); |
|
89 CleanupStack::Pop(); |
|
90 return self; |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CCamLocationSettingContainer::~CCamLocationSettingContainer |
|
96 // Destructor |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CCamLocationSettingContainer::~CCamLocationSettingContainer() |
|
100 { |
|
101 PRINT( _L("Camera => ~CCamLocationSettingContainer") ); |
|
102 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( iEikonEnv->AppUi() ); |
|
103 if ( appUi ) |
|
104 { |
|
105 TInt resId = ( ECamControllerVideo == iMode ) |
|
106 ? R_CAM_VIDEO_SETTINGS_TITLE_NAME |
|
107 : R_CAM_PHOTO_SETTINGS_TITLE_NAME; |
|
108 |
|
109 TRAP_IGNORE( appUi->SetTitleL( resId ) ); |
|
110 } |
|
111 iDescArray.ResetAndDestroy(); |
|
112 iDescLayoutArray.Close(); |
|
113 if ( iCurrentDescLineArray ) |
|
114 { |
|
115 iCurrentDescLineArray->Reset(); |
|
116 delete iCurrentDescLineArray; |
|
117 } |
|
118 delete iListBox; |
|
119 |
|
120 if ( iTextTitle ) |
|
121 { |
|
122 delete iTextTitle; |
|
123 iTextTitle = NULL; |
|
124 } |
|
125 |
|
126 PRINT( _L("Camera <= ~CCamLocationSettingContainer") ); |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CCamLocationSettingContainer::SelectedQuality |
|
131 // Returns the value selected by the listbox |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 TInt CCamLocationSettingContainer::SelectedValue() const |
|
135 { |
|
136 CCamCaptureSetupListBoxModel *model = static_cast<CCamCaptureSetupListBoxModel *>( iListBox->Model() ); |
|
137 return model->ItemValue( iListBox->CurrentItemIndex() ); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CCamLocationSettingContainer::ConstructFromResourceL |
|
142 // Constructs the container from the resource |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CCamLocationSettingContainer::ConstructFromResourceL( TResourceReader& /*aReader*/ ) |
|
146 { |
|
147 CAknViewAppUi* viewAppUi = static_cast<CAknViewAppUi*>( CCoeEnv::Static()->AppUi() ); |
|
148 CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> |
|
149 ( viewAppUi->View( KGSCamcorderGSPluginUid ) ); |
|
150 |
|
151 // set up the container windows here as setting page window |
|
152 // isn't created until CAknSettingPage::ConstructFromResourceL is called |
|
153 SetContainerWindowL( *iParent ); |
|
154 |
|
155 TRect mainPaneRect; |
|
156 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
157 mainPaneRect ); |
|
158 TRect statusPaneRect; |
|
159 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, |
|
160 statusPaneRect ); |
|
161 |
|
162 // layout area rectangle contains the area, where components need to be |
|
163 // drawn to. the container size is the whole screen, but the layouts are |
|
164 // for the client area. aRect is the container size that might include or |
|
165 // might not include statuspane area. calculating area self will |
|
166 // go around the problem |
|
167 TRect layoutAreaRect; |
|
168 layoutAreaRect = mainPaneRect; |
|
169 layoutAreaRect.BoundingRect( statusPaneRect ); |
|
170 |
|
171 // set the layouts for the rect containing the description |
|
172 if ( CamUtility::IsNhdDevice() ) |
|
173 { |
|
174 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
175 { |
|
176 iSummaryRect.LayoutRect( layoutAreaRect, AknLayoutScalable_Apps::main_cset_text2_pane( 0 ) ); |
|
177 } |
|
178 else |
|
179 { |
|
180 iSummaryRect.LayoutRect( layoutAreaRect, AknLayoutScalable_Apps::main_cset_text2_pane( 1 ) ); |
|
181 } |
|
182 } |
|
183 else |
|
184 { |
|
185 iSummaryRect.LayoutRect( layoutAreaRect, AknLayoutScalable_Apps::main_cset6_text2_pane( 0 ) ); |
|
186 } |
|
187 |
|
188 TRAPD( ignore, |
|
189 ConstructSummaryDetailsFromResourceL( R_CAM_OFF_ON_LOC_TEXT_LIST_SUMMARY ); |
|
190 ) |
|
191 if ( ignore ) |
|
192 { |
|
193 // Do nothing ( removes build warning ) |
|
194 } |
|
195 |
|
196 iCurrentDescLineArray = new( ELeave ) CArrayFixFlat<TPtrC>( 5 ); |
|
197 |
|
198 // set layout for 5 lines of descriptive text |
|
199 iDescLayoutArray.Reset(); |
|
200 TAknLayoutText layout; |
|
201 TAknLayoutScalableParameterLimits listLimits = |
|
202 AknLayoutScalable_Apps::main_cset_text2_pane_t1_copy1_ParamLimits( 0 ); |
|
203 TInt lineCount = listLimits.LastRow() + 1; |
|
204 for ( TInt i = 0; i < lineCount; i++ ) |
|
205 { |
|
206 if ( CamUtility::IsNhdDevice() ) |
|
207 { |
|
208 layout.LayoutText( iSummaryRect.Rect(), |
|
209 AknLayoutScalable_Apps::main_cset_text2_pane_t1( i ) ); |
|
210 } |
|
211 else |
|
212 { |
|
213 layout.LayoutText( iSummaryRect.Rect(), |
|
214 AknLayoutScalable_Apps::main_cset_text2_pane_t1_copy1(0,0,i) ); |
|
215 } |
|
216 User::LeaveIfError( iDescLayoutArray.Append( layout ) ); |
|
217 } |
|
218 |
|
219 TInt listInt = ECamSettingItemRecLocation; |
|
220 iListBox = new( ELeave ) CCamCaptureSetupListBox( this, iController ); |
|
221 iListBox->ConstructL( this, |
|
222 R_CAM_OFF_ON_LOC_TEXT_LIST, |
|
223 TInt( ECamSettingItemRecLocation ), |
|
224 0, |
|
225 EFalse, |
|
226 ETrue ); |
|
227 if ( parent ) |
|
228 { |
|
229 iListBox->InitializeL |
|
230 ( parent->IntegerSettingValue( listInt ) ); |
|
231 } |
|
232 iListBox->SetContainerWindowL( *iParent ); |
|
233 |
|
234 TRect listboxRect; |
|
235 ReadListboxLayoutL(listboxRect); |
|
236 |
|
237 // Determine the height of the listbox; Either the height based on the number of items, |
|
238 // or the maximum allowed listbox height. |
|
239 CEikScrollBarFrame::TScrollBarVisibility visibility = CEikScrollBarFrame::EOff; |
|
240 TInt maxListBoxHeight = listboxRect.Height(); |
|
241 TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( |
|
242 iListBox->Model()->NumberOfItems() ); |
|
243 if ( maxListBoxHeight < listBoxHeight ) |
|
244 { |
|
245 // there are more items than would fit to the listbox rectangle |
|
246 |
|
247 // the maximum height is the total height of items |
|
248 // that can fit to the maxlistboxheight |
|
249 TInt itemHeight = iListBox->ItemHeight(); |
|
250 TInt itemsVisible = maxListBoxHeight / itemHeight; |
|
251 listBoxHeight = itemsVisible * itemHeight; |
|
252 |
|
253 // the scrollbar needs to be turned on |
|
254 visibility = CEikScrollBarFrame::EOn; |
|
255 } |
|
256 |
|
257 // get layout for the listbox rect |
|
258 TAknLayoutRect listboxLayoutRect; |
|
259 if ( visibility == CEikScrollBarFrame::EOn ) |
|
260 { |
|
261 // if scrollbars are used, use scrollbar layout |
|
262 if ( CamUtility::IsNhdDevice() ) |
|
263 { |
|
264 listboxLayoutRect.LayoutRect( listboxRect, |
|
265 AknLayoutScalable_Apps::main_cset_list_pane( 0 ) ); |
|
266 } |
|
267 else |
|
268 { |
|
269 listboxLayoutRect.LayoutRect( listboxRect, |
|
270 AknLayoutScalable_Apps::main_cset_list_pane_copy1( 0 ) ); |
|
271 } |
|
272 } |
|
273 else |
|
274 { |
|
275 if ( CamUtility::IsNhdDevice() ) |
|
276 { |
|
277 listboxLayoutRect.LayoutRect( listboxRect, |
|
278 AknLayoutScalable_Apps::main_cset_list_pane( 1 ) ); |
|
279 } |
|
280 else |
|
281 { |
|
282 listboxLayoutRect.LayoutRect( listboxRect, |
|
283 AknLayoutScalable_Apps::main_cset_list_pane_copy1( 1 ) ); |
|
284 } |
|
285 } |
|
286 |
|
287 // layout scrollbarpane (will not be visible if not needed) |
|
288 TAknLayoutRect scrollbarLayoutRect; |
|
289 if ( CamUtility::IsNhdDevice() ) |
|
290 { |
|
291 scrollbarLayoutRect.LayoutRect( listboxRect, |
|
292 AknLayoutScalable_Apps::scroll_pane_cp028( 0 ) ); |
|
293 } |
|
294 else |
|
295 { |
|
296 scrollbarLayoutRect.LayoutRect( listboxRect, |
|
297 AknLayoutScalable_Apps::scroll_pane_cp028_copy1( 0 ) ); |
|
298 } |
|
299 |
|
300 // calculate the layout for the listbox with changed height |
|
301 const AknLayoutUtils::SAknLayoutControl listboxLayout = |
|
302 { ELayoutEmpty, listboxRect.iTl.iX, listboxRect.iTl.iY, |
|
303 ELayoutEmpty, ELayoutEmpty, |
|
304 listboxLayoutRect.Rect().Width(), listBoxHeight }; |
|
305 |
|
306 AknLayoutUtils::LayoutControl( iListBox, |
|
307 layoutAreaRect, listboxLayout); |
|
308 |
|
309 iListBox->CreateScrollBarFrameL( ETrue ); |
|
310 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
311 CEikScrollBarFrame::EOff, |
|
312 visibility ); |
|
313 iListBox->MakeVisible( ETrue ); |
|
314 iListBox->SetFocus( EFalse, ENoDrawNow ); |
|
315 iListBox->UpdateScrollBarsL(); |
|
316 iListBox->ScrollBarFrame()->DrawScrollBarsNow(); |
|
317 iListBox->SetListBoxObserver(this); |
|
318 SplitCurrentTextL(); |
|
319 |
|
320 // Prevents the system filling invalidated areas with the background colour - |
|
321 // helps reduce flicker. |
|
322 Window().SetBackgroundColor(); |
|
323 |
|
324 ConstructContainerTitleFromResourceL( R_CAM_PHOTO_LOCATION_SETTINGS_TITLE_NAME ); |
|
325 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( iEikonEnv->AppUi() ); |
|
326 appUi->SetTitleL( iTextTitle->Des() ); |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // CCamLocationSettingContainer::CountComponentControls |
|
331 // return the number of component controls |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 TInt CCamLocationSettingContainer::CountComponentControls() const |
|
335 { |
|
336 return 1; // the listbox |
|
337 } |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CCamLocationSettingContainer::ComponentControl |
|
341 // return the control at a given index |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 CCoeControl* CCamLocationSettingContainer::ComponentControl( TInt /*aIndex*/ ) const |
|
345 { |
|
346 return iListBox; |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CCamLocationSettingContainer::Draw |
|
351 // Draws the container |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 void CCamLocationSettingContainer::Draw( const TRect& /*aRect*/ ) const |
|
355 { |
|
356 CWindowGc& gc = SystemGc(); |
|
357 |
|
358 // Draw skin background |
|
359 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
360 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
361 AknsDrawUtils::Background( skin, cc, gc, Rect() ); |
|
362 |
|
363 // Draw summary text |
|
364 DrawSummaryText( gc ); |
|
365 } |
|
366 |
|
367 // ----------------------------------------------------------------------------- |
|
368 // CCamLocationSettingContainer::SizeChanged |
|
369 // Handles a change in the size of the control |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 void CCamLocationSettingContainer::SizeChanged() |
|
373 { |
|
374 // Do this only if the listbox has been created, ie. ConstructFromResourceL() has been called |
|
375 if (iListBox) |
|
376 { |
|
377 TRect listboxRect; |
|
378 TRAPD( ignore, ReadListboxLayoutL(listboxRect) ); |
|
379 if ( ignore ) |
|
380 { |
|
381 // Just return if the resource reader fails |
|
382 return; |
|
383 } |
|
384 |
|
385 TRect mainPaneRect; |
|
386 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
387 mainPaneRect ); |
|
388 TRect statusPaneRect; |
|
389 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, |
|
390 statusPaneRect ); |
|
391 |
|
392 // layout area rectangle contains the area, where components need to be |
|
393 // drawn to. the container size is the whole screen, but the layouts are |
|
394 // for the client area. aRect is the container size that might include or |
|
395 // might not include statuspane area. calculating area self will |
|
396 // go around the problem |
|
397 TRect layoutAreaRect; |
|
398 layoutAreaRect = mainPaneRect; |
|
399 layoutAreaRect.BoundingRect( statusPaneRect ); |
|
400 |
|
401 // Determine the height of the listbox; Either the height based on the number of items, |
|
402 // or the maximum allowed listbox height. |
|
403 CEikScrollBarFrame::TScrollBarVisibility visibility = CEikScrollBarFrame::EOff; |
|
404 TInt maxListBoxHeight = listboxRect.Height(); |
|
405 TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( |
|
406 iListBox->Model()->NumberOfItems() ); |
|
407 if ( maxListBoxHeight < listBoxHeight ) |
|
408 { |
|
409 // there are more items than would fit to the listbox rectangle |
|
410 |
|
411 // the maximum height is the total height of items |
|
412 // that can fit to the maxlistboxheight |
|
413 TInt itemHeight = iListBox->ItemHeight(); |
|
414 TInt itemsVisible = maxListBoxHeight / itemHeight; |
|
415 listBoxHeight = itemsVisible * itemHeight; |
|
416 |
|
417 // the scrollbar needs to be turned on |
|
418 visibility = CEikScrollBarFrame::EOn; |
|
419 } |
|
420 |
|
421 // get layout for the listbox rect |
|
422 TAknLayoutRect listboxLayoutRect; |
|
423 if ( visibility == CEikScrollBarFrame::EOn ) |
|
424 { |
|
425 // if scrollbars are used, use scrollbar layout |
|
426 if ( CamUtility::IsNhdDevice() ) |
|
427 { |
|
428 listboxLayoutRect.LayoutRect( listboxRect, |
|
429 AknLayoutScalable_Apps::main_cset_list_pane( 0 ) ); |
|
430 } |
|
431 else |
|
432 { |
|
433 listboxLayoutRect.LayoutRect( listboxRect, |
|
434 AknLayoutScalable_Apps::main_cset_list_pane_copy1( 0 ) ); |
|
435 } |
|
436 } |
|
437 else |
|
438 { |
|
439 if ( CamUtility::IsNhdDevice() ) |
|
440 { |
|
441 listboxLayoutRect.LayoutRect( listboxRect, |
|
442 AknLayoutScalable_Apps::main_cset_list_pane( 1 ) ); |
|
443 } |
|
444 else |
|
445 { |
|
446 listboxLayoutRect.LayoutRect( listboxRect, |
|
447 AknLayoutScalable_Apps::main_cset_list_pane_copy1( 1 ) ); |
|
448 } |
|
449 } |
|
450 |
|
451 // layout scrollbarpane (will not be visible if not needed) |
|
452 TAknLayoutRect scrollbarLayoutRect; |
|
453 if ( CamUtility::IsNhdDevice() ) |
|
454 { |
|
455 scrollbarLayoutRect.LayoutRect( listboxRect, |
|
456 AknLayoutScalable_Apps::scroll_pane_cp028( 0 ) ); |
|
457 } |
|
458 else |
|
459 { |
|
460 scrollbarLayoutRect.LayoutRect( listboxRect, |
|
461 AknLayoutScalable_Apps::scroll_pane_cp028_copy1( 0 ) ); |
|
462 } |
|
463 |
|
464 // calculate the layout for the listbox with changed height |
|
465 const AknLayoutUtils::SAknLayoutControl listboxLayout = |
|
466 { ELayoutEmpty, listboxRect.iTl.iX, listboxRect.iTl.iY, |
|
467 ELayoutEmpty, ELayoutEmpty, |
|
468 listboxLayoutRect.Rect().Width(), listBoxHeight }; |
|
469 |
|
470 AknLayoutUtils::LayoutControl( iListBox, |
|
471 layoutAreaRect, listboxLayout); |
|
472 } |
|
473 } |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // CCamLocationSettingContainer::OfferKeyEventL |
|
477 // Handles key events |
|
478 // ----------------------------------------------------------------------------- |
|
479 // |
|
480 TKeyResponse CCamLocationSettingContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
481 TEventCode aType ) |
|
482 { |
|
483 TKeyResponse keyResponse = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
484 if ( keyResponse == EKeyWasConsumed ) |
|
485 { |
|
486 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
|
487 } |
|
488 return keyResponse; |
|
489 } |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // CCamLocationSettingContainer::HandleSettingValueUpdateL |
|
493 // Handles a change to the setting value |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 void CCamLocationSettingContainer::HandleSettingValueUpdateL( TInt /*aNewValue*/ ) |
|
497 { |
|
498 SplitCurrentTextL(); |
|
499 ActivateGc(); |
|
500 Window().Invalidate( iSummaryRect.Rect() ); |
|
501 DeactivateGc(); |
|
502 } |
|
503 |
|
504 // ----------------------------------------------------------------------------- |
|
505 // CCamLocationSettingContainer::ReadListboxLayoutL |
|
506 // Reads the listbox layout |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 void CCamLocationSettingContainer::ReadListboxLayoutL( TRect& aRect ) |
|
510 { |
|
511 TRect mainPaneRect; |
|
512 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
513 mainPaneRect ); |
|
514 TRect statusPaneRect; |
|
515 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, |
|
516 statusPaneRect ); |
|
517 |
|
518 // layout area rectangle contains the area, where components need to be |
|
519 // drawn to. the container size is the whole screen, but the layouts are |
|
520 // for the client area. aRect is the container size that might include or |
|
521 // might not include statuspane area. calculating area self will |
|
522 // go around the problem |
|
523 TRect layoutAreaRect; |
|
524 layoutAreaRect = mainPaneRect; |
|
525 layoutAreaRect.BoundingRect( statusPaneRect ); |
|
526 |
|
527 // get the rect size for listbox in the layout |
|
528 TAknLayoutRect listboxLayoutRect; |
|
529 if ( CamUtility::IsNhdDevice() ) |
|
530 { |
|
531 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
532 { |
|
533 listboxLayoutRect.LayoutRect( layoutAreaRect, |
|
534 AknLayoutScalable_Apps::main_cset_listscroll_pane( 4 ) ); |
|
535 } |
|
536 else |
|
537 { |
|
538 listboxLayoutRect.LayoutRect( layoutAreaRect, |
|
539 AknLayoutScalable_Apps::main_cset_listscroll_pane( 5 ) ); |
|
540 } |
|
541 } |
|
542 else |
|
543 { |
|
544 listboxLayoutRect.LayoutRect( layoutAreaRect, |
|
545 AknLayoutScalable_Apps::main_cset6_listscroll_pane( 4 ) ); |
|
546 } |
|
547 aRect.SetRect(listboxLayoutRect.Rect().iTl, listboxLayoutRect.Rect().Size() ); |
|
548 } |
|
549 |
|
550 // ----------------------------------------------------------------- |
|
551 // CCamLocationSettingContainer::ConstructSummaryDetailsFromResourceL |
|
552 // Sets up the layouts of the summary items |
|
553 // ----------------------------------------------------------------- |
|
554 void CCamLocationSettingContainer::ConstructSummaryDetailsFromResourceL(TInt aResourceId) |
|
555 { |
|
556 TResourceReader reader; |
|
557 iEikonEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
558 const TInt count = reader.ReadInt16(); |
|
559 |
|
560 TInt i = -1; |
|
561 // bitmapID and SummarySceneId are needed since we are using |
|
562 // a resource that requires fetching those values also. |
|
563 // The reason why the resource itself is not changed is |
|
564 // that we are using a CamCaptureSetupListBox that needs those. |
|
565 // This requires much less work if not creating own listbox type that |
|
566 // would otherwise have to be created. CamCaptureSetupListBox is now |
|
567 // used here in such a way that the listbox icon are is set to zero width |
|
568 // and no bitmap icon is showed. |
|
569 TInt bitmapId = -1; |
|
570 // To remove warning about setting variable but never using it |
|
571 TInt summarySceneId = bitmapId; |
|
572 // made to remove warning. (explained above comments) |
|
573 bitmapId = summarySceneId; |
|
574 |
|
575 HBufC16* descr = NULL; |
|
576 |
|
577 // Read all of the summary entries from the resource file |
|
578 for ( i = 0; i < count; i++ ) |
|
579 { |
|
580 summarySceneId = reader.ReadInt16(); |
|
581 bitmapId = reader.ReadInt32(); |
|
582 descr = reader.ReadHBufC16L(); |
|
583 |
|
584 // This hack because an empty resource string which comes as NULL from the resource reader. |
|
585 // This would create crash later on. |
|
586 if ( NULL == descr ) |
|
587 { |
|
588 _LIT(KText,""); |
|
589 HBufC* buf; |
|
590 buf = HBufC::NewL(0); |
|
591 *buf = KText; |
|
592 User::LeaveIfError( iDescArray.Append( buf ) ); |
|
593 } |
|
594 else |
|
595 { |
|
596 User::LeaveIfError( iDescArray.Append( descr ) ); |
|
597 } |
|
598 } |
|
599 CleanupStack::PopAndDestroy(); // reader |
|
600 } |
|
601 |
|
602 |
|
603 // ----------------------------------------------------------------- |
|
604 // CCamLocationModeContainer::DrawSummaryText |
|
605 // Draws summary title and description text |
|
606 // ----------------------------------------------------------------- |
|
607 void CCamLocationSettingContainer::DrawSummaryText( CWindowGc& aGc ) const |
|
608 { |
|
609 // aGc.SetBrushColor( KRgbShadedWhite ); |
|
610 // aGc.Clear( iSummaryRect.Rect() ); |
|
611 |
|
612 TInt count = iCurrentDescLineArray->Count(); |
|
613 TInt layoutCount = iDescLayoutArray.Count(); |
|
614 TRgb color; |
|
615 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
616 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 ); |
|
617 |
|
618 if ( layoutCount < count ) |
|
619 { |
|
620 count = layoutCount; |
|
621 } |
|
622 TInt i; |
|
623 for ( i = 0; i < count; i++ ) |
|
624 { |
|
625 iDescLayoutArray[i].DrawText( aGc, ( *iCurrentDescLineArray )[i], ETrue, color ); |
|
626 } |
|
627 } |
|
628 |
|
629 // ----------------------------------------------------------------- |
|
630 // CCamLocationModeContainer::SplitCurrentTextL |
|
631 // Splits the summary title and description text into multiple lines that fit the status layouts |
|
632 // ----------------------------------------------------------------- |
|
633 void CCamLocationSettingContainer::SplitCurrentTextL() |
|
634 { |
|
635 // Use the layout info from the first line for width and font |
|
636 TAknLayoutText layout = iDescLayoutArray[0]; |
|
637 AknTextUtils::WrapToArrayL( *iDescArray[iListBox->CurrentItemIndex()], |
|
638 layout.TextRect().Width(), |
|
639 *( layout.Font() ), |
|
640 *iCurrentDescLineArray ); |
|
641 } |
|
642 |
|
643 |
|
644 // -------------------------------------------------------------------------- |
|
645 // CCamLocationSettingContainer::ConstructContainerTitleFromResourceL |
|
646 // -------------------------------------------------------------------------- |
|
647 // |
|
648 void CCamLocationSettingContainer::ConstructContainerTitleFromResourceL( TInt aResourceId ) |
|
649 { |
|
650 TResourceReader reader; |
|
651 iEikonEnv->CreateResourceReaderLC( reader, aResourceId ); // cleanupstack |
|
652 |
|
653 iTextTitle = reader.ReadHBufC16L(); |
|
654 |
|
655 CleanupStack::PopAndDestroy(); // reader |
|
656 } |
|
657 |
|
658 // -------------------------------------------------------------------------- |
|
659 // CCamLocationSettingContainer::HandlePointerEventL |
|
660 // -------------------------------------------------------------------------- |
|
661 // |
|
662 void CCamLocationSettingContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
663 { |
|
664 RDebug::Print(_L("CCamLocationSettingContainer::HandlePointerEventL iType=%d iPosition=(%d, %d)"), |
|
665 aPointerEvent.iType, |
|
666 aPointerEvent.iPosition.iX, |
|
667 aPointerEvent.iPosition.iY ); |
|
668 iListBox->HandlePointerEventL( aPointerEvent ); |
|
669 /*TInt oldListItemIndex = -1; |
|
670 TInt newListItemIndex = -1; |
|
671 TBool handleItemActivation = EFalse; |
|
672 |
|
673 if ( iListBox ) |
|
674 { |
|
675 oldListItemIndex = iListBox->CurrentItemIndex(); |
|
676 } |
|
677 |
|
678 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
679 |
|
680 if ( iListBox ) |
|
681 { |
|
682 newListItemIndex = iListBox->CurrentItemIndex(); |
|
683 } |
|
684 |
|
685 if ( oldListItemIndex != -1 && newListItemIndex != -1 ) |
|
686 { |
|
687 |
|
688 // figure out if item was activated by touch down + release combination on same item |
|
689 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
690 { |
|
691 if ( newListItemIndex != oldListItemIndex ) |
|
692 { |
|
693 iActivateOnTouchRelease = EFalse; |
|
694 } |
|
695 else |
|
696 { |
|
697 // set the current item to be activated on touch release |
|
698 iActivateOnTouchRelease = ETrue; |
|
699 } |
|
700 } |
|
701 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
702 { |
|
703 if ( iActivateOnTouchRelease && ( newListItemIndex == oldListItemIndex ) ) |
|
704 { |
|
705 TInt pointedItemIndex; |
|
706 TBool focusableItemPointed = iListBox->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointedItemIndex ); |
|
707 // check that pointer is in focusable area |
|
708 if ( focusableItemPointed ) |
|
709 { |
|
710 // only if list item index has not changed during event and iActivateOnTouchRelease is true |
|
711 handleItemActivation = ETrue; |
|
712 iActivateOnTouchRelease = EFalse; |
|
713 } |
|
714 else |
|
715 { |
|
716 iActivateOnTouchRelease = EFalse; |
|
717 } |
|
718 } |
|
719 } |
|
720 else |
|
721 { |
|
722 // aPointerEvent.iType == TPointerEvent::EDrag |
|
723 |
|
724 if ( newListItemIndex != oldListItemIndex ) |
|
725 { |
|
726 // change only when drag event changes the listitem index |
|
727 iActivateOnTouchRelease = EFalse; |
|
728 } |
|
729 } |
|
730 |
|
731 } // end if ( oldListItemIndex != -1 && newListItemIndex != -1 ) |
|
732 |
|
733 if ( handleItemActivation ) |
|
734 { |
|
735 TKeyEvent key; |
|
736 key.iRepeats = 0; |
|
737 key.iCode = EKeyOK; |
|
738 key.iModifiers = 0; |
|
739 iEikonEnv->SimulateKeyEventL( key, EEventKey ); |
|
740 }*/ |
|
741 |
|
742 } // end of HandlePointerEventL |
|
743 // --------------------------------------------------------------------------- |
|
744 // CCamLocationSettingContainer::HandleListBoxEventL |
|
745 // Handles Listbox events |
|
746 // --------------------------------------------------------------------------- |
|
747 // |
|
748 void CCamLocationSettingContainer::HandleListBoxEventL( CEikListBox* aListBox, |
|
749 TListBoxEvent aEventType ) |
|
750 { |
|
751 |
|
752 switch( aEventType ) |
|
753 { |
|
754 |
|
755 case EEventEnterKeyPressed: |
|
756 case EEventItemDoubleClicked: |
|
757 case EEventItemSingleClicked: |
|
758 { |
|
759 TKeyEvent key; |
|
760 key.iRepeats = 0; |
|
761 key.iCode = EKeyOK; |
|
762 key.iModifiers = 0; |
|
763 iEikonEnv->SimulateKeyEventL( key, EEventKey ); |
|
764 } |
|
765 break; |
|
766 case EEventItemClicked: |
|
767 { |
|
768 HandleSettingValueUpdateL( iListBox->CurrentItemIndex() ); |
|
769 } |
|
770 break; |
|
771 default: |
|
772 break; |
|
773 } |
|
774 } |
|
775 // End of File |
|