TetrisContainer.cpp
上传用户:snevogroup
上传日期:2008-06-06
资源大小:432k
文件大小:2k
- #include <eikspane.h>
- #include <eiktbar.h>
- #include "TetrisContainer.h"
- #include "Tetris.hrh"
- #include "CEngine.h"
- #include "TetrisDocument.h"
- // construct and destruct
- CTetrisContainer::CTetrisContainer(CTetrisDocument* aDocument) : iDocument(aDocument)
- {}
- //~CTetrisContainer()
- CTetrisContainer::~CTetrisContainer()
- {
- if(iEngine)
- {
- //iEngine->Stop();
- delete iEngine;
- iEngine = NULL;
- }
-
- ControlEnv()->RemoveForegroundObserver(*this);
- }
- // ConstructL()
- void CTetrisContainer::ConstructL(const TRect& aRect)
- {
- CreateWindowL();
- // Set the windows size
- SetRect(aRect);
- ActivateL();
- SetFullScreen();
- ControlEnv()->AddForegroundObserverL( *this );
- // Start the engine
- iEngine = CEngine::NewL( iDocument->Model(), SystemGc(), Window(),
- CCoeEnv::Static()->ScreenDevice()->DisplayMode());
- //iEngine->Start();
- }
- ///////////////////////////////////////////////////////////////
- // Method from Parent
- void CTetrisContainer::HandleGainingForeground()
- {
- iEngine->Start();
- }
- void CTetrisContainer::HandleLosingForeground()
- {
- iEngine->Stop();
- }
- // Other Method
- // SetFullScreen
- void CTetrisContainer::SetFullScreen()
- {
- CEikButtonGroupContainer* iToolBar; // use
- CEikStatusPane* iStatusPane; // use
- MEikAppUiFactory* f = CEikonEnv::Static()->AppUiFactory();
- iStatusPane = f->StatusPane();
- iToolBar = f->ToolBar();
- if( iToolBar )
- iToolBar->MakeVisible( EFalse );
- if( iStatusPane )
- iStatusPane->MakeVisible( EFalse );
- SetExtentToWholeScreen();
- }
- // Command()
- void CTetrisContainer::Command(TInt aCommand)
- {
- iEngine->Command(aCommand);
- }