TetrisContainer.cpp
上传用户:snevogroup
上传日期:2008-06-06
资源大小:432k
文件大小:2k
源码类别:

Symbian

开发平台:

C/C++

  1. #include <eikspane.h>
  2. #include <eiktbar.h>
  3. #include "TetrisContainer.h"
  4. #include "Tetris.hrh"
  5. #include "CEngine.h"
  6. #include "TetrisDocument.h"
  7. // construct and destruct
  8. CTetrisContainer::CTetrisContainer(CTetrisDocument* aDocument) : iDocument(aDocument)
  9. {}
  10. //~CTetrisContainer()
  11. CTetrisContainer::~CTetrisContainer()
  12. {
  13. if(iEngine)
  14. {
  15. //iEngine->Stop();
  16. delete iEngine;
  17. iEngine = NULL;
  18. }
  19. ControlEnv()->RemoveForegroundObserver(*this);
  20. }
  21. // ConstructL()
  22. void CTetrisContainer::ConstructL(const TRect& aRect)
  23. {
  24.     CreateWindowL();
  25.     // Set the windows size
  26.     SetRect(aRect);
  27. ActivateL();
  28. SetFullScreen();
  29. ControlEnv()->AddForegroundObserverL( *this );
  30. // Start the engine
  31. iEngine = CEngine::NewL( iDocument->Model(), SystemGc(), Window(), 
  32. CCoeEnv::Static()->ScreenDevice()->DisplayMode());
  33. //iEngine->Start();
  34. }
  35. ///////////////////////////////////////////////////////////////
  36. // Method from Parent
  37. void CTetrisContainer::HandleGainingForeground()
  38. {
  39. iEngine->Start();
  40. }
  41. void CTetrisContainer::HandleLosingForeground()
  42. {
  43. iEngine->Stop();
  44. }
  45. // Other Method
  46. // SetFullScreen
  47. void CTetrisContainer::SetFullScreen()
  48. {
  49. CEikButtonGroupContainer* iToolBar; // use
  50. CEikStatusPane* iStatusPane; // use
  51. MEikAppUiFactory* f = CEikonEnv::Static()->AppUiFactory();
  52. iStatusPane = f->StatusPane();
  53. iToolBar = f->ToolBar();
  54. if( iToolBar )
  55. iToolBar->MakeVisible( EFalse );
  56. if( iStatusPane )
  57. iStatusPane->MakeVisible( EFalse );
  58. SetExtentToWholeScreen();
  59. }
  60. // Command()
  61. void CTetrisContainer::Command(TInt aCommand)
  62. {
  63. iEngine->Command(aCommand);
  64. }