- #include <eikmenub.h>
- #include <eikspane.h>
- #include <eikbtgpc.h>
- #include <eiktbar.h>
- #include "TetrisAppView.h"
- #include "Tetris.hrh"
- #include "CSplash.h"
- // construct and destruct
- // NewL()
- CTetrisAppView* CTetrisAppView::NewL(const TRect& aRect)
- {
- CTetrisAppView* self = NewLC(aRect);
- CleanupStack::Pop(self);
- return self;
- }
- // NewLC()
- CTetrisAppView* CTetrisAppView::NewLC(const TRect& aRect)
- {
- CTetrisAppView* self = new (ELeave) CTetrisAppView();
- CleanupStack::PushL(self);
- self->ConstructL(aRect);
- return self;
- }
- // CTetrisAppView()
- CTetrisAppView::CTetrisAppView()
- {
- }
- //~CTetrisAppView()
- CTetrisAppView::~CTetrisAppView()
- {
- delete iSplash;
- iSplash = NULL;
- }
- // ConstructL()
- void CTetrisAppView::ConstructL(const TRect& aRect)
- {
- // Create a window for this application view
- CreateWindowL();
- // Set the windows size
- SetRect(aRect);
- MEikAppUiFactory* f = CEikonEnv::Static()->AppUiFactory();
- iStatusPane = f->StatusPane();
- iToolBar = f->ToolBar();
- // Activate the window, which makes it ready to be drawn
- ActivateL();
- if( iToolBar )
- {
- iToolBar->MakeVisible( EFalse );
- iToolBar->SetCommandL( 0, ECommand1, _L("Exitnfullscreen") );
- }
- if( iStatusPane )
- iStatusPane->MakeVisible( EFalse );
- SetExtentToWholeScreen();
- iFullScreen = 1;
- // create the Splash
- iSplash = CSplash::NewL();
- iSplash->iAppView = this;
- iSplash->StartTime();
- }
- ///////////////////////////////////////////////////////////////
- // Method
- // Draw()
- void CTetrisAppView::Draw(const TRect&) const
- {
- CWindowGc& gc = SystemGc();
- TRect rect = Rect();
- if(iSplash->iCount < 9)
- {
- iSplash->Show(gc, rect);
- //DrawNow();
- }
- else
- {
- gc.Clear();
- rect.Shrink(10, 10);
- gc.DrawRect(rect);
- }
- }
- // Command()
- void CTetrisAppView::Command(TInt aCommand)
- {
- if( aCommand == ECommand1 )
- {
- iFullScreen ^= 1;
- if( iFullScreen )
- {
- if( iToolBar )
- {
- iToolBar->SetCommandL( 0, ECommand1, _L("Exitnfullscreen") );
- iToolBar->MakeVisible( EFalse );
- }
- if( iStatusPane )
- {
- iStatusPane->MakeVisible( EFalse );
- }
- SetExtentToWholeScreen();
- }
- else
- {
- if( iToolBar )
- {
- iToolBar->SetCommandL( 0, ECommand1, _L("Fullscreen") );
- iToolBar->MakeVisible( ETrue );
- iToolBar->DrawNow();
- }
- if( iStatusPane )
- {
- iStatusPane->MakeVisible( ETrue );
- }
- TRect rect = CEikonEnv::Static()->EikAppUi()->ClientRect();
- SetPosition( rect.iTl );
- TSize size = rect.Size();
- // make even width
- // odd width CFbsBitmap has unwanted padding bytes
- //size.iWidth &= 0xfffffffe;
- SetSize( size );
- }
- }
- }
- void CTetrisAppView::SetState(TState aState)
- {
- iState = aState;
- }