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

Symbian

开发平台:

C/C++

  1. // Copyright (c) 2006 Nokia Corporation.
  2. #include "S60UIExampleList.h"
  3. #include "S60UIExampleSettingsView.h"
  4. #include "S60UIExample.hrh"
  5. #include <S60UIExample.rsg>
  6. #include <aknviewappui.h>
  7. // -----------------------------------------------------------------------------
  8. // CS60UIExampleSettingsView::NewL()
  9. // Two-phased constructor.
  10. // -----------------------------------------------------------------------------
  11. //
  12. CS60UIExampleSettingsView* CS60UIExampleSettingsView::NewL()
  13.     {
  14.     CS60UIExampleSettingsView* self = new (ELeave) CS60UIExampleSettingsView;
  15.     CleanupStack::PushL (self);
  16.     self->ConstructL();
  17.     CleanupStack::Pop();
  18.     return self;
  19.     }
  20. // -----------------------------------------------------------------------------
  21. // CS60UIExampleSettingsView::ConstructL()
  22. // Symbian 2nd phase constructor can leave.
  23. // -----------------------------------------------------------------------------
  24. //
  25. void CS60UIExampleSettingsView::ConstructL()
  26.     {
  27.     BaseConstructL (R_S60UIEXAMPLE_SETTINGS_VIEW);
  28.     }
  29. // -----------------------------------------------------------------------------
  30. // CS60UIExampleSettingsView::CS60UIExampleSettingsView()
  31. // C++ default constructor can NOT contain any code, that might leave.
  32. // -----------------------------------------------------------------------------
  33. //
  34. CS60UIExampleSettingsView::CS60UIExampleSettingsView() : iList (NULL)
  35.     {
  36.     }
  37. // -----------------------------------------------------------------------------
  38. // CS60UIExampleSettingsView::~CS60UIExampleSettingsView()
  39. // Destructor.
  40. // -----------------------------------------------------------------------------
  41. //
  42. CS60UIExampleSettingsView::~CS60UIExampleSettingsView()
  43.     {
  44.     if (iList)
  45.         {
  46.         AppUi()->RemoveFromStack (iList);
  47.         }
  48.     delete iList;
  49.     }
  50. // -----------------------------------------------------------------------------
  51. // TUid CS60UIExampleSettingsView::Id()
  52. // Returns the View Id.
  53. // -----------------------------------------------------------------------------
  54. //
  55. TUid CS60UIExampleSettingsView::Id() const
  56.     {
  57.     return TUid::Uid (ES60UIExampleSettingsViewId);
  58.     }
  59. // -----------------------------------------------------------------------------
  60. // CS60UIExampleSettingsView::HandleCommandL()
  61. // Handles the commands.
  62. // -----------------------------------------------------------------------------
  63. //
  64. void CS60UIExampleSettingsView::HandleCommandL (TInt aCommand)
  65.     {
  66.     switch (aCommand)
  67.         {
  68.         case EEikCmdExit:
  69.         case EAknSoftkeyExit:
  70.          {
  71.             AppUi()->Exit();
  72.             break;
  73.          }
  74.         
  75.         case ES60UIExampleChange:
  76.          {
  77.          TInt index = iList->ListBox()->CurrentItemIndex();
  78.          iList->EditItemL(index, EFalse);
  79.             break;
  80.             }
  81.         case EAknSoftkeyBack:
  82.             {
  83.             AppUi()->ActivateLocalViewL (TUid::Uid (ES60UIExampleInitialViewId));
  84.             break;
  85.             }
  86.         default:
  87.             AppUi()->HandleCommandL (aCommand);
  88.         }
  89.     }
  90. // -----------------------------------------------------------------------------
  91. // CS60UIExampleSettingsView::DoActivateL()
  92. // Creates the Container class object.
  93. // -----------------------------------------------------------------------------
  94. //
  95. void CS60UIExampleSettingsView::DoActivateL (const TVwsViewId& /*aPrevViewId*/,
  96.                                              TUid /*aCustomMessageId*/, 
  97.                                              const TDesC8& /*aCustomMessage*/)
  98.     {
  99.     if (!iList)
  100.         {
  101.         iList = new (ELeave) CS60UIExampleList;
  102.         iList->SetData(iVolume, iSpeed, iBacktrack);
  103.         iList->SetMopParent(this);
  104.         iList->ConstructFromResourceL(R_S60UIEXAMPLE_SETTING_LIST);
  105.         AppUi()->AddToStackL(*this, iList);
  106.         }
  107.     iList->MakeVisible (ETrue);
  108.     iList->SetRect(ClientRect());
  109.     iList->ActivateL();
  110.     iList->DrawNow();
  111.     }
  112. // -----------------------------------------------------------------------------
  113. // CS60UIExampleSettingsView::DoDeactivate()
  114. // Deletes the Container class object.
  115. // -----------------------------------------------------------------------------
  116. //
  117. void CS60UIExampleSettingsView::DoDeactivate()
  118.     {
  119.     if (iList)
  120.         {
  121.         iList->MakeVisible (EFalse);
  122.         }
  123.         
  124.     }
  125. // End of File