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.     return ETrue;
  81.     }
  82.     
  83. // -----------------------------------------------------------------------------
  84. // CS60UIExampleForm::DoNotSaveFormDataL()
  85. // loads editors with previous text
  86. // -----------------------------------------------------------------------------
  87. //
  88. void CS60UIExampleForm::DoNotSaveFormDataL()
  89.     {
  90.     if (ControlOrNull(ES60UIExCtrlIdName))
  91.         {
  92.         SetEdwinTextL(ES60UIExCtrlIdName, &iName);
  93.         }
  94.         
  95.     if (ControlOrNull(ES60UIExCtrlIdBirthDate))
  96.         {
  97.         SetTTimeEditorValue(ES60UIExCtrlIdBirthDate, iBirthDate);
  98.         }
  99.         
  100.     }
  101. // -----------------------------------------------------------------------------
  102. // CS60UIExampleForm::DynInitMenuPaneL()
  103. // Used to remove unwanted default options from edit mode menu
  104. // -----------------------------------------------------------------------------
  105. //
  106. void CS60UIExampleForm::DynInitMenuPaneL(TInt aResourceId, 
  107.                                           CEikMenuPane* aMenuPane)
  108.     {
  109.     CAknForm::DynInitMenuPaneL(aResourceId, aMenuPane);
  110.     if (aResourceId == R_AVKON_FORM_MENUPANE)
  111.         {
  112.         // Override the default form options. 
  113.         aMenuPane->SetItemDimmed(EAknFormCmdAdd, ETrue);
  114.         aMenuPane->SetItemDimmed(EAknFormCmdLabel, ETrue);
  115.         aMenuPane->SetItemDimmed(EAknFormCmdDelete, ETrue);
  116.         }
  117.         
  118.     }