imstutils/imconversationview/imcvuiapp/src/cimcvappsmileicondialog.cpp
branchRCL_3
changeset 10 d20aea8a18b6
parent 7 bef90b82da71
child 14 6b620215f837
equal deleted inserted replaced
9:9fdee5e1da30 10:d20aea8a18b6
   204 //
   204 //
   205 
   205 
   206 TInt CIMCVAppSmileIconDialog::CalculatePopupVariety()
   206 TInt CIMCVAppSmileIconDialog::CalculatePopupVariety()
   207     {
   207     {
   208     IM_CV_LOGS(TXT("CIMCVAppSmileIconDialog::CalculatePopupVariety() start") );
   208     IM_CV_LOGS(TXT("CIMCVAppSmileIconDialog::CalculatePopupVariety() start") );
   209 	CIMCVAppSmileIconGrid* grid =
       
   210 			static_cast< CIMCVAppSmileIconGrid*>(
       
   211 			Control( EIMIdSelectSmileGrid ) );   
       
   212 
   209 
   213     TAknLayoutScalableParameterLimits smileyDialogVariety = 
   210     TAknLayoutScalableParameterLimits smileyDialogVariety = 
   214     	AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
   211     	AknLayoutScalable_Avkon::popup_grid_graphic_window_ParamLimits();
   215     TInt maxVariety = smileyDialogVariety.LastVariety();
   212     TInt maxVariety = smileyDialogVariety.LastVariety();
   216 
   213 
   249 // Set dialog layout.
   246 // Set dialog layout.
   250 // (other items were commented in a header).
   247 // (other items were commented in a header).
   251 // ---------------------------------------------------------
   248 // ---------------------------------------------------------
   252 //
   249 //
   253 void CIMCVAppSmileIconDialog::SetLayout()
   250 void CIMCVAppSmileIconDialog::SetLayout()
   254 	{   
   251     {
   255 	IM_CV_LOGS(TXT("CIMCVAppSmileIconDialog::SetLayout() start") );
   252     IM_CV_LOGS(TXT("CIMCVAppSmileIconDialog::SetLayout() start"));
   256 	iIsMirrored = AknLayoutUtils::LayoutMirrored() ;
   253     iIsMirrored = AknLayoutUtils::LayoutMirrored();
   257 	TRect clientRect = iAvkonAppUi->ApplicationRect();
   254     TRect clientRect; 
   258     //check LAF docs for constants
   255     //check LAF docs for constants
   259     TAknLayoutRect mainPane;
   256     //AknLayoutUtils::LayoutMetricsRect
   260     mainPane.LayoutRect( clientRect, AknLayoutScalable_Avkon::main_pane( 6 ) );
   257     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EApplicationWindow,
   261 	
   258             clientRect);
   262 	CIMCVAppSmileIconGrid* grid =
   259     CIMCVAppSmileIconGrid* grid =
   263 
   260 
   264 			static_cast< CIMCVAppSmileIconGrid*>(
   261     static_cast<CIMCVAppSmileIconGrid*> (
   265 
   262 
   266 			Control( EIMIdSelectSmileGrid ) ); 	
   263     Control(EIMIdSelectSmileGrid));
   267 			
   264 
   268     // Select correct popup layout
   265     // Select correct popup layout
   269 
   266 
   270     TInt varietyNumber = CalculatePopupVariety();
   267     TInt varietyNumber = CalculatePopupVariety();
   271     TRect rect = grid->GetFirstCellRect();
   268     TRect rect = grid->GetFirstCellRect();
       
   269 
   272     TInt iconCount = iIconArray.Count();
   270     TInt iconCount = iIconArray.Count();
   273     // calculating the number of rows required by the icon grid.
   271     // calculating the number of rows required by the icon grid.
   274     TInt rowCount = 1 + ( iconCount/4 );
   272 
       
   273     TInt viewableWidth = 0;
   275     
   274     
   276     // 4 * rowCount denotes the maximum number of icons accomodated
   275     for (TInt i = varietyNumber; i >= 0; i--)
   277     // in the row.
   276         {
   278     TInt areaOfIcon = 4 * rowCount * rect.Width() * rect.Height();
   277 
   279 	TInt viewableWidth=0;
   278         TAknWindowLineLayout popupGridDialogLayout(
   280 	    
   279                 AknLayoutScalable_Avkon::popup_grid_graphic_window(i)); 
   281     for (TInt i=varietyNumber; i>0; i--)
   280 
   282 	    {    
   281         TAknLayoutRect dialogRect;
   283 
   282 
   284     TAknWindowLineLayout popupGridDialogLayout( 
   283         dialogRect.LayoutRect(clientRect, popupGridDialogLayout);
   285 	        AknLayoutScalable_Avkon::popup_grid_graphic_window( i ) );
   284         
   286 
   285         viewableWidth = CheckDialog(dialogRect, rect);
   287 
   286         if (viewableWidth)
   288 	    TAknLayoutRect dialogRect;
   287             {
   289 
   288             varietyNumber = i;
   290 	    dialogRect.LayoutRect(
   289             break;
   291 	        mainPane.Rect(), popupGridDialogLayout );
   290             }
   292 		    
   291         }
   293 		viewableWidth = CheckDialog(dialogRect,rect);    
   292     if (viewableWidth)
   294 	    if(viewableWidth)
   293         {
   295 		    {
   294         TAknWindowLineLayout popupGridDialogLayout(
   296 		    varietyNumber = i;
   295                 AknLayoutScalable_Avkon::popup_grid_graphic_window(
   297 		    break;
   296                         varietyNumber));
   298 		    }
   297         TAknLayoutRect dialogRect;
   299 	    }
   298         dialogRect.LayoutRect(clientRect, popupGridDialogLayout);
   300     
   299         grid->SetViewableWindowWidth(viewableWidth);
   301 	if(viewableWidth)
   300         SetRect(dialogRect.Rect());
   302 		{
   301         }
   303 	    TAknWindowLineLayout popupGridDialogLayout( 
   302     // If there is no suitable solution for the smiley dialog layout
   304         AknLayoutScalable_Avkon::popup_grid_graphic_window( varietyNumber ) );
   303     else
   305     TAknLayoutRect dialogRect;
   304         {
   306     dialogRect.LayoutRect(
   305         // No variety of the popup_grid_graphic_window has provided sufficient area
   307         mainPane.Rect(), popupGridDialogLayout );
   306         // for the grid display. Hence selecting 0 variety for displaying the grid
   308 		grid->SetViewableWindowWidth(viewableWidth);
   307         // because it has the greatest area.
   309     SetRect( dialogRect.Rect() );
   308         varietyNumber = 0;
   310 	    }
   309         TAknWindowLineLayout popupGridDialogLayout(
   311 	// If there is no suitable solution for the smiley dialog layout
   310                 AknLayoutScalable_Avkon::popup_grid_graphic_window(
   312 	else 
   311                         varietyNumber));
   313 	    {
   312 
   314 	    // Use the max variety number
   313         TAknLayoutRect dialogRect;
   315 	    varietyNumber = CalculatePopupVariety();
   314 
   316 
   315         dialogRect.LayoutRect(clientRect, popupGridDialogLayout);
   317 	    TAknWindowLineLayout popupGridDialogLayout( 
   316 
   318 	            AknLayoutScalable_Avkon::popup_grid_graphic_window( varietyNumber ) );
   317         if (!iIsMirrored)
   319 
   318             {
   320 	    TAknLayoutRect dialogRect;
   319             // Right Margin of the top left (top right) icon's X
   321 
   320             TInt leftMargin = rect.iTl.iX;
   322 	    dialogRect.LayoutRect(
   321 
   323 	            mainPane.Rect(), popupGridDialogLayout );
   322             // Use the max viewable width
   324 
   323             viewableWidth = dialogRect.Rect().iBr.iX
   325 	  
   324                     - dialogRect.Rect().iTl.iX - leftMargin;
   326 
   325             }
   327 	    if ( !iIsMirrored )
   326         else
   328 	        {
   327             {
   329 	        // Right Margin of the top left (top right) icon's X
   328             // Left Margin of the top left (top right) icon's X
   330 	        TInt leftMargin = rect.iTl.iX;
   329             TInt rightMargin = rect.iBr.iX;
   331 
   330 
   332 	        // Use the max viewable width
   331             // Use the max viewable width
   333 	        viewableWidth = dialogRect.Rect().iBr.iX - dialogRect.Rect().iTl.iX - leftMargin;
   332             viewableWidth = dialogRect.Rect().iBr.iX
   334 	        }
   333                     - dialogRect.Rect().iTl.iX + rightMargin;
   335 	    else 
   334             }
   336 	        {
   335 
   337 	        // Left Margin of the top left (top right) icon's X
   336         grid->SetViewableWindowWidth(viewableWidth);
   338 	        TInt rightMargin = rect.iBr.iX;
   337 
   339 
   338         if (!iIsMirrored)
   340 	        // Use the max viewable width
   339             SetRect(dialogRect.Rect());
   341 	        viewableWidth = dialogRect.Rect().iBr.iX - dialogRect.Rect().iTl.iX + rightMargin;
   340         // When the Hebrew is the language as well as the Arb languages
   342 	        }
   341         // The align is not right
   343 
   342         else
   344 	    grid->SetViewableWindowWidth( viewableWidth );
   343             {
   345 
   344             TRect mirroredDialogRect;
   346 	    if ( !iIsMirrored )
   345 
   347 	        SetRect( dialogRect.Rect() );
   346             // Align to right.
   348 	    // When the Hebrew is the language as well as the Arb languages
   347             mirroredDialogRect = dialogRect.Rect();
   349 	    // The align is not right
   348 
   350 	    else 
   349             // Get the rect of the cba pane.
   351 	        {
   350             TRect controlPaneRect;
   352 	        TRect mirroredDialogRect;
   351             AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane,
   353 
   352                     controlPaneRect);
   354 	        // Align to right.
   353 
   355 	        mirroredDialogRect = dialogRect.Rect();
   354             TInt cbaWidth = controlPaneRect.iBr.iX - controlPaneRect.iTl.iX;
   356 
   355 
   357 	        // Get the rect of the cba pane.
   356             mirroredDialogRect.iTl.iX -= cbaWidth;
   358 	        TRect controlPaneRect;
   357             mirroredDialogRect.iBr.iX -= cbaWidth;
   359 	        AknLayoutUtils::LayoutMetricsRect(
   358 
   360 	                AknLayoutUtils::EControlPane, controlPaneRect);
   359             SetRect(mirroredDialogRect);
   361 
   360             }
   362 	        TInt cbaWidth = controlPaneRect.iBr.iX - controlPaneRect.iTl.iX;
   361         }
   363 
   362     }
   364 	        mirroredDialogRect.iTl.iX -= cbaWidth;
       
   365 	        mirroredDialogRect.iBr.iX -= cbaWidth;
       
   366 
       
   367 	        SetRect( mirroredDialogRect );
       
   368 	        }
       
   369 	    }
       
   370 	}
       
   371 
   363 
   372 
   364 
   373 
   365 
   374 // ---------------------------------------------------------
   366 // ---------------------------------------------------------
   375 
   367 
   381 
   373 
   382 // ---------------------------------------------------------
   374 // ---------------------------------------------------------
   383 
   375 
   384 TInt CIMCVAppSmileIconDialog::CheckDialog(TAknLayoutRect aDialogRect,TRect aRect)
   376 TInt CIMCVAppSmileIconDialog::CheckDialog(TAknLayoutRect aDialogRect,TRect aRect)
   385 		{
   377 		{
   386         TInt topMargin = aRect.iTl.iY;
   378         // topMargin is the height of the margin which the smiley grid has 
       
   379         // above its top horizontal line and bottom horizontal line.
       
   380         TInt topMargin = aRect.Height();
   387         
   381         
   388         TInt viewableWidth = 0;
   382         TRect dialogRect = aDialogRect.Rect();
   389         
   383         
       
   384         TInt vWidth = 0;
       
   385         TInt vheight = 0;
       
   386         TInt vArea = 0;
       
   387         vheight = dialogRect.iBr.iY - dialogRect.iTl.iY - 2*topMargin;
   390         if ( !iIsMirrored )
   388         if ( !iIsMirrored )
   391             {
   389             {
   392             TInt leftMargin = aRect.iTl.iX;
   390             vWidth = dialogRect.iBr.iX - dialogRect.iTl.iX - 2*aRect.iTl.iX;;
   393                     
       
   394             viewableWidth = aDialogRect.Rect().iBr.iX - aDialogRect.Rect().iTl.iX - 2*leftMargin;
       
   395             }
   391             }
   396         else 
   392         else 
   397             {
   393             {
   398             TInt rightMargin = aRect.iBr.iX;
   394             vWidth = dialogRect.iBr.iX - dialogRect.iTl.iX + 2*aRect.iBr.iX;
   399                                 
   395             }
   400             viewableWidth = aDialogRect.Rect().iBr.iX - aDialogRect.Rect().iTl.iX + 2*rightMargin;
   396 		vArea = vWidth*vheight;
   401             }
       
   402         TInt viewableHight = aDialogRect.Rect().iBr.iY -aDialogRect.Rect().iTl.iY - topMargin;
       
   403 		
       
   404 		TInt viewableArea = viewableWidth*viewableHight;
       
   405 		
   397 		
   406 	    TInt iconCount = iIconArray.Count();
   398 	    TInt iconCount = iIconArray.Count();
   407 
   399 
   408 	    // calculating the number of rows required by the icon grid.
   400 	    TInt areaOfIcon = iconCount * aRect.Width() * aRect.Height();
   409 	    TInt rowCount = 1 + ( iconCount/4 );
       
   410 	    
   401 	    
   411 	    // 4 * rowCount denotes the maximum number of icons accomodated
   402 	    if(areaOfIcon > vArea)
   412 	    // in the row.
       
   413 	    TInt areaOfIcon = 4 * rowCount * aRect.Width() * aRect.Height();
       
   414 	    
       
   415 	    if(areaOfIcon > viewableArea)
       
   416 		    {
   403 		    {
   417 			return 0;
   404 			return 0;
   418 		    }
   405 		    }
   419 		else
   406 		else
   420 			{
   407 			{
   421 			return viewableWidth;
   408 			return vWidth;
   422 			}
   409 			}
   423 		}
   410 		}
   424 
   411 
   425 
   412 
   426 // ---------------------------------------------------------
   413 // ---------------------------------------------------------