S60UIExampleForm.cpp
上传用户:laixiong
上传日期:2007-03-11
资源大小:2994k
文件大小:5k
- // Copyright (c) 2006 Nokia Corporation.
- #include "S60UIExampleForm.h"
- #include <S60UIExample.rsg>
- #include "S60UIExample.hrh"
- #include <avkon.rsg> // for AknForm menu resource id
- #include <avkon.hrh> // for AknForm menu command ids
- #include <eikmenup.h> // for CEikMenuPane
- // -----------------------------------------------------------------------------
- // CS60UIExampleForm::NewL()
- // Two stage constructor
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleForm* CS60UIExampleForm::NewL(TDes& aName,
- TTime& aBirthDate,
- TDes& aMobile)
- {
- CS60UIExampleForm* self = new (ELeave) CS60UIExampleForm(aName,
- aBirthDate,
- aMobile);
- CleanupStack::PushL(self);
- self->CAknForm::ConstructL();
- CleanupStack::Pop(self);
- return self;
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleForm::CS60UIExampleForm()
- // First stage constructor
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleForm::CS60UIExampleForm(TDes& aName,
- TTime& aBirthDate,
- TDes& aMobile)
- : iName(aName), iBirthDate(aBirthDate), iMobile(aMobile)
- {
- // nothing to do here
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleForm::~CS60UIExampleForm()
- // Destructor
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleForm::~CS60UIExampleForm()
- {
- // nothing to do here
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleForm::RunDlgLD()
- // Creates, initialises, displays and then deletes the form
- // -----------------------------------------------------------------------------
- //
- TInt CS60UIExampleForm::RunDlgLD(TDes& aName,
- TTime& aBirthDate,
- TDes& aMobile)
- {
- CS60UIExampleForm* form = CS60UIExampleForm::NewL(aName,
- aBirthDate,
- aMobile);
- form->PrepareLC(R_S60UIEX_FORM_DIALOG);
- form->DoNotSaveFormDataL(); // to load initial data
- return form->RunLD();
- }
-
- // -----------------------------------------------------------------------------
- // CS60UIExampleForm::SaveFormDataL()
- // extracts information from editors
- // -----------------------------------------------------------------------------
- //
- TBool CS60UIExampleForm::SaveFormDataL()
- {
- if (ControlOrNull(ES60UIExCtrlIdName))
- {
- GetEdwinText(iName, ES60UIExCtrlIdName);
- }
-
- if (ControlOrNull(ES60UIExCtrlIdBirthDate))
- {
- iBirthDate = TTimeEditorValue(ES60UIExCtrlIdBirthDate);
- }
-
- return ETrue;
- }
-
- // -----------------------------------------------------------------------------
- // CS60UIExampleForm::DoNotSaveFormDataL()
- // loads editors with previous text
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleForm::DoNotSaveFormDataL()
- {
- if (ControlOrNull(ES60UIExCtrlIdName))
- {
- SetEdwinTextL(ES60UIExCtrlIdName, &iName);
- }
-
- if (ControlOrNull(ES60UIExCtrlIdBirthDate))
- {
- SetTTimeEditorValue(ES60UIExCtrlIdBirthDate, iBirthDate);
- }
-
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleForm::DynInitMenuPaneL()
- // Used to remove unwanted default options from edit mode menu
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleForm::DynInitMenuPaneL(TInt aResourceId,
- CEikMenuPane* aMenuPane)
- {
- CAknForm::DynInitMenuPaneL(aResourceId, aMenuPane);
- if (aResourceId == R_AVKON_FORM_MENUPANE)
- {
- // Override the default form options.
- aMenuPane->SetItemDimmed(EAknFormCmdAdd, ETrue);
- aMenuPane->SetItemDimmed(EAknFormCmdLabel, ETrue);
- aMenuPane->SetItemDimmed(EAknFormCmdDelete, ETrue);
- }
-
- }