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

📄 allmgridscontainer.cpp

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

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

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

    // Create the grid
    iGrid = new( ELeave )CAknCaleMonthStyleGrid;
    iGrid->SetContainerWindowL( *this );
    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC( reader, R_ALLMGRIDS_CALEMONTH_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(6);
    CleanupStack::PushL(icons);
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale0, EMbmAllmgridsCalem0));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale1, EMbmAllmgridsCalem1));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale2));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale31));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale32));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale33));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale34));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale35));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale36));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale37));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale4, EMbmAllmgridsCalem4));
    icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmgridsCale5, EMbmAllmgridsCalem5));
    CleanupStack::Pop(icons);
    // Transfer ownership
    iGrid->ItemDrawer()->FormattedCellData()->SetIconArray(icons);


    SetRect(aRect);
    ActivateL();
    }

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


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

// ---------------------------------------------------------
// CAllMGridsContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CAllMGridsContainer::SizeChanged()
    {
    iGrid->SetRect(Rect());
    // Apply layout
    TRAPD(err, iGrid->SetLayoutL(ETrue, ETrue, ETrue, 7, 8, TSize(21,19), 1, 1));
    }

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

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

// ---------------------------------------------------------
// CAllMGridsContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CAllMGridsContainer::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 CAllMGridsContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    return iGrid->OfferKeyEventL(aKeyEvent, aType);
    }


// End of File  

⌨️ 快捷键说明

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