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

Symbian

开发平台:

C/C++

  1. // Copyright (c) 2006 Nokia Corporation.
  2. #include "S60UIExampleForm.h"
  3. #include <S60UIExample.rsg>
  4. #include "S60UIExample.hrh"
  5. #include <avkon.rsg>  // for AknForm menu resource id
  6. #include <avkon.hrh>  // for AknForm menu command ids
  7. #include <eikmenup.h> // for CEikMenuPane
  8. // -----------------------------------------------------------------------------
  9. // CS60UIExampleForm::NewL()
  10. // Two stage constructor
  11. // -----------------------------------------------------------------------------
  12. //
  13. CS60UIExampleForm* CS60UIExampleForm::NewL(TDes& aName, 
  14.                                            TTime& aBirthDate, 
  15.                                            TDes& aMobile) 
  16.     {
  17.     CS60UIExampleForm* self = new (ELeave) CS60UIExampleForm(aName, 
  18.                                                              aBirthDate,  
  19.                                                              aMobile);
  20.     CleanupStack::PushL(self);
  21.     self->CAknForm::ConstructL(); 
  22.     CleanupStack::Pop(self);
  23.     return self;
  24.     }
  25. // -----------------------------------------------------------------------------
  26. // CS60UIExampleForm::CS60UIExampleForm()
  27. // First stage constructor
  28. // -----------------------------------------------------------------------------
  29. //
  30. CS60UIExampleForm::CS60UIExampleForm(TDes& aName, 
  31.                                       TTime& aBirthDate,  
  32.                                       TDes& aMobile) 
  33.     : iName(aName), iBirthDate(aBirthDate), iMobile(aMobile)
  34.     {
  35.     // nothing to do here
  36.     }
  37. // -----------------------------------------------------------------------------
  38. // CS60UIExampleForm::~CS60UIExampleForm()
  39. // Destructor
  40. // -----------------------------------------------------------------------------
  41. //
  42. CS60UIExampleForm::~CS60UIExampleForm()
  43.     {
  44.     // nothing to do here
  45.     }
  46. // -----------------------------------------------------------------------------
  47. // CS60UIExampleForm::RunDlgLD()
  48. // Creates, initialises, displays and then deletes the form
  49. // -----------------------------------------------------------------------------
  50. //
  51. TInt CS60UIExampleForm::RunDlgLD(TDes& aName, 
  52.                                  TTime& aBirthDate,  
  53.                                  TDes& aMobile)
  54.     {
  55.     CS60UIExampleForm* form =  CS60UIExampleForm::NewL(aName, 
  56.                                                        aBirthDate,  
  57.                                                        aMobile);
  58.     form->PrepareLC(R_S60UIEX_FORM_DIALOG);  
  59.     form->DoNotSaveFormDataL();   // to load initial data                           
  60.     return form->RunLD();                                 
  61.     }
  62.     
  63. // -----------------------------------------------------------------------------
  64. // CS60UIExampleForm::SaveFormDataL()
  65. // extracts information from editors
  66. // -----------------------------------------------------------------------------
  67. //
  68. TBool CS60UIExampleForm::SaveFormDataL()
  69.     {
  70.     if (ControlOrNull(ES60UIExCtrlIdName))
  71.         {
  72.         GetEdwinText(iName, ES60UIExCtrlIdName);
  73.         }
  74.         
  75.     if (ControlOrNull(ES60UIExCtrlIdBirthDate))
  76.         {
  77.         iBirthDate = TTimeEditorValue(ES60UIExCtrlIdBirthDate);
  78.         }
  79.     
  80.     if (ControlOrNull(ES60UIExCtrlIdMobile))
  81.         {
  82.         GetEdwinText(iMobile, ES60UIExCtrlIdMobile);
  83.         }
  84.         
  85.     return ETrue;
  86.     }
  87.     
  88. // -----------------------------------------------------------------------------
  89. // CS60UIExampleForm::DoNotSaveFormDataL()
  90. // loads editors with previous text
  91. // -----------------------------------------------------------------------------
  92. //
  93. void CS60UIExampleForm::DoNotSaveFormDataL()
  94.     {
  95.     if (ControlOrNull(ES60UIExCtrlIdName))
  96.         {
  97.         SetEdwinTextL(ES60UIExCtrlIdName, &iName);
  98.         }
  99.         
  100.     if (ControlOrNull(ES60UIExCtrlIdBirthDate))
  101.         {
  102.         SetTTimeEditorValue(ES60UIExCtrlIdBirthDate, iBirthDate);
  103.         }
  104.         
  105.     if (ControlOrNull(ES60UIExCtrlIdMobile))
  106.      {
  107.      SetEdwinTextL(ES60UIExCtrlIdMobile, &iMobile);
  108.      }
  109.     }
  110. // -----------------------------------------------------------------------------
  111. // CS60UIExampleForm::DynInitMenuPaneL()
  112. // Used to remove unwanted default options from edit mode menu
  113. // -----------------------------------------------------------------------------
  114. //
  115. void CS60UIExampleForm::DynInitMenuPaneL(TInt aResourceId, 
  116.                                           CEikMenuPane* aMenuPane)
  117.     {
  118.     CAknForm::DynInitMenuPaneL(aResourceId, aMenuPane);
  119.     if (aResourceId == R_AVKON_FORM_MENUPANE)
  120.         {
  121.         // Override the default form options. 
  122.         aMenuPane->SetItemDimmed(EAknFormCmdAdd, ETrue);
  123.         aMenuPane->SetItemDimmed(EAknFormCmdLabel, ETrue);
  124.         aMenuPane->SetItemDimmed(EAknFormCmdDelete, ETrue);
  125.         }
  126.         
  127.     }