From e24adb18e330ff25dd35a278f0f8593378e14668 Mon Sep 17 00:00:00 2001 From: ydong10 Date: Thu, 30 Dec 2010 07:26:56 +0000 Subject: [PATCH] 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 --- .../Universal/SetupBrowserDxe/InputHandler.c | 123 +++++++++++++----- .../Universal/SetupBrowserDxe/Presentation.c | 14 +- MdeModulePkg/Universal/SetupBrowserDxe/Ui.c | 5 +- 3 files changed, 98 insertions(+), 44 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c index 2905006856..0d42beae50 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c @@ -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; diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 6d9a555b49..f41ac58feb 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -716,14 +716,14 @@ UpdateKeyHelp ( ARROW_LEFT, gMoveHighlight ); - PrintStringAt (SecCol, BottomRowOfHelp, gAdjustNumber); + PrintStringAt (SecCol, BottomRowOfHelp, gEnterString); + PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber); } else { PrintAt (StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight); if (Statement->Operand == EFI_IFR_NUMERIC_OP && Statement->Step != 0) { - PrintStringAt (SecCol, BottomRowOfHelp, gAdjustNumber); - } else { - PrintStringAt (SecCol, BottomRowOfHelp, gEnterString); - } + PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber); + } + PrintStringAt (SecCol, BottomRowOfHelp, gEnterString); } } else { PrintStringAt (SecCol, BottomRowOfHelp, gEnterCommitString); @@ -731,7 +731,9 @@ UpdateKeyHelp ( // // If it is a selected numeric with manual input, display different message // - if ((Statement->Operand == EFI_IFR_NUMERIC_OP) && (Statement->Step == 0)) { + if ((Statement->Operand == EFI_IFR_NUMERIC_OP) || + (Statement->Operand == EFI_IFR_DATE_OP) || + (Statement->Operand == EFI_IFR_TIME_OP)) { PrintStringAt ( SecCol, TopRowOfHelp, diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index 36ae3db0da..736d9e822a 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -2497,10 +2497,7 @@ UiDisplayMenu ( ASSERT(MenuOption != NULL); Statement = MenuOption->ThisTag; - if ((Statement->Operand == EFI_IFR_TEXT_OP) || - (Statement->Operand == EFI_IFR_DATE_OP) || - (Statement->Operand == EFI_IFR_TIME_OP) || - (Statement->Operand == EFI_IFR_NUMERIC_OP && Statement->Step != 0)) { + if (Statement->Operand == EFI_IFR_TEXT_OP) { break; }