?? simplegridcontainer.cpp
字號(hào):
/**
*
* @brief Definition of CSimpleGridContainer
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
// Class include
#include "SimpleGridContainer.h"
// System includes
#include <SimpleGrid.rsg> // R_SIMPLEGRID_GAMES_GRID, R_ICON_FILE_NAME
// User includes
#include "SimpleGridGamesGrid.h"//CSimpleGridGamesGrid
// CONSTANTS
// #defined as DLL cannot contain writable static data
#define KGridPosition TPoint(0,0)
// ================= MEMBER FUNCTIONS =======================
/**
* Symbian OS 2nd phase constructor. Creates a Window for the controls, which it contains.
* Constructs a grid and adds it to the window, which it then activates.
* @param aRect The rectangle for this window
*/
void CSimpleGridContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
// Construct the grid
iGamesGrid = new (ELeave)CSimpleGridGamesGrid;
iGamesGrid->SetContainerWindowL(*this);
iGamesGrid->ConstructL(R_SIMPLEGRID_GAMES_GRID, R_ICON_FILE_NAME);
// Observe the grid
iGamesGrid->SetListBoxObserver(this);
SetRect(aRect);
ActivateL();
}
/**
* Symbian OS 2 phase constructor.
* Constructs the CSimpleGridContainer using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CSimpleGridContainer
*/
CSimpleGridContainer* CSimpleGridContainer::NewL(const TRect& aRect)
{
CSimpleGridContainer* self = CSimpleGridContainer::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
/**
* Symbian OS 2 phase constructor.
* Constructs the CSimpleGridContainer using the constructor and ConstructL
* method, leaving the constructed object on the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CSimpleGridContainer
*/
CSimpleGridContainer* CSimpleGridContainer::NewLC(const TRect& aRect)
{
CSimpleGridContainer* self = new (ELeave) CSimpleGridContainer;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
/**
* Destructor. Frees up memory for the iGamesGrid.
*/
CSimpleGridContainer::~CSimpleGridContainer()
{
delete iGamesGrid;
}
/**
*
* Called by framework when the view size is changed. Resizes the
* iGamesGrid accordingly.
*
*/
void CSimpleGridContainer::SizeChanged()
{
// Do not use MinimumSize() here as it does not work when scrolling
// through the grid
if (iGamesGrid)
{
iGamesGrid->SetExtent (KGridPosition,Rect().Size());
}
}
/**
* Called by the framework in compound controls
* @return The number of controls in this CSimpleGridContainer
*/
TInt CSimpleGridContainer::CountComponentControls() const
{
return 1; // return number of controls inside this container
}
/**
* Called by the framework in compound controls
* @param The index of the control to return
* @return The control for aIndex
*/
CCoeControl* CSimpleGridContainer::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
return iGamesGrid;
default:
return NULL;
}
}
/**
* Called by the framework to draw this control. Clears the area in
* aRect.
* @param aRect in which to draw
*/
void CSimpleGridContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.Clear(aRect);
}
/**
* Called by the framework whenever a key event occurs.
* Passes the key event to the games grid if it is not null, otherwise returns
* EKeyWasNotConsumed
* @param aKeyEvent the Key event which occured, e.g. select key pressed
* @param aType the type of Key event which occurred, e.g. key up, key down
* @return TKeyResponse EKeyWasNotConsumed if the key was not processed, EKeyWasConsumed if it was
*/
TKeyResponse CSimpleGridContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
// if it's not an event key we're not interested so return not consumed
if (aType != EEventKey)
return EKeyWasNotConsumed;
if (iGamesGrid)
return iGamesGrid->OfferKeyEventL (aKeyEvent, aType);
else
return EKeyWasNotConsumed;
}
/**
* Plays the currently select game in the iGamesGrid, if one exists.
* This is an empty implementation of this method
*/
void CSimpleGridContainer::PlaySelectedGame()
{
}
/**
* Called by the framework whenever a grid event occurs for which this container
* is an observer.
* @param aListBoxEvent The type of event which occured
*
*/
void CSimpleGridContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
{
// if the Select Key has been pressed
if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
(aListBoxEvent == MEikListBoxObserver::EEventItemClicked))
{
PlaySelectedGame();
}
}
// End of File
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -