|
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: Taskswitcher view class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AknUtils.h> |
|
20 #include <AknsUtils.h> |
|
21 #include <aknlayoutscalable_apps.cdl.h> |
|
22 #include <aknlayoutscalable_avkon.cdl.h> |
|
23 #include <layoutmetadata.cdl.h> |
|
24 #include <AknsFrameBackgroundControlContext.h> |
|
25 #include <AknsDrawUtils.h> |
|
26 #include <eikmenub.h> |
|
27 #include <gfxtranseffect/gfxtranseffect.h> |
|
28 #include <akntransitionutils.h> |
|
29 #include <akntranseffect.h> |
|
30 #include <aknPopupHeadingPane.h> |
|
31 #include <StringLoader.h> |
|
32 #include <taskswitcher.rsg> |
|
33 #include "tsappview.h" |
|
34 #include "tsappui.h" |
|
35 #include "tsapplogging.h" |
|
36 #include "tsfastswaparea.h" |
|
37 #include "tseventcontroler.h" |
|
38 #include "tsuid.hrh" |
|
39 |
|
40 |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CTsAppView::NewL |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CTsAppView* CTsAppView::NewL( const TRect& aRect, |
|
47 CTsDeviceState& aDeviceState, |
|
48 RWindowGroup& aWg) |
|
49 { |
|
50 CTsAppView* self = CTsAppView::NewLC( aRect, aDeviceState, aWg ); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CTsAppView::NewLC |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CTsAppView* CTsAppView::NewLC( const TRect& aRect, |
|
60 CTsDeviceState& aDeviceState, |
|
61 RWindowGroup& aWg) |
|
62 { |
|
63 CTsAppView* self = new (ELeave) CTsAppView( aDeviceState ); |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL( aRect, aWg ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CTsAppView::CTsAppView |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CTsAppView::CTsAppView(CTsDeviceState& aDeviceState) |
|
74 : iDeviceState( aDeviceState ), iExitOnPointerUp(EFalse) |
|
75 { |
|
76 // no implementation required |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // InvalidateWindows |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 static void InvalidateWindows( CCoeControl* aControl ) |
|
84 { |
|
85 if ( aControl ) |
|
86 { |
|
87 if ( aControl->OwnsWindow() ) |
|
88 { |
|
89 static_cast<RWindow*>( aControl->DrawableWindow() )->ClearRedrawStore(); |
|
90 } |
|
91 |
|
92 for ( TInt i = aControl->CountComponentControls() - 1; i >= 0; --i ) |
|
93 { |
|
94 InvalidateWindows( aControl->ComponentControl( i ) ); |
|
95 } |
|
96 } |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CTsAppView::~CTsAppView |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 CTsAppView::~CTsAppView() |
|
104 { |
|
105 delete iBgContext; |
|
106 delete iFastSwapArea; |
|
107 delete iAppsHeading; |
|
108 |
|
109 delete iEvtHandler; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CTsAppView::ConstructL |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CTsAppView::ConstructL( const TRect& aRect, RWindowGroup& aWg ) |
|
117 { |
|
118 TSLOG_CONTEXT( CTsAppView::ConstructL, TSLOG_LOCAL ); |
|
119 TSLOG_IN(); |
|
120 |
|
121 // Create a window for this application view |
|
122 CreateWindowL(aWg); |
|
123 |
|
124 // Store rect |
|
125 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
126 TAknLayoutRect mainView; |
|
127 mainView.LayoutRect( aRect, |
|
128 AknLayoutScalable_Apps::main_tport_pane( variety ) ); |
|
129 iViewRect = mainView.Rect(); |
|
130 |
|
131 // Background control context is for a frame |
|
132 UpdatePopupRects(); |
|
133 iBgContext = CAknsFrameBackgroundControlContext::NewL( |
|
134 KAknsIIDQsnFrPopup, |
|
135 iBgContextOuterRect, |
|
136 iBgContextInnerRect, |
|
137 EFalse ); |
|
138 iBgContext->SetFrameRects(iBgContextOuterRect, iBgContextInnerRect); |
|
139 iBgContext->SetCenter( KAknsIIDQsnFrPopupCenter ); |
|
140 |
|
141 TSLOG4( TSLOG_INFO, "view rect = %d %d %d %d", |
|
142 iViewRect.iTl.iX, iViewRect.iTl.iY, |
|
143 iViewRect.iBr.iX, iViewRect.iBr.iY ); |
|
144 |
|
145 // Create components |
|
146 CreateControlsL(); |
|
147 |
|
148 // Hide 'active applications' item in Options menu |
|
149 CEikMenuBar* menub = iEikonEnv->AppUiFactory()->MenuBar(); |
|
150 if ( menub ) |
|
151 { |
|
152 menub->SetMenuType( CEikMenuBar::EMenuOptionsNoTaskSwapper ); |
|
153 } |
|
154 |
|
155 // Register for notifications about orientation etc. changes |
|
156 iDeviceState.AddObserverL( *this, MTsDeviceStateObserver::EAny ); |
|
157 SetRect( iViewRect ); |
|
158 //SetExtentToWholeScreen(); |
|
159 iViewRect = Rect(); |
|
160 // try to enable window transparency |
|
161 if( CAknEnv::Static()->TransparencyEnabled() ) |
|
162 { |
|
163 Window().SetRequiredDisplayMode( EColor16MA ); |
|
164 if ( Window().SetTransparencyAlphaChannel() == KErrNone ) |
|
165 { |
|
166 Window().SetBackgroundColor( ~0 ); |
|
167 } |
|
168 } |
|
169 |
|
170 DrawableWindow()->EnableBackup(EWindowBackupFullScreen); |
|
171 SetComponentsToInheritVisibility(ETrue); |
|
172 MakeVisible(EFalse); |
|
173 // Ready to be drawn |
|
174 ActivateL(); |
|
175 |
|
176 TSLOG_OUT(); |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CTsAppView::DisableAppSwitchEffects |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void CTsAppView::DisableAppSwitchEffects() |
|
184 { |
|
185 TInt flags = AknTransEffect::TParameter::ENoEffects; |
|
186 GfxTransEffect::BeginFullScreen( |
|
187 AknTransEffect::ENone, |
|
188 TRect(0,0,0,0), |
|
189 AknTransEffect::EParameterType, |
|
190 AknTransEffect::GfxTransParam( TUid::Uid(KTsAppUidValue), flags ) ); |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CTsAppView::GetPopupRects |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CTsAppView::UpdatePopupRects( ) |
|
198 { |
|
199 TSLOG_CONTEXT( UpdatePopupRects, TSLOG_LOCAL ); |
|
200 TSLOG_IN(); |
|
201 |
|
202 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
203 |
|
204 TAknLayoutRect bgTport; |
|
205 bgTport.LayoutRect( iViewRect, |
|
206 AknLayoutScalable_Apps::bg_popup_window_pane_cp01( variety ) ); |
|
207 iBgContextOuterRect = bgTport.Rect(); |
|
208 bgTport.LayoutRect( iBgContextOuterRect, |
|
209 AknLayoutScalable_Avkon::aid_inside_area_window_primary( variety ) ); |
|
210 iBgContextInnerRect = bgTport.Rect(); |
|
211 TSLOG4( TSLOG_INFO, "outer rect for popup = %d %d %d %d", |
|
212 iBgContextOuterRect.iTl.iX, iBgContextOuterRect.iTl.iY, |
|
213 iBgContextOuterRect.iBr.iX, iBgContextOuterRect.iBr.iY ); |
|
214 TSLOG4( TSLOG_INFO, "inner rect for popup = %d %d %d %d", |
|
215 iBgContextInnerRect.iTl.iX, iBgContextInnerRect.iTl.iY, |
|
216 iBgContextInnerRect.iBr.iX, iBgContextInnerRect.iBr.iY ); |
|
217 |
|
218 TSLOG_OUT(); |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CTsAppView::CreateControlsL |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CTsAppView::CreateControlsL() |
|
226 { |
|
227 RArray<TRect> rects; |
|
228 CleanupClosePushL( rects ); |
|
229 rects.ReserveL( 2 ); // so appending in GetRects cannot fail |
|
230 GetRects( rects ); |
|
231 |
|
232 iEvtHandler = CTsEventControler::NewL(*this, *this); |
|
233 iFastSwapArea = CTsFastSwapArea::NewL(rects[1], *this, |
|
234 iDeviceState, *iEvtHandler); |
|
235 iAppsHeading = new ( ELeave ) CAknPopupHeadingPane; |
|
236 |
|
237 iFastSwapArea->SetMopParent( this ); |
|
238 iFastSwapArea->SetFocusing( ETrue ); |
|
239 iFastSwapArea->Setup( *this ); |
|
240 iFastSwapArea->SetDataChangeObserver( this ); |
|
241 |
|
242 iAppsHeading->SetContainerWindowL( *this ); |
|
243 iAppsHeading->ConstructL( KNullDesC() ); |
|
244 iAppsHeading->SetLayout( CAknPopupHeadingPane::EListHeadingPane ); |
|
245 |
|
246 //TODO: check why we need to set rect (set already in contructL) |
|
247 iFastSwapArea->SetRect( rects[1] ); // cannot be before iAppsHeading constructL |
|
248 iAppsHeading->SetRect( rects[0] ); |
|
249 |
|
250 CleanupStack::PopAndDestroy( &rects ); |
|
251 |
|
252 UpdateHeadingsL(0); |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CTsAppView::GetRects |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 void CTsAppView::GetRects( RArray<TRect>& aRects ) |
|
260 { |
|
261 TSLOG_CONTEXT( CTsAppView::GetRects, TSLOG_LOCAL ); |
|
262 TSLOG_IN(); |
|
263 |
|
264 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
265 |
|
266 TAknLayoutRect appsLabel; |
|
267 TAknLayoutRect fastSwapAreaPane; |
|
268 |
|
269 appsLabel.LayoutRect( iViewRect, |
|
270 AknLayoutScalable_Apps::heading_pane_cp07( variety ) ); |
|
271 TSLOG4( TSLOG_INFO, "apps heading rect = %d %d %d %d", |
|
272 appsLabel.Rect().iTl.iX, appsLabel.Rect().iTl.iY, |
|
273 appsLabel.Rect().iBr.iX, appsLabel.Rect().iBr.iY ); |
|
274 |
|
275 |
|
276 fastSwapAreaPane.LayoutRect( iViewRect, |
|
277 AknLayoutScalable_Apps::tport_appsw_pane( variety ) ); |
|
278 TSLOG4( TSLOG_INFO, "fsw rect = %d %d %d %d", |
|
279 fastSwapAreaPane.Rect().iTl.iX, fastSwapAreaPane.Rect().iTl.iY, |
|
280 fastSwapAreaPane.Rect().iBr.iX, fastSwapAreaPane.Rect().iBr.iY ); |
|
281 |
|
282 aRects.Append( appsLabel.Rect() ); |
|
283 aRects.Append( fastSwapAreaPane.Rect() ); |
|
284 |
|
285 TSLOG_OUT(); |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CTsAppView::SizeChanged |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 void CTsAppView::SizeChanged() |
|
293 { |
|
294 TSLOG_CONTEXT( CTsAppView::SizeChanged, TSLOG_LOCAL ); |
|
295 TSLOG_IN(); |
|
296 iViewRect = Rect(); |
|
297 UpdatePopupRects(); |
|
298 iBgContext->SetFrameRects(iBgContextOuterRect, iBgContextInnerRect); |
|
299 iBgContext->SetParentPos(PositionRelativeToScreen()); |
|
300 if ( iFastSwapArea && iAppsHeading ) |
|
301 { |
|
302 RArray<TRect> rects; |
|
303 // make sure that appending in GetRect cannot fail |
|
304 if ( rects.Reserve( 2 ) == KErrNone ) |
|
305 { |
|
306 GetRects( rects ); |
|
307 iAppsHeading->SetRect( rects[0] ); |
|
308 iFastSwapArea->SetRect( rects[1] ); |
|
309 |
|
310 DrawDeferred(); |
|
311 } |
|
312 rects.Close(); |
|
313 |
|
314 // Focus jumps back to fsw |
|
315 ChangeFocus( iFastSwapArea ); |
|
316 } |
|
317 |
|
318 TSLOG_OUT(); |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CTsAppView::Draw |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 void CTsAppView::Draw( const TRect& /*aRect*/ ) const |
|
326 { |
|
327 CWindowGc& gc = SystemGc(); |
|
328 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
329 AknsDrawUtils::DrawFrame( skin, |
|
330 gc, |
|
331 iBgContextOuterRect, |
|
332 iBgContextInnerRect, |
|
333 KAknsIIDQsnFrPopup, |
|
334 KAknsIIDQsnFrPopupCenter ); |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CTsAppView::MopSupplyObject |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 TTypeUid::Ptr CTsAppView::MopSupplyObject( TTypeUid aId ) |
|
342 { |
|
343 if ( aId.iUid == MAknsControlContext::ETypeId ) |
|
344 { |
|
345 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
346 } |
|
347 return CCoeControl::MopSupplyObject( aId ); |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CTsAppView::OfferKeyEventL |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 TKeyResponse CTsAppView::OfferKeyEventL( |
|
355 const TKeyEvent& aKeyEvent, |
|
356 TEventCode aType ) |
|
357 { |
|
358 TSLOG_CONTEXT( OfferKeyEventL, TSLOG_LOCAL ); |
|
359 TSLOG2_IN( "iCode = %d type = %d", aKeyEvent.iCode, aType ); |
|
360 |
|
361 TKeyResponse result = EKeyWasNotConsumed; |
|
362 |
|
363 // Always use the portrait version, the layout in landscape is now |
|
364 // similar to portrait. |
|
365 result = OfferKeyEventPortraitStyleL( aKeyEvent, aType ); |
|
366 |
|
367 // handle some other keys |
|
368 if ( result == EKeyWasNotConsumed && aType == EEventKey ) |
|
369 { |
|
370 switch ( aKeyEvent.iCode ) |
|
371 { |
|
372 case EKeyYes: // send (green) key |
|
373 result = EKeyWasConsumed; |
|
374 break; |
|
375 } |
|
376 } |
|
377 |
|
378 // forward to focused control if not yet handled |
|
379 if ( result == EKeyWasNotConsumed && iFocused ) |
|
380 { |
|
381 result = iFocused->OfferKeyEventL( aKeyEvent, aType ); |
|
382 } |
|
383 |
|
384 TSLOG1_OUT( "response = %d", result ); |
|
385 return result; |
|
386 } |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // CTsAppView::OfferKeyEventPortraitStyleL |
|
390 // ----------------------------------------------------------------------------- |
|
391 // |
|
392 TKeyResponse CTsAppView::OfferKeyEventPortraitStyleL( |
|
393 const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) |
|
394 { |
|
395 TKeyResponse result = EKeyWasNotConsumed; |
|
396 return result; |
|
397 } |
|
398 |
|
399 |
|
400 // ----------------------------------------------------------------------------- |
|
401 // CTsAppView::CountComponentControls |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 TInt CTsAppView::CountComponentControls() const |
|
405 { |
|
406 return 2; |
|
407 } |
|
408 |
|
409 // ----------------------------------------------------------------------------- |
|
410 // CTsAppView::ComponentControl |
|
411 // ----------------------------------------------------------------------------- |
|
412 // |
|
413 CCoeControl* CTsAppView::ComponentControl( TInt aIndex ) const |
|
414 { |
|
415 switch ( aIndex ) |
|
416 { |
|
417 case 0: |
|
418 return iFastSwapArea; |
|
419 case 1: |
|
420 return iAppsHeading; |
|
421 default: |
|
422 return NULL; |
|
423 } |
|
424 } |
|
425 |
|
426 // ----------------------------------------------------------------------------- |
|
427 // CTsAppView::HandleSwitchToBackgroundEvent |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 void CTsAppView::HandleSwitchToBackgroundEvent() |
|
431 { |
|
432 iPopupFader.FadeBehindPopup( this, NULL, EFalse ); |
|
433 |
|
434 iFastSwapArea->HandleSwitchToBackgroundEvent(); |
|
435 |
|
436 } |
|
437 |
|
438 // ----------------------------------------------------------------------------- |
|
439 // CTsAppView::HandleSwitchToForegroundEvent |
|
440 // ----------------------------------------------------------------------------- |
|
441 // |
|
442 void CTsAppView::HandleSwitchToForegroundEvent() |
|
443 { |
|
444 TSLOG_CONTEXT( CTsAppView::HandleSwitchToForegroundEvent, TSLOG_LOCAL ); |
|
445 TSLOG_IN(); |
|
446 |
|
447 // Forward event to interested controls |
|
448 iFastSwapArea->HandleSwitchToForegroundEvent(); |
|
449 |
|
450 // Check for layout updates |
|
451 CTsAppUi* appUi = static_cast<CTsAppUi*>(iCoeEnv->AppUi()); |
|
452 if ( iViewRect != appUi->ApplicationRect() && |
|
453 appUi->LayoutChangeAllowed() ) |
|
454 { |
|
455 HandleDeviceStateChanged( EOrientation ); |
|
456 } |
|
457 |
|
458 Window().Invalidate(Rect()); |
|
459 |
|
460 iEvtHandler->EnableEventHandling(ETrue); |
|
461 |
|
462 // Fade behind the pop-up |
|
463 iPopupFader.FadeBehindPopup( this, NULL, ETrue ); |
|
464 |
|
465 DrawDeferred(); // otherwise some parts may not be drawn properly |
|
466 |
|
467 // Focus jumps back to fsw |
|
468 ChangeFocus( iFastSwapArea ); |
|
469 |
|
470 // Start animation |
|
471 CTsAppUi* appui = |
|
472 static_cast<CTsAppUi*>( iEikonEnv->AppUi() ); |
|
473 if ( appui->EffectsEnabled() ) |
|
474 { |
|
475 InvalidateWindows( this ); |
|
476 appui->StartTransion(CTsAppUi::EForegroundTransition); |
|
477 } |
|
478 else |
|
479 { |
|
480 CAknTransitionUtils::MakeVisibleSubComponents( this, |
|
481 CAknTransitionUtils::EForceVisible ); |
|
482 MakeVisible( ETrue ); |
|
483 } |
|
484 |
|
485 DrawDeferred(); |
|
486 |
|
487 TSLOG_OUT(); |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // CTsAppView::ChangeFocus |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 void CTsAppView::ChangeFocus( CCoeControl* aNewFocusedControl ) |
|
495 { |
|
496 if ( iFocused != aNewFocusedControl ) |
|
497 { |
|
498 if ( iFocused ) |
|
499 { |
|
500 iFocused->SetFocus( EFalse, EDrawNow ); |
|
501 } |
|
502 iFocused = aNewFocusedControl; |
|
503 if ( iFocused ) |
|
504 { |
|
505 iFocused->SetFocus( ETrue, EDrawNow ); |
|
506 } |
|
507 } |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // CTsAppView::HandleControlEventL |
|
512 // EEventRequestFocus must be handled to have proper focus change also with |
|
513 // pointer events. |
|
514 // Observed controls are the ganes list and grid. |
|
515 // ----------------------------------------------------------------------------- |
|
516 // |
|
517 void CTsAppView::HandleControlEventL( CCoeControl* aControl, |
|
518 TCoeEvent aEventType ) |
|
519 { |
|
520 switch ( aEventType ) |
|
521 { |
|
522 case EEventRequestFocus: |
|
523 // must use the parent because aControl is the ganes control |
|
524 ChangeFocus( aControl->Parent() ); |
|
525 break; |
|
526 } |
|
527 } |
|
528 |
|
529 // ----------------------------------------------------------------------------- |
|
530 // CTsAppView::HandleDeviceStateChanged |
|
531 // Called when screen orientation, touch awareness, or the skin has been changed. |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 void CTsAppView::HandleDeviceStateChanged( TChangeType aChangeType ) |
|
535 { |
|
536 TSLOG_CONTEXT( HandleDeviceStateChanged, TSLOG_LOCAL ); |
|
537 TSLOG_IN(); |
|
538 |
|
539 // Just set all the sizes, even when there is a skin change, because this will |
|
540 // guarantee proper redraw also with the ganes controls. |
|
541 |
|
542 if(aChangeType == EOrientation) |
|
543 { |
|
544 SetRect( static_cast<CAknAppUi*>(iEikonEnv->AppUi())->ApplicationRect() ); |
|
545 } |
|
546 else |
|
547 { |
|
548 iViewRect = Rect(); |
|
549 TSLOG4( TSLOG_INFO, "setting rect %d %d %d %d", |
|
550 iViewRect.iTl.iX, iViewRect.iTl.iY, |
|
551 iViewRect.iBr.iX, iViewRect.iBr.iY ); |
|
552 SetRect( iViewRect ); |
|
553 } |
|
554 |
|
555 InvalidateWindows(this); |
|
556 |
|
557 TSLOG_OUT(); |
|
558 } |
|
559 |
|
560 // ----------------------------------------------------------------------------- |
|
561 // CTsAppView::CountFadedComponents |
|
562 // ----------------------------------------------------------------------------- |
|
563 // |
|
564 TInt CTsAppView::CountFadedComponents() |
|
565 { |
|
566 return 3; |
|
567 } |
|
568 |
|
569 // ----------------------------------------------------------------------------- |
|
570 // CTsAppView::FadedComponent |
|
571 // ----------------------------------------------------------------------------- |
|
572 // |
|
573 CCoeControl* CTsAppView::FadedComponent( TInt aIndex ) |
|
574 { |
|
575 // well, these are in fact the components that will _not_ be faded... |
|
576 // Must return the bottom-level controls here, e.g. the ganes controls, not the wrappers over them. |
|
577 switch ( aIndex ) |
|
578 { |
|
579 case 0: |
|
580 return this; |
|
581 case 1: |
|
582 return iFastSwapArea->GetChildControl(); |
|
583 case 2: |
|
584 return iAppsHeading; |
|
585 // case 3: |
|
586 // return iEikonEnv->AppUiFactory()->Cba(); |
|
587 default: |
|
588 return NULL; |
|
589 } |
|
590 } |
|
591 |
|
592 // ----------------------------------------------------------------------------- |
|
593 // CTsAppView::HandlePointerEventL |
|
594 // ----------------------------------------------------------------------------- |
|
595 // |
|
596 void CTsAppView::HandlePointerEventL( const TPointerEvent &aPointerEvent ) |
|
597 { |
|
598 if( TPointerEvent::EButton1Down == aPointerEvent.iType ) |
|
599 { |
|
600 iEvtHandler->EnableEventHandling(ETrue); |
|
601 iExitOnPointerUp = EFalse; |
|
602 |
|
603 if( !DragArea().Contains(aPointerEvent.iParentPosition) || |
|
604 !iFastSwapArea->Count() ) |
|
605 { |
|
606 //move task switcher to background |
|
607 iEvtHandler->EnableEventHandling(EFalse); |
|
608 if ( !iAppsHeading->Rect().Contains( aPointerEvent.iParentPosition ) || |
|
609 !iFastSwapArea->Count() ) |
|
610 { |
|
611 iExitOnPointerUp = ETrue; |
|
612 } |
|
613 } |
|
614 else if ( !iAppsHeading->Rect().Contains( aPointerEvent.iParentPosition ) || |
|
615 !iFastSwapArea->Count() ) |
|
616 { |
|
617 // Feedback only on "active" areas of UI |
|
618 LaunchFeedback(ETouchFeedbackBasic, TTouchFeedbackType( |
|
619 ETouchFeedbackVibra | ETouchFeedbackAudio), aPointerEvent); |
|
620 } |
|
621 } |
|
622 else if( TPointerEvent::EButton1Up == aPointerEvent.iType && iExitOnPointerUp ) |
|
623 { |
|
624 // Possible exit, check if pointer up is outside of control area |
|
625 if( ( !DragArea().Contains(aPointerEvent.iParentPosition) && |
|
626 !iAppsHeading->Rect().Contains(aPointerEvent.iParentPosition) ) || |
|
627 !iFastSwapArea->Count() ) |
|
628 { |
|
629 LaunchFeedback(ETouchFeedbackBasic, TTouchFeedbackType( |
|
630 ETouchFeedbackVibra ), aPointerEvent); |
|
631 iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit); |
|
632 } |
|
633 } |
|
634 iFastSwapArea->HandlePointerEventL(aPointerEvent); |
|
635 } |
|
636 |
|
637 // ----------------------------------------------------------------------------- |
|
638 // CTsAppView::DataChanged |
|
639 // ----------------------------------------------------------------------------- |
|
640 // |
|
641 void CTsAppView::DataChanged( CCoeControl* /*aWhere*/, TInt aNewCount ) |
|
642 { |
|
643 TRAP_IGNORE( UpdateHeadingsL( aNewCount ) ); |
|
644 } |
|
645 |
|
646 // ----------------------------------------------------------------------------- |
|
647 // CTsAppView::UpdateHeadingsL |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 void CTsAppView::UpdateHeadingsL( TInt aNewCount ) |
|
651 { |
|
652 HBufC* text = StringLoader::LoadLC( |
|
653 R_TASK_SWITCHER_HEADING_APPLICATIONS, aNewCount ); |
|
654 iAppsHeading->SetTextL( *text ); |
|
655 iAppsHeading->DrawDeferred(); |
|
656 CleanupStack::PopAndDestroy( text ); |
|
657 } |
|
658 |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // CTsAppView::HandleAppKey |
|
662 // ----------------------------------------------------------------------------- |
|
663 // |
|
664 void CTsAppView::HandleAppKey(TInt aType) |
|
665 { |
|
666 iFastSwapArea->HandleAppKey(aType); |
|
667 } |
|
668 |
|
669 |
|
670 // ----------------------------------------------------------------------------- |
|
671 // CTsAppView::OrderBackgrRedraw |
|
672 // ----------------------------------------------------------------------------- |
|
673 // |
|
674 void CTsAppView::OrderFullWindowRedraw() |
|
675 { |
|
676 InvalidateWindows(this); |
|
677 DrawNow(); |
|
678 } |
|
679 |
|
680 |
|
681 // ----------------------------------------------------------------------------- |
|
682 // CTsAppView::EnableDragEvents |
|
683 // ----------------------------------------------------------------------------- |
|
684 // |
|
685 void CTsAppView::EnableDragEvents( TBool aEnable ) |
|
686 { |
|
687 iEvtHandler->EnableDragEventHandling( aEnable ); |
|
688 } |
|
689 |
|
690 |
|
691 // ----------------------------------------------------------------------------- |
|
692 // CTsAppView::MoveOffset |
|
693 // ----------------------------------------------------------------------------- |
|
694 // |
|
695 void CTsAppView::MoveOffset(const TPoint& aOffset, TBool aDrawNow) |
|
696 { |
|
697 if ( aDrawNow ) |
|
698 { |
|
699 DrawDeferred(); |
|
700 } |
|
701 iFastSwapArea->MoveOffset(aOffset, aDrawNow); |
|
702 } |
|
703 |
|
704 // ----------------------------------------------------------------------------- |
|
705 // CTsAppView::TapL |
|
706 // ----------------------------------------------------------------------------- |
|
707 // |
|
708 void CTsAppView::TapL(const TPoint& aPoint) |
|
709 { |
|
710 if(iFastSwapArea->Rect().Contains(aPoint)) |
|
711 { |
|
712 iFastSwapArea->TapL(aPoint); |
|
713 DrawNow(); |
|
714 } |
|
715 } |
|
716 |
|
717 // ----------------------------------------------------------------------------- |
|
718 // CTsAppView::LongTapL |
|
719 // ----------------------------------------------------------------------------- |
|
720 // |
|
721 void CTsAppView::LongTapL(const TPoint& aPoint) |
|
722 { |
|
723 if(iFastSwapArea->Rect().Contains(aPoint)) |
|
724 { |
|
725 iFastSwapArea->LongTapL(aPoint); |
|
726 } |
|
727 } |
|
728 |
|
729 // ----------------------------------------------------------------------------- |
|
730 // CTsAppView::DragL() |
|
731 // ----------------------------------------------------------------------------- |
|
732 // |
|
733 void CTsAppView::DragL(const MAknTouchGestureFwDragEvent& aEvent) |
|
734 { |
|
735 if(DragArea().Contains(aEvent.StartPosition())) |
|
736 { |
|
737 iFastSwapArea->DragL(aEvent); |
|
738 } |
|
739 } |
|
740 |
|
741 // ----------------------------------------------------------------------------- |
|
742 // CTsAppView::Stop |
|
743 // ----------------------------------------------------------------------------- |
|
744 // |
|
745 void CTsAppView::Stop() |
|
746 { |
|
747 iFastSwapArea->Stop(); |
|
748 } |
|
749 |
|
750 // ----------------------------------------------------------------------------- |
|
751 // CTsAppView::ViewPos |
|
752 // ----------------------------------------------------------------------------- |
|
753 // |
|
754 TPoint CTsAppView::ViewPos() const |
|
755 { |
|
756 return iFastSwapArea->ViewPos(); |
|
757 } |
|
758 |
|
759 // ----------------------------------------------------------------------------- |
|
760 // CTsAppView::LaunchFeedback |
|
761 // ----------------------------------------------------------------------------- |
|
762 // |
|
763 void CTsAppView::LaunchFeedback( TTouchLogicalFeedback aLogicalType, |
|
764 TTouchFeedbackType aFeedbackType, |
|
765 const TPointerEvent& aPointerEvent) |
|
766 { |
|
767 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
768 if(0 != feedback) |
|
769 { |
|
770 feedback->InstantFeedback(this, aLogicalType, |
|
771 aFeedbackType, |
|
772 aPointerEvent); |
|
773 } |
|
774 } |
|
775 |
|
776 |
|
777 // ----------------------------------------------------------------------------- |
|
778 // CTsAppView::AppCloseInProgress() |
|
779 // ----------------------------------------------------------------------------- |
|
780 // |
|
781 TBool CTsAppView::AppCloseInProgress( TInt aWgId ) |
|
782 { |
|
783 return iFastSwapArea->IsAppClosing(aWgId); |
|
784 } |
|
785 |
|
786 |
|
787 // ----------------------------------------------------------------------------- |
|
788 // CTsAppView::WgOnTaskList() |
|
789 // ----------------------------------------------------------------------------- |
|
790 // |
|
791 TBool CTsAppView::WgOnTaskList( TInt aWgId ) |
|
792 { |
|
793 return iFastSwapArea->WgOnTaskList(aWgId); |
|
794 } |
|
795 |
|
796 // ----------------------------------------------------------------------------- |
|
797 // CTsAppView::DragArea |
|
798 // ----------------------------------------------------------------------------- |
|
799 // |
|
800 TRect CTsAppView::DragArea() |
|
801 { |
|
802 TRect dragArea; |
|
803 if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
804 { |
|
805 dragArea.SetRect(iAppsHeading->Rect().iTl.iX, |
|
806 iFastSwapArea->Rect().iTl.iY, iFastSwapArea->Rect().iBr.iX, |
|
807 iFastSwapArea->Rect().iBr.iY); |
|
808 } |
|
809 else |
|
810 { |
|
811 dragArea.SetRect(Rect().iTl.iX, iFastSwapArea->Rect().iTl.iY, |
|
812 Rect().iBr.iX, iFastSwapArea->Rect().iBr.iY); |
|
813 } |
|
814 return dragArea; |
|
815 } |
|
816 |
|
817 |
|
818 // End of file |