Enable number input for numeric, date and time opcode

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11208 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ydong10
2010-12-30 07:26:56 +00:00
parent a06638eac2
commit e24adb18e3
3 changed files with 98 additions and 44 deletions

View File

@@ -270,6 +270,12 @@ GetNumericInput (
Minimum = Question->Minimum;
Maximum = Question->Maximum;
//
// Only two case, user can enter to this function: Enter and +/- case.
// In Enter case, gDirection = 0; in +/- case, gDirection = SCAN_LEFT/SCAN_WRIGHT
//
ManualInput = (BOOLEAN)(gDirection == 0 ? TRUE : FALSE);
if ((Question->Operand == EFI_IFR_DATE_OP) || (Question->Operand == EFI_IFR_TIME_OP)) {
DateOrTime = TRUE;
} else {
@@ -344,12 +350,6 @@ GetNumericInput (
}
}
if (Step == 0) {
ManualInput = TRUE;
} else {
ManualInput = FALSE;
}
if ((Question->Operand == EFI_IFR_NUMERIC_OP) &&
((Question->Flags & EFI_IFR_DISPLAY) == EFI_IFR_DISPLAY_UINT_HEX)) {
HexInput = TRUE;
@@ -357,41 +357,96 @@ GetNumericInput (
HexInput = FALSE;
}
//
// Enter from "Enter" input, clear the old word showing.
//
if (ManualInput) {
if (HexInput) {
InputWidth = Question->StorageWidth * 2;
} else {
switch (Question->StorageWidth) {
case 1:
InputWidth = 3;
break;
if (Question->Operand == EFI_IFR_NUMERIC_OP) {
if (HexInput) {
InputWidth = Question->StorageWidth * 2;
} else {
switch (Question->StorageWidth) {
case 1:
InputWidth = 3;
break;
case 2:
InputWidth = 5;
break;
case 2:
InputWidth = 5;
break;
case 4:
InputWidth = 10;
break;
case 4:
InputWidth = 10;
break;
case 8:
InputWidth = 20;
break;
case 8:
InputWidth = 20;
break;
default:
InputWidth = 0;
break;
default:
InputWidth = 0;
break;
}
}
InputText[0] = LEFT_NUMERIC_DELIMITER;
SetUnicodeMem (InputText + 1, InputWidth, L' ');
ASSERT (InputWidth + 2 < MAX_NUMERIC_INPUT_WIDTH);
InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;
InputText[InputWidth + 2] = L'\0';
PrintAt (Column, Row, InputText);
Column++;
}
if (Question->Operand == EFI_IFR_DATE_OP) {
if (MenuOption->Sequence == 2) {
InputWidth = 4;
} else {
InputWidth = 2;
}
if (MenuOption->Sequence == 0) {
InputText[0] = LEFT_NUMERIC_DELIMITER;
SetUnicodeMem (InputText + 1, InputWidth, L' ');
} else {
SetUnicodeMem (InputText, InputWidth, L' ');
}
if (MenuOption->Sequence == 2) {
InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;
} else {
InputText[InputWidth + 1] = DATE_SEPARATOR;
}
InputText[InputWidth + 2] = L'\0';
PrintAt (Column, Row, InputText);
if (MenuOption->Sequence == 0) {
Column++;
}
}
InputText[0] = LEFT_NUMERIC_DELIMITER;
SetUnicodeMem (InputText + 1, InputWidth, L' ');
ASSERT (InputWidth + 2 < MAX_NUMERIC_INPUT_WIDTH);
InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;
InputText[InputWidth + 2] = L'\0';
if (Question->Operand == EFI_IFR_TIME_OP) {
InputWidth = 2;
PrintAt (Column, Row, InputText);
Column++;
if (MenuOption->Sequence == 0) {
InputText[0] = LEFT_NUMERIC_DELIMITER;
SetUnicodeMem (InputText + 1, InputWidth, L' ');
} else {
SetUnicodeMem (InputText, InputWidth, L' ');
}
if (MenuOption->Sequence == 2) {
InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;
} else {
InputText[InputWidth + 1] = TIME_SEPARATOR;
}
InputText[InputWidth + 2] = L'\0';
PrintAt (Column, Row, InputText);
if (MenuOption->Sequence == 0) {
Column++;
}
}
}
//
@@ -425,7 +480,7 @@ TheKey2:
switch (Key.ScanCode) {
case SCAN_LEFT:
case SCAN_RIGHT:
if (DateOrTime) {
if (DateOrTime && !ManualInput) {
//
// By setting this value, we will return back to the caller.
// We need to do this since an auto-refresh will destroy the adjustment
@@ -435,7 +490,7 @@ TheKey2:
gDirection = SCAN_DOWN;
}
if (!ManualInput) {
if ((Step != 0) && !ManualInput) {
if (Key.ScanCode == SCAN_LEFT) {
if (EditValue > Step) {
EditValue = EditValue - Step;