From 4a6876b72f2d654c168bfe7e3a80da7b98fff8b5 Mon Sep 17 00:00:00 2001 From: ydong10 Date: Wed, 16 Nov 2011 07:16:03 +0000 Subject: Patch include: 1. Browser not support suppress attribute for date/time opcode, not enable this attribute. 2. Show year field in %04d format, old format is %4d. 3. Add sample to use the suppress attribute. Signed-off-by: ydong10 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12722 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 2 +- .../Universal/SetupBrowserDxe/ProcessOptions.c | 2 +- MdeModulePkg/Universal/SetupBrowserDxe/Ui.c | 147 ++++++++++++++------- 3 files changed, 103 insertions(+), 48 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr index f5e3193c29..03ae667e7c 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -616,7 +616,7 @@ formset varid = MyIfrNVData.Time, prompt = STRING_TOKEN(STR_TIME_PROMPT), help = STRING_TOKEN(STR_TIME_PROMPT), - flags = STORAGE_NORMAL, + flags = STORAGE_NORMAL | SECOND_SUPPRESS, default = 15:33:33, endtime; diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c b/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c index f97d91a2d6..1ce139cbb0 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c @@ -699,7 +699,7 @@ ProcessOptions ( case 2: SetUnicodeMem (OptionString[0], 7, L' '); - UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%4d", QuestionValue->Value.date.Year); + UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%04d", QuestionValue->Value.date.Year); *(OptionString[0] + 11) = RIGHT_NUMERIC_DELIMITER; break; } diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index 93399c4028..0be50263dd 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -324,6 +324,102 @@ UiFreeRefreshList ( } +/** + Process option string for date/time opcode. + + @param MenuOption Menu option point to date/time. + @param OptionString Option string input for process. + @param AddOptCol Whether need to update MenuOption->OptCol. + +**/ +VOID +ProcessStringForDateTime ( + UI_MENU_OPTION *MenuOption, + CHAR16 *OptionString, + BOOLEAN AddOptCol + ) +{ + UINTN Index; + UINTN Count; + FORM_BROWSER_STATEMENT *Statement; + + ASSERT (MenuOption != NULL && OptionString != NULL); + + Statement = MenuOption->ThisTag; + + // + // If leading spaces on OptionString - remove the spaces + // + for (Index = 0; OptionString[Index] == L' '; Index++) { + // + // Base on the blockspace to get the option column info. + // + if (AddOptCol) { + MenuOption->OptCol++; + } + } + + for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) { + OptionString[Count] = OptionString[Index]; + Count++; + } + OptionString[Count] = CHAR_NULL; + + // + // Enable to suppress field in the opcode base on the flag. + // + if (Statement->Operand == EFI_IFR_DATE_OP) { + // + // OptionString format is: <**: **: ****> + // |month|day|year| + // 4 3 5 + // + if ((Statement->Flags & EFI_QF_DATE_MONTH_SUPPRESS) && (MenuOption->Sequence == 0)) { + // + // At this point, only "<**:" in the optionstring. + // Clean the day's ** field, after clean, the format is "< :" + // + SetUnicodeMem (&OptionString[1], 2, L' '); + } else if ((Statement->Flags & EFI_QF_DATE_DAY_SUPPRESS) && (MenuOption->Sequence == 1)) { + // + // At this point, only "**:" in the optionstring. + // Clean the month's "**" field, after clean, the format is " :" + // + SetUnicodeMem (&OptionString[0], 2, L' '); + } else if ((Statement->Flags & EFI_QF_DATE_YEAR_SUPPRESS) && (MenuOption->Sequence == 2)) { + // + // At this point, only "****>" in the optionstring. + // Clean the year's "****" field, after clean, the format is " >" + // + SetUnicodeMem (&OptionString[0], 4, L' '); + } + } else if (Statement->Operand == EFI_IFR_TIME_OP) { + // + // OptionString format is: <**: **: **> + // |hour|minute|second| + // 4 3 3 + // + if ((Statement->Flags & QF_TIME_HOUR_SUPPRESS) && (MenuOption->Sequence == 0)) { + // + // At this point, only "<**:" in the optionstring. + // Clean the hour's ** field, after clean, the format is "< :" + // + SetUnicodeMem (&OptionString[1], 2, L' '); + } else if ((Statement->Flags & QF_TIME_MINUTE_SUPPRESS) && (MenuOption->Sequence == 1)) { + // + // At this point, only "**:" in the optionstring. + // Clean the minute's "**" field, after clean, the format is " :" + // + SetUnicodeMem (&OptionString[0], 2, L' '); + } else if ((Statement->Flags & QF_TIME_SECOND_SUPPRESS) && (MenuOption->Sequence == 2)) { + // + // At this point, only "**>" in the optionstring. + // Clean the second's "**" field, after clean, the format is " >" + // + SetUnicodeMem (&OptionString[0], 2, L' '); + } + } +} /** Refresh question. @@ -336,7 +432,6 @@ RefreshQuestion ( ) { CHAR16 *OptionString; - UINTN Index; EFI_STATUS Status; UI_MENU_SELECTION *Selection; FORM_BROWSER_STATEMENT *Question; @@ -353,12 +448,6 @@ RefreshQuestion ( ProcessOptions (Selection, MenuRefreshEntry->MenuOption, FALSE, &OptionString); if (OptionString != NULL) { - // - // If leading spaces on OptionString - remove the spaces - // - for (Index = 0; OptionString[Index] == L' '; Index++) - ; - // // If old Text is longer than new string, need to clean the old string before paint the newer. // This option is no need for time/date opcode, because time/data opcode has fixed string length. @@ -375,7 +464,8 @@ RefreshQuestion ( } gST->ConOut->SetAttribute (gST->ConOut, MenuRefreshEntry->CurrentAttribute); - PrintStringAt (MenuRefreshEntry->CurrentColumn, MenuRefreshEntry->CurrentRow, &OptionString[Index]); + ProcessStringForDateTime(MenuRefreshEntry->MenuOption, OptionString, FALSE); + PrintStringAt (MenuRefreshEntry->CurrentColumn, MenuRefreshEntry->CurrentRow, OptionString); FreePool (OptionString); } @@ -1993,7 +2083,6 @@ UiDisplayMenu ( UINTN BottomRow; UINTN OriginalRow; UINTN Index; - UINT32 Count; UINT16 Width; CHAR16 *StringPtr; CHAR16 *OptionString; @@ -2235,19 +2324,7 @@ UiDisplayMenu ( if (OptionString != NULL) { if (Statement->Operand == EFI_IFR_DATE_OP || Statement->Operand == EFI_IFR_TIME_OP) { - // - // If leading spaces on OptionString - remove the spaces - // - for (Index = 0; OptionString[Index] == L' '; Index++) { - MenuOption->OptCol++; - } - - for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) { - OptionString[Count] = OptionString[Index]; - Count++; - } - - OptionString[Count] = CHAR_NULL; + ProcessStringForDateTime(MenuOption, OptionString, TRUE); } Width = (UINT16) gOptionBlockWidth; @@ -2554,18 +2631,7 @@ UiDisplayMenu ( if ((MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) || (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP) ) { - // - // If leading spaces on OptionString - remove the spaces - // - for (Index = 0; OptionString[Index] == L' '; Index++) - ; - - for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) { - OptionString[Count] = OptionString[Index]; - Count++; - } - - OptionString[Count] = CHAR_NULL; + ProcessStringForDateTime(MenuOption, OptionString, FALSE); } Width = (UINT16) gOptionBlockWidth; @@ -2664,18 +2730,7 @@ UiDisplayMenu ( ProcessOptions (Selection, MenuOption, FALSE, &OptionString); if (OptionString != NULL) { if (Statement->Operand == EFI_IFR_DATE_OP || Statement->Operand == EFI_IFR_TIME_OP) { - // - // If leading spaces on OptionString - remove the spaces - // - for (Index = 0; OptionString[Index] == L' '; Index++) - ; - - for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) { - OptionString[Count] = OptionString[Index]; - Count++; - } - - OptionString[Count] = CHAR_NULL; + ProcessStringForDateTime(MenuOption, OptionString, FALSE); } Width = (UINT16) gOptionBlockWidth; -- cgit v1.2.3