examples/Graphics/WS/transparent/eventhandler.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 // This encapsulates both issuing a request for getting pointer events to an asynchronous service provider
00015 // and handling the completed requests.
00016 //
00017 
00018 
00019 
00024 #include "transparent.h"
00025 
00030 CEventHandler* CEventHandler::NewL(RWsSession& aWs)
00031         {
00032         CEventHandler* eventHandler = new(ELeave) CEventHandler(aWs);
00033         CleanupStack::PushL(eventHandler);
00034         eventHandler->ConstructL();
00035         CleanupStack::Pop(eventHandler);
00036         return eventHandler;
00037         }
00038 
00043 CEventHandler::CEventHandler(RWsSession& aWs) : CActive(CActive::EPriorityStandard),iWs(aWs)
00044         {
00045         }
00046 
00050 void CEventHandler ::ConstructL()
00051         {
00052         CActiveScheduler::Add(this);
00053         }
00054 
00058 CEventHandler ::~CEventHandler ()
00059         {
00060         Cancel();
00061         }
00062 
00067 void CEventHandler ::DoCancel()
00068         {
00069         iWs.EventReadyCancel();
00070         }
00071 
00076 void CEventHandler::RunL()
00077         {
00078         iWs.GetEvent(iWsEvent);
00079         TInt eventType = iWsEvent.Type();
00080 
00081         // Take action for the event that occurred
00082         switch (eventType)
00083                 {
00084                 // Events global within window group
00085                 case EEventNull:
00086                         break;
00087                 case EEventPointer:
00088                         {
00089                         TPointerEvent& pointerEvent = *iWsEvent.Pointer();
00090                         HandlePointerEvent(pointerEvent);
00091                         }
00092                         break;
00093                 }
00094         // Maintain outstanding request
00095         IssueRequest();
00096         }
00097 
00103 void CEventHandler::HandlePointerEvent(TPointerEvent& aPointerEvent)
00104         {
00105         switch (aPointerEvent.iType)
00106                 {
00107                 case TPointerEvent::EButton1Down:
00108                         {
00109                         InfoMessage(KEventButton1Pressed);
00110                         break;
00111                         }
00112                         case TPointerEvent::EButton2Down:
00113                         {
00114                         InfoMessage(KEventButton2Pressed);
00115                         break;
00116                         }
00117                         case TPointerEvent::EButton3Down:
00118                         {
00119                         InfoMessage(KEventButton3Pressed);
00120                         break;
00121                         }
00122                         default:
00123                         {
00124                         break;
00125                         }
00126                 }
00127         }
00128 
00133 void CEventHandler::IssueRequest()
00134         {
00135         if(!IsActive())
00136                 {
00137                 iWs.EventReady(&iStatus);
00138                 SetActive();
00139                 }
00140         }
00141 
00146 void CEventHandler::InfoMessage(const TDesC& aMsg)
00147         {
00148         CEikonEnv *obj = CEikonEnv::Static();
00149         obj->InfoMsg(aMsg);
00150         }
00151 

Generated by  doxygen 1.6.2