uiacceltk/hitchcock/Client/src/alfroster.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Roster.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alf/alfroster.h"
       
    21 #include "alf/alfdisplay.h"
       
    22 #include "alf/alfcontrolgroup.h"
       
    23 #include "alf/alfcontrol.h"
       
    24 #include "alf/alfenv.h"
       
    25 #include "alfclient.h"
       
    26 #include "alf/alfevent.h"
       
    27 #include "alflogger.h"
       
    28 #include "alfpanic.h"
       
    29 
       
    30 #include <uiacceltk/HuiUtil.h>
       
    31 
       
    32 // Private data
       
    33     
       
    34 struct CAlfRoster::TPrivateData
       
    35     {
       
    36     CAlfDisplay* iDisplay;                      // Not owned.
       
    37     RPointerArray<CAlfControlGroup> iEntries;    // Not owned. Kept in order.
       
    38     CAlfControl* iInputFocus;                   // Not owned.
       
    39     RPointerArray<MAlfControlGroupOrderChangedObserver> iControlGroupOrderChangedObservers; // Not owned.
       
    40     };
       
    41 
       
    42 
       
    43 // ======== MEMBER FUNCTIONS ========
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Constructor
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CAlfRoster::CAlfRoster()
       
    50     {
       
    51     }
       
    52 
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // ConstructL
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void CAlfRoster::ConstructL(CAlfDisplay* aDisplay)
       
    59     {
       
    60     iData = new (ELeave) TPrivateData;
       
    61     iData->iDisplay = aDisplay;
       
    62     iData->iInputFocus = NULL;
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Destructor
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CAlfRoster::~CAlfRoster()
       
    70     {
       
    71     if ( iData )
       
    72         {
       
    73         iData->iEntries.Close();
       
    74         iData->iControlGroupOrderChangedObservers.Close();
       
    75         }
       
    76     
       
    77     delete iData;
       
    78     iData = NULL;
       
    79     }
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // Shows given control group.
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C void CAlfRoster::ShowL(CAlfControlGroup& aGroup, TInt aWhere )
       
    87     {
       
    88     // If the group is already shown on the display, just adjust its 
       
    89     // position according to the parameters.
       
    90     if(Find(aGroup) != KErrNotFound)
       
    91         {
       
    92         // It is already shown. Only adjust position.
       
    93         TInt newPos = aWhere;
       
    94         if(newPos == KAlfRosterShowAtTop)
       
    95             {
       
    96             newPos = Count() - 1;
       
    97             }
       
    98         else if(newPos == KAlfRosterShowAtBottom)
       
    99             {
       
   100             newPos = 0;
       
   101             }
       
   102         else
       
   103             {
       
   104             // for PC lint
       
   105             }
       
   106             
       
   107         // Move the control group to a new position in the roster.
       
   108         const TBool lWasMoved = Move(aGroup, newPos);
       
   109         
       
   110         // Move on the server side
       
   111         iData->iDisplay->Env().Client().RosterShow( 
       
   112               aGroup.Identifier(), 
       
   113                 aWhere, 
       
   114                 iData->iDisplay->ServerHandle() );                 
       
   115                 
       
   116         //fix for bug  "ESMA-7L3H7F". Notification is moved from Move() to here.          
       
   117         // Notify control group order changed observers about changed control group order
       
   118         
       
   119          if(lWasMoved)
       
   120         	{
       
   121         	NotifyControlGroupOrderChangedObservers();		
       
   122         	}
       
   123                               
       
   124         return;
       
   125         }
       
   126 
       
   127     if(aWhere == KAlfRosterShowAtTop)
       
   128         {
       
   129         // Put the group on top of the roster.
       
   130         AppendL(aGroup);
       
   131         }
       
   132     else if(aWhere == KAlfRosterShowAtBottom)
       
   133         {
       
   134         InsertL(aGroup, 0);
       
   135         }
       
   136     else
       
   137         {
       
   138         InsertL(aGroup, aWhere);
       
   139         }
       
   140 
       
   141 
       
   142     // The group will automatically accept input events once shown.
       
   143     aGroup.SetAcceptInput(ETrue);
       
   144 
       
   145     // Show all the controls of the group.
       
   146     for(TInt i = 0; i < aGroup.Count(); ++i)
       
   147         {
       
   148         aGroup.Control(i).ShowL(*iData->iDisplay);
       
   149         }
       
   150     
       
   151     // Bind the control group to the correct display.
       
   152     aGroup.BindDisplay(iData->iDisplay);
       
   153         
       
   154     // Show on the server side
       
   155     TInt err = 
       
   156         iData->iDisplay->Env().Client().RosterShow( 
       
   157             aGroup.Identifier(), 
       
   158             aWhere, 
       
   159             iData->iDisplay->ServerHandle() );
       
   160             
       
   161     // hide on error
       
   162     if ( err != KErrNone )
       
   163         {
       
   164         // There is no window group ID if we are not running this from a 
       
   165         // Symbian application. Therefore the roster::show returns an error.
       
   166         // -> only concider this to be an error if the CCoeEnv is present.
       
   167         if ( err == KErrNotFound && !CCoeEnv::Static() )
       
   168             {
       
   169             __ALFLOGSTRING1( "CAlfRoster::ShowL ignore error %d (no CCoeEnv)", err )
       
   170             return;
       
   171             }
       
   172         
       
   173         // Hide all the controls of the group.
       
   174         for(TInt i = 0; i < aGroup.Count(); ++i)
       
   175             {
       
   176             aGroup.Control(i).Hide(*iData->iDisplay);
       
   177             }
       
   178         
       
   179         // Unbind the control group from the display.
       
   180         aGroup.BindDisplay(NULL);
       
   181                
       
   182         __ALFLOGSTRING1( "CAlfRoster::ShowL leave error %d", err )
       
   183         User::Leave( err );
       
   184         }
       
   185         
       
   186     // Notify control group order changed observers about changed control group order
       
   187     NotifyControlGroupOrderChangedObservers();
       
   188     }
       
   189     
       
   190 // ---------------------------------------------------------------------------
       
   191 // Hides given control group
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 EXPORT_C void CAlfRoster::Hide(CAlfControlGroup& aGroup)
       
   195     {
       
   196     // Hide on the server side
       
   197     TInt err = 
       
   198         iData->iDisplay->Env().Client().RosterHide( 
       
   199             aGroup.Identifier(), 
       
   200             iData->iDisplay->ServerHandle() );
       
   201             
       
   202     if ( err != KErrNone )
       
   203         {
       
   204         __ALFLOGSTRING1( "CAlfRoster::Hide panic error %d", err )
       
   205         USER_INVARIANT();
       
   206         }
       
   207             
       
   208     // Hide all the controls of the group.
       
   209     for(TInt i = 0; i < aGroup.Count(); ++i)
       
   210         {
       
   211         aGroup.Control(i).Hide(*iData->iDisplay);
       
   212         }
       
   213 
       
   214     // Unbind the control group from the display.
       
   215     aGroup.BindDisplay(NULL);
       
   216 
       
   217     // Investigate whether control group was shown
       
   218     TBool wasShown = (Find(aGroup) == KErrNotFound) ? EFalse : ETrue;
       
   219 
       
   220     Remove(&aGroup);
       
   221     
       
   222     // Notify control group order changed observers about changed control group order
       
   223     // if control group was shown before.
       
   224     if(wasShown)
       
   225         {
       
   226         NotifyControlGroupOrderChangedObservers();
       
   227         }    
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // Returns index of the given group
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C TInt CAlfRoster::Find(const CAlfControlGroup& aGroup) const
       
   235     {
       
   236     return iData->iEntries.Find( &aGroup );
       
   237     }
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // Removes group
       
   241 // ---------------------------------------------------------------------------
       
   242 //    
       
   243 void CAlfRoster::Remove(CAlfControlGroup* aGroup)
       
   244     {
       
   245     if ( aGroup )
       
   246         {
       
   247         TInt index = Find(*aGroup);
       
   248         if(index != KErrNotFound)
       
   249             {
       
   250             iData->iEntries.Remove(index);
       
   251             }
       
   252         }
       
   253     }
       
   254     
       
   255 // ---------------------------------------------------------------------------
       
   256 // Number of control groups
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 EXPORT_C TInt CAlfRoster::Count() const
       
   260     {
       
   261     return iData->iEntries.Count();
       
   262     }
       
   263    
       
   264 // ---------------------------------------------------------------------------
       
   265 // Moves group.
       
   266 // ---------------------------------------------------------------------------
       
   267 // 
       
   268 TBool CAlfRoster::Move(CAlfControlGroup& aGroup, TInt aPos)
       
   269     {
       
   270     TInt index = Find(aGroup);
       
   271     TInt k = 0;
       
   272     
       
   273     if(index != KErrNotFound && index != aPos)
       
   274         {
       
   275         CAlfControlGroup* moving = iData->iEntries[index];
       
   276         
       
   277         if(aPos > index)
       
   278             {
       
   279             for(k = index; k < aPos; ++k)
       
   280                 {
       
   281                 iData->iEntries[k] = iData->iEntries[k + 1];
       
   282                 }
       
   283             }
       
   284         else 
       
   285             {
       
   286             for(k = index; k > aPos; --k)
       
   287                 {
       
   288                 iData->iEntries[k] = iData->iEntries[k - 1];
       
   289                 }
       
   290             }
       
   291         iData->iEntries[aPos] = moving;
       
   292         return ETrue;
       
   293         }
       
   294     return EFalse;    
       
   295     }
       
   296 
       
   297 // ---------------------------------------------------------------------------
       
   298 // Appends new group
       
   299 // ---------------------------------------------------------------------------
       
   300 //
       
   301 void CAlfRoster::AppendL(CAlfControlGroup& aGroup)
       
   302     {
       
   303     User::LeaveIfError(iData->iEntries.Append(&aGroup));
       
   304     }
       
   305     
       
   306 // ---------------------------------------------------------------------------
       
   307 // Inserts new group
       
   308 // ---------------------------------------------------------------------------
       
   309 //
       
   310 void CAlfRoster::InsertL(CAlfControlGroup& aGroup, TInt aPos)
       
   311     {
       
   312     if(Find(aGroup) != KErrNotFound)
       
   313         {
       
   314         User::Leave(KErrAlreadyExists);
       
   315         }
       
   316 
       
   317     User::LeaveIfError(iData->iEntries.Insert(&aGroup, aPos));
       
   318     }    
       
   319     
       
   320 // ---------------------------------------------------------------------------
       
   321 // Handles received event
       
   322 // ---------------------------------------------------------------------------
       
   323 //
       
   324 TBool CAlfRoster::HandleEventL(const TAlfEvent& aEvent)
       
   325     {
       
   326     TInt i = 0;
       
   327     TInt k = 0;
       
   328 
       
   329     if(iData->iDisplay)
       
   330         {
       
   331         iData->iDisplay->Env().ContinueRefresh();
       
   332         }
       
   333 
       
   334     if(aEvent.IsPointerEvent())
       
   335         {
       
   336         // The order pointer events are offered in depends on the visuals.
       
   337 
       
   338         for(i = iData->iEntries.Count() - 1; i >= 0; --i)
       
   339             {
       
   340             CAlfControlGroup& group = *iData->iEntries[i];
       
   341             
       
   342             if(!group.AcceptInput())
       
   343                 {
       
   344                 // The group will not be receiving input events.
       
   345                 continue;
       
   346                 }
       
   347             
       
   348             for(k = group.Count() - 1; k >= 0; --k)
       
   349                 {
       
   350                 CAlfControl& control = group.Control(k);
       
   351                 if(control.HitTest(aEvent.PointerEvent().iPosition))
       
   352                     {
       
   353                     if(control.OfferEventL(aEvent))
       
   354                         {
       
   355                         // The event was consumed, now it can't be handled by
       
   356                         // anyone else.
       
   357                         return ETrue;
       
   358                         }
       
   359                     }
       
   360                 }
       
   361             }
       
   362         }
       
   363     else 
       
   364         {
       
   365         // First offer to the input control.
       
   366         if(aEvent.IsKeyEvent() && iData->iInputFocus && iData->iInputFocus->AcceptInput())
       
   367             {
       
   368             // check if the focus control has a host
       
   369             CAlfControl* focusRoot = iData->iInputFocus;
       
   370             while ( focusRoot->Host() )
       
   371                 {
       
   372                 focusRoot = focusRoot->Host();
       
   373                 }
       
   374                 
       
   375             if(focusRoot->OfferEventL(aEvent))
       
   376                 {
       
   377                 return ETrue;
       
   378                 }
       
   379             }
       
   380 
       
   381         // Iterate through the groups and controls in priority order.
       
   382         for(i = iData->iEntries.Count() - 1; i >= 0; --i)
       
   383             {
       
   384             CAlfControlGroup& group = *iData->iEntries[i];
       
   385             
       
   386             if(!group.AcceptInput())
       
   387                 {
       
   388                 // The group will not be receiving input events.
       
   389                 continue;
       
   390                 }
       
   391             
       
   392             for(k = 0 ; k < group.Count() ; k++ )
       
   393                 {
       
   394                 CAlfControl& control = group.Control(k);
       
   395                 if(control.OfferEventL(aEvent))
       
   396                     {
       
   397                     // The event was consumed, now it can't be handled by
       
   398                     // anyone else.
       
   399                     return ETrue;
       
   400                     }
       
   401                 }
       
   402             // Notify observer that group didn't handle event?
       
   403             }
       
   404         }
       
   405 
       
   406     return EFalse;
       
   407     }
       
   408     
       
   409 // ---------------------------------------------------------------------------
       
   410 // 
       
   411 // ---------------------------------------------------------------------------
       
   412 //
       
   413 EXPORT_C CAlfControlGroup& CAlfRoster::ControlGroup(TInt aIndex) const
       
   414     {
       
   415     return *iData->iEntries[aIndex];
       
   416     }
       
   417   
       
   418 // ---------------------------------------------------------------------------
       
   419 // 
       
   420 // ---------------------------------------------------------------------------
       
   421 //  
       
   422 EXPORT_C CAlfControl* CAlfRoster::FindControl(TInt aControlId) const
       
   423     {
       
   424     for(TInt i = 0; i < iData->iEntries.Count(); ++i)
       
   425         {
       
   426         CAlfControl* control = 
       
   427             iData->iEntries[i]->FindControl(aControlId);
       
   428         if(control)
       
   429             {
       
   430             return control;
       
   431             }
       
   432         }
       
   433     return NULL;
       
   434     }
       
   435 
       
   436 // ---------------------------------------------------------------------------
       
   437 // 
       
   438 // ---------------------------------------------------------------------------
       
   439 //    
       
   440 EXPORT_C void CAlfRoster::SetFocus(CAlfControl& aControl)
       
   441     {
       
   442     TRAP_IGNORE(ShowL( *aControl.ControlGroup(), KAlfRosterShowAtTop))
       
   443         
       
   444     // Something needs to change if these are not the same
       
   445     if ( &aControl != iData->iInputFocus ) 
       
   446         {
       
   447         ChangeInputFocus( &aControl );
       
   448         }
       
   449     }    
       
   450 
       
   451 // ---------------------------------------------------------------------------
       
   452 // Clears the input focus so that no control has focus.
       
   453 // No change is implied for the visibility of the control group
       
   454 // ---------------------------------------------------------------------------
       
   455 //
       
   456 EXPORT_C void CAlfRoster::ClearFocus()
       
   457     { 
       
   458     // Only do something if not cleared already
       
   459     if ( iData->iInputFocus != NULL ) 
       
   460         {
       
   461         ChangeInputFocus(NULL);
       
   462         }
       
   463     }
       
   464     
       
   465 // ---------------------------------------------------------------------------
       
   466 // The main job of this routine is to change iData->iInputFocus, and perform the 
       
   467 // necessary co-ordinated activities.  This should be the only place to change this
       
   468 // member datum. 
       
   469 // ---------------------------------------------------------------------------
       
   470 //      
       
   471 void CAlfRoster::ChangeInputFocus( CAlfControl* aControl )
       
   472     {
       
   473     // This method will always do something except when both old value and new are NULL
       
   474     // If they are non-null and identical, then focus will be removed and then re-applied.
       
   475     // That is, any optimizations need to be done by the caller.
       
   476     
       
   477     // The policy of whether focus is altered in the AlfControl is maintained uniformly by storing the cone focus 
       
   478     // state at the beginning of the routine
       
   479     // Current implementation is for one display/roster.  If multiple displays added then this will have to be reconsidered
       
   480     TBool displayIsInitiallyFocused = iData->iDisplay ? iData->iDisplay->IsFocused() : EFalse;
       
   481     
       
   482     // There can be a latent focus only if display is unfocused.
       
   483     TBool latentFocus = ((iData->iInputFocus != NULL) && (!iData->iInputFocus->Focus()));    
       
   484     __ASSERT_DEBUG((latentFocus ? !displayIsInitiallyFocused : ETrue), User::Panic(_L("UIAcceltkClient"), EAlfRosterPanicFocusAnomaly));
       
   485     
       
   486     CAlfControl* oldFocusedControl = iData->iInputFocus;
       
   487     
       
   488     // Remove focus from the currently focused control
       
   489     if ( iData->iInputFocus )
       
   490         {
       
   491         // Remove focus from the control
       
   492         // Only need to change actual focus if the roster is focused
       
   493         if ( displayIsInitiallyFocused )
       
   494             {
       
   495             // This control should be focused at the moment or then there is a latent focus that we are manipulating.
       
   496             __ASSERT_DEBUG( iData->iInputFocus->Focus(), User::Panic(_L("UIAcceltkClient"),EAlfRosterPanicFocusAnomaly ));
       
   497 
       
   498             CAlfDisplay* display = iData->iInputFocus->Display();
       
   499             if ( display )
       
   500                 {
       
   501                // SetFocus should cause the control to perform any required changes its visuals.
       
   502                 iData->iInputFocus->SetFocus( *display, EFalse);
       
   503                 }
       
   504             }
       
   505 
       
   506         // Still change the iInputFocus even if actual focus has not been removed
       
   507         if ( !aControl )
       
   508             {
       
   509             iData->iInputFocus = NULL;
       
   510             }
       
   511         }
       
   512     
       
   513     if ( aControl )
       
   514         {
       
   515         // Check that the control switched to is in this Roster. Ignore it if not.
       
   516         CAlfControl* control = FindControl(aControl->Id());
       
   517         if( control == aControl )
       
   518             {
       
   519             iData->iInputFocus = aControl;
       
   520             // This control should not be focused at the moment
       
   521             __ASSERT_DEBUG( !(iData->iInputFocus->Focus()), User::Panic(_L("UIAcceltkClient"),EAlfRosterPanicFocusAnomaly ));
       
   522             
       
   523             // Only manipulate actual focus if the roster is focused
       
   524             if ( displayIsInitiallyFocused )
       
   525                 {               
       
   526                 CAlfDisplay* display2 =  iData->iInputFocus->Display();
       
   527                 if ( display2 )
       
   528                     {
       
   529                     iData->iInputFocus->SetFocus( *display2, ETrue);
       
   530                     }
       
   531                 }
       
   532             }
       
   533         }
       
   534        
       
   535     ReportHostsAboutChangingInputFocus( oldFocusedControl, aControl );
       
   536     }    
       
   537 
       
   538 // ---------------------------------------------------------------------------
       
   539 // Inform host containers for the change 
       
   540 // ---------------------------------------------------------------------------
       
   541 //    
       
   542 void CAlfRoster::ReportHostsAboutChangingInputFocus( 
       
   543     CAlfControl* aOldFocusControl, 
       
   544     CAlfControl* aNewFocusControl )
       
   545     {
       
   546     // collect new focused control host tree
       
   547     RPointerArray<CAlfControl> gainingHostControls;
       
   548     if ( aNewFocusControl ) 
       
   549         {
       
   550         CAlfControl* hostTmp = aNewFocusControl->Host();
       
   551         while ( hostTmp )
       
   552             {
       
   553             (void)gainingHostControls.Append( hostTmp );
       
   554             hostTmp = hostTmp->Host();
       
   555             }
       
   556         }
       
   557         
       
   558     // Go through the hosts 
       
   559     // 1. starting from the losing leaf host
       
   560     // 2. continue to the losing root or combined host
       
   561     // 3. start from the gaining root or combined host
       
   562     // 4. end to the gaining leaf host
       
   563     
       
   564     TInt combinedIndex = KErrNotFound;
       
   565     // 1
       
   566     if ( aOldFocusControl )
       
   567         {
       
   568         CAlfControl* losingHostTmp = aOldFocusControl->Host();
       
   569         while ( losingHostTmp && (combinedIndex == KErrNotFound ) ) // 2
       
   570             {
       
   571             combinedIndex = gainingHostControls.Find( losingHostTmp );
       
   572             if ( combinedIndex == KErrNotFound )
       
   573                 {
       
   574                 losingHostTmp->FocusChainChanged( EFalse );
       
   575                 losingHostTmp = losingHostTmp->Host();
       
   576                 }
       
   577             }
       
   578         }
       
   579         
       
   580     // 3
       
   581     TInt gainingStartIndex = gainingHostControls.Count() - 1;
       
   582     if ( combinedIndex != KErrNotFound )
       
   583         {
       
   584         gainingStartIndex = combinedIndex - 1; // If we want to inform the combined host, remove the '-1'
       
   585         }
       
   586         
       
   587     if ( gainingStartIndex >= 0 )
       
   588         {
       
   589         for ( TInt gainingHostIndex = gainingStartIndex ; gainingHostIndex >= 0 ; gainingHostIndex-- ) // 4
       
   590             {
       
   591             gainingHostControls[gainingHostIndex]->FocusChainChanged( ETrue );
       
   592             }
       
   593         }
       
   594 
       
   595     gainingHostControls.Close();
       
   596     }
       
   597     
       
   598 // ---------------------------------------------------------------------------
       
   599 // Notifies registered control group order changed observers about changed
       
   600 // order in control group relative order.
       
   601 // ---------------------------------------------------------------------------
       
   602 //    
       
   603 void CAlfRoster::NotifyControlGroupOrderChangedObservers()
       
   604     {
       
   605     for(TInt i = 0; i < iData->iControlGroupOrderChangedObservers.Count(); i++)
       
   606         {
       
   607         iData->iControlGroupOrderChangedObservers[i]->NotifyControlGroupOrderChanged();
       
   608         }    
       
   609     }
       
   610     
       
   611 // ---------------------------------------------------------------------------
       
   612 // 
       
   613 // ---------------------------------------------------------------------------
       
   614 //
       
   615 EXPORT_C void CAlfRoster::ShowVisualL(CAlfVisual& aVisual)
       
   616     {
       
   617     TInt err = 
       
   618         iData->iDisplay->Env().Client().RosterShowVisual( 
       
   619             aVisual.Identifier(), 
       
   620             iData->iDisplay->ServerHandle() );
       
   621             
       
   622     if ( err != KErrNone )
       
   623         {
       
   624         __ALFLOGSTRING1( "CAlfRoster::ShowVisualL leave error %d", err )
       
   625         User::Leave( err );
       
   626         }
       
   627     }
       
   628 
       
   629 // ---------------------------------------------------------------------------
       
   630 // 
       
   631 // ---------------------------------------------------------------------------
       
   632 //    
       
   633 EXPORT_C void CAlfRoster::HideVisual(CAlfVisual& aVisual)
       
   634     {
       
   635     TInt err = 
       
   636         iData->iDisplay->Env().Client().RosterHideVisual( 
       
   637             aVisual.Identifier(), 
       
   638             iData->iDisplay->ServerHandle() );
       
   639             
       
   640     if ( err != KErrNone )
       
   641         {
       
   642         __ALFLOGSTRING1( "CAlfRoster::HideVisual ignore error %d", err )
       
   643         }
       
   644     }
       
   645 
       
   646 // ---------------------------------------------------------------------------
       
   647 // 
       
   648 // ---------------------------------------------------------------------------
       
   649 //    
       
   650 EXPORT_C void CAlfRoster::MoveVisualToFront(CAlfVisual& aRootVisual)
       
   651     {
       
   652     TInt err =
       
   653         iData->iDisplay->Env().Client().RosterMoveVisualToFront( 
       
   654             aRootVisual.Identifier(), 
       
   655             iData->iDisplay->ServerHandle() );
       
   656             
       
   657     if ( err != KErrNone )
       
   658         {
       
   659         __ALFLOGSTRING1( "CAlfRoster::MoveVisualToFront ignore error %d", err )
       
   660         }
       
   661     }
       
   662 
       
   663 // ---------------------------------------------------------------------------
       
   664 // Adds a pointer event observer
       
   665 // ---------------------------------------------------------------------------
       
   666 //  
       
   667 EXPORT_C TInt CAlfRoster::AddPointerEventObserver( 
       
   668         TAlfPointerEventFlags aObserver, 
       
   669         CAlfControl& aControl )
       
   670     {
       
   671     switch ( aObserver )
       
   672         {
       
   673         case EAlfPointerEventReportDrag:
       
   674         case EAlfPointerEventReportLongTap:
       
   675         case EAlfPointerEventReportUnhandled:
       
   676             break;
       
   677         default:
       
   678             USER_INVARIANT();
       
   679             break;
       
   680         }
       
   681     
       
   682     TInt err =
       
   683         iData->iDisplay->Env().Client().RosterAddPointerEventObserver( 
       
   684             aObserver, 
       
   685             aControl.Identifier(), 
       
   686             iData->iDisplay->ServerHandle()  );
       
   687             
       
   688     return err;
       
   689     }
       
   690 
       
   691 // ---------------------------------------------------------------------------
       
   692 // Removes a pointer event observer
       
   693 // ---------------------------------------------------------------------------
       
   694 //  
       
   695 EXPORT_C TInt CAlfRoster::RemovePointerEventObserver( 
       
   696         TAlfPointerEventFlags aObserver, 
       
   697         CAlfControl& aControl )
       
   698     {
       
   699     switch ( aObserver )
       
   700         {
       
   701         case EAlfPointerEventReportDrag:
       
   702         case EAlfPointerEventReportLongTap:
       
   703         case EAlfPointerEventReportUnhandled:
       
   704             break;
       
   705         default:
       
   706             USER_INVARIANT();
       
   707             break;
       
   708         }
       
   709         
       
   710     TInt err =
       
   711         iData->iDisplay->Env().Client().RosterRemovePointerEventObserver( 
       
   712             aObserver, 
       
   713             aControl.Identifier(), 
       
   714             iData->iDisplay->ServerHandle()  );
       
   715             
       
   716     return err;
       
   717     }
       
   718 
       
   719 // ---------------------------------------------------------------------------
       
   720 // Sets pointer event observer flags.
       
   721 // ---------------------------------------------------------------------------
       
   722 //     
       
   723 EXPORT_C TInt CAlfRoster::SetPointerEventObservers( 
       
   724     TUint aPointerEventFlags, 
       
   725     CAlfControl& aControl )
       
   726     {
       
   727     TInt err =
       
   728         iData->iDisplay->Env().Client().RosterSetPointerEventObservers( 
       
   729             aPointerEventFlags, 
       
   730             aControl.Identifier(), 
       
   731             iData->iDisplay->ServerHandle()  );
       
   732             
       
   733      return err;
       
   734     }
       
   735     
       
   736 void CAlfRoster::DisplayFocusChanged( CAlfDisplay& aDisplay, TBool aNewFocus )
       
   737     {
       
   738     // This method should only be called during a real transition of display focus. If there is a 
       
   739     // roster focused control then alter it's focus state.
       
   740     if ( iData->iInputFocus )
       
   741         {
       
   742         iData->iInputFocus->SetFocus( aDisplay, aNewFocus );
       
   743         
       
   744         if (aNewFocus)
       
   745             {
       
   746             ReportHostsAboutChangingInputFocus( NULL, iData->iInputFocus );
       
   747             }
       
   748         else
       
   749             {
       
   750             ReportHostsAboutChangingInputFocus( iData->iInputFocus, NULL );
       
   751             }
       
   752             
       
   753         }
       
   754     }
       
   755     
       
   756 CAlfControl* CAlfRoster::FocusedControl() const
       
   757     {
       
   758     return iData->iInputFocus;
       
   759     }
       
   760 
       
   761 EXPORT_C TInt CAlfRoster::SetPointerDragThreshold(const CAlfControl& aControl, const TAlfXYMetric& aXYMetric)
       
   762 	{
       
   763     TInt err =
       
   764         iData->iDisplay->Env().Client().RosterSetPointerDragTreshold( 
       
   765             aControl.Identifier(), 
       
   766             aXYMetric,
       
   767             iData->iDisplay->ServerHandle()  );
       
   768             
       
   769     return err;	
       
   770 	}
       
   771 	
       
   772 EXPORT_C TInt CAlfRoster::DisableLongTapEventsWhenDragging(const CAlfControl& aControl, TBool aDisable)
       
   773 	{
       
   774     TInt err =
       
   775         iData->iDisplay->Env().Client().RosterDisableLongTapEventsWhenDragging( 
       
   776             aControl.Identifier(), 
       
   777             aDisable,
       
   778             iData->iDisplay->ServerHandle()  );
       
   779             
       
   780     return err;	
       
   781 	}
       
   782 
       
   783 // ---------------------------------------------------------------------------
       
   784 // Adds a control group order change observer into the observers array.
       
   785 // ---------------------------------------------------------------------------
       
   786 //
       
   787 EXPORT_C void CAlfRoster::AddControlGroupOrderChangedObserverL(MAlfControlGroupOrderChangedObserver& aObserver)
       
   788     {
       
   789 	if(iData->iControlGroupOrderChangedObservers.Find(&aObserver) != KErrNotFound)
       
   790 	    {
       
   791 	    return;
       
   792 	    }
       
   793 	iData->iControlGroupOrderChangedObservers.AppendL(&aObserver);    
       
   794     }
       
   795 
       
   796 // ---------------------------------------------------------------------------
       
   797 // Removes a control group order change observer from the observers array.
       
   798 // ---------------------------------------------------------------------------
       
   799 //  
       
   800 EXPORT_C void CAlfRoster::RemoveControlGroupOrderChangedObserver(MAlfControlGroupOrderChangedObserver& aObserver)
       
   801     {
       
   802 	TInt index = iData->iControlGroupOrderChangedObservers.Find(&aObserver);
       
   803 	if(index != KErrNotFound)
       
   804 	    {
       
   805 	    iData->iControlGroupOrderChangedObservers.Remove(index);
       
   806 	    }
       
   807     }