profilesservices/FileList/Src/CFLDCommandAbsorbingControl.cpp
branchRCL_3
changeset 24 8ee96d21d9bf
parent 23 8bda91a87a00
child 25 7e0eff37aedb
equal deleted inserted replaced
23:8bda91a87a00 24:8ee96d21d9bf
     1 /*
       
     2 * Copyright (c) 2003 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:  Command absorber to eat all key presses.
       
    15 *
       
    16 */
       
    17 
       
    18 // CLASS HEADER
       
    19 #include "CFLDCommandAbsorbingControl.h"
       
    20 
       
    21 // INTERNAL INCLUDES
       
    22 
       
    23 // EXTERNAL INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <eikappui.h>
       
    26 #include <eikenv.h>
       
    27 #include <eikbtgpc.h>
       
    28 
       
    29 // CONSTANTS
       
    30 namespace
       
    31 	{
       
    32 	//position 0 --> left
       
    33 	const TInt KLeftPosition( 0 );
       
    34     //position 2 --> right
       
    35    	const TInt KRightPosition( 2 );
       
    36 	}
       
    37 
       
    38 // ============================ MEMBER FUNCTIONS ===============================
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CFLDCommandAbsorbingControl::NewL
       
    42 // Two-phased constructor.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CFLDCommandAbsorbingControl* CFLDCommandAbsorbingControl::NewL()
       
    46     {
       
    47     CFLDCommandAbsorbingControl* self = CFLDCommandAbsorbingControl::NewLC();
       
    48     CleanupStack::Pop();
       
    49     return self;
       
    50     }
       
    51     
       
    52 // -----------------------------------------------------------------------------
       
    53 // CFLDCommandAbsorbingControl::NewLC
       
    54 // Two-phased constructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CFLDCommandAbsorbingControl* CFLDCommandAbsorbingControl::NewLC()
       
    58     {
       
    59     CFLDCommandAbsorbingControl* self = new ( ELeave ) CFLDCommandAbsorbingControl();
       
    60 
       
    61     CleanupStack::PushL( self );
       
    62     self->ConstructL();
       
    63 
       
    64     return self;
       
    65     }
       
    66 
       
    67 // Destructor
       
    68 CFLDCommandAbsorbingControl::~CFLDCommandAbsorbingControl()
       
    69     {
       
    70   	Release();
       
    71     }
       
    72 
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CFLDCommandAbsorbingControl::CFLDPopupList
       
    76 // C++ constructor can NOT contain any code, that might leave.
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 CFLDCommandAbsorbingControl::CFLDCommandAbsorbingControl()
       
    80     {
       
    81     }
       
    82 
       
    83 
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CFLDCommandAbsorbingControl::ConstructL
       
    87 // Symbian 2nd phase constructor can leave.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CFLDCommandAbsorbingControl::ConstructL()
       
    91     {
       
    92     //if we don't have aplication ui,
       
    93     //then there is no need to consume commands
       
    94     iAppUi = CEikonEnv::Static()->EikAppUi();
       
    95     if( iAppUi )
       
    96         {
       
    97         //add self to eat key events
       
    98         iAppUi->AddToStackL( this, ECoeStackPriorityDialog );
       
    99         }
       
   100     }
       
   101 
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CFLDCommandAbsorbingControl::OfferKeyEventL()
       
   105 // (other items were commented in a header).
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 TKeyResponse CFLDCommandAbsorbingControl::OfferKeyEventL( const TKeyEvent& /*aKeyEvent*/,
       
   109                                                            TEventCode /*aType*/ )
       
   110     {
       
   111    	return EKeyWasConsumed;
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CFLDCommandAbsorbingControl::Release()
       
   116 // (other items were commented in a header).
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 void CFLDCommandAbsorbingControl::Release()
       
   120 	{
       
   121 	  if( iAppUi )
       
   122         {
       
   123         //remove self
       
   124         iAppUi->RemoveFromStack( this );
       
   125         }
       
   126 	}
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CFLDCommandAbsorbingControl::MakeCbaVisible()
       
   130 // (other items were commented in a header).
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void CFLDCommandAbsorbingControl::MakeCbaVisible( TBool aVisible ) const
       
   134     {
       
   135     //position 0 --> left
       
   136     TInt leftId( iCba->ButtonGroup()->CommandId( KLeftPosition ) );  
       
   137     //position 2 --> right
       
   138     TInt rightId( iCba->ButtonGroup()->CommandId( KRightPosition ) ); 
       
   139 
       
   140     iCba->MakeCommandVisible( leftId, aVisible );
       
   141     iCba->MakeCommandVisible( rightId, aVisible );
       
   142 
       
   143     iCba->DrawNow();
       
   144     }
       
   145 
       
   146 
       
   147 //  End of File
       
   148 
       
   149 
       
   150 
       
   151 
       
   152 
       
   153