📄 allgridscontainer2.cpp
字号:
/*
* ============================================================================
* Name : CAllGridsContainer2 from AllGridsContainer2.cpp
* Part of : AllGrids
* 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 <allgrids.mbg> //
#include <allgrids.rsg> //
#include "AllGridsContainer2.h"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CAllGridsContainer2::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CAllGridsContainer2::ConstructL(const TRect& aRect)
{
CreateWindowL();
// Create the grid
iGrid = new(ELeave) CAknGMSStyleGrid(EFalse);
iGrid->SetContainerWindowL(*this);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_ALLGRIDS_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, EMbmAllgridsGms1, EMbmAllgridsGmsm1));
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllgridsGms2, EMbmAllgridsGmsm2));
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllgridsGms3));
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllgridsGms4));
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllgridsGms5));
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllgridsGms6));
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllgridsGms7));
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllgridsGms8));
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllgridsGms9));
CleanupStack::Pop(icons);
// Transfer ownership
iGrid->ItemDrawer()->FormattedCellData()->SetIconArray(icons);
// Setup layout
iGrid->SetupLayout();
SetRect(aRect);
ActivateL();
}
// Destructor
CAllGridsContainer2::~CAllGridsContainer2()
{
delete iGrid;
}
// ---------------------------------------------------------
// CAllGridsContainer2::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CAllGridsContainer2::SizeChanged()
{
iGrid->SetRect(Rect());
// Apply layout
TRAPD(err, iGrid->SetLayoutL(EFalse, ETrue, ETrue, 2, 4, TSize(80,34), 1, 1));
AknLayoutUtils::LayoutControl(iGrid, Rect(), 0, 8, 2, ELayoutEmpty, ELayoutEmpty, 2, 4);
}
// ---------------------------------------------------------
// CAllGridsContainer2::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CAllGridsContainer2::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CAllGridsContainer2::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CAllGridsContainer2::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iGrid;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CAllGridsContainer2::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CAllGridsContainer2::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 CAllGridsContainer2::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
return iGrid->OfferKeyEventL(aKeyEvent, aType);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -