uifw/AvKon/AknTransitionUtils/src/akntransitionutils.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Transition utilities.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <coecntrl.h>
       
    20 #include <avkondomainpskeys.h>
       
    21 #include <centralrepository.h>
       
    22 #include <pslninternalcrkeys.h>
       
    23 #include <AknUtils.h>
       
    24 
       
    25 #include "akntransitionutils.h"
       
    26 #include "aknpsobserver.h"
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 struct CAknTransitionUtils::TDataEntry
       
    32     {
       
    33     TDataEntry( const TInt iKey, TAny* aData );
       
    34       
       
    35     static TBool SameKey( const TDataEntry& aEntry1,
       
    36                           const TDataEntry& aEntry2 );
       
    37 
       
    38     const TInt iKey;
       
    39     TAny* iData;
       
    40     };
       
    41         
       
    42 // -----------------------------------------------------------------------------
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 struct CAknTransitionUtils::TTransitionObserver
       
    46     {
       
    47     TTransitionObserver( const TInt iKey, TInt iEvents,
       
    48                          MAknTransitionUtilsObserver* aObserver );
       
    49  
       
    50     static TBool Equal( const TTransitionObserver& aObserver1,
       
    51                         const TTransitionObserver& aObserver2 );
       
    52 
       
    53     TInt iEvents;        
       
    54     TInt iKey;
       
    55     MAknTransitionUtilsObserver* iObserver;
       
    56     };
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CAknTransitionUtils::TDataEntry::TDataEntry( const TInt aKey, 
       
    62                                              TAny* aData ) :
       
    63         iKey( aKey ), iData( aData )
       
    64     {
       
    65     }
       
    66         
       
    67 // -----------------------------------------------------------------------------
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 TBool CAknTransitionUtils::TDataEntry::SameKey( const TDataEntry& aEntry1, 
       
    71                                                 const TDataEntry& aEntry2 )
       
    72     {
       
    73     return aEntry1.iKey == aEntry2.iKey;
       
    74     }
       
    75     
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 CAknTransitionUtils::TTransitionObserver::TTransitionObserver( 
       
    81             const TInt aKey, const TInt aEvents, 
       
    82             MAknTransitionUtilsObserver* aObserver ) :
       
    83     iEvents( ( TEvents )aEvents ), iKey( aKey ), iObserver( aObserver )
       
    84     {
       
    85     }
       
    86  
       
    87 // -----------------------------------------------------------------------------
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 TBool CAknTransitionUtils::TTransitionObserver::Equal( 
       
    91         const TTransitionObserver& aObserver1,
       
    92         const TTransitionObserver& aObserver2 )
       
    93     {
       
    94     return aObserver1.iObserver == aObserver2.iObserver;
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 CAknTransitionUtils::~CAknTransitionUtils() 
       
   101     {
       
   102     TInt count = iUserData.Count();        
       
   103     for ( TInt i = 0; i < count; i++ )
       
   104         {
       
   105         delete iUserData[i];
       
   106         }
       
   107             
       
   108     count = iObservers.Count();        
       
   109     for ( TInt i = 0; i < count; i++ )
       
   110         {
       
   111         delete iObservers[i];
       
   112         }
       
   113 
       
   114     iUserData.Reset();
       
   115     iObservers.Reset();
       
   116     delete iPsObserver;
       
   117     delete iRepository;
       
   118     };
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 EXPORT_C TInt CAknTransitionUtils::AddObserver( 
       
   124         MAknTransitionUtilsObserver* aObserver, TInt aEvents,  
       
   125         const TDesC8* aParams )
       
   126     {
       
   127     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   128     if ( !singleton )
       
   129         {
       
   130         return KErrNoMemory;
       
   131         }
       
   132     
       
   133     TInt key = reinterpret_cast<TInt>( aParams );
       
   134     TInt count = singleton->iObservers.Count();
       
   135     TInt newEvents = 0;
       
   136     TBool foundObserver = EFalse;
       
   137     for ( TInt i = 0; i < count; i++ )
       
   138         {
       
   139         TTransitionObserver* o = singleton->iObservers[i];
       
   140         if ( o->iObserver == aObserver )
       
   141             {
       
   142             foundObserver = ETrue;
       
   143             newEvents = aEvents & ~o->iEvents;
       
   144             o->iEvents |= aEvents;
       
   145             break;
       
   146             }
       
   147         }
       
   148         
       
   149     if ( !foundObserver )
       
   150         {
       
   151         TTransitionObserver* o = new TTransitionObserver( key, aEvents, 
       
   152                                                           aObserver );
       
   153         if ( !o )
       
   154             {
       
   155             return KErrNoMemory;
       
   156             }
       
   157         singleton->iObservers.Append( o );
       
   158         newEvents = aEvents;
       
   159         }
       
   160 
       
   161     if ( newEvents & EEventControlTransitionFinished )
       
   162         {
       
   163         GfxTransEffect::SetTransitionObserver( singleton );
       
   164         singleton->iNumControlTransitionObservers++;
       
   165         }
       
   166     
       
   167     if ( newEvents & EEventWsBufferRedirection )
       
   168         {
       
   169         if ( !singleton->iPsObserver )
       
   170             {
       
   171             singleton->iPsObserver = CAknPsObserver::New( singleton, 
       
   172                                                           KPSUidAvkonDomain, 
       
   173                                                           KAknTfxServerRedirectionStatus );
       
   174             if ( !singleton->iPsObserver )
       
   175                 {
       
   176                 return KErrNoMemory;
       
   177                 }
       
   178              TInt value = 0;
       
   179              singleton->iPsObserver->GetCurrentValue( value ); 
       
   180              singleton->iScreenRedirected = value & ETfxScreenRedirected;
       
   181             }
       
   182         singleton->iNumPsObservers++;
       
   183         }
       
   184         
       
   185     return KErrNone;
       
   186     }
       
   187   
       
   188 // -----------------------------------------------------------------------------
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 EXPORT_C TInt CAknTransitionUtils::RemoveObserver( 
       
   192         MAknTransitionUtilsObserver* aObserver, TInt aEvents )
       
   193     {
       
   194     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   195     if ( !singleton )
       
   196         {
       
   197         return KErrNoMemory;
       
   198         }
       
   199 
       
   200     TIdentityRelation<TTransitionObserver> identity( 
       
   201                                               TTransitionObserver::Equal );
       
   202     TTransitionObserver tmp( 0, aEvents, aObserver );
       
   203     TInt index = singleton->iObservers.Find( &tmp, identity );
       
   204     if ( index != KErrNotFound )
       
   205         {
       
   206         TTransitionObserver* o = singleton->iObservers[index];
       
   207         TInt removedEvents = aEvents & o->iEvents;
       
   208         o->iEvents &= ~removedEvents;
       
   209 
       
   210         if ( o->iEvents == 0 )
       
   211             {
       
   212             delete singleton->iObservers[index];
       
   213             singleton->iObservers.Remove( index );
       
   214             }
       
   215             
       
   216         if ( removedEvents & EEventControlTransitionFinished )
       
   217             {
       
   218             if ( --singleton->iNumControlTransitionObservers == 0 )
       
   219                 {
       
   220                 GfxTransEffect::SetTransitionObserver( NULL );
       
   221                 }
       
   222             }
       
   223         
       
   224         if ( removedEvents & EEventWsBufferRedirection )
       
   225             {
       
   226             if ( --singleton->iNumPsObservers == 0 )
       
   227                 {
       
   228                 delete singleton->iPsObserver;
       
   229                 singleton->iPsObserver = NULL;
       
   230                 }
       
   231             }
       
   232         
       
   233         return KErrNone;
       
   234         }
       
   235         
       
   236     return KErrNotFound;
       
   237     }
       
   238     
       
   239 // -----------------------------------------------------------------------------
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 EXPORT_C TInt CAknTransitionUtils::GetState( TInt aEvent, TInt* aState, 
       
   243                                              TDes8* /*aParams*/ )
       
   244     {
       
   245     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   246     if ( !singleton )
       
   247         {
       
   248         return KErrNoMemory;
       
   249         }
       
   250         
       
   251     if ( aEvent & EEventWsBufferRedirection )
       
   252         {
       
   253         *aState = singleton->iScreenRedirected;
       
   254         }
       
   255     else
       
   256         {
       
   257         return KErrNotSupported;
       
   258         }
       
   259 
       
   260     return KErrNone;
       
   261     }
       
   262 
       
   263 // -----------------------------------------------------------------------------
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 void CAknTransitionUtils::TransitionFinished( const CCoeControl* aControl, 
       
   267                                               TUint /* aAction */ )
       
   268     {
       
   269     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   270     if ( !singleton )
       
   271         {
       
   272         return;
       
   273         }
       
   274 
       
   275     TInt key = reinterpret_cast<TInt>( aControl );
       
   276 
       
   277     for ( TInt i = 0; i < singleton->iObservers.Count(); i++ )
       
   278         {
       
   279         if ( ( singleton->iObservers[i]->iEvents & 
       
   280                EEventControlTransitionFinished ) &&
       
   281              ( singleton->iObservers[i]->iKey == key ) )
       
   282             {
       
   283             singleton->iObservers[i]->iObserver->AknTransitionCallback(
       
   284                 EEventControlTransitionFinished, 0, 
       
   285                 reinterpret_cast<const TDesC8*>( aControl ) );
       
   286             }
       
   287         }
       
   288     }
       
   289     
       
   290 // -----------------------------------------------------------------------------
       
   291 // -----------------------------------------------------------------------------
       
   292 //
       
   293 void CAknTransitionUtils::PsValueUpdated( const TUid /* aCategory */, 
       
   294                                           const TUint /* aKey */,
       
   295                                           const TInt aVal )
       
   296     {
       
   297     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   298     if ( !singleton )
       
   299         {
       
   300         return;
       
   301         }
       
   302 
       
   303     iScreenRedirected = aVal & ETfxScreenRedirected;
       
   304 
       
   305     for ( TInt i = 0; i < singleton->iObservers.Count(); i++ )
       
   306         {
       
   307         if ( singleton->iObservers[i]->iEvents & EEventWsBufferRedirection )
       
   308             {
       
   309            	MAknTransitionUtilsObserver* observer = singleton->iObservers[i]->iObserver;
       
   310            	observer->AknTransitionCallback(
       
   311                 EEventWsBufferRedirection, iScreenRedirected );
       
   312             if ( (i >= singleton->iObservers.Count() ) // Out of bounds
       
   313             	|| ( observer != singleton->iObservers[i]->iObserver ) ) // removed
       
   314             	{
       
   315             	// Observer removed itself during AknTransitionCallback()
       
   316             	i--;
       
   317             	}
       
   318             }
       
   319         }
       
   320     }
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // -----------------------------------------------------------------------------
       
   324 //
       
   325 EXPORT_C void CAknTransitionUtils::RemoveData( const TInt aKey )
       
   326     {
       
   327     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   328     if ( !singleton )
       
   329         {
       
   330         return;
       
   331         }
       
   332 
       
   333     TIdentityRelation<TDataEntry> identity( TDataEntry::SameKey );
       
   334     TDataEntry tmp( aKey, NULL );
       
   335     TInt index = singleton->iUserData.Find( &tmp, identity );
       
   336     if ( index != KErrNotFound )
       
   337         {
       
   338         delete singleton->iUserData[index];
       
   339         singleton->iUserData.Remove( index );
       
   340         }
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // -----------------------------------------------------------------------------
       
   345 //
       
   346 EXPORT_C TInt CAknTransitionUtils::SetData( const TInt aKey, TAny* aData )
       
   347     {
       
   348     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   349     if ( !singleton )
       
   350         {
       
   351         return KErrNoMemory;
       
   352         }
       
   353         
       
   354     TIdentityRelation<TDataEntry> identity( TDataEntry::SameKey );
       
   355     TDataEntry* tmp = new TDataEntry( aKey, aData );
       
   356     if ( !tmp )
       
   357         {
       
   358         return KErrNoMemory;
       
   359         }
       
   360     TInt index = singleton->iUserData.Find( tmp, identity );
       
   361     if ( index != KErrNotFound )
       
   362         {
       
   363         delete singleton->iUserData[index];
       
   364         singleton->iUserData.Remove( index );
       
   365         }
       
   366 
       
   367     singleton->iUserData.Append( tmp );
       
   368 
       
   369     return KErrNone;
       
   370     }
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // -----------------------------------------------------------------------------
       
   374 //
       
   375 EXPORT_C TAny* CAknTransitionUtils::GetData( const TInt aKey )
       
   376     {
       
   377     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   378     if ( !singleton )
       
   379         {
       
   380         return NULL;
       
   381         }
       
   382         
       
   383     TIdentityRelation<TDataEntry> identity( TDataEntry::SameKey );
       
   384     TDataEntry tmp( aKey, NULL );
       
   385     TInt index = singleton->iUserData.Find( &tmp, identity );
       
   386     if ( index != KErrNotFound )
       
   387         {
       
   388         return singleton->iUserData[index]->iData;
       
   389         }
       
   390     else
       
   391         {
       
   392         return NULL;
       
   393         }
       
   394     }
       
   395         
       
   396 // -----------------------------------------------------------------------------
       
   397 // -----------------------------------------------------------------------------
       
   398 //
       
   399 EXPORT_C void CAknTransitionUtils::SetAllParents( const CCoeControl* aControl )
       
   400     {
       
   401     CCoeControl* child = NULL;
       
   402     CCoeControl* parent = const_cast<CCoeControl*>( aControl );
       
   403 
       
   404     TInt compControlCount = parent->CountComponentControls();
       
   405 
       
   406     for( TInt i( 0 ); i < compControlCount; i++ )
       
   407         {
       
   408         child = parent->ComponentControl( i );
       
   409         if ( child )
       
   410             {
       
   411             child->SetParent( parent );
       
   412             SetAllParents( child );
       
   413             }
       
   414         }
       
   415     }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // -----------------------------------------------------------------------------
       
   419 //
       
   420 EXPORT_C TBool CAknTransitionUtils::TransitionsEnabled( TInt aEffectCategory )
       
   421     {
       
   422     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   423     if ( !singleton )
       
   424         {
       
   425         // if singleton does not exist we create a temporary CRepository
       
   426         // to check the value
       
   427         CRepository* rep( NULL ); 
       
   428         TRAPD( err, rep = CRepository::NewL( KCRUidThemes ) );
       
   429         if ( err != KErrNone )
       
   430             {
       
   431             delete rep;
       
   432             return EFalse;
       
   433             }       
       
   434         TInt val;
       
   435         err = rep->Get( KThemesTransitionEffects, val );
       
   436         if ( err != KErrNone )
       
   437             {
       
   438             delete rep;
       
   439             return EFalse;
       
   440             }
       
   441  
       
   442         if ( val & aEffectCategory )
       
   443             {
       
   444             delete rep;
       
   445             return EFalse;
       
   446             }
       
   447     
       
   448         delete rep;
       
   449         return ETrue;
       
   450         }
       
   451 
       
   452     if ( !singleton->iRepository )
       
   453         {
       
   454         TRAPD( err, singleton->iRepository = CRepository::NewL( KCRUidThemes ) );
       
   455         if ( err != KErrNone )
       
   456             {
       
   457             return EFalse;
       
   458             }
       
   459         }
       
   460 
       
   461     TInt val;
       
   462     TInt err = singleton->iRepository->Get( KThemesTransitionEffects, val );
       
   463     if ( err != KErrNone )
       
   464         {
       
   465         return EFalse;
       
   466         }
       
   467 
       
   468     if ( val & aEffectCategory )
       
   469         {
       
   470         return EFalse;
       
   471         }
       
   472     
       
   473     return ETrue;
       
   474     }
       
   475 
       
   476 // -----------------------------------------------------------------------------
       
   477 // -----------------------------------------------------------------------------
       
   478 //
       
   479 TInt CAknTransitionUtils::MakeVisibleSubComponentsR( CCoeControl* aControl,
       
   480                                         TMakeVisibleSubComponentsInfo aInfo )
       
   481     {
       
   482     CCoeControl* child = NULL;
       
   483     TInt compControlCount = aControl->CountComponentControls();
       
   484 
       
   485     for( TInt i = 0; i < compControlCount; i++ )
       
   486         {
       
   487         child = aControl->ComponentControl( i );
       
   488         if( child )
       
   489             {
       
   490             if( child->OwnsWindow() )
       
   491                 {
       
   492                 TBool makeVisible;
       
   493                 TBool call = ETrue;
       
   494                 TBool visible = child->IsVisible();
       
   495                 switch ( aInfo )
       
   496                     {
       
   497                     case EForceInvisible:
       
   498                     case EDisappearInvisible:
       
   499                         makeVisible = EFalse;
       
   500                         break;
       
   501                     case EForceVisible:
       
   502                         makeVisible = ETrue;
       
   503                         break;
       
   504                     case EAppearInvisible:
       
   505                         call = visible;
       
   506                         if ( !visible &&
       
   507                              iIgnoredChildControls.Append( child ) == KErrNone )
       
   508                             {
       
   509                             GfxTransEffect::NotifyExternalState(
       
   510                                                     EAddIgnoreWOChildComponent,
       
   511                                                     ( const TDesC8* ) child );
       
   512                             }
       
   513                         makeVisible = EFalse;
       
   514                         break;
       
   515                     case EAppearVisible:
       
   516                         {
       
   517                         TInt pos = iIgnoredChildControls.Find( child );
       
   518                         if ( pos >= 0 )
       
   519                             {
       
   520                             iIgnoredChildControls.Remove( pos );
       
   521                             GfxTransEffect::NotifyExternalState(
       
   522                                                 ERemoveIgnoreWOChildComponent,
       
   523                                                 ( const TDesC8* ) child );
       
   524                             call = EFalse;
       
   525                             }
       
   526                         makeVisible = ETrue;
       
   527                         }
       
   528                         break;
       
   529                     default:
       
   530                         call = ETrue;
       
   531                         makeVisible = ETrue;
       
   532                     }
       
   533                 if ( call )
       
   534                     {
       
   535                     child->MakeVisible( makeVisible );
       
   536                     }
       
   537                 }
       
   538             MakeVisibleSubComponentsR( child, aInfo );
       
   539             }
       
   540         }
       
   541 
       
   542     return KErrNone;
       
   543     }
       
   544 
       
   545 // -----------------------------------------------------------------------------
       
   546 // -----------------------------------------------------------------------------
       
   547 //
       
   548 EXPORT_C TInt CAknTransitionUtils::MakeVisibleSubComponents(
       
   549         CCoeControl* aControl, TMakeVisibleSubComponentsInfo aInfo )
       
   550     {
       
   551     TInt err = KErrNone;
       
   552     CAknTransitionUtils* singleton = CAknTransitionUtils::Static();
       
   553     if ( !singleton )
       
   554         {
       
   555         return KErrNoMemory;
       
   556         }
       
   557 
       
   558     if ( aInfo != EClearIgnored )
       
   559         {
       
   560         err = singleton->MakeVisibleSubComponentsR( aControl, aInfo );
       
   561         }
       
   562 
       
   563     if ( aInfo == EClearIgnored || aInfo == EAppearVisible )
       
   564         {
       
   565         for ( TInt i = 0; i < singleton->iIgnoredChildControls.Count(); i++ )
       
   566             {
       
   567             GfxTransEffect::NotifyExternalState( ERemoveIgnoreWOChildComponent,
       
   568                         ( const TDesC8* ) singleton->iIgnoredChildControls[i] );
       
   569             }
       
   570         singleton->iIgnoredChildControls.Reset();
       
   571         }
       
   572 
       
   573     return err;
       
   574     }
       
   575 
       
   576 // -----------------------------------------------------------------------------
       
   577 // -----------------------------------------------------------------------------
       
   578 //
       
   579 static void GetDemarcationOptionsMenu( TRect& aRect )
       
   580     {
       
   581     if ( AknLayoutUtils::LayoutMetricsRect( 
       
   582             AknLayoutUtils::EControlPaneBottom, aRect ) )
       
   583         {
       
   584         // Options soft button on the left or right
       
   585         return;
       
   586         }
       
   587     else
       
   588         {
       
   589         // Soft buttons at the bottom of the screen
       
   590         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EControlPane, aRect );
       
   591         }
       
   592     }
       
   593     
       
   594 static void GetDemarcationPopup( TRect& aRect )
       
   595     {
       
   596     TRect controlTop;
       
   597     TRect controlBottom;
       
   598     TBool topRet = AknLayoutUtils::LayoutMetricsRect(
       
   599         AknLayoutUtils::EControlPaneTop, controlTop);
       
   600     TBool bottomRet = AknLayoutUtils::LayoutMetricsRect(
       
   601         AknLayoutUtils::EControlPaneBottom, controlBottom);
       
   602     if (bottomRet)
       
   603         {
       
   604         if (controlTop.iTl.iX == 0)
       
   605             {
       
   606             // The softkeys are on the left
       
   607             aRect.iTl.iX = aRect.iBr.iX = 0;
       
   608             aRect.iTl.iY = controlTop.iBr.iY;
       
   609             aRect.iBr.iY = controlBottom.iTl.iY;
       
   610             }
       
   611         else
       
   612             {
       
   613             // The softkeys are on the right
       
   614             aRect.iTl = controlTop.iBr;
       
   615             aRect.iBr.iX = controlBottom.iBr.iX;
       
   616             aRect.iBr.iY = controlBottom.iTl.iY;    
       
   617             }
       
   618         }
       
   619     else
       
   620         {
       
   621         // The softkeys are on the top or bottom
       
   622         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, aRect);
       
   623         }
       
   624     }
       
   625     
       
   626 EXPORT_C TInt CAknTransitionUtils::GetDemarcation( 
       
   627         TGfxControlType aControlType, TRect& aRect )
       
   628     {
       
   629     if ( aControlType == EOptionsMenu )
       
   630         {
       
   631         GetDemarcationOptionsMenu( aRect );
       
   632         }
       
   633     else // EPopup
       
   634         {
       
   635         GetDemarcationPopup( aRect );
       
   636         }
       
   637 
       
   638     return KErrNone;
       
   639     };
       
   640     
       
   641 // -----------------------------------------------------------------------------
       
   642 // -----------------------------------------------------------------------------
       
   643 //
       
   644 CAknTransitionUtils::CAknTransitionUtils() :
       
   645         CCoeStatic( KAknTransitionUtilsUid, -1, CCoeStatic::EThread ),
       
   646         iNumControlTransitionObservers( 0 )
       
   647     {
       
   648     }
       
   649 
       
   650 // -----------------------------------------------------------------------------
       
   651 // -----------------------------------------------------------------------------
       
   652 //
       
   653 CAknTransitionUtils* CAknTransitionUtils::Static()
       
   654     {
       
   655 	CCoeEnv *env = CCoeEnv::Static();
       
   656 	if(!env)
       
   657 	{
       
   658 		return NULL;
       
   659 	}
       
   660     CAknTransitionUtils* singleton = 
       
   661         reinterpret_cast<CAknTransitionUtils*>(CCoeEnv::Static( 
       
   662                                                   KAknTransitionUtilsUid ) );
       
   663     if ( !singleton )
       
   664         {
       
   665         singleton = new CAknTransitionUtils();
       
   666         }
       
   667         
       
   668     return singleton;
       
   669     }
       
   670 
       
   671 // -----------------------------------------------------------------------------
       
   672 // -----------------------------------------------------------------------------
       
   673 //
       
   674 void CAknTransitionUtils::RemoveControlTransitionObserver( const TInt aKey )
       
   675     {
       
   676     TInt count = iObservers.Count();
       
   677     for ( TInt i = 0; i < count; i++ )
       
   678         {
       
   679         TTransitionObserver* o = iObservers[i];
       
   680         if ( o->iKey == aKey )
       
   681             {
       
   682             CAknTransitionUtils::RemoveObserver( o->iObserver, 0xffffffff );
       
   683             break;
       
   684             }
       
   685         }
       
   686     }
       
   687