photosgallery/viewframework/uiutilities/src/glxuiutility.cpp
branchRCL_3
changeset 30 a60acebbbd9d
parent 22 2dac0fdba72b
child 35 420f6808bf21
equal deleted inserted replaced
25:191387a8b767 30:a60acebbbd9d
    37 #include <alf/alftexture.h>
    37 #include <alf/alftexture.h>
    38 #include <alf/alftextstyle.h> 
    38 #include <alf/alftextstyle.h> 
    39 #include <alf/alftextstylemanager.h>
    39 #include <alf/alftextstylemanager.h>
    40 #include <featmgr.h>
    40 #include <featmgr.h>
    41 #include <bldvariant.hrh>   // For feature constants
    41 #include <bldvariant.hrh>   // For feature constants
       
    42 #include <eikenv.h> 
       
    43 #include <eikappui.h>
       
    44 #include <aknclearer.h>
    42 
    45 
    43 // Internal incudes
    46 // Internal incudes
    44 #include <glxresolutionmanager.h>       // for CGlxResolutionManager
    47 #include <glxresolutionmanager.h>       // for CGlxResolutionManager
    45 #include <glxsingletonstore.h>      
    48 #include <glxsingletonstore.h>      
    46 #include <glxpanic.h>
    49 #include <glxpanic.h>
    53 #include <glxtexturemanager.h>
    56 #include <glxtexturemanager.h>
    54 #include <glxtracer.h>
    57 #include <glxtracer.h>
    55 
    58 
    56 #include <e32property.h>
    59 #include <e32property.h>
    57 
    60 
       
    61 //For animation Effects
       
    62 #include <akntranseffect.h>
       
    63 #include <akntransitionutils.h>
       
    64 
    58 //Publish-Subscribe from Thumbnail manager
    65 //Publish-Subscribe from Thumbnail manager
    59 const TUid KTAGDPSNotification = { 0x2001FD51 }; //PS category 
    66 const TUid KTAGDPSNotification = { 0x2001FD51 }; //PS category 
    60 const TInt KForceBackgroundGeneration = 0x00000010; //PS Key 
    67 const TInt KForceBackgroundGeneration = 0x00000010; //PS Key 
    61 const TInt KItemsleft = 0x00000008; //PS key value
    68 const TInt KItemsleft = 0x00000008; //PS key value
    62 
    69 /**
       
    70  * Start Delay for the periodic timer, in microseconds
       
    71  */
       
    72 const TInt KPeriodicStartDelay = 1000000; 
    63 
    73 
    64 //Hg 
    74 //Hg 
    65 //#include <hg/hgcontextutility.h>
    75 //#include <hg/hgcontextutility.h>
    66 
    76 
    67 // TV size constants
    77 // TV size constants
   105 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   106 // Constructor
   116 // Constructor
   107 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
   108 //
   118 //
   109 CGlxUiUtility::CGlxUiUtility()
   119 CGlxUiUtility::CGlxUiUtility()
   110 :   iNavigationDirection( EGlxNavigationForwards ),
   120 :   iEnv(NULL),iNavigationDirection( EGlxNavigationForwards ),
   111     iOrientation( EGlxOrientationUninitialised )
   121     iOrientation( EGlxOrientationUninitialised )
   112     {
   122     {
   113     TRACER("CGlxUiUtility::CGlxUiUtility()");
   123     TRACER("CGlxUiUtility::CGlxUiUtility()");
   114     iAppUi = CCoeEnv::Static()->AppUi();
   124     iAppUi = CCoeEnv::Static()->AppUi();
   115     }
   125     }
   120 //
   130 //
   121 void CGlxUiUtility::ConstructL()
   131 void CGlxUiUtility::ConstructL()
   122     {
   132     {
   123     TRACER("CGlxUiUtility::ConstructL()");
   133     TRACER("CGlxUiUtility::ConstructL()");
   124     iSettingsModel = CGlxSettingsModel::InstanceL();
   134     iSettingsModel = CGlxSettingsModel::InstanceL();
   125     
   135 
   126 	iOrientation = EGlxOrientationDefault; // Always start in default orientation
   136     iOrientation = EGlxOrientationDefault; // Always start in default orientation
       
   137 	
       
   138     if (!iPeriodic)
       
   139         {
       
   140         iPeriodic = CPeriodic::NewL(CActive::EPriorityStandard);
       
   141         }
       
   142 		
       
   143     if (!iPeriodic->IsActive())
       
   144         {
       
   145         iPeriodic->Start(KPeriodicStartDelay, KMaxTInt,
       
   146                 TCallBack(&PeriodicCallback, static_cast<TAny*> (this)));
       
   147         }
       
   148 		
       
   149     GridIconSizeL();
       
   150     iScreenFurniture = CGlxScreenFurniture::NewL(*this);
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // Callback from periodic timer
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 TInt CGlxUiUtility::PeriodicCallback(TAny* aPtr )
       
   158     {
       
   159     TRACER("CGlxUiUtility::PeriodicCallback");
       
   160     static_cast< CGlxUiUtility* >( aPtr )->CreateAlfEnvCallbackL();
       
   161     return KErrNone;
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // Callback from periodic timer-- non static
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CGlxUiUtility::CreateAlfEnvCallbackL()
       
   169     {
       
   170     TRACER("CGlxUiUtility::CreateAlfEnvCallbackL");
       
   171     CreateAlfEnvL();
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // Create ALF env
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 void CGlxUiUtility::CreateAlfEnvL()
       
   179     {
       
   180     TRACER("CGlxUiUtility::CreateAlfEnvL");
       
   181     if (iPeriodic->IsActive())
       
   182         {
       
   183         iPeriodic->Cancel();
       
   184         }
       
   185     
   127     iEnv = CAlfEnv::Static();
   186     iEnv = CAlfEnv::Static();
   128     if (!iEnv)
   187     if (!iEnv)
   129        {
   188        {
   130        iEnv = CAlfEnv::NewL();
   189        iEnv = CAlfEnv::NewL();
   131        }
   190        }
   141     
   200     
   142     // Add TextureManager as a skin change event observer here itself because
   201     // Add TextureManager as a skin change event observer here itself because
   143     // calling CGlxHuiUtility::Utility() in CGlxTextureManager creates a recursive call
   202     // calling CGlxHuiUtility::Utility() in CGlxTextureManager creates a recursive call
   144     // to CGlxTextureManager::NewL which again calls CGlxHuiUtility::Utility() and so on.
   203     // to CGlxTextureManager::NewL which again calls CGlxHuiUtility::Utility() and so on.
   145     AddSkinChangeObserverL( *iGlxTextureManager );    
   204     AddSkinChangeObserverL( *iGlxTextureManager );    
   146 	GridIconSizeL();
   205     
   147 	TRect rect;
   206     TRect rect;
   148 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, rect ); 
   207     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, rect ); 
   149     iAlfDisplay = &iEnv->NewDisplayL(rect,
   208     iAlfDisplay = &iEnv->NewDisplayL(rect,
   150             CAlfEnv::ENewDisplayAsCoeControl | CAlfEnv::ENewDisplayFullScreen );
   209             CAlfEnv::ENewDisplayAsCoeControl | CAlfEnv::ENewDisplayFullScreen );
   151             
   210             
   152      iEnv->AddActionObserverL (this);
   211      iEnv->AddActionObserverL (this);
   153      
   212      
   158     iGlxTvOut = CGlxTv::NewL(*this);
   217     iGlxTvOut = CGlxTv::NewL(*this);
   159     
   218     
   160     // Is the TV Out display on
   219     // Is the TV Out display on
   161     // Note that this also sets the initial size for the resolution manager
   220     // Note that this also sets the initial size for the resolution manager
   162     HandleTvStatusChangedL( ETvConnectionChanged );
   221     HandleTvStatusChangedL( ETvConnectionChanged );
   163     
   222     }
   164     iScreenFurniture = CGlxScreenFurniture::NewL(*this);
       
   165 	}
       
   166 
   223 
   167 // -----------------------------------------------------------------------------
   224 // -----------------------------------------------------------------------------
   168 // Destructor
   225 // Destructor
   169 // -----------------------------------------------------------------------------
   226 // -----------------------------------------------------------------------------
   170 //
   227 //
   171 CGlxUiUtility::~CGlxUiUtility()
   228 CGlxUiUtility::~CGlxUiUtility()
   172     {
   229     {
   173     TRACER("CGlxUiUtility::~CGlxUiUtility()");
   230     TRACER("CGlxUiUtility::~CGlxUiUtility()");
   174     GLX_LOG_INFO("~CGlxUiUtility");
   231     GLX_LOG_INFO("~CGlxUiUtility");
   175     delete iScreenFurniture;
   232 
   176     // Destroy TV Out related objects
   233     if(iClearer)
   177     delete iGlxTvOut;
   234         {
   178     delete iGlxResolutionManager;
   235         delete iClearer;
       
   236         }
       
   237 
       
   238     if(iScreenFurniture)
       
   239         {
       
   240         delete iScreenFurniture;
       
   241         }
       
   242     
       
   243     if(iGlxTvOut)
       
   244         {
       
   245         // Destroy TV Out related objects
       
   246         delete iGlxTvOut;
       
   247         }
       
   248     
       
   249     if(iGlxResolutionManager)
       
   250         {
       
   251         delete iGlxResolutionManager;
       
   252         }
       
   253     
   179     DestroyTvOutDisplay();
   254     DestroyTvOutDisplay();
   180     
   255     
   181 	if( iGlxTextureManager )
   256 	if( iGlxTextureManager )
   182 		{
   257 		{
   183 	    RemoveSkinChangeObserver( *iGlxTextureManager ); 
   258 	    RemoveSkinChangeObserver( *iGlxTextureManager ); 
   186 
   261 
   187     if(iAlfDisplay)
   262     if(iAlfDisplay)
   188         {
   263         {
   189         delete iAlfDisplay;
   264         delete iAlfDisplay;
   190         }
   265         }
   191    
   266     if(iEnv)
   192     iEnv->RemoveActionObserver(this);
   267        {
       
   268        iEnv->RemoveActionObserver(this);
       
   269        }
   193 
   270 
   194     if ( iGlxSkinChangeMonitor )
   271     if ( iGlxSkinChangeMonitor )
   195         {
   272         {
   196         iAppUi->RemoveFromStack(iGlxSkinChangeMonitor);
   273         iAppUi->RemoveFromStack(iGlxSkinChangeMonitor);
   197         delete iGlxSkinChangeMonitor;
   274         delete iGlxSkinChangeMonitor;
   199         
   276         
   200     if (!iShared)
   277     if (!iShared)
   201         {
   278         {
   202         delete iEnv;
   279         delete iEnv;
   203         }
   280         }
   204         
       
   205     iTextStyles.Close();
   281     iTextStyles.Close();
   206     if ( iSettingsModel )
   282     if ( iSettingsModel )
   207         {
   283         {
   208         iSettingsModel->Close();
   284         iSettingsModel->Close();
   209         }    
   285         }    
   210 
   286     
       
   287 	if (iPeriodic)
       
   288         {
       
   289         iPeriodic->Cancel();
       
   290         delete iPeriodic;
       
   291         }
   211     }
   292     }
   212 
   293 
   213 // -----------------------------------------------------------------------------
   294 // -----------------------------------------------------------------------------
   214 // Env
   295 // Env
   215 // -----------------------------------------------------------------------------
   296 // -----------------------------------------------------------------------------
   216 //
   297 //
   217 EXPORT_C CAlfEnv* CGlxUiUtility::Env() const
   298 EXPORT_C CAlfEnv* CGlxUiUtility::Env()
   218 	{
   299 	{
   219 	TRACER("CGlxUiUtility::Env()");
   300 	TRACER("CGlxUiUtility::EnvL()");
       
   301 	if(!iEnv)
       
   302 	    {
       
   303         TRAP_IGNORE(CreateAlfEnvL());
       
   304 	    }
   220 	return iEnv;
   305 	return iEnv;
   221 	}
   306 	}
       
   307 
   222 
   308 
   223 // -----------------------------------------------------------------------------
   309 // -----------------------------------------------------------------------------
   224 // Display
   310 // Display
   225 // -----------------------------------------------------------------------------
   311 // -----------------------------------------------------------------------------
   226 //
   312 //
   301 // -----------------------------------------------------------------------------
   387 // -----------------------------------------------------------------------------
   302 //
   388 //
   303 EXPORT_C TSize CGlxUiUtility::DisplaySize() const
   389 EXPORT_C TSize CGlxUiUtility::DisplaySize() const
   304     {
   390     {
   305     TRACER("CGlxUiUtility::DisplaySize()");
   391     TRACER("CGlxUiUtility::DisplaySize()");
   306     const TRect& rect = Env()->PrimaryDisplay().VisibleArea();
   392     const TRect& rect = CEikonEnv::Static()->EikAppUi()->ApplicationRect();
   307 	return rect.Size();
   393 	return rect.Size();
   308     }
   394     }
   309 
   395 
   310 // -----------------------------------------------------------------------------
   396 // -----------------------------------------------------------------------------
   311 // TextStyleIdL
   397 // TextStyleIdL
   748         GLX_LOG_INFO1("GetItemsLeftCount: RProperty::Get errorcode %d", err);
   834         GLX_LOG_INFO1("GetItemsLeftCount: RProperty::Get errorcode %d", err);
   749         leftVariable = 0;
   835         leftVariable = 0;
   750         }
   836         }
   751     return leftVariable;
   837     return leftVariable;
   752     }
   838     }
       
   839 
       
   840 // -----------------------------------------------------------------------------
       
   841 // DisplayScreenClearer
       
   842 // -----------------------------------------------------------------------------
       
   843 //
       
   844 EXPORT_C void CGlxUiUtility::DisplayScreenClearerL()
       
   845     {
       
   846     TRACER("CGlxUiUtility::DisplayScreenClearerL");
       
   847     if(!iClearer && CAknTransitionUtils::TransitionsEnabled(
       
   848             AknTransEffect::EFullScreenTransitionsOff))
       
   849         {
       
   850         iClearer = CAknLocalScreenClearer::NewL( ETrue );
       
   851         }
       
   852     }
       
   853 
       
   854 // -----------------------------------------------------------------------------
       
   855 // DisplayScreenClearer
       
   856 // -----------------------------------------------------------------------------
       
   857 //
       
   858 EXPORT_C void CGlxUiUtility::DestroyScreenClearer()
       
   859     {
       
   860     TRACER("CGlxUiUtility::DestroyScreenClearer");
       
   861     if(iClearer)
       
   862         {
       
   863         delete iClearer;
       
   864         iClearer = NULL;
       
   865         }
       
   866     }
   753 // End of file
   867 // End of file