S60MMFLabAppUi.cpp
上传用户:laixiong
上传日期:2007-03-11
资源大小:2994k
文件大小:4k
源码类别:

Symbian

开发平台:

C/C++

  1. // Copyright (c) 2006 Nokia Corporation.
  2. // INCLUDE FILES
  3. #include "S60MMFLabAppUi.h"
  4. #include "S60MMFLabContainer.h" 
  5. #include <S60mmflab.rsg>
  6. #include "s60mmflab.hrh"
  7. #include <avkon.hrh>
  8. #include <eikmenup.h>
  9. #include <S60MMFLab.rsg>
  10. // ================= MEMBER FUNCTIONS =======================
  11. //
  12. // ----------------------------------------------------------
  13. // CS60MMFLabAppUi::ConstructL()
  14. // 
  15. // ----------------------------------------------------------
  16. //
  17. void CS60MMFLabAppUi::ConstructL()
  18.     {
  19.     BaseConstructL(EAknEnableSkin);
  20.     iAppContainer = new (ELeave) CS60MMFLabContainer;
  21.     iAppContainer->SetMopParent( this );
  22.     iToneUtility = CS60MMFLabToneUtility::NewL();
  23.     iPlayerUtility = CS60MMFLabPlayerUtility::NewL();
  24.     // start with tone utility
  25.     iCurrentUtility = EToneUtility;
  26.     iAppContainer->ConstructL( ClientRect(), iToneUtility->GetLabel());
  27.     AddToStackL( iAppContainer );
  28.     }
  29. // ----------------------------------------------------
  30. // CS60MMFLabAppUi::~CS60MMFLabAppUi()
  31. // Destructor
  32. // Frees reserved resources
  33. // ----------------------------------------------------
  34. //
  35. CS60MMFLabAppUi::~CS60MMFLabAppUi()
  36.     {
  37.     if (iAppContainer)
  38.         {
  39.         RemoveFromStack( iAppContainer );
  40.         delete iAppContainer;
  41.         }
  42.         
  43.     delete iToneUtility;
  44.     delete iPlayerUtility;
  45. }
  46. // ------------------------------------------------------------------------------
  47. // CS60MMFLabAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
  48. //  This function is called by the EIKON framework just before it displays
  49. //  a menu pane. Its default implementation is empty, and by overriding it,
  50. //  the application can set the state of menu items dynamically according
  51. //  to the state of application data.
  52. // ------------------------------------------------------------------------------
  53. //
  54. void CS60MMFLabAppUi::DynInitMenuPaneL(
  55.     TInt aResourceId, CEikMenuPane* aMenuPane)
  56.     {
  57. if (aResourceId == R_S60MMFLAB_MENU)
  58. {
  59. if (iCurrentUtility == EToneUtility)
  60.     {
  61. iToneUtility->SetOptionsMenuL(aMenuPane);
  62.     }
  63. else if (iCurrentUtility == EPlayerUtility)
  64.     {
  65. iPlayerUtility->SetOptionsMenuL(aMenuPane);
  66.     }
  67. }
  68.     }
  69. // ----------------------------------------------------
  70. // CS60MMFLabAppUi::HandleCommandL(TInt aCommand)
  71. // takes care of command handling
  72. // ----------------------------------------------------
  73. //
  74. void CS60MMFLabAppUi::HandleCommandL(TInt aCommand)
  75.     {
  76.     switch ( aCommand )
  77.         {
  78.         case EAknSoftkeyBack:
  79.         case EEikCmdExit:
  80.             {
  81.             Exit();
  82.             break;
  83.             }
  84.             
  85.         case ES60MMFLabCmdAppChange:
  86.             {
  87.             break;
  88.             }
  89.             
  90.         case ES60MMFLabCmdAppPlay:
  91.             {
  92. if (iCurrentUtility==EToneUtility)
  93. iToneUtility->Play();
  94. else if (iCurrentUtility==EPlayerUtility)
  95. iPlayerUtility->Play();
  96. break;
  97. }
  98.         case ES60MMFLabCmdAppStop:
  99.             {
  100. if (iCurrentUtility==EToneUtility)
  101. iToneUtility->CancelPlay();
  102. else if (iCurrentUtility==EPlayerUtility)
  103. iPlayerUtility->Stop();
  104. break;
  105. }
  106.         case ES60MMFLabCmdAppTonePlayer:
  107.             {
  108.     iCurrentUtility = EToneUtility;
  109. iAppContainer->SetLabelL(iToneUtility->GetLabel());
  110.     iAppContainer->DrawNow();
  111.             break;
  112.             }
  113.             
  114.         case ES60MMFLabCmdAppAudioPlayer:
  115.             {
  116.     iCurrentUtility = EPlayerUtility;
  117. iAppContainer->SetLabelL(iPlayerUtility->GetLabel());
  118.     iAppContainer->DrawNow();
  119.             break;
  120.             }
  121.        
  122.         default:
  123.             break;      
  124.         }
  125.     }
  126. // -----------------------------------------------------------------------------
  127. // CS60MMFLabAppUi::HandleScreenDeviceChangedL
  128. // Handle change in screen resolution.
  129. // -----------------------------------------------------------------------------
  130. //
  131. void CS60MMFLabAppUi::HandleScreenDeviceChangedL()
  132.     {
  133.     CAknAppUi::HandleScreenDeviceChangedL();
  134.     // Reposition the view
  135.     if ( iAppContainer )
  136.         {
  137.         iAppContainer->SetRect(ClientRect());
  138.         }
  139.     }
  140.     
  141. // End of File