photosgallery/viewframework/uiutilities/src/glxuiutility.cpp
changeset 0 4e91876724a2
child 1 9ba538e329bd
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-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:    ALFTK utilities
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 // Class header
       
    24 
       
    25 // USER INCLUDE FILES
       
    26 #include "glxuiutility.h"
       
    27 #include "glxscreenfurniture.h"
       
    28 #include "glxskinchangemonitor.h"
       
    29 
       
    30 // SYSTEM INCLUDE FILES
       
    31 #include <aknappui.h>
       
    32 #include <AknUtils.h>
       
    33 #include <alf/alfcontrolgroup.h>
       
    34 #include <alf/alfdisplay.h>
       
    35 #include <alf/alfutil.h>
       
    36 #include <alf/alfenv.h>
       
    37 #include <alf/alftexture.h>
       
    38 #include <alf/alftextstyle.h> 
       
    39 #include <alf/alftextstylemanager.h>
       
    40 #include <featmgr.h>
       
    41 #include <bldvariant.hrh>   // For feature constants
       
    42 
       
    43 // Internal incudes
       
    44 #include <glxresolutionmanager.h>       // for CGlxResolutionManager
       
    45 #include <glxsingletonstore.h>      
       
    46 #include <glxpanic.h>
       
    47 #include <glxassert.h>                  // for GLX_ASSERT_DEBUG
       
    48 #include <glxtvconstants.h>             // for ETvConnectionChanged
       
    49 #include <glxtv.h>                      // for CGlxTv
       
    50 #include <glxthumbnail.h>
       
    51 #include <glxsettingsmodel.h>
       
    52 #include <glxsingletonstore.h>
       
    53 #include <glxtexturemanager.h>
       
    54 #include <glxtracer.h>
       
    55 //Hg 
       
    56 //#include <hg/hgcontextutility.h>
       
    57 
       
    58 // TV size constants
       
    59 using namespace glxTvOut;
       
    60 
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // UtilityL
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 EXPORT_C CGlxUiUtility* CGlxUiUtility::UtilityL()
       
    67 	{
       
    68 	TRACER("CGlxUiUtility::UtilityL()");
       
    69 	return CGlxSingletonStore::InstanceL(&NewL);
       
    70 	}
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // Close
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C void CGlxUiUtility::Close()
       
    77 	{
       
    78 	TRACER("CGlxUiUtility::Close()");
       
    79     CGlxSingletonStore::Close(this);
       
    80 	}
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // 2-phase constructor
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 CGlxUiUtility* CGlxUiUtility::NewL() 
       
    87     {
       
    88     TRACER("CGlxUiUtility::NewL()");
       
    89 	CGlxUiUtility* obj = new (ELeave) CGlxUiUtility();
       
    90 	CleanupStack::PushL(obj);
       
    91 	obj->ConstructL();
       
    92 	CleanupStack::Pop(obj);
       
    93     return obj;
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // Constructor
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 CGlxUiUtility::CGlxUiUtility()
       
   101 :   iNavigationDirection( EGlxNavigationForwards ),
       
   102     iOrientation( EGlxOrientationUninitialised )
       
   103     {
       
   104     TRACER("CGlxUiUtility::CGlxUiUtility()");
       
   105     iAppUi = CCoeEnv::Static()->AppUi();
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // ConstructL
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CGlxUiUtility::ConstructL()
       
   113     {
       
   114     TRACER("CGlxUiUtility::ConstructL()");
       
   115     iSettingsModel = CGlxSettingsModel::InstanceL();
       
   116     
       
   117 
       
   118 	// Always start in default orientation
       
   119     //SetAppOrientationL(EGlxOrientationDefault);
       
   120 
       
   121 	iOrientation = EGlxOrientationDefault;
       
   122     // in emulator use bitgdi as open GL does not support changing orientation
       
   123 
       
   124     // Ferhan (28/06/07) : commenting out usage of opengl because causing drawing problems when using
       
   125     // the preview list (gldrawelements method in opengl seems to hang)
       
   126    // iEnv = CHuiEnv::Static();
       
   127    	//@ Fix for error id EABI-7RJA8C
       
   128     iEnv = CAlfEnv::Static();
       
   129     if (!iEnv)
       
   130        {
       
   131        iEnv = CAlfEnv::NewL();
       
   132        // change to this on hw that supports opengl
       
   133        // iEnv = CHuiEnv::NewL( EHuiRendererGles10 );
       
   134        }
       
   135     else
       
   136        {
       
   137        iShared = ETrue;
       
   138        }
       
   139     iGlxTextureManager = CGlxTextureManager::NewL(iEnv->TextureManager());
       
   140 
       
   141     //Skin change observer
       
   142     iGlxSkinChangeMonitor = CGlxSkinChangeMonitor::NewL();
       
   143     iAppUi->AddToStackL(iGlxSkinChangeMonitor);
       
   144     
       
   145     // Add TextureManager as a skin change event observer here itself because
       
   146     // calling CGlxHuiUtility::Utility() in CGlxTextureManager creates a recursive call
       
   147     // to CGlxTextureManager::NewL which again calls CGlxHuiUtility::Utility() and so on.
       
   148     AddSkinChangeObserverL( *iGlxTextureManager );    
       
   149 	GridIconSizeL();
       
   150 	TRect rect;
       
   151 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, rect ); 
       
   152     iAlfDisplay = &iEnv->NewDisplayL(rect,
       
   153             CAlfEnv::ENewDisplayAsCoeControl | CAlfEnv::ENewDisplayFullScreen );
       
   154             
       
   155      iEnv->AddActionObserverL (this);
       
   156      
       
   157     // Use the Avkon skin background as the display background.    
       
   158     //iAlfDisplay->SetClearBackgroundL(CAlfDisplay::EClearWithSkinBackground);
       
   159     
       
   160     // create the resoltuion manager - needs to be informed when screen size 
       
   161     // changes
       
   162     iGlxResolutionManager = CGlxResolutionManager::NewL();
       
   163     
       
   164     iGlxTvOut = CGlxTv::NewL(*this);
       
   165     
       
   166     // Is the TV Out display on
       
   167     // Note that this also sets the initial size for the resolution manager
       
   168     HandleTvStatusChangedL( ETvConnectionChanged );
       
   169     
       
   170     iScreenFurniture = CGlxScreenFurniture::NewL(*this);
       
   171     
       
   172 //    iContextUtility = CHgContextUtility::NewL();
       
   173 //    iContextUtility->RePublishWhenFgL( ETrue );
       
   174 	}
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // Destructor
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 CGlxUiUtility::~CGlxUiUtility()
       
   181     {
       
   182     TRACER("CGlxUiUtility::~CGlxUiUtility()");
       
   183     GLX_LOG_INFO("~CGlxUiUtility");
       
   184     delete iScreenFurniture;
       
   185 /*    if (iContextUtility)
       
   186         {
       
   187         delete iContextUtility;
       
   188         iContextUtility = NULL;
       
   189         }
       
   190 */
       
   191     // Destroy TV Out related objects
       
   192     delete iGlxTvOut;
       
   193     delete iGlxResolutionManager;
       
   194     DestroyTvOutDisplay();
       
   195     
       
   196 	if( iGlxTextureManager )
       
   197 		{
       
   198 	    RemoveSkinChangeObserver( *iGlxTextureManager ); 
       
   199 	    delete iGlxTextureManager;   	
       
   200 		}
       
   201 
       
   202     if(iAlfDisplay)
       
   203         {
       
   204         delete iAlfDisplay;
       
   205         }
       
   206    
       
   207     iEnv->RemoveActionObserver(this);
       
   208 
       
   209     if ( iGlxSkinChangeMonitor )
       
   210         {
       
   211         iAppUi->RemoveFromStack(iGlxSkinChangeMonitor);
       
   212         delete iGlxSkinChangeMonitor;
       
   213         }
       
   214         
       
   215     if (!iShared)
       
   216         {
       
   217         delete iEnv;
       
   218         }
       
   219         
       
   220     iTextStyles.Close();
       
   221     if ( iSettingsModel )
       
   222         {
       
   223         iSettingsModel->Close();
       
   224         }    
       
   225 
       
   226     }
       
   227 
       
   228 // -----------------------------------------------------------------------------
       
   229 // Env
       
   230 // -----------------------------------------------------------------------------
       
   231 //
       
   232 EXPORT_C CAlfEnv* CGlxUiUtility::Env() const
       
   233 	{
       
   234 	TRACER("CGlxUiUtility::Env()");
       
   235 	return iEnv;
       
   236 	}
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 // Display
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 EXPORT_C CAlfDisplay* CGlxUiUtility::Display() const
       
   243 	{
       
   244 	TRACER("CGlxUiUtility::Display()");
       
   245 	return iAlfDisplay;
       
   246 	}
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // ShowAlfDisplay
       
   250 // -----------------------------------------------------------------------------
       
   251 EXPORT_C void CGlxUiUtility::ShowAlfDisplayL()
       
   252 	{
       
   253 	TRACER("CGlxUiUtility::ShowAlfDisplayL()");
       
   254 	// make it visible as well
       
   255 	CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL();
       
   256 
       
   257 	CCoeControl* contl = (CCoeControl*)uiUtility->Display()->ObjectProvider();
       
   258 	contl->MakeVisible (ETrue);
       
   259 
       
   260 	uiUtility->Close();
       
   261 	// no need to do anything else, the coecontrol handles the visibility
       
   262 	}
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 // HideAlfDisplay
       
   266 // -----------------------------------------------------------------------------
       
   267 EXPORT_C void CGlxUiUtility::HideAlfDisplayL()
       
   268 	{
       
   269 	TRACER("CGlxUiUtility::HideAlfDisplayL()");
       
   270 	// make it invisible as well (this might be all that is needed)
       
   271 	CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL();
       
   272 	
       
   273 	CCoeControl* contl = (CCoeControl*)uiUtility->Display()->ObjectProvider();
       
   274 	contl->MakeVisible (EFalse);
       
   275 	
       
   276 	uiUtility->Close();
       
   277 	// no need to do anything else, the coecontrol handles the visibility
       
   278 	}
       
   279 	
       
   280 // -----------------------------------------------------------------------------
       
   281 // GlxTextureManager
       
   282 // -----------------------------------------------------------------------------
       
   283 //
       
   284 EXPORT_C CGlxTextureManager& CGlxUiUtility::GlxTextureManager()
       
   285 	{
       
   286 	TRACER("CGlxUiUtility::GlxTextureManager()");
       
   287 	__ASSERT_ALWAYS(iGlxTextureManager, Panic(EGlxPanicLogicError));
       
   288     return *iGlxTextureManager;
       
   289 	}
       
   290 	
       
   291 // -----------------------------------------------------------------------------
       
   292 // ViewNavigationDirection
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 EXPORT_C TGlxNavigationDirection CGlxUiUtility::ViewNavigationDirection()
       
   296     {
       
   297     TRACER("CGlxUiUtility::ViewNavigationDirection()");
       
   298     return iNavigationDirection;
       
   299     }
       
   300     
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // SetViewNavigationDirection
       
   304 // -----------------------------------------------------------------------------
       
   305 //
       
   306 EXPORT_C void CGlxUiUtility::SetViewNavigationDirection(TGlxNavigationDirection aDirection)
       
   307     {
       
   308     TRACER("CGlxUiUtility::SetViewNavigationDirection()");
       
   309     iNavigationDirection = aDirection;
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // DisplaySize
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 EXPORT_C TSize CGlxUiUtility::DisplaySize() const
       
   317     {
       
   318     TRACER("CGlxUiUtility::DisplaySize()");
       
   319     //return Env()->PrimaryDisplay().Size();
       
   320     const TRect& rect = Env()->PrimaryDisplay().VisibleArea();
       
   321 	return rect.Size();
       
   322     }
       
   323 
       
   324 // -----------------------------------------------------------------------------
       
   325 // TextStyleIdL
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 EXPORT_C TInt CGlxUiUtility::TextStyleIdL(TInt aFontId, TInt aSizeInPixels)
       
   329     {
       
   330     TRACER("CGlxUiUtility::TextStyleIdL()");
       
   331     TInt id = 0;
       
   332     TBool found = EFalse;
       
   333     TInt index = 0;
       
   334     TInt count = iTextStyles.Count();
       
   335     // Look for existing style with this font and size
       
   336     while(index < count && !found)
       
   337         {
       
   338         if(iTextStyles[index].iSizeInPixels == aSizeInPixels &&
       
   339            iTextStyles[index].iFontId == aFontId)
       
   340             {
       
   341             // found it. Prepare to return found id
       
   342             id = iTextStyles[index].iStyleId;
       
   343             found = ETrue;
       
   344             }
       
   345         else
       
   346             {
       
   347             // check next style
       
   348             index++;
       
   349             }
       
   350         }
       
   351     if(!found)
       
   352         {
       
   353         // Create a new style based on the required font
       
   354         CAlfTextStyleManager& styleMan = iEnv->TextStyleManager();
       
   355         
       
   356         // remember its id for return later
       
   357         id = styleMan.CreatePlatformTextStyleL(aFontId);
       
   358         
       
   359         // Get style. It is not owned
       
   360         CAlfTextStyle* style = styleMan.TextStyle(id);
       
   361         
       
   362         // Set this style to have required size and to be normal weight
       
   363         style->SetTextSizeInPixels(aSizeInPixels);
       
   364         
       
   365         style->SetBold(EFalse);
       
   366         
       
   367         // Add this style to list
       
   368         TGlxTextStyle textStyle(aFontId, aSizeInPixels, id);
       
   369         iTextStyles.AppendL(textStyle);
       
   370         }
       
   371     return id;
       
   372     }
       
   373 
       
   374 // ---------------------------------------------------------------------------
       
   375 // SetAppOrientationL
       
   376 // ---------------------------------------------------------------------------
       
   377 //
       
   378 EXPORT_C void CGlxUiUtility::SetAppOrientationL(TGlxOrientation aOrientation)
       
   379     {
       
   380     TRACER("CGlxUiUtility::SetAppOrientationL()");
       
   381     GLX_LOG_INFO1( "CGlxUiUtility::SetAppOrientationL(%d)", aOrientation );
       
   382 
       
   383     if ( iOrientation != aOrientation )
       
   384         {
       
   385         CAknAppUiBase::TAppUiOrientation orientation(
       
   386                                 CAknAppUiBase::EAppUiOrientationUnspecified);
       
   387 
       
   388         switch ( aOrientation )
       
   389             {
       
   390             case EGlxOrientationTextEntry:
       
   391                 if ( iSettingsModel->IsTextEntryPortrait() )
       
   392                     {
       
   393                     orientation = CAknAppUiBase::EAppUiOrientationPortrait;
       
   394                     break;
       
   395                     }
       
   396                 // else fall through to EGlxOrientationDefault
       
   397 
       
   398             case EGlxOrientationDefault:
       
   399                 {
       
   400                 if ( CGlxSettingsModel::ELandscape
       
   401                         == iSettingsModel->SupportedOrientations() )
       
   402                     {
       
   403                     orientation = CAknAppUiBase::EAppUiOrientationLandscape;
       
   404                     }
       
   405                 else
       
   406                     {
       
   407                     orientation = CAknAppUiBase::EAppUiOrientationAutomatic;
       
   408                     }
       
   409                 }
       
   410                 break;
       
   411 
       
   412             case EGlxOrientationLandscape:
       
   413                 orientation = CAknAppUiBase::EAppUiOrientationLandscape;
       
   414                 break;
       
   415 
       
   416             default:
       
   417                 Panic(EGlxPanicIllegalArgument);
       
   418                 break;
       
   419             }
       
   420 
       
   421         static_cast<CAknAppUiBase*>(iAppUi)->SetOrientationL(orientation);
       
   422         iOrientation = aOrientation;
       
   423         }
       
   424     }
       
   425 
       
   426 // ---------------------------------------------------------------------------
       
   427 // AppOrientation
       
   428 // ---------------------------------------------------------------------------
       
   429 //
       
   430 EXPORT_C TGlxOrientation CGlxUiUtility::AppOrientation() const
       
   431     {
       
   432     TRACER("CGlxUiUtility::AppOrientation()");
       
   433     return iOrientation;
       
   434     }
       
   435 // -----------------------------------------------------------------------------
       
   436 // GetGridIconSize
       
   437 // -----------------------------------------------------------------------------
       
   438 //  
       
   439 EXPORT_C TSize CGlxUiUtility::GetGridIconSize()
       
   440     {
       
   441 	 TRACER("CGlxUiUtility::GetGridIconSize()");
       
   442     return iGridIconSize;
       
   443     }    
       
   444 // -----------------------------------------------------------------------------
       
   445 // HandleTvStatusChangedL
       
   446 // -----------------------------------------------------------------------------
       
   447 //
       
   448 EXPORT_C void CGlxUiUtility::HandleTvStatusChangedL( TTvChangeType aChangeType )
       
   449     {
       
   450     TRACER("CGlxUiUtility::HandleTvStatusChangedL()");
       
   451 
       
   452     if ( aChangeType == ETvDisplayNotVisible )         // Visibility event
       
   453         {
       
   454         iEnv->Release();
       
   455         return; // don't redraw the display
       
   456         }
       
   457     else if ( aChangeType == ETvDisplayIsVisible )     // Visibility event
       
   458         {
       
   459         iEnv->RestoreL();
       
   460         }
       
   461      else                                              // TV Connection event
       
   462         {
       
   463         GLX_ASSERT_DEBUG( (aChangeType == ETvConnectionChanged), 
       
   464                             Panic( EGlxPanicLogicError ), 
       
   465                             "Expected TV Connection Changed" );
       
   466 
       
   467         if ( iGlxTvOut->IsConnected() )
       
   468             {
       
   469             // Remove the TV Diplay - a ETvConnectionChanged may result from
       
   470             // the user changing the central repository TV values.
       
   471             DestroyTvOutDisplay();
       
   472             CreateTvOutDisplayL();
       
   473             }
       
   474         else
       
   475             {
       
   476             DestroyTvOutDisplay();
       
   477             // Set the display size to that of the phone
       
   478             iGlxResolutionManager->SetScreenSizeL( DisplaySize() );
       
   479             }
       
   480         }
       
   481         
       
   482     if (iTvDisplay)
       
   483         {
       
   484         iTvDisplay->SetDirty(); // redraw
       
   485         }        
       
   486     }
       
   487     
       
   488 // -----------------------------------------------------------------------------
       
   489 // SetRotatedImageSize
       
   490 // -----------------------------------------------------------------------------
       
   491 //
       
   492 EXPORT_C void CGlxUiUtility::SetRotatedImageSize(TSize aRotatedImageSize)
       
   493     {
       
   494     iRotatedImageSize = aRotatedImageSize;
       
   495     }
       
   496 
       
   497 // -----------------------------------------------------------------------------
       
   498 // SetRotatedImageSize
       
   499 // -----------------------------------------------------------------------------
       
   500 //
       
   501 EXPORT_C TSize CGlxUiUtility::GetRotatedImageSize()
       
   502     {
       
   503     return iRotatedImageSize;
       
   504     }
       
   505 
       
   506 void  CGlxUiUtility::HandleActionL (const TAlfActionCommand &aActionCommand) 
       
   507     {
       
   508     TRACER("CGlxUiUtility::HandleActionL()");
       
   509    	
       
   510    	if(aActionCommand.Id() == KAlfActionIdDeviceLayoutChanged  )
       
   511    	    {   	  
       
   512     	// check if tv-out is connected
       
   513         if ( iGlxTvOut->IsConnected() )
       
   514             {
       
   515         	// The primary (phone) display has changed orientation
       
   516         	DestroyTvOutDisplay();
       
   517                 CreateTvOutDisplayL(); //@ will generate false positive in codescanner
       
   518             }
       
   519         else
       
   520             {
       
   521             // reset the screen size in case the orientation changed for example
       
   522             iGlxResolutionManager->SetScreenSizeL( DisplaySize() );
       
   523             }
       
   524    	    }
       
   525     }
       
   526   
       
   527 // -----------------------------------------------------------------------------
       
   528 // DestroyTvOutDisplay
       
   529 // -----------------------------------------------------------------------------
       
   530 //
       
   531 void CGlxUiUtility::DestroyTvOutDisplay()
       
   532     {
       
   533     TRACER("CGlxUiUtility::DestroyTvOutDisplay()");
       
   534     if (iTvDisplay)
       
   535         {
       
   536         delete iTvDisplay;
       
   537         iTvDisplay = NULL; 
       
   538         // Remove Primary Window Refresh observer
       
   539         //Display()->iRefreshObservers.Remove( *this );  
       
   540         iEnv->PauseRefresh();
       
   541         // Disable Primary Window Visibility events
       
   542         CCoeControl* contl = (CCoeControl*)iEnv->PrimaryDisplay().ObjectProvider();
       
   543         contl->DrawableWindow()->DisableVisibilityChangeEvents();
       
   544         }
       
   545     }
       
   546        
       
   547         
       
   548 // -----------------------------------------------------------------------------
       
   549 // CreateTvOutDisplayL
       
   550 // -----------------------------------------------------------------------------
       
   551 //
       
   552 void CGlxUiUtility::CreateTvOutDisplayL()
       
   553 	{
       
   554 	TRACER("CGlxUiUtility::CreateTvOutDisplayL()");
       
   555 	
       
   556 	// Get the TV Out display size buffer in pixels
       
   557     TSize tvOutDisplaySz = iGlxTvOut->ScreenSizeL();
       
   558     
       
   559     // Calculate the TV Out buffer by using
       
   560     // A) aspect ratio that matches the phone screen and 
       
   561     // B) size that fills the TV so that either width or height of TV is fully  
       
   562     //             used (in practice height is always restricting dimension). 
       
   563     TSize phoneDisplaySz   = DisplaySize();
       
   564   
       
   565     // Scale the tv display size to match that of the phone display size
       
   566     tvOutDisplaySz = TSize (tvOutDisplaySz.iHeight * phoneDisplaySz.iWidth 
       
   567                           / phoneDisplaySz.iHeight, tvOutDisplaySz.iHeight );
       
   568     const TRect tvOutDisplayBuffer( tvOutDisplaySz );
       
   569  
       
   570 	// Commenting out Creation of second display as it goes into posting surface, 
       
   571 	// Right now, only cloning is going to be the funcationality and posting would be done
       
   572 	// only for specific views (FS , Zoom and Slideshow)
       
   573 //    if (!iTvDisplay)
       
   574 //	    {
       
   575 //        iTvDisplay = &iEnv->NewDisplayL( tvOutDisplayBuffer, 
       
   576 //                 CAlfEnv::ENewDisplayAsCoeControl, 
       
   577 //                 iGlxTvOut->IsWidescreen() ? CAlfDisplay::EDisplayTvOutWide :
       
   578 //                 CAlfDisplay::EDisplayTvOut );
       
   579 //        
       
   580 //        if (iTvDisplay)                                 
       
   581 //            {
       
   582 //            // Use the Avkon skin background as the display background.
       
   583 //            iTvDisplay->SetClearBackgroundL( 
       
   584 //                                        CAlfDisplay::EClearWithSkinBackground );
       
   585 //            //Todo
       
   586 //            // Primary Window Refresh observer
       
   587 //            iEnv->SetRefreshMode(EAlfRefreshModeAutomatic);
       
   588 //            }
       
   589 //	    }
       
   590 			
       
   591 	// Set the TV screen size    
       
   592     iGlxResolutionManager->SetScreenSizeL( tvOutDisplaySz );   
       
   593 	}
       
   594 
       
   595 // -----------------------------------------------------------------------------
       
   596 // AddSkinChangeObserverL
       
   597 // -----------------------------------------------------------------------------
       
   598 //
       
   599 EXPORT_C void CGlxUiUtility::AddSkinChangeObserverL(MGlxSkinChangeObserver& aObserver)
       
   600     {
       
   601     TRACER("CGlxUiUtility::AddSkinChangeObserverL()");
       
   602     iGlxSkinChangeMonitor->AddSkinChangeObserverL( aObserver );
       
   603     }
       
   604     
       
   605 // -----------------------------------------------------------------------------
       
   606 // RemoveSkinChangeObserver
       
   607 // -----------------------------------------------------------------------------
       
   608 //    
       
   609 EXPORT_C void CGlxUiUtility::RemoveSkinChangeObserver(MGlxSkinChangeObserver& aObserver)
       
   610     {      
       
   611     TRACER("CGlxUiUtility::RemoveSkinChangeObserver()");
       
   612     iGlxSkinChangeMonitor->RemoveSkinChangeObserver( aObserver );
       
   613     }
       
   614 
       
   615 // -----------------------------------------------------------------------------
       
   616 // ScreenFurniture
       
   617 // -----------------------------------------------------------------------------
       
   618 //
       
   619 EXPORT_C CGlxScreenFurniture* CGlxUiUtility::ScreenFurniture()
       
   620     {
       
   621     return iScreenFurniture;
       
   622     }
       
   623 
       
   624 // -----------------------------------------------------------------------------
       
   625 // Context Utility for Teleport
       
   626 // -----------------------------------------------------------------------------
       
   627 //
       
   628 /*EXPORT_C CHgContextUtility* CGlxUiUtility::ContextUtility()
       
   629     {
       
   630     return iContextUtility;
       
   631     }
       
   632 */
       
   633 // -----------------------------------------------------------------------------
       
   634 // IsPenSupported
       
   635 // -----------------------------------------------------------------------------
       
   636 //
       
   637 EXPORT_C TBool CGlxUiUtility::IsPenSupported()
       
   638     {
       
   639     TRACER("CGlxUiUtility::IsPenSupported");
       
   640 
       
   641     return AknLayoutUtils::PenEnabled();
       
   642     }
       
   643 
       
   644 // -----------------------------------------------------------------------------
       
   645 // GridIconSize
       
   646 // -----------------------------------------------------------------------------
       
   647 //	
       
   648 void CGlxUiUtility::GridIconSizeL()
       
   649 	{
       
   650 	TRACER("CGlxUiUtility::GridIconSize()");
       
   651 	// Sets up TLS, must be done before FeatureManager is used.
       
   652 	    FeatureManager::InitializeLibL();
       
   653 	    
       
   654 	  if(FeatureManager::FeatureSupported( KFeatureIdLayout640_360_Touch ) || FeatureManager::FeatureSupported( KFeatureIdLayout360_640_Touch ))
       
   655 	      {
       
   656 	      iGridIconSize = TSize(111,83);
       
   657 	      }
       
   658 	  else if(FeatureManager::FeatureSupported(KFeatureIdLayout640_480_Touch) || FeatureManager::FeatureSupported(KFeatureIdLayout480_640_Touch) || 
       
   659 	          FeatureManager::FeatureSupported(KFeatureIdLayout640_480) || FeatureManager::FeatureSupported(KFeatureIdLayout480_640))
       
   660 	      {
       
   661 	      iGridIconSize = TSize(146,110);
       
   662 	      }
       
   663 	  else
       
   664 	      {
       
   665 	      iGridIconSize = TSize(146,110);
       
   666 	      }
       
   667 	// Frees the TLS. Must be done after FeatureManager is used.
       
   668 	    FeatureManager::UnInitializeLib(); 
       
   669 	}
       
   670 
       
   671 
       
   672  
       
   673 EXPORT_C TBool CGlxUiUtility::IsExitingState()
       
   674     {
       
   675     TRACER("CGlxUiUtility::ExitingState");
       
   676     RDebug::Printf("iIsExiting = %d", iIsExiting);
       
   677     return iIsExiting;
       
   678     }
       
   679 
       
   680 EXPORT_C void CGlxUiUtility::SetExitingState(TBool aIsExiting)
       
   681     {
       
   682     TRACER("CGlxUiUtility::SetExitingState");
       
   683     iIsExiting = aIsExiting;
       
   684     }
       
   685 
       
   686 
       
   687 // -----------------------------------------------------------------------------
       
   688 // VisibleItemsInPageGranularityL
       
   689 // -----------------------------------------------------------------------------
       
   690 //
       
   691 EXPORT_C TInt CGlxUiUtility::VisibleItemsInPageGranularityL()
       
   692     {
       
   693     TRACER("CGlxUiUtility::VisibleItemsInPageGranularityL");
       
   694     
       
   695     //TBD: In MCL 9.1/Corolla env currently the feature flags 
       
   696     //KFeatureIdLayout640_480 and KFeatureIdLayout480_640 are not defined.
       
   697     //so making the default granularity as 21 instead of 15.
       
   698     //Need to replace with KGlxDefaultVisibleItemsGranularity after
       
   699     //getting the feature flag.
       
   700     TInt ret = KGlxVGAVisibleItemsGranularity;
       
   701     FeatureManager::InitializeLibL();
       
   702     
       
   703     if (FeatureManager::FeatureSupported( KFeatureIdLayout640_360_Touch ) || 
       
   704         FeatureManager::FeatureSupported( KFeatureIdLayout360_640_Touch ))
       
   705       {
       
   706       ret = KGlxQHDVisibleItemsGranularity;
       
   707       }
       
   708     else if(FeatureManager::FeatureSupported(KFeatureIdLayout640_480_Touch) || 
       
   709           FeatureManager::FeatureSupported(KFeatureIdLayout480_640_Touch) || 
       
   710           FeatureManager::FeatureSupported(KFeatureIdLayout640_480) || 
       
   711           FeatureManager::FeatureSupported(KFeatureIdLayout480_640))
       
   712       {
       
   713       ret = KGlxVGAVisibleItemsGranularity;
       
   714       }
       
   715     FeatureManager::UnInitializeLib(); 
       
   716     return ret;
       
   717     }
       
   718 
       
   719 
       
   720 // End of file