phonebookui/Phonebook/View/src/CPbkInputAbsorber.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *      Methods for control which absorbs all keyboard and CBA events.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPbkInputAbsorber.h"
       
    22 #include <eikenv.h>
       
    23 #include <eikappui.h>
       
    24 #include <eikbtgpc.h>
       
    25 #include <avkon.rsg>
       
    26 
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 inline CPbkInputAbsorber::CPbkInputAbsorber()
       
    31     {
       
    32     }
       
    33 
       
    34 inline void CPbkInputAbsorber::InitControlL()
       
    35     {
       
    36     MakeVisible(EFalse);
       
    37 	SetExtent(TPoint(0,0), TSize(0,0));
       
    38 	CreateWindowL();
       
    39     }
       
    40 
       
    41 inline void CPbkInputAbsorber::CaptureEventsL()
       
    42     {
       
    43     SetPointerCapture(ETrue);
       
    44 	ClaimPointerGrab(ETrue);
       
    45     CEikAppUi* appUi = iEikonEnv->EikAppUi();
       
    46     appUi->AddToStackL(this, ECoeStackPriorityDialog);
       
    47     iAppUi = appUi;
       
    48     }
       
    49 
       
    50 inline void CPbkInputAbsorber::InitCbaL(TInt aCbaResource)
       
    51     {
       
    52     if (!aCbaResource)
       
    53         {
       
    54         aCbaResource = R_AVKON_SOFTKEYS_EMPTY;
       
    55         }
       
    56     iCba = CEikButtonGroupContainer::NewL
       
    57         (CEikButtonGroupContainer::ECba, 
       
    58         CEikButtonGroupContainer::EHorizontal, 
       
    59         this, 
       
    60         aCbaResource, 
       
    61         *this);
       
    62 	const TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels();
       
    63 	iCba->SetBoundingRect(TRect(screenSize));
       
    64     }
       
    65 
       
    66 inline void CPbkInputAbsorber::ConstructL(TInt aCbaResource)
       
    67     {
       
    68     InitControlL();
       
    69     CaptureEventsL();
       
    70     InitCbaL(aCbaResource);
       
    71 	iWait = new (ELeave) CActiveSchedulerWait();
       
    72     }
       
    73 
       
    74 CPbkInputAbsorber* CPbkInputAbsorber::NewL(TInt aCbaResource/*=0*/)
       
    75     {
       
    76     CPbkInputAbsorber* self = CPbkInputAbsorber::NewLC(aCbaResource);
       
    77     CleanupStack::Pop(self);
       
    78     return self;
       
    79     }
       
    80 
       
    81 CPbkInputAbsorber* CPbkInputAbsorber::NewLC(TInt aCbaResource/*=0*/)
       
    82     {
       
    83     CPbkInputAbsorber* self = new (ELeave) CPbkInputAbsorber;
       
    84     CleanupStack::PushL(self);
       
    85     self->ConstructL(aCbaResource);
       
    86     return self;
       
    87     }
       
    88 
       
    89 CPbkInputAbsorber::~CPbkInputAbsorber()
       
    90     {
       
    91     StopWait();
       
    92     delete iCba;
       
    93 	delete iWait;
       
    94 	if (iCoeEnv && iAppUi)
       
    95         {
       
    96 		iAppUi->RemoveFromStack(this);
       
    97         }
       
    98     }
       
    99 
       
   100 void CPbkInputAbsorber::SetCommandObserver(MEikCommandObserver* aCmdObserver)
       
   101     {
       
   102     iCmdObserver = aCmdObserver;
       
   103     }
       
   104 
       
   105 void CPbkInputAbsorber::Wait()
       
   106     {
       
   107     if (iWait->IsStarted())
       
   108         {
       
   109         iWait->AsyncStop();
       
   110         }
       
   111     iWait->Start();
       
   112     }
       
   113 
       
   114 void CPbkInputAbsorber::StopWait()
       
   115     {
       
   116     if ((iWait) && (iWait->IsStarted()))
       
   117         {
       
   118         iWait->AsyncStop();
       
   119         }
       
   120     }
       
   121 
       
   122 TBool CPbkInputAbsorber::IsWaiting() const
       
   123     {
       
   124     return iWait->IsStarted();
       
   125     }
       
   126 
       
   127 TKeyResponse CPbkInputAbsorber::OfferKeyEventL
       
   128         (const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
       
   129     {
       
   130     return EKeyWasConsumed;
       
   131     }
       
   132 
       
   133 void CPbkInputAbsorber::ProcessCommandL(TInt aCommandId)
       
   134     {
       
   135     if (iCmdObserver)
       
   136         {
       
   137         iCmdObserver->ProcessCommandL(aCommandId);
       
   138         }
       
   139     }
       
   140 
       
   141 //  End of File