shapesform.cpp
来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C++ 代码 · 共 152 行
CPP
152 行
/**
*
* @brief Definition of CShapesForm
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
// Class includes
#include "ShapesForm.h"
// User includes
#include "Shapes.hrh" // Command IDs
#include "ShapesModel.h" // CShapesModel
// ================= MEMBER FUNCTIONS =========================================
/**
* Symbian OS 2 phase constructor.
* Constructs the CShapesModel using the C++ constructor and ConstructL method,
* popping the constructed object from the CleanupStack before returning it.
*
* @return The newly constructed CShapesModel
*/
CShapesForm* CShapesForm::NewL(CShapesModel& aShapesModel)
{
CShapesForm* self = new (ELeave) CShapesForm(aShapesModel);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}
/**
* Destructor.
*/
CShapesForm::~CShapesForm()
{
}
/**
* Standard C++ constructor.
*/
CShapesForm::CShapesForm(CShapesModel& aShapesModel)
: iShapesModel(aShapesModel)
{
}
/**
* Symbian OS 2nd phase constructor.
* Constructs the base class.
*/
void CShapesForm::ConstructL()
{
CAknForm::ConstructL();
}
/**
* Tests if the dialog can exit when a soft key is pressed.
* Called automatically by the application framework.
* This override just saves all values to the model on exit.
*
* @param aKeyCode The soft key pressed.
* @return Can the dialog exit?
*/
TBool CShapesForm::OkToExitL(TInt /*aKeyCode*/)
{
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor1))
{
// ...and save it's value in the model at index 0.
iShapesModel.SetElement(NumberEditorValue(EShapesFormNumEditor1), 0);
}
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor2))
{
// ...and save it's value in the model at index 1.
iShapesModel.SetElement(NumberEditorValue(EShapesFormNumEditor2), 1);
}
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor3))
{
// ...and save it's value in the model at index 2.
iShapesModel.SetElement(NumberEditorValue(EShapesFormNumEditor3), 2);
}
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor4))
{
// ...and save it's value in the model at index 3.
iShapesModel.SetElement(NumberEditorValue(EShapesFormNumEditor4), 3);
}
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor5))
{
// ...and save it's value in the model at index 4.
iShapesModel.SetElement(NumberEditorValue(EShapesFormNumEditor5), 4);
}
return ETrue;
}
/**
* Initializes the dialog components prior to layout.
* Called automatically by the application framework.
* This override sets all values from the model.
*/
void CShapesForm::PreLayoutDynInitL()
{
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor1))
{
// ...and set it's value from the model element at index 0.
SetNumberEditorValue(EShapesFormNumEditor1, iShapesModel.ElementAt(0));
}
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor2))
{
// ...and set it's value from the model element at index 1.
SetNumberEditorValue(EShapesFormNumEditor2, iShapesModel.ElementAt(1));
}
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor3))
{
// ...and set it's value from the model element at index 2.
SetNumberEditorValue(EShapesFormNumEditor3, iShapesModel.ElementAt(2));
}
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor4))
{
// ...and set it's value from the model element at index 3.
SetNumberEditorValue(EShapesFormNumEditor4, iShapesModel.ElementAt(3));
}
// Test if the control exists...
if (ControlOrNull(EShapesFormNumEditor5))
{
// ...and set it's value from the model element at index 4.
SetNumberEditorValue(EShapesFormNumEditor5, iShapesModel.ElementAt(4));
}
}
// End of File
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?