⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simplegridgamesgrid.cpp

📁 series60 应用程序开发的源代码 series60 应用程序开发的源代码
💻 CPP
字号:
/**
* 
* @brief Definition of CSimpleGridGamesGrid
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "SimpleGridGamesGrid.h"

// System includes
#include <akniconarray.h> // CAknIconArray
#include <aknlists.h> // AknListBoxLayouts
#include <barsread.h> // TResourceReader
#include <simplegrid.mbg> // contains icon enumeration
#include <stringloader.h> // StringLoader

// CONSTANTS
const TInt KNumberOfIcons(7);
const TInt KGraphicsHeight = 50;
const TInt KTextColor = 215;

// ================= MEMBER FUNCTIONS =======================

/**
* Symbian OS 2nd phase constructor.  Constructs the grd from aGridResource
* sets up the icons container in the file in aIconFileResource and draws itself.
* @param aGridResource The GRID resource
* @param aIconFileResource The resource defining the icon file name
*/        
void CSimpleGridGamesGrid::ConstructL(TInt aGridResource, TInt aIconFileResource)
{
    // Construct the grid from resource
    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC(reader, aGridResource);
    ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy(); // reader

    // Set up the icons
    SetupGridIconsL (aIconFileResource);

    // Draw the grid
    SizeChanged();
}


/**
*    
* Sets up the grid's icons, which are contained in a file.
*
* @param aIconFileResource the file name resource
*/
void CSimpleGridGamesGrid::SetupGridIconsL(TInt aIconFileResource)
{
    // Get the name of the file containing the icons    
    HBufC* iconFileName;
    iconFileName = StringLoader::LoadLC(aIconFileResource);    // Pushes iconFileName onto the Cleanup Stack.
    
    // Create an array of icons, reading them from the file
    CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(KNumberOfIcons);
    CleanupStack::PushL(icons);
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridSnap, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridGolf, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridClock, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridAces, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridHearts, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridRummy, EMbmSimplegridCard_mask));
    icons->AppendL(iEikonEnv->CreateIconL(*iconFileName, EMbmSimplegridPoker, EMbmSimplegridCard_mask));
    CleanupStack::Pop(icons);
    CleanupStack::PopAndDestroy(iconFileName);
    
    ItemDrawer()->FormattedCellData()->SetIconArray(icons); // passing ownership of icons

}

/**
*    
* Sets up colors, and subcells for the grid.
*
*/
void CSimpleGridGamesGrid::SetupGrid()
{
        
    // Setup text foreground and background colours to default
    AknListBoxLayouts::SetupStandardGrid(*this);


    // Get local copies of data we will need    
    CFormattedCellListBoxItemDrawer* itemDrawer = this->ItemDrawer();
    TInt cellWidth = ColumnWidth();
    TInt cellHeight = ItemHeight();

        
    // Set up graphics subcells
    AknListBoxLayouts::SetupFormGfxCell(*this,  //the grid
                                        itemDrawer, // the grid's drawer
                                        0, // index of the graphic within item strings
                                        0, // left position
                                        0, // top position
                                        0, // right - unused
                                        0, // bottom - unused
                                        cellWidth, // width of graphic
                                        KGraphicsHeight, // height of graphic
                                        TPoint (0, 0), // start position
                                        TPoint (cellWidth , KGraphicsHeight)); // end position

    // Set up text subcells
    const CFont* KFont = LatinBold12();
    TInt baseline = cellHeight - KFont->DescentInPixels() - 1;

    AknListBoxLayouts::SetupFormTextCell(*this, // the grid
                                         itemDrawer, // the grid's drawer
                                         1, // index of text within item strings
                                         KFont, // the font for the text
                                         KTextColor, // the color of the text - N.B. although commented out in the header file, this is still used!
                                         0, // left margin
                                         0, // right margin - unused
                                         baseline, // Baseline
                                         cellWidth, // text width (would need to take margin into account if set, i.e. - lm)
                                         CGraphicsContext::ECenter, // Alignment
                                         TPoint (0, KGraphicsHeight), // start position
                                         TPoint(cellWidth, cellHeight)); // end position
    
}


/**
*    
* Called by framework when the view size is changed and by ConstructL to intialise the grid.  
*
*/
void CSimpleGridGamesGrid::SizeChanged()
{
    CAknGrid::SizeChanged();
    SetupGrid();
}





// End of File    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -