From b00964a9992deedb135ff24d1b9618c97f93687c Mon Sep 17 00:00:00 2001 From: ydong10 Date: Wed, 8 Jun 2011 07:27:39 +0000 Subject: Add new "Modal form" opcode, also add sample code to use it. Signed-off-by: ydong10 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11764 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c | 8 ++++ .../Universal/SetupBrowserDxe/Presentation.c | 25 ++++++++-- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 24 ++++++++++ MdeModulePkg/Universal/SetupBrowserDxe/Setup.h | 7 ++- MdeModulePkg/Universal/SetupBrowserDxe/Ui.c | 55 ++++++++++++++++++---- 5 files changed, 103 insertions(+), 16 deletions(-) (limited to 'MdeModulePkg/Universal/SetupBrowserDxe') diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index 564a246a1b..469b274b44 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -2068,6 +2068,14 @@ ParseOpCodes ( CurrentStatement->RefreshInterval = ((EFI_IFR_REFRESH *) OpCodeData)->RefreshInterval; break; + // + // Modal tag + // + case EFI_IFR_MODAL_TAG_OP: + ASSERT (CurrentForm != NULL); + CurrentForm->ModalForm = TRUE; + break; + // // Vendor specific // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 94ba239950..0372f2755b 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -182,10 +182,13 @@ GetStringWidth ( /** This function displays the page frame. + @param Selection Selection contains the information about + the Selection, form and formset to be displayed. + Selection action may be updated in retrieve callback. **/ VOID DisplayPageFrame ( - VOID + IN UI_MENU_SELECTION *Selection ) { UINTN Index; @@ -203,6 +206,10 @@ DisplayPageFrame ( gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &LocalScreen.RightColumn, &LocalScreen.BottomRow); ClearLines (0, LocalScreen.RightColumn, 0, LocalScreen.BottomRow, KEYHELP_BACKGROUND); + if (Selection->Form->ModalForm) { + return; + } + CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); // @@ -484,7 +491,11 @@ DisplayForm ( StringPtr = GetToken (Selection->Form->FormTitle, Handle); if ((gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) != FORMSET_CLASS_FRONT_PAGE) { - gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | TITLE_BACKGROUND); + if (Selection->Form->ModalForm) { + gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | EFI_BACKGROUND_BLACK); + } else { + gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | TITLE_BACKGROUND); + } PrintStringAt ( (LocalScreen.RightColumn + LocalScreen.LeftColumn - GetStringWidth (StringPtr) / 2) / 2, LocalScreen.TopRow + 1, @@ -673,6 +684,12 @@ UpdateKeyHelp ( EFI_SCREEN_DESCRIPTOR LocalScreen; FORM_BROWSER_STATEMENT *Statement; + gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND); + + if (Selection->Form->ModalForm) { + return; + } + CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); SecCol = LocalScreen.LeftColumn + (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3; @@ -684,8 +701,6 @@ UpdateKeyHelp ( TopRowOfHelp = LocalScreen.BottomRow - 4; BottomRowOfHelp = LocalScreen.BottomRow - 3; - gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND); - Statement = MenuOption->ThisTag; switch (Statement->Operand) { case EFI_IFR_ORDERED_LIST_OP: @@ -1338,7 +1353,7 @@ SetupBrowser ( // // Displays the Header and Footer borders // - DisplayPageFrame (); + DisplayPageFrame (Selection); // // Display form diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 0eaa78321f..dbf6a79b8c 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -2835,6 +2835,7 @@ InitializeCurrentSetting ( FORMSET_STORAGE *StorageSrc; FORMSET_STORAGE *OldStorage; FORM_BROWSER_FORM *Form; + FORM_BROWSER_FORM *Form2; EFI_STATUS Status; // @@ -2896,6 +2897,29 @@ InitializeCurrentSetting ( Link = GetNextNode (&FormSet->StorageListHead, Link); } + // + // If has old formset, get the old nv update status. + // + if (gOldFormSet != NULL) { + Link = GetFirstNode (&FormSet->FormListHead); + while (!IsNull (&FormSet->FormListHead, Link)) { + Form = FORM_BROWSER_FORM_FROM_LINK (Link); + + Link2 = GetFirstNode (&gOldFormSet->FormListHead); + while (!IsNull (&gOldFormSet->FormListHead, Link2)) { + Form2 = FORM_BROWSER_FORM_FROM_LINK (Link2); + + if (Form->FormId == Form2->FormId) { + Form->NvUpdateRequired = Form2->NvUpdateRequired; + break; + } + + Link2 = GetNextNode (&gOldFormSet->FormListHead, Link2); + } + Link = GetNextNode (&FormSet->FormListHead, Link); + } + } + return EFI_SUCCESS; } diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index d76569e8ec..cb09fee344 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -426,6 +426,8 @@ typedef struct { EFI_IMAGE_ID ImageId; + BOOLEAN ModalForm; // Whether this is a modal form. + BOOLEAN NvUpdateRequired; // Whether this form has NV update request. LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION) @@ -717,10 +719,13 @@ DestroyFormSet ( /** This function displays the page frame. + @param Selection Selection contains the information about + the Selection, form and formset to be displayed. + Selection action may be updated in retrieve callback. **/ VOID DisplayPageFrame ( - VOID + IN UI_MENU_SELECTION *Selection ); /** diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index d5f726b0ce..9d08c130e7 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -1648,6 +1648,7 @@ UiDisplayMenu ( UI_MENU_LIST *CurrentMenu; UI_MENU_LIST *MenuList; FORM_BROWSER_FORM *RefForm; + UINTN ModalSkipColumn; CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR)); @@ -1670,6 +1671,7 @@ UiDisplayMenu ( PreviousMenuOption = NULL; SavedMenuOption = NULL; RefForm = NULL; + ModalSkipColumn = (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 6; ZeroMem (&Key, sizeof (EFI_INPUT_KEY)); @@ -1681,7 +1683,12 @@ UiDisplayMenu ( Row = LocalScreen.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT + SCROLL_ARROW_HEIGHT; } - Col = LocalScreen.LeftColumn + LEFT_SKIPPED_COLUMNS; + if (Selection->Form->ModalForm) { + Col = LocalScreen.LeftColumn + LEFT_SKIPPED_COLUMNS + ModalSkipColumn; + } else { + Col = LocalScreen.LeftColumn + LEFT_SKIPPED_COLUMNS; + } + BottomRow = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - FOOTER_HEIGHT - SCROLL_ARROW_HEIGHT - 1; Selection->TopRow = TopRow; @@ -1757,14 +1764,23 @@ UiDisplayMenu ( Temp = (UINTN) SkipValue; Temp2 = (UINTN) SkipValue; - ClearLines ( - LocalScreen.LeftColumn, - LocalScreen.RightColumn, - TopRow - SCROLL_ARROW_HEIGHT, - BottomRow + SCROLL_ARROW_HEIGHT, - PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND - ); - + if (Selection->Form->ModalForm) { + ClearLines ( + LocalScreen.LeftColumn + ModalSkipColumn, + LocalScreen.LeftColumn + ModalSkipColumn + gPromptBlockWidth + gOptionBlockWidth, + TopRow - SCROLL_ARROW_HEIGHT, + BottomRow + SCROLL_ARROW_HEIGHT, + PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND + ); + } else { + ClearLines ( + LocalScreen.LeftColumn, + LocalScreen.RightColumn, + TopRow - SCROLL_ARROW_HEIGHT, + BottomRow + SCROLL_ARROW_HEIGHT, + PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND + ); + } UiFreeRefreshList (); MinRefreshInterval = 0; @@ -1772,7 +1788,11 @@ UiDisplayMenu ( MenuOption = MENU_OPTION_FROM_LINK (Link); MenuOption->Row = Row; MenuOption->Col = Col; - MenuOption->OptCol = gPromptBlockWidth + 1 + LocalScreen.LeftColumn; + if (Selection->Form->ModalForm) { + MenuOption->OptCol = gPromptBlockWidth + 1 + LocalScreen.LeftColumn + ModalSkipColumn; + } else { + MenuOption->OptCol = gPromptBlockWidth + 1 + LocalScreen.LeftColumn; + } Statement = MenuOption->ThisTag; if (Statement->InSubtitle) { @@ -2293,6 +2313,9 @@ UiDisplayMenu ( case CfUpdateHelpString: ControlFlag = CfPrepareToReadKey; + if (Selection->Form->ModalForm) { + break; + } if (Repaint || NewLine) { // @@ -2447,6 +2470,12 @@ UiDisplayMenu ( // } else { for (Index = 0; Index < sizeof (gScanCodeToOperation) / sizeof (gScanCodeToOperation[0]); Index++) { + if (Selection->Form->ModalForm && + (Key.ScanCode == SCAN_F9 || Key.ScanCode == SCAN_F10 || Key.ScanCode == SCAN_ESC)) { + ControlFlag = CfReadKey; + break; + } + if (Key.ScanCode == gScanCodeToOperation[Index].ScanCode) { if (Key.ScanCode == SCAN_F9) { // @@ -2503,6 +2532,9 @@ UiDisplayMenu ( switch (Statement->Operand) { case EFI_IFR_REF_OP: if (Statement->RefDevicePath != 0) { + if (Selection->Form->ModalForm) { + break; + } // // Goto another Hii Package list // @@ -2558,6 +2590,9 @@ UiDisplayMenu ( Selection->FormId = Statement->RefFormId; Selection->QuestionId = Statement->RefQuestionId; } else if (!CompareGuid (&Statement->RefFormSetId, &gZeroGuid)) { + if (Selection->Form->ModalForm) { + break; + } // // Goto another Formset, check for uncommitted data // -- cgit v1.2.3