widgetmodel/alfwidgetmodel/src/alfwidgeteventhandler.cpp
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     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:   File implements eventhandler in widgetmodel.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <alf/alftypes.h>
       
    19 #include <osn/ustring.h>
       
    20 
       
    21 #include "alf/alfwidgeteventhandler.h"
       
    22 #include <alf/alfwidgetcontrol.h>
       
    23 #include <alf/alfvarianttype.h>
       
    24 #include <alf/alfexceptions.h>
       
    25 #include "alf/alfattribute.h"
       
    26 #include <alf/alfeventoutputsignalsubscriber.h>
       
    27 #include <alf/ialfappeventlistener.h>
       
    28 #include <stdexcept>
       
    29 #include <osn/osnnew.h>
       
    30 
       
    31 #ifdef RD_TACTILE_FEEDBACK
       
    32 #include <touchfeedback.h>
       
    33 #endif // RD_TACTILE_FEEDBACK
       
    34 
       
    35 #include "alfwidgeteventhandlerimpl.h"
       
    36 #include "alfanimationoutput.h"
       
    37 #include "alfeventinput.h"
       
    38 #include "alfeventoutput.h"
       
    39 
       
    40 
       
    41 namespace Alf
       
    42     {
       
    43 // ======== LOCAL FUNCTIONS ========
       
    44 
       
    45 // ======== MEMBER FUNCTIONS ========
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // ?description_if_needed
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 OSN_EXPORT AlfWidgetEventHandler::AlfWidgetEventHandler(
       
    52     IAlfWidgetEventHandler::AlfEventHandlerType aEventHandlerType,
       
    53     IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase aEventHandlerExecutionPhase )
       
    54     {
       
    55     mImpl.reset( new (EMM) AlfWidgetEventHandlerImpl(
       
    56         aEventHandlerType, aEventHandlerExecutionPhase ) );
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // ?description_if_needed
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 AlfWidgetEventHandler::~AlfWidgetEventHandler()
       
    64     {
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // ?implementation_description
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 OSN_EXPORT void AlfWidgetEventHandler::addKeyInput(
       
    72     int aEventID,
       
    73     EventTypeFlags aEventTypeFlags,
       
    74     uint aModifiers )
       
    75     {
       
    76     if ( aEventTypeFlags != keyDown && aEventTypeFlags != keyUp )
       
    77         {
       
    78         ALF_THROW(
       
    79             AlfException,
       
    80             EInvalidArgument,
       
    81             "AlfWidgetEventHandler - invalid event type given in addKeyInput()" );
       
    82         }
       
    83     
       
    84     mImpl->mInputs.resize(mImpl->mInputs.count()+1);
       
    85     AlfEventInput* input = new( EMM ) AlfEventInput( aEventTypeFlags, aEventID, 0, aModifiers );
       
    86     mImpl->mInputs.insert(mImpl->mInputs.count(),input);
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // ?implementation_description
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 OSN_EXPORT void AlfWidgetEventHandler::addCustomInput(
       
    94     int aEventID, bool aUseEventData, int aEventData )
       
    95     {
       
    96     mImpl->mInputs.resize(mImpl->mInputs.count()+1);
       
    97     AlfEventInput* input = new( EMM ) AlfEventInput(custom, aEventID, aEventData, 0 );
       
    98     if ( aUseEventData )
       
    99         {
       
   100         input->mEventTypeFlags |= useEventData;
       
   101         }
       
   102 
       
   103     mImpl->mInputs.insert(mImpl->mInputs.count(), input);
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // ?implementation_description
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 OSN_EXPORT void AlfWidgetEventHandler::addPointerInput(
       
   111     const char* aElementName, const char* aVisualName, 
       
   112     WidgetPointerEvent aEvent )
       
   113     {
       
   114     mImpl->mPointerInputs.resize(mImpl->mPointerInputs.count()+1);
       
   115     AlfPointerEventInput* input = new( EMM ) AlfPointerEventInput( aElementName, aVisualName, aEvent );
       
   116     mImpl->mPointerInputs.insert(mImpl->mPointerInputs.count(), input);
       
   117     }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // ?implementation_description
       
   121 // ---------------------------------------------------------------------------
       
   122 
       
   123 OSN_EXPORT void AlfWidgetEventHandler::addOutput(
       
   124     int aEventType,
       
   125     int aEventID,
       
   126     const char* aTargetControl,
       
   127     unsigned int aDelay )
       
   128     {
       
   129     mImpl->mOutputs.resize(mImpl->mOutputs.count()+1);
       
   130     AlfEventOutput* output = new( EMM ) AlfEventOutput( aEventType, aEventID, aTargetControl, aDelay );
       
   131     mImpl->mOutputs.insert(mImpl->mOutputs.count(), output);
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // ?implementation_description
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 OSN_EXPORT void AlfWidgetEventHandler::addAnimationOutput(
       
   139     AlfReferenceToVisual* aTargetVisual,
       
   140     AlfReferenceToVisual* aReferenceVisual,
       
   141     IAlfAttributeSetter* aAttributeSetter,
       
   142     AlfAttributeContainer* aAttributeContainer,
       
   143     unsigned int aAnimationTime,
       
   144     unsigned int aDelay )
       
   145     {
       
   146     mImpl->mAnimationOutputs.resize(mImpl->mAnimationOutputs.count()+1);
       
   147 
       
   148     AlfAnimationOutput* output = new( EMM ) AlfAnimationOutput(
       
   149         aTargetVisual,
       
   150         aReferenceVisual,
       
   151         aAttributeSetter,
       
   152         aAttributeContainer,
       
   153         aAnimationTime,
       
   154         aDelay );
       
   155 
       
   156     // This should always succeed, because the array has already been resized.
       
   157     mImpl->mAnimationOutputs.insert(mImpl->mAnimationOutputs.count(), output );
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // ?implementation_description
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 OSN_EXPORT void AlfWidgetEventHandler::addCancelOutput(
       
   165     const char* aTargetWidget, int aEventID, bool aCancelAll )
       
   166     {
       
   167     mImpl->mCancelOutputs.resize(mImpl->mCancelOutputs.count()+1);
       
   168     AlfEventCancelOutput* output = new( EMM ) AlfEventCancelOutput( aTargetWidget, aEventID, aCancelAll );
       
   169     mImpl->mCancelOutputs.insert(mImpl->mCancelOutputs.count(), output);
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // ?implementation_description
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 OSN_EXPORT void AlfWidgetEventHandler::addAnimationCancelOutput(
       
   177     const char* aElementName,
       
   178     const char* aVisualName,
       
   179     TAlfOp aOperation,
       
   180     bool aCancelAll )
       
   181     {
       
   182     mImpl->mAnimationCancelOutputs.resize(mImpl->mAnimationCancelOutputs.count()+1);
       
   183     AlfAnimationCancelOutput* output = new( EMM ) AlfAnimationCancelOutput(aElementName, aVisualName, aOperation, aCancelAll );
       
   184     mImpl->mAnimationCancelOutputs.insert(mImpl->mAnimationCancelOutputs.count(), output);
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // AddWidgetAttributeOutput
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 OSN_EXPORT void AlfWidgetEventHandler::addWidgetAttributeOutput(
       
   192     AlfAttribute& aAttribute, const char* aWidgetId )
       
   193     {
       
   194     mImpl->mWidgetAttributeOutputs.resize( mImpl->mWidgetAttributeOutputs.count() + 1 );
       
   195     AlfWidgetAttributeOutput* output = new (EMM) AlfWidgetAttributeOutput( aAttribute, aWidgetId );
       
   196     mImpl->mWidgetAttributeOutputs.insert( mImpl->mWidgetAttributeOutputs.count(), output );
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // addWidgetAttributeOutput
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 OSN_EXPORT void AlfWidgetEventHandler::addWidgetAttributeOutput(
       
   204     UString& aName, AlfAttributeValueType* aValue, const char* aWidgetId )
       
   205     {
       
   206     auto_ptr<AlfAttribute> attr(
       
   207         new( EMM ) AlfAttribute(aName.getUtf8(), AlfAttribute::EStatic ) );
       
   208     attr->addTargetValue( aValue );
       
   209 
       
   210     mImpl->mWidgetAttributeOutputs.resize( mImpl->mWidgetAttributeOutputs.count() + 1 );
       
   211     // Add attribute to attribute output. Onwership is transferred.
       
   212     AlfWidgetAttributeOutput* output = new (EMM) AlfWidgetAttributeOutput( *attr.get(), aWidgetId );
       
   213     attr.release();
       
   214     mImpl->mWidgetAttributeOutputs.insert( mImpl->mWidgetAttributeOutputs.count(), output );
       
   215     }
       
   216     
       
   217 // ---------------------------------------------------------------------------
       
   218 // addWidgetAttributeInput
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 OSN_EXPORT void AlfWidgetEventHandler::addWidgetAttributeInput(
       
   222 	UString& aName, AlfAttributeValueType* aValue, const char* aElementId )
       
   223     {
       
   224     auto_ptr<AlfAttribute> attr(
       
   225         new( EMM ) AlfAttribute(aName.getUtf8(), AlfAttribute::EStatic ) );
       
   226     attr->addTargetValue( aValue );
       
   227 
       
   228     mImpl->mWidgetAttributeInputs.resize( mImpl->mWidgetAttributeInputs.count() + 1 );
       
   229     // Add attribute to attribute input. Onwership is transferred.
       
   230     AlfWidgetAttributeInput* input = new (EMM) AlfWidgetAttributeInput( *attr.get(), aElementId );
       
   231     attr.release();
       
   232     mImpl->mWidgetAttributeInputs.insert( mImpl->mWidgetAttributeInputs.count(), input );
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------------------------
       
   236 // addTactileOutput
       
   237 // ---------------------------------------------------------------------------
       
   238 //
       
   239 OSN_EXPORT void AlfWidgetEventHandler::addTactileOutput( 
       
   240     WidgetTactileFeedbackType aFeedbackType )
       
   241     {
       
   242 #ifdef RD_TACTILE_FEEDBACK
       
   243 	// map the feedback type to official tactile feedback type
       
   244     TTouchLogicalFeedback feedback = ETouchFeedbackNone;
       
   245 
       
   246     switch ( aFeedbackType )
       
   247         {
       
   248         case tactileFeedbackBasic:
       
   249             feedback = ETouchFeedbackBasic;
       
   250             break;
       
   251         case tactileFeedbackSensitive:
       
   252             feedback = ETouchFeedbackSensitive;
       
   253             break;
       
   254         case tactileFeedbackNone:
       
   255         default:
       
   256             break;
       
   257         }
       
   258 
       
   259     // create tactile output
       
   260     mImpl->mTactileOutputs.resize( mImpl->mTactileOutputs.count() + 1 );
       
   261     AlfTactileOutput* output = new (EMM) AlfTactileOutput( feedback );
       
   262     mImpl->mTactileOutputs.insert( mImpl->mTactileOutputs.count(), output );
       
   263 #endif // RD_TACTILE_FEEDBACK
       
   264     }
       
   265 
       
   266 // ---------------------------------------------------------------------------
       
   267 // addEventPasserInput
       
   268 // ---------------------------------------------------------------------------
       
   269 //
       
   270 OSN_EXPORT void AlfWidgetEventHandler::addEventPasserInput (
       
   271     int aEventId, int aCustomData )
       
   272     {
       
   273     mImpl->mEventPasserInputs.resize( mImpl->mEventPasserInputs.count() + 1 );                                                                      
       
   274     
       
   275     AlfEventPasserInput* input = new( EMM ) AlfEventPasserInput(
       
   276         aEventId, aCustomData );
       
   277     mImpl->mEventPasserInputs.insert( mImpl->mEventPasserInputs.count(), input ); 
       
   278     }
       
   279 
       
   280 // ---------------------------------------------------------------------------
       
   281 // addEventPasserOutput
       
   282 // ---------------------------------------------------------------------------
       
   283 //
       
   284 OSN_EXPORT void AlfWidgetEventHandler::addEventPasserOutput( 
       
   285     const char* aSourceWidget , const char* aTargetWidget )
       
   286     {
       
   287     mImpl->mEventPasserOutputs.resize( mImpl->mEventPasserOutputs.count() + 1 );
       
   288 
       
   289     //create new output here
       
   290     AlfEventPasserOutput* output = new( EMM ) AlfEventPasserOutput(
       
   291         aSourceWidget, aTargetWidget );
       
   292         
       
   293     mImpl->mEventPasserOutputs.insert( mImpl->mEventPasserOutputs.count(), output );
       
   294     }
       
   295 
       
   296 // ---------------------------------------------------------------------------
       
   297 // addEventPasserOutput
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 OSN_EXPORT void AlfWidgetEventHandler::addEventPasserOutput( 
       
   301     const char* aSourceWidget , const char* aTargetWidget, int aNewEventId, int aNewEventCustomData )
       
   302     {
       
   303     //create new output here
       
   304     auto_ptr<AlfEventPasserOutput> output(new (EMM) AlfEventPasserOutput( aSourceWidget,
       
   305                                                                           aTargetWidget,
       
   306                                                                           aNewEventId,
       
   307                                                                           aNewEventCustomData ));
       
   308     mImpl->mEventPasserOutputs.resize( mImpl->mEventPasserOutputs.count() + 1 );                                                                      
       
   309     mImpl->mEventPasserOutputs.insert( mImpl->mEventPasserOutputs.count(), output.get() ); 
       
   310     output.release();        
       
   311     }
       
   312     
       
   313 // ---------------------------------------------------------------------------
       
   314 // addWidgetEventOutputSignalSubscriber
       
   315 // ---------------------------------------------------------------------------
       
   316 //
       
   317 OSN_EXPORT void AlfWidgetEventHandler::addWidgetEventOutputSignalSubscriber(
       
   318 	IAlfEventOutputSignalSubscriber& aSubscriber )
       
   319 	{
       
   320 	auto_ptr<AlfEventOutputSignal> signal(new (EMM) AlfEventOutputSignal( aSubscriber ));
       
   321 	mImpl->mWidgetEventOutputSignals.resize( mImpl->mWidgetEventOutputSignals.count() + 1 );
       
   322 	mImpl->mWidgetEventOutputSignals.insert( mImpl->mWidgetEventOutputSignals.count(), signal.get() );
       
   323 	signal.release();
       
   324 	}
       
   325 
       
   326 // ---------------------------------------------------------------------------
       
   327 // addWidgetStateOutput
       
   328 // ---------------------------------------------------------------------------
       
   329 //
       
   330 OSN_EXPORT void AlfWidgetEventHandler::addWidgetStateOutput( 
       
   331     const UString& aName, uint aEnableStates, uint aDisableStates )
       
   332     {
       
   333     auto_ptr<AlfStateChangeOutput> output(new (EMM) AlfStateChangeOutput( aName.getUtf8(), aEnableStates, aDisableStates ));
       
   334     mImpl->mStateChangeOutputs.resize( mImpl->mStateChangeOutputs.count() + 1 );
       
   335     mImpl->mStateChangeOutputs.insert( mImpl->mStateChangeOutputs.count(), output.get() ); 
       
   336     output.release();
       
   337     }
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // addAppEventOutput
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 OSN_EXPORT void AlfWidgetEventHandler::addAppEventOutput(const UString& aCmd , IAlfAppEventListener& aAppEvent )
       
   344     {
       
   345     auto_ptr<AlfAppEventOutput> appOutput(new (EMM) AlfAppEventOutput( aCmd, aAppEvent ));
       
   346     mImpl->mAppEventOutputs.resize( mImpl->mAppEventOutputs.count() + 1 );
       
   347     mImpl->mAppEventOutputs.insert( mImpl->mAppEventOutputs.count(), appOutput.get() );
       
   348     appOutput.release();
       
   349     }
       
   350     
       
   351 // ---------------------------------------------------------------------------
       
   352 // From class IAlfWidgetEventHandler.
       
   353 // ?implementation_description
       
   354 // ---------------------------------------------------------------------------
       
   355 //
       
   356 bool AlfWidgetEventHandler::accept(
       
   357     CAlfWidgetControl& aControl, const TAlfEvent& aEvent ) const
       
   358     {
       
   359     bool ret = false;
       
   360 
       
   361     // Custom and key events
       
   362     if ( !aEvent.IsPointerEvent() )
       
   363         {
       
   364         int count = mImpl->mInputs.count();
       
   365 
       
   366         for ( int i = 0 ; i < count ; i++ )
       
   367             {
       
   368             if ( mImpl->mInputs[i]->accept( aEvent ) )
       
   369                 {
       
   370                 ret = true;
       
   371                 break;
       
   372                 }
       
   373             }
       
   374         }
       
   375 
       
   376     // Pointer events
       
   377     else
       
   378         {
       
   379         int count = mImpl->mPointerInputs.count();
       
   380 
       
   381         for ( int i = 0 ; i < count ; i++ )
       
   382             {
       
   383             if ( mImpl->mPointerInputs[i]->accept( aControl, aEvent ) )
       
   384                 {
       
   385                 ret = true;
       
   386                 break;
       
   387                 }
       
   388             }
       
   389         }
       
   390 
       
   391     // All the inputs below handle only custom events.
       
   392     
       
   393     if (!ret) 
       
   394         {
       
   395         int count = mImpl->mWidgetAttributeInputs.count();
       
   396 
       
   397         for ( int i = 0 ; i < count ; i++ )
       
   398             {
       
   399             if ( mImpl->mWidgetAttributeInputs[i]->accept( aEvent ) )
       
   400                 {
       
   401                 ret = true;
       
   402                 break;
       
   403                 }
       
   404             }
       
   405         }
       
   406     
       
   407     if (!ret) 
       
   408         {
       
   409         int count = mImpl->mEventPasserInputs.count();
       
   410 
       
   411         for ( int i = 0 ; i < count ; i++ )
       
   412             {
       
   413             if ( mImpl->mEventPasserInputs[i]->accept( aEvent ) )
       
   414                 {
       
   415                 ret = true;
       
   416                 break;
       
   417                 }
       
   418             }
       
   419         }        
       
   420 
       
   421     return ret;
       
   422     }
       
   423 
       
   424 // ---------------------------------------------------------------------------
       
   425 // From class IAlfWidgetEventHandler.
       
   426 // ?implementation_description
       
   427 // ---------------------------------------------------------------------------
       
   428 //
       
   429 AlfEventStatus AlfWidgetEventHandler::offerEvent( 
       
   430     CAlfWidgetControl& aControl,
       
   431     const TAlfEvent& aEvent )
       
   432     {
       
   433     AlfEventStatus ret(EEventNotHandled);
       
   434         
       
   435     // If the event handler is active in the control's current state and
       
   436     // any of the inputs accept the event, execute all outputs.
       
   437 
       
   438     if ( ( (mImpl->mActiveStates == ~0) ||
       
   439             (aControl.state() & mImpl->mActiveStates) ) &&
       
   440             accept( aControl, aEvent ) )
       
   441         {
       
   442         ret = EEventHandled;
       
   443 
       
   444         // Normal event outputs, property outputs and cancel outputs
       
   445         // are executed with all types of events (custom, key, pointer).
       
   446 
       
   447         int i;
       
   448         int count = mImpl->mCancelOutputs.count();
       
   449 
       
   450         for ( i = 0 ; i < count ; i++ )
       
   451             {
       
   452             mImpl->mCancelOutputs[i]->execute( aControl );
       
   453             }
       
   454 
       
   455         count = mImpl->mOutputs.count();
       
   456 
       
   457         for ( i = 0 ; i < count ; i++ )
       
   458             {
       
   459             mImpl->mOutputs[i]->execute( aControl, aEvent );
       
   460             }
       
   461 
       
   462         // Tactile outputs
       
   463 #ifdef RD_TACTILE_FEEDBACK
       
   464         count = mImpl->mTactileOutputs.count();
       
   465 
       
   466         for ( i = 0 ; i < count ; i++ )
       
   467             {
       
   468             mImpl->mTactileOutputs[i]->execute();
       
   469             }
       
   470 #endif // RD_TACTILE_FEEDBACK
       
   471 
       
   472         // widget attribute outputs
       
   473         count = mImpl->mWidgetAttributeOutputs.count();
       
   474 
       
   475         for ( i = 0 ; i < count ; i++ )
       
   476             {
       
   477             mImpl->mWidgetAttributeOutputs[i]->execute(
       
   478                 aControl );
       
   479             }
       
   480 
       
   481         // Event output signal subscribers
       
   482         count = mImpl->mWidgetEventOutputSignals.count();
       
   483         for ( i = 0 ; i < count ; i++ )
       
   484             {
       
   485             mImpl->mWidgetEventOutputSignals[i]->execute();
       
   486             }
       
   487         
       
   488         // Animation event outputs, animation cancel outputs and property outputs
       
   489         // are executed only with custom events.
       
   490 
       
   491         if ( aEvent.IsCustomEvent() )
       
   492             {
       
   493             // Custom events have the associated data ID for finding the target
       
   494             // visual in the event data parameter.
       
   495 
       
   496             int dataID = aEvent.CustomEventData();
       
   497 
       
   498             count = mImpl->mAnimationCancelOutputs.count();
       
   499 
       
   500             for ( i = 0 ; i < count ; i++ )
       
   501                 {
       
   502                 mImpl->mAnimationCancelOutputs[i]->execute( aControl, dataID );
       
   503                 }
       
   504 
       
   505             count = mImpl->mAnimationOutputs.count();
       
   506 
       
   507             for ( i = 0 ; i < count ; i++ )
       
   508                 {
       
   509                 mImpl->mAnimationOutputs[i]->sendCommand( aControl, dataID );
       
   510                 }
       
   511             }
       
   512 
       
   513         // State change outputs
       
   514         count = mImpl->mStateChangeOutputs.count();
       
   515         for( i = 0; i < count; i++)
       
   516             {
       
   517             mImpl->mStateChangeOutputs[i]->execute( aControl );
       
   518             }
       
   519             
       
   520         // Event passer outputs
       
   521         count = mImpl->mEventPasserOutputs.count();
       
   522         for( i = 0; i < count; i++)
       
   523             {
       
   524             mImpl->mEventPasserOutputs[i]->execute( &aControl , aEvent );
       
   525             }      
       
   526         
       
   527         // AlfAppEvent outputs
       
   528         count = mImpl->mAppEventOutputs.count();
       
   529         for( i = 0; i < count; i++)
       
   530             {
       
   531             mImpl->mAppEventOutputs[i]->execute( aEvent );
       
   532             } 
       
   533         }
       
   534 
       
   535     return ret;
       
   536     }
       
   537 
       
   538 // ---------------------------------------------------------------------------
       
   539 // From class IAlfWidgetEventHandler.
       
   540 // ---------------------------------------------------------------------------
       
   541 //
       
   542 void AlfWidgetEventHandler::setActiveStates( unsigned int aStates )
       
   543     {
       
   544     mImpl->mActiveStates = aStates;
       
   545     }
       
   546 
       
   547 // ---------------------------------------------------------------------------
       
   548 // From class IAlfWidgetEventHandler.
       
   549 // ?implementation_description
       
   550 // ---------------------------------------------------------------------------
       
   551 //
       
   552 void AlfWidgetEventHandler::setCapturing( bool aCapturing )
       
   553     {
       
   554     mImpl->mCapturing = aCapturing;
       
   555     }
       
   556 
       
   557 // ---------------------------------------------------------------------------
       
   558 // From class IAlfWidgetEventHandler.
       
   559 // ?implementation_description
       
   560 // ---------------------------------------------------------------------------
       
   561 //
       
   562 bool AlfWidgetEventHandler::capturing() const
       
   563     {
       
   564     return mImpl->mCapturing;
       
   565     }
       
   566 
       
   567 // ---------------------------------------------------------------------------
       
   568 // From class MAlfInterfaceBase.
       
   569 // ?implementation_description
       
   570 // ---------------------------------------------------------------------------
       
   571 //
       
   572 IAlfInterfaceBase* AlfWidgetEventHandler::makeInterface( const IfId& aType )
       
   573     {
       
   574     UString param( aType.mImplementationId );
       
   575     if ( param == IAlfWidgetEventHandler::type().mImplementationId )
       
   576         {
       
   577         return static_cast<IAlfWidgetEventHandler*>( this );
       
   578         }
       
   579 
       
   580     return NULL;
       
   581     }
       
   582     
       
   583 // ---------------------------------------------------------------------------
       
   584 // setEventHandlerData
       
   585 // ---------------------------------------------------------------------------
       
   586 //    
       
   587 void AlfWidgetEventHandler::setEventHandlerData(const AlfWidgetEventHandlerInitData& aData)
       
   588 	{
       
   589 	// Set event handler id
       
   590 	if (aData.mWidgetEventHandlerId)
       
   591 	    {
       
   592 	    int len = strlen(aData.mWidgetEventHandlerId);
       
   593 	    char* tmp = new( EMM ) char[len + 1];
       
   594 	    
       
   595         delete[] mImpl->mEhData.mWidgetEventHandlerId;
       
   596 	        
       
   597         strcpy(tmp, aData.mWidgetEventHandlerId);
       
   598 	    tmp[len] = 0;
       
   599 	    mImpl->mEhData.mWidgetEventHandlerId = tmp;
       
   600 	    }
       
   601 	// we don't need to set node at the moment
       
   602 	mImpl->mEhData.mNode = 0;
       
   603 	}
       
   604 
       
   605 // ---------------------------------------------------------------------------
       
   606 // eventHandlerData
       
   607 // ---------------------------------------------------------------------------
       
   608 //
       
   609 AlfWidgetEventHandlerInitData* AlfWidgetEventHandler::eventHandlerData()
       
   610 	{
       
   611 	return &mImpl->mEhData;
       
   612 	}
       
   613 
       
   614 // ---------------------------------------------------------------------------
       
   615 // eventHandlerType
       
   616 // ---------------------------------------------------------------------------
       
   617 //
       
   618 IAlfWidgetEventHandler::AlfEventHandlerType AlfWidgetEventHandler::eventHandlerType()
       
   619     {
       
   620     return mImpl->mEventHandlerType;
       
   621     }
       
   622 
       
   623 // ---------------------------------------------------------------------------
       
   624 // eventExecutionPhase
       
   625 // ---------------------------------------------------------------------------
       
   626 //
       
   627 IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase AlfWidgetEventHandler::eventExecutionPhase()
       
   628     {
       
   629     return mImpl->mEventHandlerExecutionPhase;
       
   630     }
       
   631 }
       
   632 // End of File.