uifw/AvKon/src/akndigitalclock.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
     1 /*
     1 /*
     2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   321         {
   321         {
   322         CWindowGc& gc = SystemGc();
   322         CWindowGc& gc = SystemGc();
   323 
   323 
   324         TRect rect( Rect() );
   324         TRect rect( Rect() );
   325 
   325 
   326         if ( iFlags & EAknDigitalClockInStatusPane )
   326         const MCoeControlBackground* backgroundDrawer = FindBackground();
       
   327         if ( !backgroundDrawer &&
       
   328              iFlags & EAknDigitalClockInStatusPane )
   327             {
   329             {
   328             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   330             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   329             MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
   331             MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
   330             AknsDrawUtils::Background( skin, cc, this, gc, Rect() );
   332             AknsDrawUtils::Background( skin, cc, this, gc, Rect() );
   331             }
   333             }
   351     }
   353     }
   352 
   354 
   353 
   355 
   354 // -----------------------------------------------------------------------------
   356 // -----------------------------------------------------------------------------
   355 // CAknDigitalClock::HandlePointerEventL
   357 // CAknDigitalClock::HandlePointerEventL
   356 // Starts clock application in down event.
   358 // Opens the universal indicator popup upon tap.
   357 // -----------------------------------------------------------------------------
   359 // -----------------------------------------------------------------------------
   358 //
   360 //
   359 void CAknDigitalClock::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   361 void CAknDigitalClock::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   360     {
   362     {
   361     CAknControl:: HandlePointerEventL( aPointerEvent );
   363     CAknControl::HandlePointerEventL( aPointerEvent );
   362 
   364 
   363     if ( AknLayoutUtils::PenEnabled() )
   365     // Do nothing if dimmed.
   364         {
   366     if ( IsDimmed() || Window().IsFaded() )
   365         // Do nothing if dimmed.
   367         {
   366         if ( IsDimmed() ||
   368         return;
   367              Window().IsFaded() )
   369         }
   368             {
   370 
   369             return;
   371     TRect rect( Rect() );
   370             }
   372 
   371 
   373     // Currently the small digital clock pane, universal
   372         TRect rect( Rect() );
   374     // indicator pane and battery pane (in status pane layouts
   373 
   375     // where it's adjacent to universal indicator or digital
   374         // Currently the small digital clock pane and universal
   376     // clock pane) are regarded as one touch responsive
   375         // indicator pane are regarded as one touch responsive area from
   377     // area from which the universal indicator popup should
   376         // which the universal indicator popup should open on tap,
   378     // open on tap, so upon pointer up event it must be checked
   377         // so upon pointer up event it must be checked here if
   379     // here if the down event happened inside this control,
   378         // the down event happened inside this control, but the up event
   380     // but the up event inside battery or indicator pane area.
   379         // inside indicator pane area.
   381     TBool pointerUpInIndicatorArea( EFalse );
   380         TRect indicatorRect( 0, 0, 0, 0 );
   382     TBool pointerUpInBatteryArea( EFalse );
   381 
   383 
   382         if ( iFlags & EAknDigitalClockInStatusPane &&
   384     if ( iFlags & EAknDigitalClockInStatusPane &&
   383              aPointerEvent.iType == TPointerEvent::EButton1Up )
   385          aPointerEvent.iType == TPointerEvent::EButton1Up )
   384             {
   386         {
   385             CEikStatusPaneBase* sp = CEikStatusPaneBase::Current();
   387         CEikStatusPaneBase* sp = CEikStatusPaneBase::Current();
   386 
   388 
   387             if ( sp )
   389         if ( sp )
       
   390             {
       
   391             CCoeControl* indicatorPane = sp->ContainerControlL(
       
   392                 TUid::Uid( EEikStatusPaneUidIndic ) );
       
   393             if ( indicatorPane )
   388                 {
   394                 {
   389                 CCoeControl* indicatorPane = sp->ContainerControlL(
   395                 TRect indicatorRect( indicatorPane->PositionRelativeToScreen(),
   390                     TUid::Uid( EEikStatusPaneUidIndic ) );
   396                                      indicatorPane->Size() );
   391                 if ( indicatorPane )
   397                 pointerUpInIndicatorArea =
       
   398                     indicatorRect.Contains( aPointerEvent.iParentPosition );
       
   399                 }
       
   400             
       
   401             if ( !AknStatuspaneUtils::ExtendedFlatLayoutActive() )
       
   402                 {
       
   403                 CCoeControl* batteryPane = sp->ContainerControlL(
       
   404                     TUid::Uid( EEikStatusPaneUidBattery ) );
       
   405                 if ( batteryPane )
   392                     {
   406                     {
   393                     indicatorRect =
   407                     TRect batteryRect( batteryPane->PositionRelativeToScreen(),
   394                         TRect( indicatorPane->PositionRelativeToScreen(),
   408                                        batteryPane->Size() );
   395                                indicatorPane->Size() );
   409                     pointerUpInBatteryArea =
       
   410                         batteryRect.Contains( aPointerEvent.iParentPosition );
   396                     }
   411                     }
   397                 }
   412                 }
   398             }
   413             }
   399 
   414         }
   400         if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   415 
   401              rect.Contains( aPointerEvent.iPosition ) )
   416     if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   402             {
   417          rect.Contains( aPointerEvent.iPosition ) )
   403             // Set flag that down event was inside the clock.
   418         {
   404             iFlags |= EAknDigitalClockButton1DownReceived;
   419         // Set flag that down event was inside the clock.
   405 
   420         iFlags |= EAknDigitalClockButton1DownReceived;
   406             // tactile feedback is done with SetFeedbackArea
   421 
       
   422         // tactile feedback is done with SetFeedbackArea
       
   423         }
       
   424     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up &&
       
   425               ( ( iFlags & EAknDigitalClockButton1DownReceived &&
       
   426                   rect.Contains( aPointerEvent.iPosition ) ) ||
       
   427                 pointerUpInIndicatorArea ||
       
   428                 pointerUpInBatteryArea ) )
       
   429         {
       
   430         if ( pointerUpInIndicatorArea || pointerUpInBatteryArea )
       
   431             {
       
   432             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   433             if ( feedback )
       
   434                 {
       
   435                 // The pointer down was received in another control,
       
   436                 // so the tactile feedback must be given directly.
       
   437                 feedback->InstantFeedback( this,
       
   438                                            ETouchFeedbackSensitiveButton,
       
   439                                            ETouchFeedbackVibra,
       
   440                                            aPointerEvent );
       
   441                 }
   407             }
   442             }
   408         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up &&
   443     
   409                   ( ( iFlags & EAknDigitalClockButton1DownReceived &&
   444         // Launch the universal indicator popup.
   410                       rect.Contains( aPointerEvent.iPosition ) ) ||
   445         CAknSmallIndicator* indicatorNotifier =
   411                     ( indicatorRect.Contains( aPointerEvent.iParentPosition ) ) ) )
   446             CAknSmallIndicator::NewLC( TUid::Uid( 0 ) );
   412             {
   447         indicatorNotifier->HandleIndicatorTapL();
   413             // Launch the universal indicator popup.
   448         //for indicator popup event
   414             CAknSmallIndicator* indicatorNotifier =
   449         MTouchFeedback* feedback = MTouchFeedback::Instance();
   415                 CAknSmallIndicator::NewLC( TUid::Uid( 0 ) );
   450         if ( feedback )
   416             indicatorNotifier->HandleIndicatorTapL();
   451             {
   417             CleanupStack::PopAndDestroy( indicatorNotifier );
   452             feedback->InstantFeedback(
   418 
   453                                this,
   419             // Up event received, reset button down flag.
   454                                ETouchFeedbackPopUp,
   420             iFlags &= ( ~EAknDigitalClockButton1DownReceived );
   455                                ETouchFeedbackVibra,
       
   456                                aPointerEvent );
   421             }
   457             }
       
   458         CleanupStack::PopAndDestroy( indicatorNotifier );
       
   459 
       
   460         // Up event received, reset button down flag.
       
   461         iFlags &= ( ~EAknDigitalClockButton1DownReceived );
   422         }
   462         }
   423     }
   463     }
   424 
   464 
   425 
   465 
   426 // -----------------------------------------------------------------------------
   466 // -----------------------------------------------------------------------------