uifw/AvKon/aknphysics/src/aknphysicskeyconsumer.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2009 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:  AknPhysics key consuming control
       
    15 *
       
    16 */
       
    17 
       
    18 #include <aknappui.h>
       
    19 
       
    20 #include "aknphysicsconeobserver.h"
       
    21 #include "aknphysicskeyconsumer.h"
       
    22 
       
    23 // ======== MEMBER FUNCTIONS ========
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // CAknPhysicsKeyConsumer::NewL
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 CAknPhysicsKeyConsumer* CAknPhysicsKeyConsumer::NewL(
       
    30     CAknPhysicsConeObserver* aConeObserver )
       
    31     {
       
    32     CAknPhysicsKeyConsumer* self = 
       
    33         CAknPhysicsKeyConsumer::NewLC( aConeObserver );
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CAknPhysicsKeyConsumer::NewLC
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 CAknPhysicsKeyConsumer* CAknPhysicsKeyConsumer::NewLC( 
       
    44     CAknPhysicsConeObserver* aConeObserver )
       
    45     {
       
    46     CAknPhysicsKeyConsumer* self 
       
    47         = new ( ELeave ) CAknPhysicsKeyConsumer( aConeObserver );
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     return self;
       
    51     }
       
    52 
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CAknPhysicsKeyConsumer::~CAknPhysicsKeyConsumer
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CAknPhysicsKeyConsumer::~CAknPhysicsKeyConsumer()
       
    59     {
       
    60     }
       
    61 
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CAknPhysicsKeyConsumer::CAknPhysicsKeyConsumer
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CAknPhysicsKeyConsumer::CAknPhysicsKeyConsumer( 
       
    68     CAknPhysicsConeObserver* aConeObserver )
       
    69     :
       
    70     iConeObserver( aConeObserver )
       
    71     {
       
    72     }
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CAknPhysicsKeyConsumer::ConstructL
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void CAknPhysicsKeyConsumer::ConstructL()
       
    80     {
       
    81     }
       
    82 
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CAknPhysicsKeyConsumer::OfferKeyEventL
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 TKeyResponse CAknPhysicsKeyConsumer::OfferKeyEventL( 
       
    89     const TKeyEvent& aKeyEvent, TEventCode aType )
       
    90     {
       
    91     TKeyResponse response( EKeyWasNotConsumed );
       
    92     
       
    93     // EKeyEscape can't be blocked otherwise dialog or menu will not be
       
    94     // closed correctly when user pressed end key or application key
       
    95     TBool dialogShutEvent(
       
    96             aType == EEventKey
       
    97             && aKeyEvent.iCode == EKeyEscape
       
    98             && iCoeEnv->AppUi()->IsDisplayingMenuOrDialog() );
       
    99     
       
   100     if ( !dialogShutEvent && iConeObserver 
       
   101         && !iConeObserver->EventHandlingAllowed() )
       
   102         {
       
   103         response = EKeyWasConsumed;
       
   104         }
       
   105 
       
   106     return response;
       
   107     }