mulwidgets/mulcoverflowwidget/src/mulcovertemplate4.cpp
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Description of various grid templates
       
    15  *
       
    16 */
       
    17 
       
    18  
       
    19 #include "mulcoverflowtemplate.h"
       
    20 
       
    21 #include <AknUtils.h>
       
    22 
       
    23 #include <alf/alftextvisual.h>
       
    24 #include <alf/alfutil.h>
       
    25 #include "mulassert.h"
       
    26 
       
    27 namespace Alf
       
    28     {
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // MulCoverLogicalTemplate4
       
    32 // ---------------------------------------------------------------------------
       
    33 //  
       
    34 MulCoverFlowTemplate4::MulCoverFlowTemplate4(MulCoverFlowControl &aControl, 
       
    35         MulBaseElement &aBaseElement):MulCoverFlowTemplate(aControl, aBaseElement)
       
    36     {
       
    37     
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // ~MulCoverLogicalTemplate4
       
    42 // ---------------------------------------------------------------------------
       
    43 //  
       
    44 MulCoverFlowTemplate4::~MulCoverFlowTemplate4()
       
    45     {
       
    46     
       
    47     }
       
    48     
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // GetIconSize
       
    52 // ---------------------------------------------------------------------------
       
    53 //  
       
    54 void MulCoverFlowTemplate4::GetIconSize(mulvisualitem::TVisualAttribute aAttribute,bool aIslandscape, int& aHeight, int& aWidth)
       
    55 	{
       
    56 	int appMainPaneVerityId;
       
    57 	int coverFlowPaneVarietyId;
       
    58 	int imagePaneVerityId ;
       
    59 	int videoIndVerityId ;
       
    60 	if (aIslandscape)
       
    61 		{
       
    62 		appMainPaneVerityId = 7;
       
    63 		coverFlowPaneVarietyId = 1;
       
    64 		imagePaneVerityId = 6;
       
    65 		videoIndVerityId = 0;
       
    66 		}
       
    67 	else
       
    68 		{
       
    69 		appMainPaneVerityId = 7;
       
    70 		coverFlowPaneVarietyId = 1;
       
    71 		imagePaneVerityId = 6;
       
    72 		videoIndVerityId = 0;
       
    73 		}
       
    74 	
       
    75 	// Get  the size of the appwindow
       
    76 	TAknWindowLineLayout appMainLayout = 
       
    77 		AknLayoutScalable_UiAccel::main_pane(appMainPaneVerityId).LayoutLine();
       
    78 	TAknLayoutRect appMainRect;
       
    79 	appMainRect.LayoutRect(  AlfUtil::ScreenSize(), appMainLayout );
       
    80 	TSize appMainSize(appMainRect.Rect().Size());
       
    81 	
       
    82 	// Get the size of the coverflow main window
       
    83 	TAknWindowLineLayout mainLayout = 
       
    84 	AknLayoutScalable_UiAccel::main_aa_coverflow_pane(coverFlowPaneVarietyId).LayoutLine();
       
    85 	TAknLayoutRect mainRect;
       
    86 	mainRect.LayoutRect(  AlfUtil::ScreenSize(), mainLayout );
       
    87 	TSize mainSize(mainRect.Rect().Size());
       
    88 
       
    89 	switch(aAttribute)
       
    90 		{
       
    91 		case mulvisualitem::KMulIcon1:
       
    92 			{
       
    93             TAknWindowLineLayout centerLayout = 
       
    94                 AknLayoutScalable_UiAccel::aacf_image_pane(imagePaneVerityId).LayoutLine();
       
    95             TAknLayoutRect centerRect;
       
    96             centerRect.LayoutRect( TSize(mainSize), centerLayout );
       
    97             aHeight = centerRect.Rect().Size().iHeight;
       
    98             aWidth  = centerRect.Rect().Size().iWidth;
       
    99 			break;
       
   100 			}
       
   101 		case mulvisualitem::KMulIndicator2:
       
   102 			{
       
   103             TAknWindowLineLayout centerLayout = 
       
   104                 AknLayoutScalable_UiAccel::main_aa_video_pane_g1(videoIndVerityId).LayoutLine();
       
   105             TAknLayoutRect centerRect;
       
   106             centerRect.LayoutRect( TSize(mainSize), centerLayout );
       
   107             aHeight = centerRect.Rect().Size().iHeight;
       
   108             aWidth  = centerRect.Rect().Size().iWidth;			
       
   109 			break;
       
   110 			}
       
   111 		default:
       
   112 			{
       
   113 			// invalid attribute
       
   114 			// raise exception.
       
   115 			__MUL_ASSERT(false,KInvalidAttribute);
       
   116 			
       
   117 			break;
       
   118 			}
       
   119 		}
       
   120 	}
       
   121     
       
   122     
       
   123 // ---------------------------------------------------------------------------
       
   124 // CreateVisualisation
       
   125 // ---------------------------------------------------------------------------
       
   126 //  
       
   127 void MulCoverFlowTemplate4::CreateVisualisation(bool aIsLandscape,bool aIsOrientationChange)
       
   128 	{
       
   129 	// set the default attribue of the template
       
   130 	// irrespective of the orientation
       
   131     mData->mSliderEnabled = false;
       
   132     mData->mUiOnOffFlag = true;
       
   133 	mData->mMaxVisibleCount = 1;
       
   134 	mData->mEnhancedSupportFlag = true;
       
   135 	
       
   136     // store the default attribute in base element
       
   137     mData->mBaseElement->SetFitMode(true);
       
   138 	mData->mBaseElement->StoreTextVisibility( false );
       
   139 	
       
   140     // get the main text layout
       
   141     CAlfLayout& textLayout = mData->mBaseElement->TextLayout();	
       
   142     textLayout.SetOpacity(0);
       
   143 	
       
   144 	mData->mOrientationChange = aIsOrientationChange;
       
   145 	if (aIsLandscape)
       
   146 		{
       
   147 		// create visualisation for landscape
       
   148 		CreateLscStructure();
       
   149 		}
       
   150 	else
       
   151 		{
       
   152 		// create visualisation for potrait
       
   153 		CreatePrtStructure();
       
   154 		}
       
   155 	mData->mOrientationChange = false;
       
   156 	}
       
   157 
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // CreatePrtStructure
       
   161 // ---------------------------------------------------------------------------
       
   162 //  
       
   163 void MulCoverFlowTemplate4::CreatePrtStructure()
       
   164 	{
       
   165 	// list of all component lct verity id.
       
   166 	int mainPaneVerityId = 1;
       
   167 	int imagePaneVerityId = 6;
       
   168 	int videoPaneVerityId = 0;
       
   169 	int counterPaneVerityId = 3;
       
   170 	
       
   171 	CAlfVisual* main = mData->mBaseElement->findVisual(KMainLayoutIndex);        
       
   172 	CAlfLayout* parentLayout = main->Layout();
       
   173 	TSize mainSize = parentLayout->Size().Target().AsSize();
       
   174 	
       
   175 	// get for main layout
       
   176 	TAknWindowLineLayout componentLayout = 
       
   177 		AknLayoutScalable_UiAccel::main_aa_coverflow_pane(mainPaneVerityId).LayoutLine();
       
   178 	TRect mainRect = IconWindowRect(componentLayout, mainSize);
       
   179 	main->SetPos(TAlfRealPoint(0,0));
       
   180 	main->SetSize(mainRect.Size());
       
   181 	
       
   182 	
       
   183 	// for deck layout
       
   184 	CAlfDeckLayout& deckLayout = static_cast<CAlfDeckLayout&>(
       
   185 	        static_cast<CAlfLayout*>(main)->Visual(KMainLayoutIndex) );
       
   186 	deckLayout.SetSize(mainRect.Size(),0);
       
   187 	
       
   188 	// if set background with some skin id is called before calling set model
       
   189 	// then the visual and texture would be created with 0,0 sizes
       
   190 	// hence we need to resize them                
       
   191 	CAlfVisual* backgroundVisual = deckLayout.FindTag(backgroundvisual);
       
   192 	if(backgroundVisual)
       
   193 	   {
       
   194 	   backgroundVisual->SetSize(mainRect.Size(),0);              
       
   195 	   }
       
   196 	
       
   197 	// for center item	  
       
   198     componentLayout = 
       
   199         AknLayoutScalable_UiAccel::aacf_image_pane(imagePaneVerityId).LayoutLine();
       
   200 	TRect centerRect = IconWindowRect(componentLayout,mainRect);          
       
   201 	
       
   202 	TMulCoverFlowItem highlightItem(centerRect.iTl.iX,
       
   203 		centerRect.iTl.iY,centerRect.Size().iWidth,centerRect.Size().iHeight);
       
   204 
       
   205 	// apply attribute
       
   206     mData->mBaseElement->StoreVisualDimensions(highlightItem,highlightItem,mData->mMaxVisibleCount );
       
   207 	 
       
   208    
       
   209 	 
       
   210 	 // for indicator icon
       
   211 	componentLayout =
       
   212 	    AknLayoutScalable_UiAccel::main_aa_video_pane_g1(videoPaneVerityId).LayoutLine();
       
   213 	TRect indRect = IconWindowRect(componentLayout,mainRect);
       
   214     TSize indSize(indRect.Size());
       
   215     mData->mIndicatorDimensions.height = indSize.iHeight;
       
   216     mData->mIndicatorDimensions.width  = indSize.iWidth;
       
   217     mData->mIndicatorDimensions.posx   = indRect.iTl.iX;
       
   218     mData->mIndicatorDimensions.posy   = indRect.iTl.iY; 
       
   219     
       
   220     // crete counter
       
   221     ApplyCounterAttribute(counterPaneVerityId,mainRect);
       
   222 	}
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // CreateLscStructure
       
   226 // ---------------------------------------------------------------------------
       
   227 //  
       
   228 void MulCoverFlowTemplate4::CreateLscStructure()
       
   229 	{
       
   230 	// list of all component lct verity id.
       
   231 	int mainPaneVerityId = 1;
       
   232 	int imagePaneVerityId = 6;
       
   233 	int videoPaneVerityId = 0;
       
   234 	int counterPaneVerityId = 6;
       
   235 	if(AknLayoutUtils::CbaLocation() == AknLayoutUtils::EAknCbaLocationRight)
       
   236 	    {
       
   237 	    counterPaneVerityId = 8;
       
   238 	    }
       
   239 	
       
   240 	CAlfVisual* main = mData->mBaseElement->findVisual(KMainLayoutIndex);        
       
   241 	CAlfLayout* prntLay = main->Layout();
       
   242 	TSize main_size = prntLay->Size().Target().AsSize();
       
   243 	TAknWindowLineLayout componentLayout;
       
   244 
       
   245 	// get for main layout
       
   246 	componentLayout = 
       
   247 		AknLayoutScalable_UiAccel::main_aa_coverflow_pane(mainPaneVerityId).LayoutLine();
       
   248 	TRect mainRect = IconWindowRect(componentLayout, main_size);
       
   249 	main->SetPos(TAlfRealPoint(0,0));
       
   250 	main->SetSize(mainRect.Size());
       
   251 	
       
   252 	// for deck layout
       
   253 	CAlfDeckLayout& deckLayout = static_cast<CAlfDeckLayout&>(
       
   254 	        static_cast<CAlfLayout*>(main)->Visual(KMainLayoutIndex) );
       
   255 	deckLayout.SetSize(mainRect.Size(),0);
       
   256 	
       
   257 	// if set background with some skin id is called before calling set model
       
   258 	// then the visual and texture would be created with 0,0 sizes
       
   259 	// hence we need to resize them                
       
   260 	CAlfVisual* backgroundVisual = deckLayout.FindTag(backgroundvisual);
       
   261 	if(backgroundVisual)
       
   262 	   {
       
   263 	   backgroundVisual->SetSize(mainRect.Size(),0);              
       
   264 	   }
       
   265 	
       
   266 	// for center item
       
   267 	  
       
   268     componentLayout = 
       
   269         AknLayoutScalable_UiAccel::aacf_image_pane(imagePaneVerityId).LayoutLine();
       
   270 	TRect centerRect = IconWindowRect(componentLayout,mainRect);          
       
   271 
       
   272 	TMulCoverFlowItem highlightItem(centerRect.iTl.iX,
       
   273 		centerRect.iTl.iY,centerRect.Size().iWidth,centerRect.Size().iHeight);
       
   274 	
       
   275 	// apply attribute
       
   276     mData->mBaseElement->StoreVisualDimensions(highlightItem,highlightItem,mData->mMaxVisibleCount );
       
   277 	   
       
   278  
       
   279 	 // for indicator icon
       
   280 	componentLayout =
       
   281 	    AknLayoutScalable_UiAccel::main_aa_video_pane_g1(videoPaneVerityId).LayoutLine();
       
   282 	TRect indRect = IconWindowRect(componentLayout,mainRect);
       
   283     TSize indSize(indRect.Size());
       
   284     mData->mIndicatorDimensions.height = indSize.iHeight;
       
   285     mData->mIndicatorDimensions.width  = indSize.iWidth;
       
   286     mData->mIndicatorDimensions.posx   = indRect.iTl.iX;
       
   287     mData->mIndicatorDimensions.posy   = indRect.iTl.iY; 
       
   288     
       
   289     // crete counter
       
   290     ApplyCounterAttribute(counterPaneVerityId,mainRect);
       
   291 	}
       
   292 	
       
   293 // ---------------------------------------------------------------------------
       
   294 // ApplyCounterAttribute
       
   295 // ---------------------------------------------------------------------------
       
   296 //  
       
   297 void MulCoverFlowTemplate4::ApplyCounterAttribute(int acounterPaneVerityId,const TRect& aMainRect)
       
   298 	{
       
   299     mData->mUiOnOffFlag = true;
       
   300 	TAknTextLineLayout counterComponentLayout = 
       
   301 		AknLayoutScalable_UiAccel::main_aa_coverflow_pane_t1(acounterPaneVerityId).LayoutLine();   
       
   302     	
       
   303 	TRect counterRect = TextWindowRect(counterComponentLayout, aMainRect);
       
   304 	TSize counterSize(counterRect.Size());
       
   305 	mData->mCounterDimensions.posx = counterRect.iTl.iX;
       
   306 	mData->mCounterDimensions.posy = counterRect.iTl.iY;
       
   307 	mData->mCounterDimensions.width = counterSize.iWidth;
       
   308 	mData->mCounterDimensions.height = counterSize.iHeight;
       
   309 	
       
   310 	// Create a Counter visual if it is not Created.
       
   311 	CAlfTextVisual& counterVisual = mData->mBaseElement->CounterVisual();
       
   312 	
       
   313     // Set Properties to Counter Visual if we are creating.
       
   314     // no need to apply attribute for orientation change
       
   315     // as all are same.
       
   316     if(!mData->mOrientationChange)
       
   317 	    {
       
   318 	    //get font Id for counter
       
   319 	    int fontId = counterComponentLayout.FontId();
       
   320 	    int counterFontId = 0x000000FF &  fontId;
       
   321 		// apply default brush color to the counter background
       
   322 		ApplyBrush(counterVisual,KRgbBlack,0.5); 
       
   323 		// apply default attribute
       
   324 		counterVisual.SetAlign(EAlfAlignHCenter,EAlfAlignVCenter);
       
   325 	    SetTextStyle(counterFontId, counterVisual);       
       
   326 
       
   327 		// check if user has set some different attribute.
       
   328 		TMulVisualColorProperty counterColor = mData->mBaseElement->TextColor(ECounterVisual);
       
   329 		if (counterColor.mIsColorSet)
       
   330 			{
       
   331 			// apply the color set by the application
       
   332 			counterVisual.SetColor(counterColor.mColor);
       
   333 			}
       
   334 		else
       
   335 			{
       
   336 			// apply the default color
       
   337 			counterVisual.SetColor(KRgbWhite);
       
   338 			}
       
   339 		mData->mCounterFontMaxCharLength = UpdateMaxFontWidth(&counterVisual);						
       
   340 	    }
       
   341 	
       
   342 	}
       
   343       
       
   344     }//namespace ends