imstutils/imconversationview/imcvuiapp/src/cimcvappsmileicongrid.cpp
branchRCL_3
changeset 13 76f25fb7a6a1
parent 12 36d367c62acb
child 14 6b620215f837
equal deleted inserted replaced
12:36d367c62acb 13:76f25fb7a6a1
    28 #include <aknappui.h>
    28 #include <aknappui.h>
    29 #include <aknlayoutscalable_avkon.cdl.h>
    29 #include <aknlayoutscalable_avkon.cdl.h>
    30 #include <AknDef.h>
    30 #include <AknDef.h>
    31 #include "imcvlogger.h"
    31 #include "imcvlogger.h"
    32 #include "imcvuiapputils.h"
    32 #include "imcvuiapputils.h"
    33 
       
    34 #include "mimcvtapeventobserver.h"
    33 #include "mimcvtapeventobserver.h"
    35 
    34 
       
    35 
    36 // CONSTANTS
    36 // CONSTANTS
    37 
    37 // The (KTopLeft_x,KTopLeft_y) and (KBottomRight_x,KBottomRight_y) are the co ordinates of the 
    38     // -- The (KTopLeft_x,KTopLeft_y) and (KBottomRight_x,KBottomRight_y) are the co ordinates of the 
    38 // topleft and bottomright points of the first cell in the grid.
    39     // topleft and bottomright points of the first cell in the grid.
    39 // These co-ordinates to draw the grid lines and the logic to draw the grid lines is based on the topleft 
    40     // These co-ordinates to draw the grid lines and the logic to draw the grid lines is based on the topleft 
    40 // and bottomright points of the first cell in the grid.
    41     //and bottomright points of the first cell in the grid
       
    42 #define KTopLeft_x 56
    41 #define KTopLeft_x 56
    43 #define KTopLeft_y 55
    42 #define KTopLeft_y 55
    44 #define KBottomRight_x 105
    43 #define KBottomRight_x 105
    45 #define KBottomRight_y 104
    44 #define KBottomRight_y 104
       
    45 
    46 
    46 
    47 // ================= MEMBER FUNCTIONS =======================
    47 // ================= MEMBER FUNCTIONS =======================
    48 
    48 
    49 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    50 // CIMCVAppSmileIconGrid::NewL
    50 // CIMCVAppSmileIconGrid::NewL
   338 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   338 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   339 	MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
   339 	MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
   340 
   340 
   341 	if( !iDragEvent )
   341 	if( !iDragEvent )
   342 		{
   342 		{
   343 		//draw the grid
   343 		// Draw the grid
   344 		gc.SetPenStyle(CGraphicsContext::ESolidPen);    
   344 		gc.SetPenStyle(CGraphicsContext::ESolidPen);    
   345 		gc.SetBrushStyle(CGraphicsContext::ENullBrush);
   345 		gc.SetBrushStyle(CGraphicsContext::ENullBrush);
   346 		gc.SetPenSize(TSize(1,1));    
   346 		gc.SetPenSize(TSize(1,1));    
   347 		gc.SetPenColor(AKN_LAF_COLOR(215));
   347 		gc.SetPenColor(AKN_LAF_COLOR(215));
   348 
   348 
   365 			}
   365 			}
   366 
   366 
   367     	TInt lastRowIconsCount = iIconCount % iMaxColumns;
   367     	TInt lastRowIconsCount = iIconCount % iMaxColumns;
   368 		if( lastRowIconsCount == 0 && iIconCount > 0 )
   368 		if( lastRowIconsCount == 0 && iIconCount > 0 )
   369 			{
   369 			{
   370 			// last row is full
   370 			// Last row is full
   371     	    lastRowIconsCount = iMaxColumns;
   371     	    lastRowIconsCount = iMaxColumns;
   372 			}
   372 			}
   373 
   373 
   374 		TInt i( 0 );
   374 		TInt i( 0 );
   375 		TPoint cellLeftTop( KTopLeft_x,KTopLeft_y );
   375 		TPoint cellLeftTop( KTopLeft_x,KTopLeft_y );
   376 		TPoint cellBottomRight( KBottomRight_x,KBottomRight_y );
   376 		TPoint cellBottomRight( KBottomRight_x,KBottomRight_y );
   377 		if(!iIsMirrored)	
   377 		if(!iIsMirrored)	
   378 			{
   378 			{
   379 			//draw horizontal lines
   379 			// Draw horizontal lines
   380 			for( i = 0; i <= iRowCount; ++i )
   380 			for( i = 0; i <= iRowCount; ++i )
   381 				{
   381 				{
   382 				TPoint startPoint( cellLeftTop );
   382 				TPoint startPoint( cellLeftTop );
   383 				TPoint endPoint( cellLeftTop );
   383 				TPoint endPoint( cellLeftTop );
   384 				startPoint.iY += i * iCellHeight;
   384 				startPoint.iY += i * iCellHeight;
   389 				// add 1 pixel to remove the gap from bottom right corners
   389 				// add 1 pixel to remove the gap from bottom right corners
   390 				++endPoint.iX;
   390 				++endPoint.iX;
   391 				gc.DrawLine( startPoint, endPoint );
   391 				gc.DrawLine( startPoint, endPoint );
   392 				}
   392 				}
   393 
   393 
   394 			//draw vertical lines
   394 			// Draw vertical lines
   395     	for( i = 0; i <= iMaxColumns; ++i )
   395 			for( i = 0; i <= iMaxColumns; ++i )
   396 				{
   396 				{
   397         TPoint startPoint( cellLeftTop );
   397 				TPoint startPoint( cellLeftTop );
   398         TPoint endPoint( cellLeftTop );
   398 				TPoint endPoint( cellLeftTop );
   399 				startPoint.iX += i * iCellWidth;
   399 				startPoint.iX += i * iCellWidth;
   400 				endPoint.iX += i * iCellWidth;
   400 				endPoint.iX += i * iCellWidth;
   401 				endPoint.iY += ( i <= lastRowIconsCount ? 
   401 				endPoint.iY += ( i <= lastRowIconsCount ? 
   402 				    iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1  ) );
   402 				    iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1  ) );
   403 				gc.DrawLine( startPoint, endPoint );
   403 				gc.DrawLine( startPoint, endPoint );
   404 				}
   404 				}
   405 			}
   405 			}
   406 		else
   406 		else
   407 			{
   407 			{
   408 			//draw horizontal lines
   408 			// Draw horizontal lines
   409 			for( i = 0; i <= iRowCount; ++i )
   409 			for( i = 0; i <= iRowCount; ++i )
   410 				{
   410 				{
   411 				TPoint startPoint( cellBottomRight.iX, cellLeftTop.iY);
   411 				TPoint startPoint( cellLeftTop );
   412 				TPoint endPoint( cellBottomRight.iX, cellLeftTop.iY );
   412 				TPoint endPoint( cellLeftTop );
   413 				startPoint.iY += i * iCellHeight;
   413 				startPoint.iY += i * iCellHeight;
   414 				endPoint.iY += i * iCellHeight;
   414 				endPoint.iY += i * iCellHeight;
   415 				endPoint.iX -= ( ( i == iRowCount ) || ( i == 0 && iRowCount == 1 )
   415 				endPoint.iX += ( ( i == iRowCount ) || ( i == 0 && iRowCount == 1 )
   416 				    ? ( lastRowIconsCount ) 
   416 								    ? ( lastRowIconsCount ) 
   417     		    * iCellWidth : iMaxColumns * iCellWidth );
   417 				    		    * iCellWidth : iMaxColumns * iCellWidth );
   418 				// sub 1 pixel to remove the gap from bottom left corners
   418 				// subtract one pixel to remove the gap from bottom left corners
   419 				--endPoint.iX;
   419 				--endPoint.iX;
   420 				gc.DrawLine( startPoint, endPoint );
   420 				gc.DrawLine( startPoint, endPoint );
   421 				}
   421 				}
   422 
   422 
   423 			//draw vertical lines
   423 			// Draw vertical lines
   424     	for( i = 0; i <= iMaxColumns; ++i )
   424 			for( i = 0; i <= iMaxColumns; ++i )
   425 				{
   425 				{
   426 				TPoint startPoint( cellBottomRight.iX, cellLeftTop.iY );
   426 				TPoint startPoint( cellLeftTop );
   427 				TPoint endPoint( cellBottomRight.iX, cellLeftTop.iY);
   427 				TPoint endPoint( cellLeftTop );
   428 				startPoint.iX -= i * iCellWidth;
   428 				startPoint.iX += i * iCellWidth;
   429 				endPoint.iX -= i * iCellWidth;
   429 				endPoint.iX += i * iCellWidth;
   430 				endPoint.iY += ( i <= lastRowIconsCount ? 
   430 				endPoint.iY += ( i <= lastRowIconsCount ? 
   431 				    iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1  ) );
   431 				    iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1  ) );
   432 				gc.DrawLine( startPoint, endPoint );
   432 				gc.DrawLine( startPoint, endPoint );
   433 				}
   433 				}
   434 
   434 
   435 			}
   435 			}
   436 
   436 
   437 		//draw icons
   437 		// Draw icons
   438 		for( i = 0; i < iIconCount; ++i )
   438 		for( i = 0; i < iIconCount; ++i )
   439 			{
   439 			{
   440 			DrawItem( gc, skins, skin, cc, i, i == iCursorPos );
   440 			DrawItem( gc, skins, skin, cc, i, i == iCursorPos );
   441 			}
   441 			}
   442 		}
   442 		}
   443 	else
   443 	else
   444 		{
   444 		{
   445 		// only selection changed, highlight new pos
   445 		// Only selection changed, highlight new pos
   446 		DrawItem( gc, cc != NULL, skin, cc, iCursorPos, ETrue );        
   446 		DrawItem( gc, cc != NULL, skin, cc, iCursorPos, ETrue );        
   447 		// and clear old
   447 		// And clear old
   448 		DrawItem( gc, cc != NULL, skin, cc, iPrevCursorPos, EFalse );
   448 		DrawItem( gc, cc != NULL, skin, cc, iPrevCursorPos, EFalse );
   449 		}
   449 		}
   450 	IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::Draw() end") );    
   450 	IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::Draw() end") );    
   451 	}
   451 	}
   452 
   452 
   459                        MAknsSkinInstance* aSkin, 
   459                        MAknsSkinInstance* aSkin, 
   460                        MAknsControlContext* aSkinCc,
   460                        MAknsControlContext* aSkinCc,
   461                        TInt aIndex, TBool aSelected ) const
   461                        TInt aIndex, TBool aSelected ) const
   462     {
   462     {
   463     IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::DrawItem() start") );
   463     IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::DrawItem() start") );
   464     //lets count currect cell
   464     //lets count current cell
   465     TPoint cellLeftTop( KTopLeft_x,KTopLeft_y );
   465     TPoint cellLeftTop( KTopLeft_x,KTopLeft_y );
   466     TPoint cellBottomRight( KBottomRight_x,KBottomRight_y );
   466     TPoint cellBottomRight( KBottomRight_x,KBottomRight_y );
   467 
   467 
   468     TRect myRect;
   468     TRect myRect;
   469     myRect.SetRect( cellLeftTop, cellBottomRight );
   469     myRect.SetRect( cellLeftTop, cellBottomRight );
   473     {
   473     {
   474     	offset.iX = ( aIndex % iMaxColumns ) * iCellWidth;	
   474     	offset.iX = ( aIndex % iMaxColumns ) * iCellWidth;	
   475     }
   475     }
   476     else
   476     else
   477     {
   477     {
   478     	offset.iX = -(( aIndex % iMaxColumns ) * iCellWidth);
   478     	offset.iX = ( aIndex % iMaxColumns ) * iCellWidth;
   479     }
   479     }
   480     
   480     
   481     offset.iY = aIndex / iMaxColumns * iCellHeight;
   481     offset.iY = aIndex / iMaxColumns * iCellHeight;
   482     
   482     
   483     myRect.Move( offset );
   483     myRect.Move( offset );