📄 askstationdialog.cpp
字号:
/**
*
* @brief Definition of CAskTrainDialog
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
// Class include
#include "AskStationDialog.h"
// System includes
#include <avkon.hrh> // EAknSoftkeyOk
#include <Train.rsg>
#include <eikedwin.h> // CEikEdwin
#include <eiklabel.h> // CEikLabel
#include <stringloader.h> // StringLoader
// User includes
#include "MagicTrain.hrh" // dialog lines
#include "MagicTrainAppUi.h"
// ================= MEMBER FUNCTIONS =======================
/**
* Called by the framework when a soft key is pressed.
* Saves the dialog data back to the model
* @param aButtonId The soft key which was pressed
*/
TBool CAskStationDialog::OkToExitL(TInt aButtonId)
{
if (aButtonId == EAknSoftkeyOk)
{
iAppUi->ProcessCommandL( EAskStationOk );
}else if (aButtonId == EAknSoftkeyCancel) {
iAppUi->ProcessCommandL( EAskStationCancel);
}
return EFalse;
}
/**
* Called by the framework before the dialog is sized and laid out.
* Initialises the control values.
*/
void CAskStationDialog::PreLayoutDynInitL()
{
SetEditableL( ETrue );
CEikLabel* label1 = static_cast<CEikLabel*>(ControlOrNull(EAskstationDlgCIdName1));
if (label1)
{
HBufC* labelText1 = StringLoader::LoadLC(R_ENTER_STATION_NAME_TEXT1);
label1->SetTextL(*labelText1);
CleanupStack::PopAndDestroy(labelText1);
}
CEikLabel* label2 = static_cast<CEikLabel*>(ControlOrNull(EAskstationDlgCIdName2));
if (label2)
{
HBufC* labelText2 = StringLoader::LoadLC(R_ENTER_STATION_NAME_TEXT2);
label2->SetTextL(*labelText2);
CleanupStack::PopAndDestroy(labelText2);
}
}
/**
* Static construction and execution of the dialog.
* @param aPlayerName the name which this dialog will edit
* @return ETrue if the dialog is dismissed with a positive action, EFalse otherwise
*/
/*
TBool CAskStationDialog::RunDlgLD (TDes& aStationName1,TDes& aStationName2,CTrainAppUi* aAppUi)
{
CAskStationDialog* askStationDialog = new (ELeave) CAskStationDialog(aStationName1,aStationName2);
askStationDialog->SetMopParent(aAppUi);
askStationDialog->iFocusControl = EAskstationDlgCIdNameEditor1;
askStationDialog->iIsChageInput = EFalse;
return askStationDialog->ExecuteLD(R_ASK_STATION_DIALOG);
}
*/
//void HandleForegroundEventL(TBool aForeground)
//{
// TBool a;
// if (aForeground)
// a = aForeground;
//}
/*
TKeyResponse CAskStationDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
CEikEdwin* editor1 = static_cast<CEikEdwin*>(ControlOrNull(EAskstationDlgCIdNameEditor1));
CEikEdwin* editor2 = static_cast<CEikEdwin*>(ControlOrNull(EAskstationDlgCIdNameEditor2));
if (editor1 && editor1->IsFocused()) {
return CCoeControl::OfferKeyEventL(aKeyEvent,aType); //editor1->OfferKeyEventL(aKeyEvent,aType);
}else if (editor2 && editor2->IsFocused()) {
return editor2->OfferKeyEventL(aKeyEvent,aType);
}
return EKeyWasNotConsumed;
}
/*
CEikEdwin* editor1 = static_cast<CEikEdwin*>(ControlOrNull(EAskstationDlgCIdNameEditor1));
CEikEdwin* editor2 = static_cast<CEikEdwin*>(ControlOrNull(EAskstationDlgCIdNameEditor2));
if (editor1) {
if( editor1->OfferKeyEventL(aKeyEvent,aType) == EKeyWasConsumed) {
return EKeyWasConsumed;
}else{
if (CCoeControl::OfferKeyEventL(aKeyEvent,aType) == EKeyWasConsumed)
return EKeyWasConsumed;
}
}
//}else {
// return CAknDialog::OfferKeyEventL(aKeyEvent,aType);
//}
*/
/*
CEikEdwin* editor1 = static_cast<CEikEdwin*>(ControlOrNull(EAskstationDlgCIdNameEditor1));
CEikEdwin* editor2 = static_cast<CEikEdwin*>(ControlOrNull(EAskstationDlgCIdNameEditor2));
//editor1->
if (this->IsFocused() && aType == EEventKeyUp) {
switch(aKeyEvent.iScanCode) {
case EStdKeyRightShift:
iIsChageInput = ETrue;
if (iFocusControl == EAskstationDlgCIdNameEditor1)
return editor1->OfferKeyEventL(aKeyEvent,aType);
else if (iFocusControl == EAskstationDlgCIdNameEditor2)
return editor2->OfferKeyEventL(aKeyEvent,aType);
case EStdKeyDevice0:
if(iIsChageInput) {
iIsChageInput = EFalse;
if (iFocusControl == EAskstationDlgCIdNameEditor1)
return editor1->OfferKeyEventL(aKeyEvent,aType);
else if (iFocusControl == EAskstationDlgCIdNameEditor2)
return editor2->OfferKeyEventL(aKeyEvent,aType);
}
case EStdKeyDevice1:
if(iIsChageInput) {
iIsChageInput = EFalse;
if (iFocusControl == EAskstationDlgCIdNameEditor1)
return editor1->OfferKeyEventL(aKeyEvent,aType);
else if (iFocusControl == EAskstationDlgCIdNameEditor2)
return editor2->OfferKeyEventL(aKeyEvent,aType);
}
case EStdKeyUpArrow:
if(iIsChageInput) {
if (iFocusControl == EAskstationDlgCIdNameEditor1)
return editor1->OfferKeyEventL(aKeyEvent,aType);
else if (iFocusControl == EAskstationDlgCIdNameEditor2)
return editor2->OfferKeyEventL(aKeyEvent,aType);
}else if (iFocusControl == EAskstationDlgCIdNameEditor2) {
iFocusControl = EAskstationDlgCIdNameEditor1;
this->TryChangeFocusToL(EAskstationDlgCIdNameEditor1);
return EKeyWasConsumed;
}
case EStdKeyDownArrow:
if(iIsChageInput) {
if (iFocusControl == EAskstationDlgCIdNameEditor1)
return editor1->OfferKeyEventL(aKeyEvent,aType);
else if (iFocusControl == EAskstationDlgCIdNameEditor2)
return editor2->OfferKeyEventL(aKeyEvent,aType);
}else if (iFocusControl == EAskstationDlgCIdNameEditor1) {
// iFocusControl = EAskstationDlgCIdNameEditor2;
// this->TryChangeFocusToL(EAskstationDlgCIdNameEditor2);
// return EKeyWasConsumed;
return CCoeControl::OfferKeyEventL(aKeyEvent,aType);
}
default:
if (iFocusControl == EAskstationDlgCIdNameEditor1)
return editor1->OfferKeyEventL(aKeyEvent,aType);
else if (iFocusControl == EAskstationDlgCIdNameEditor2)
return editor2->OfferKeyEventL(aKeyEvent,aType);
}
}
return EKeyWasNotConsumed;
*/
// }
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -