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

📄 allmgridscontainer2.cpp

📁 《基于Symbian OS的手机开发与应用实践》这本书的配套源码。
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CAllMGridsContainer2 from AllMGridsContainer2.cpp
*  Part of  : AllMGrids
*  Created  : 22.03.2006 by ToBeReplacedByAuthor
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  :
*  Copyright: ToBeReplacedByCopyright
* ============================================================================
*/

// INCLUDE FILES
#include <barsread.h>       // for TResourceReader
#include <eikapp.h>         // for CEikApplication
#include <akniconarray.h>
//#include <aknlists.h>       // for CAknGrid
#include <akngmsstylegrid.h>
#include <allmgrids.mbg>     // 
#include <allmgrids.rsg>     // 

#include "AllMGridsContainer2.h"


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

// ---------------------------------------------------------
// CAllMGridsContainer2::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CAllMGridsContainer2::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    // Create the grid
    iGrid = new(ELeave) CAknGMSStyleGrid(EFalse);
    iGrid->SetContainerWindowL(*this);
    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC(reader, R_ALLMGRIDS_GMS_GRID);
    iGrid->ConstructFromResourceL( reader );
    CleanupStack::PopAndDestroy();

    // Create an array of icons, reading them from the file
    CEikonEnv* eikonEnv = CEikonEnv::Static();
    TFileName mbmFile = eikonEnv->EikAppUi()->Application()->BitmapStoreName();
    CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(5);
    CleanupStack::PushL(icons);
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCheck, EMbmAllmgridsCheckmask));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsUncheck, EMbmAllmgridsUncheckmask));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsGms2, EMbmAllmgridsGmsm2));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsGms3));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsGms4));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsGms5));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsGms6));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsGms7));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsGms8));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsGms9));
    CleanupStack::Pop(icons);
    // Transfer ownership
    iGrid->ItemDrawer()->FormattedCellData()->SetIconArray(icons);

    // Setup layout
    iGrid->SetupLayout();

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CAllMGridsContainer2::~CAllMGridsContainer2()
    {
    delete iGrid;
    }

/**
* Handles marking commands for all currently selected games, by passing them 
* to the AknSelectionService
*/
void CAllMGridsContainer2::HandleMarkCommandL(TInt aCommand)
    {
    TRAPD(err, AknSelectionService::HandleMarkableListProcessCommandL(aCommand, iGrid));
    }

// ---------------------------------------------------------
// CAllMGridsContainer2::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CAllMGridsContainer2::SizeChanged()
    {
    iGrid->SetRect(Rect());
    // Apply layout
    iGrid->SetLayoutL(EFalse, ETrue, ETrue, 2, 4, TSize(80,34), 1, 1);
    AknLayoutUtils::LayoutControl(iGrid, Rect(), 0, 8, 2, ELayoutEmpty, ELayoutEmpty, 2, 4);
    }

// ---------------------------------------------------------
// CAllMGridsContainer2::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CAllMGridsContainer2::CountComponentControls() const
    {
    return 1; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CAllMGridsContainer2::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CAllMGridsContainer2::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iGrid;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CAllMGridsContainer2::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CAllMGridsContainer2::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbWhite );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

TKeyResponse CAllMGridsContainer2::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    return iGrid->OfferKeyEventL(aKeyEvent, aType);
    }

// End of File  

⌨️ 快捷键说明

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