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

📄 allmgridscontainer3.cpp

📁 《基于Symbian OS的手机开发与应用实践》这本书的配套源码。
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CAllMGridsContainer3 from AllMGridsContainer.h
*  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 <allmgrids.mbg>     // 
#include <allmgrids.rsg>     // 

#include "AllMGridsContainer3.h"

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

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

    // Create the grid
    iGrid = new( ELeave )CAknPinbStyleGrid;
    iGrid->SetContainerWindowL( *this );
    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC( reader, R_ALLMGRIDS_PINB_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(4);
    CleanupStack::PushL(icons);
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCheck, EMbmAllmgridsCheckmask));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsUncheck, EMbmAllmgridsUncheckmask));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsPinb1, EMbmAllmgridsPinbm1));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsPinb2, EMbmAllmgridsPinbm2));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsPinb3, EMbmAllmgridsPinbm3));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsPinb4, EMbmAllmgridsPinbm4));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsPinb5, EMbmAllmgridsPinbm5));
    CleanupStack::Pop(icons);
    // Transfer ownership
    iGrid->ItemDrawer()->FormattedCellData()->SetIconArray(icons);

    SetRect(aRect);
    ActivateL();
    }

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

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

// ---------------------------------------------------------
// CAllMGridsContainer3::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CAllMGridsContainer3::SizeChanged()
    {
    iGrid->SetRect(Rect());
    // Apply layout
    iGrid->SetLayoutL(ETrue, ETrue, ETrue, 5, 5, TSize(33,28));
    }

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

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

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

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


// End of File  

⌨️ 快捷键说明

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