S60 3rd Edition SDK for Symbian OS
Example Applications Guide

CIMOpenAPIExampleGrid Class Reference

This is the graphical grid class for a IM Example application. More...

#include <IMOpenAPIExamplegrid.h>

List of all members.

Public Member Functions

void ConstructL (TInt aGridResource, const TDesC &aImageFile)
 ~CIMOpenAPIExampleGrid ()
void SetCellSign (TGameSign aCellValue, TInt aCellIndex)
void ResetGrid ()

Private Member Functions

void SizeChanged ()
void SetupGrid ()
void SetupGridIconsL (const TDesC &aImageFile)

Private Attributes

CDesCArray * iArray


Detailed Description

This is the graphical grid class for a IM Example application.

Definition at line 30 of file IMOpenAPIExampleGrid.h.


Constructor & Destructor Documentation

CIMOpenAPIExampleGrid::~CIMOpenAPIExampleGrid (   ) 
 

Destructor.

Definition at line 57 of file IMOpenAPIExampleGrid.cpp.

00058     {
00059     }


Member Function Documentation

void CIMOpenAPIExampleGrid::ConstructL (  TInt  aGridResource,
const TDesC &  aImageFile
) 
 

ConstructL. 2nd phase constructor.

Parameters:
aGridResource resource of the grip in resource file aImageFile The file name where application images are stored

Definition at line 32 of file IMOpenAPIExampleGrid.cpp.

References iArray, ResetGrid(), SetupGridIconsL(), and SizeChanged().

00033         {
00034     // Construct the grid from resource
00035         TResourceReader reader;
00036         CEikonEnv::Static()->CreateResourceReaderLC(reader, aGridResource);
00037         ConstructFromResourceL(reader);
00038         CleanupStack::PopAndDestroy(); // reader
00039 
00040         // Set up the icons
00041         SetupGridIconsL (aImageFile);
00042 
00043         // set up text and icons in array
00044     iArray = static_cast<CDesCArray*>(this->Model()->ItemTextArray());
00045     ResetGrid();
00046 
00047         // Draw the grid
00048         SizeChanged();
00049     
00050         }

void CIMOpenAPIExampleGrid::SetCellSign (  TGameSign  aCellValue,
TInt  aCellIndex
) 
 

SetCellSign. Put the specified graphical cell sign to the specified index in grid

Parameters:
aCellValue value to put in the cell aCellIndex Index in grid where value need to put 0 to 8

Definition at line 139 of file IMOpenAPIExampleGrid.cpp.

References iArray.

00140         {
00141     _LIT(KFormatString, "%d");
00142         TBuf<1> cellValueString;
00143         cellValueString.Format(KFormatString, aCellValue);
00144 
00145     // return if index is out of bound
00146     if ( (aCellIndex>8) || (aCellIndex<0) )
00147         return;
00148     iArray->Delete(aCellIndex);
00149         iArray->InsertL(aCellIndex,cellValueString);
00150     HandleItemAdditionL();
00151         }

void CIMOpenAPIExampleGrid::ResetGrid (   ) 
 

ResetGrid. Reset the whole grid and put empty signs

Definition at line 158 of file IMOpenAPIExampleGrid.cpp.

References iArray.

00159         {
00160     _LIT(KFormatString, "%d");
00161         TBuf<2> cellValueString;
00162 
00163     for (TInt i=0; i<9 ; i++)
00164         {
00165         cellValueString.Format(KFormatString, EEmptySign);
00166         iArray->Delete(i);
00167             iArray->InsertL(i,cellValueString);
00168         }
00169     HandleItemAdditionL();
00170         }

void CIMOpenAPIExampleGrid::SizeChanged (   )  [private]
 

SizeChanged. From CoeControl

Definition at line 128 of file IMOpenAPIExampleGrid.cpp.

References SetupGrid().

00129         {
00130     CAknGrid::SizeChanged();
00131         SetupGrid();
00132         }

void CIMOpenAPIExampleGrid::SetupGrid (   )  [private]
 

SetupGrid. Initialized the grid

Definition at line 90 of file IMOpenAPIExampleGrid.cpp.

00091         {
00092         // Setup text foreground and background colours to default
00093         AknListBoxLayouts::SetupStandardGrid(*this);
00094 
00095 
00096         // Get local copies of data we will need        
00097         CFormattedCellListBoxItemDrawer* itemDrawer = this->ItemDrawer();
00098         TInt cellWidth = ColumnWidth();
00099         TInt cellHeight = ItemHeight();
00100 
00101                 
00102         // Set up graphics subcells
00103         AknListBoxLayouts::SetupFormGfxCell(*this,  //the grid
00104                                                                                 itemDrawer, // the grid's drawer
00105                                                                                 0, // index of the graphic within item strings
00106                                                                                 1, // left position
00107                                                                                 1, // top position
00108                                                                                 0, // right - unused
00109                                                                                 0, // bottom - unused
00110                                                                                 cellWidth-4, // width of graphic
00111                                                                                 cellHeight-4, // height of graphic
00112                                                                                 TPoint (0, 0), // start position
00113                                                                                 TPoint (cellWidth , cellHeight)); // end position
00114     CEikScrollBarFrame* frame = ScrollBarFrame();
00115 
00116         if (frame)
00117                 {
00118                 frame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff);
00119                 }
00120 
00121         }

void CIMOpenAPIExampleGrid::SetupGridIconsL (  const TDesC &  aImageFile  )  [private]
 

SetupGridIconsL. Initialized the grid icons with the images in given file name

Definition at line 66 of file IMOpenAPIExampleGrid.cpp.

00067         {
00068 
00069         // Create an array of icons, reading them from the file
00070         CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(KNumberOfIcons);
00071         CleanupStack::PushL(icons);
00072 
00073         icons->AppendL( iEikonEnv->CreateIconL( aImageFile, 0, 3 ) );
00074         icons->AppendL( iEikonEnv->CreateIconL( aImageFile, 1, 3 ) );
00075         icons->AppendL( iEikonEnv->CreateIconL( aImageFile, 2, 3 ) );
00076 
00077         
00078         
00079         CleanupStack::Pop(icons);
00080         // passing ownership of icons
00081         ItemDrawer()->FormattedCellData()->SetIconArray(icons);
00082         
00083         }


Member Data Documentation

CDesCArray* CIMOpenAPIExampleGrid::iArray [private]
 

iArray. array of icons and text

Definition at line 90 of file IMOpenAPIExampleGrid.h.


© Nokia 2006

Back to top