imstutils/imconversationview/imcvuiapp/src/cimcvappsmileicongrid.cpp
branchRCL_3
changeset 16 d20aea8a18b6
parent 0 5e5d6b214f4f
child 18 36d367c62acb
equal deleted inserted replaced
14:9fdee5e1da30 16:d20aea8a18b6
    32 #include "imcvuiapputils.h"
    32 #include "imcvuiapputils.h"
    33 
    33 
    34 #include "mimcvtapeventobserver.h"
    34 #include "mimcvtapeventobserver.h"
    35 
    35 
    36 // CONSTANTS
    36 // CONSTANTS
       
    37 
       
    38     // -- The (KTopLeft_x,KTopLeft_y) and (KBottomRight_x,KBottomRight_y) are the co ordinates of the 
       
    39     // topleft and bottomright points of the first cell in the grid.
       
    40     // These co-ordinates to draw the grid lines and the logic to draw the grid lines is based on the topleft 
       
    41     //and bottomright points of the first cell in the grid
       
    42 #define KTopLeft_x 56
       
    43 #define KTopLeft_y 55
       
    44 #define KBottomRight_x 105
       
    45 #define KBottomRight_y 104
       
    46 
    37 // ================= MEMBER FUNCTIONS =======================
    47 // ================= MEMBER FUNCTIONS =======================
    38 
    48 
    39 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    40 // CIMCVAppSmileIconGrid::NewL
    50 // CIMCVAppSmileIconGrid::NewL
    41 // (other items were commented in a header).
    51 // (other items were commented in a header).
   223 // (other items were commented in a header).
   233 // (other items were commented in a header).
   224 // ---------------------------------------------------------
   234 // ---------------------------------------------------------
   225 //
   235 //
   226 void CIMCVAppSmileIconGrid::SetLayout()
   236 void CIMCVAppSmileIconGrid::SetLayout()
   227     {
   237     {
   228     IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::SetLayout() start") );
   238     IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::SetLayout() start"));
   229  	iIsMirrored = AknLayoutUtils::LayoutMirrored() ;
   239     iIsMirrored = AknLayoutUtils::LayoutMirrored();
   230     
   240 
   231     // popup_grid_graphic_window (Parent)
   241     // popup_grid_graphic_window (Parent)
   232     TRect parentRect( iParent->Rect() );
   242     TRect parentRect(iParent->Rect());
   233    
   243 
   234     // listscroll_popup_graphic_pane (this compoment)
   244     // listscroll_popup_graphic_pane (this compoment)
   235     TAknLayoutRect listLayoutRect;
   245     TAknLayoutRect listLayoutRect;
   236     listLayoutRect.LayoutRect( 
   246     listLayoutRect.LayoutRect(parentRect,
   237         parentRect, 
   247             AknLayoutScalable_Avkon::listscroll_popup_graphic_pane(0));
   238         AknLayoutScalable_Avkon::listscroll_popup_graphic_pane() );
   248 
   239     
       
   240     // grid_graphic_popup_pane
   249     // grid_graphic_popup_pane
   241     TAknLayoutRect gridLayoutRect;
   250     TAknLayoutRect gridLayoutRect;
   242     gridLayoutRect.LayoutRect( 
   251     gridLayoutRect.LayoutRect(listLayoutRect.Rect(),
   243         listLayoutRect.Rect(), 
   252             AknLayoutScalable_Avkon::grid_graphic_popup_pane(0));
   244         AknLayoutScalable_Avkon::grid_graphic_popup_pane( 0 ) );
   253 
   245   
   254     // cell_graphic_popup_pane (upper left cell)
   246 	// cell_graphic_popup_pane (upper left cell)
   255     TAknLayoutRect oneCellRect;
   247 	TAknLayoutRect oneCellRect;
   256     oneCellRect.LayoutRect(gridLayoutRect.Rect(),
   248 	oneCellRect.LayoutRect( 
   257             AknLayoutScalable_Avkon::cell_graphic_popup_pane(0, 0, 0));
   249         gridLayoutRect.Rect(), 
   258 
   250         AknLayoutScalable_Avkon::cell_graphic_popup_pane( 0, 0, 0 ) );
       
   251    
       
   252     iFirstCell = oneCellRect.Rect();
   259     iFirstCell = oneCellRect.Rect();
   253     iCellWidth = iFirstCell.Width();
   260     iCellWidth = iFirstCell.Width();
   254     iCellHeight = iFirstCell.Height();
   261     iCellHeight = iFirstCell.Height();
   255 
   262 
   256     // cell_graphic_popup_pane_g1 (icon size)
   263     // cell_graphic_popup_pane_g1 (icon size)
   257     TAknLayoutRect myIconRect;
   264     TAknLayoutRect myIconRect;
   258     myIconRect.LayoutRect( 
   265     myIconRect.LayoutRect(iFirstCell,
   259         iFirstCell, 
   266             AknLayoutScalable_Avkon::cell_graphic_popup_pane_g1(0));
   260         AknLayoutScalable_Avkon::cell_graphic2_pane_g5(0) );
       
   261     
       
   262     iIconSize = myIconRect.Rect().Size();
   267     iIconSize = myIconRect.Rect().Size();
   263     IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::SetLayout() end") );
   268     IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::SetLayout() end") );
   264     }
   269     }
   265    
   270    
   266 // ---------------------------------------------------------
   271 // ---------------------------------------------------------
   328 //
   333 //
   329 void CIMCVAppSmileIconGrid::Draw( const TRect& /* aRect */ ) const
   334 void CIMCVAppSmileIconGrid::Draw( const TRect& /* aRect */ ) const
   330 	{
   335 	{
   331 	IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::Draw() start") );
   336 	IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::Draw() start") );
   332 	CWindowGc& gc = SystemGc();
   337 	CWindowGc& gc = SystemGc();
   333 
       
   334 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   338 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   335 	MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
   339 	MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
   336 
   340 
   337 	if( !iDragEvent )
   341 	if( !iDragEvent )
   338 		{
   342 		{
   366 			// last row is full
   370 			// last row is full
   367     	    lastRowIconsCount = iMaxColumns;
   371     	    lastRowIconsCount = iMaxColumns;
   368 			}
   372 			}
   369 
   373 
   370 		TInt i( 0 );
   374 		TInt i( 0 );
   371 
   375 		TPoint cellLeftTop( KTopLeft_x,KTopLeft_y );
       
   376 		TPoint cellBottomRight( KBottomRight_x,KBottomRight_y );
   372 		if(!iIsMirrored)	
   377 		if(!iIsMirrored)	
   373 			{
   378 			{
   374 			//draw horizontal lines
   379 			//draw horizontal lines
   375 			for( i = 0; i <= iRowCount; ++i )
   380 			for( i = 0; i <= iRowCount; ++i )
   376 				{
   381 				{
   377 				TPoint startPoint( iFirstCell.iTl );
   382 				TPoint startPoint( cellLeftTop );
   378 				TPoint endPoint( iFirstCell.iTl );
   383 				TPoint endPoint( cellLeftTop );
   379 				startPoint.iY += i * iCellHeight;
   384 				startPoint.iY += i * iCellHeight;
   380 				endPoint.iY += i * iCellHeight;
   385 				endPoint.iY += i * iCellHeight;
   381 				endPoint.iX += ( ( i == iRowCount ) || ( i == 0 && iRowCount == 1 )
   386 				endPoint.iX += ( ( i == iRowCount ) || ( i == 0 && iRowCount == 1 )
   382 				    ? ( lastRowIconsCount ) 
   387 				    ? ( lastRowIconsCount ) 
   383     		    * iCellWidth : iMaxColumns * iCellWidth );
   388     		    * iCellWidth : iMaxColumns * iCellWidth );
   387 				}
   392 				}
   388 
   393 
   389 			//draw vertical lines
   394 			//draw vertical lines
   390     	for( i = 0; i <= iMaxColumns; ++i )
   395     	for( i = 0; i <= iMaxColumns; ++i )
   391 				{
   396 				{
   392 				TPoint startPoint( iFirstCell.iTl );
   397         TPoint startPoint( cellLeftTop );
   393 				TPoint endPoint( iFirstCell.iTl );
   398         TPoint endPoint( cellLeftTop );
   394 				startPoint.iX += i * iCellWidth;
   399 				startPoint.iX += i * iCellWidth;
   395 				endPoint.iX += i * iCellWidth;
   400 				endPoint.iX += i * iCellWidth;
   396 				endPoint.iY += ( i <= lastRowIconsCount ? 
   401 				endPoint.iY += ( i <= lastRowIconsCount ? 
   397 				    iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1  ) );
   402 				    iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1  ) );
   398 				gc.DrawLine( startPoint, endPoint );
   403 				gc.DrawLine( startPoint, endPoint );
   401 		else
   406 		else
   402 			{
   407 			{
   403 			//draw horizontal lines
   408 			//draw horizontal lines
   404 			for( i = 0; i <= iRowCount; ++i )
   409 			for( i = 0; i <= iRowCount; ++i )
   405 				{
   410 				{
   406 				TPoint startPoint( iFirstCell.iBr.iX, iFirstCell.iTl.iY);
   411 				TPoint startPoint( cellBottomRight.iX, cellLeftTop.iY);
   407 				TPoint endPoint( iFirstCell.iBr.iX, iFirstCell.iTl.iY );
   412 				TPoint endPoint( cellBottomRight.iX, cellLeftTop.iY );
   408 				startPoint.iY += i * iCellHeight;
   413 				startPoint.iY += i * iCellHeight;
   409 				endPoint.iY += i * iCellHeight;
   414 				endPoint.iY += i * iCellHeight;
   410 				endPoint.iX -= ( ( i == iRowCount ) || ( i == 0 && iRowCount == 1 )
   415 				endPoint.iX -= ( ( i == iRowCount ) || ( i == 0 && iRowCount == 1 )
   411 				    ? ( lastRowIconsCount ) 
   416 				    ? ( lastRowIconsCount ) 
   412     		    * iCellWidth : iMaxColumns * iCellWidth );
   417     		    * iCellWidth : iMaxColumns * iCellWidth );
   416 				}
   421 				}
   417 
   422 
   418 			//draw vertical lines
   423 			//draw vertical lines
   419     	for( i = 0; i <= iMaxColumns; ++i )
   424     	for( i = 0; i <= iMaxColumns; ++i )
   420 				{
   425 				{
   421 				TPoint startPoint( iFirstCell.iBr.iX, iFirstCell.iTl.iY );
   426 				TPoint startPoint( cellBottomRight.iX, cellLeftTop.iY );
   422 				TPoint endPoint( iFirstCell.iBr.iX, iFirstCell.iTl.iY);
   427 				TPoint endPoint( cellBottomRight.iX, cellLeftTop.iY);
   423 				startPoint.iX -= i * iCellWidth;
   428 				startPoint.iX -= i * iCellWidth;
   424 				endPoint.iX -= i * iCellWidth;
   429 				endPoint.iX -= i * iCellWidth;
   425 				endPoint.iY += ( i <= lastRowIconsCount ? 
   430 				endPoint.iY += ( i <= lastRowIconsCount ? 
   426 				    iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1  ) );
   431 				    iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1  ) );
   427 				gc.DrawLine( startPoint, endPoint );
   432 				gc.DrawLine( startPoint, endPoint );
   455                        MAknsControlContext* aSkinCc,
   460                        MAknsControlContext* aSkinCc,
   456                        TInt aIndex, TBool aSelected ) const
   461                        TInt aIndex, TBool aSelected ) const
   457     {
   462     {
   458     IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::DrawItem() start") );
   463     IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::DrawItem() start") );
   459     //lets count currect cell
   464     //lets count currect cell
   460     TRect myRect  = iFirstCell;
   465     TPoint cellLeftTop( KTopLeft_x,KTopLeft_y );
       
   466     TPoint cellBottomRight( KBottomRight_x,KBottomRight_y );
       
   467 
       
   468     TRect myRect;
       
   469     myRect.SetRect( cellLeftTop, cellBottomRight );
   461     TPoint offset;
   470     TPoint offset;
   462     
   471     
   463     if(!iIsMirrored)
   472     if(!iIsMirrored)
   464     {
   473     {
   465     	offset.iX = ( aIndex % iMaxColumns ) * iCellWidth;	
   474     	offset.iX = ( aIndex % iMaxColumns ) * iCellWidth;	
   506             {
   515             {
   507             aGc.DrawRect( myHighLightRect );    
   516             aGc.DrawRect( myHighLightRect );    
   508             }
   517             }
   509         }
   518         }
   510     
   519     
   511     TAknWindowLineLayout myIconLayout( AknLayoutScalable_Avkon::cell_graphic2_pane_g5(0) );
   520 
   512 
   521     TAknWindowLineLayout myIconLayout( AknLayoutScalable_Avkon::cell_graphic_popup_pane_g1(0) );
       
   522     
   513     TAknLayoutRect myIconRect;
   523     TAknLayoutRect myIconRect;
   514     myIconRect.LayoutRect( myRect, myIconLayout );
   524     myIconRect.LayoutRect( myRect, myIconLayout );
   515 
   525 
   516 	if( aIndex < iIconArray.Count() )
   526 	if( aIndex < iIconArray.Count() )
   517 	    {
   527 	    {