From 5a9f73bf065eda6b830445dc907e778f4a13d8d7 Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Mon, 12 Aug 2013 04:49:48 +0000 Subject: Refine the code logic for browser and display engine. Signed-off-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14543 6f19259b-4bc3-4df7-8a09-765794883524 --- .../CustomizedDisplayLib/CustomizedDisplayLib.c | 53 +++--- .../CustomizedDisplayLibInternal.c | 181 +++++++++------------ .../CustomizedDisplayLibInternal.h | 16 +- 3 files changed, 100 insertions(+), 150 deletions(-) (limited to 'MdeModulePkg/Library') diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c index 84df7cc249..aa28146b02 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c @@ -18,7 +18,7 @@ EFI_GUID gCustomizedDisplayLibGuid = { 0x99fdc8fd, 0x849b, 0x4eba, { 0x EFI_HII_HANDLE mCDLStringPackHandle; UINT16 gClassOfVfr; // Formset class information -UINT16 gLastClassOfVfr = 0; +BOOLEAN gLibIsFirstForm = TRUE; BANNER_DATA *gBannerData; UINTN gFooterHeight; @@ -37,8 +37,8 @@ Statement +------------------------------------------------------------------------------+ -| F1=Scroll Help F9=Reset to Defaults F10=Save and Exit | -| ^"=Move Highlight Toggles Checkbox Esc=Discard Changes | +| F9=Reset to Defaults F10=Save | +| ^"=Move Highlight Toggles Checkbox Esc=Exit | +------------------------------------------------------------------------------+ StatusBar **/ @@ -74,9 +74,6 @@ DisplayPageFrame ( } gClassOfVfr = FORMSET_CLASS_PLATFORM_SETUP; - if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) { - gClassOfVfr = FORMSET_CLASS_MODEL_PAGE; - } ProcessExternedOpcode(FormData); @@ -84,7 +81,7 @@ DisplayPageFrame ( // Calculate the ScreenForStatement. // ScreenForStatement->BottomRow = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight; - if ((gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) == FORMSET_CLASS_FRONT_PAGE) { + if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) { ScreenForStatement->TopRow = gScreenDimensions.TopRow + FRONT_PAGE_HEADER_HEIGHT; } else { ScreenForStatement->TopRow = gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT; @@ -92,42 +89,30 @@ DisplayPageFrame ( ScreenForStatement->LeftColumn = gScreenDimensions.LeftColumn; ScreenForStatement->RightColumn = gScreenDimensions.RightColumn; - // - // If Last Vfr Class is same to current Vfr Class, - // they will have the same page frame. So, Page Frame is not required to be repainted. - // - if (gLastClassOfVfr == gClassOfVfr) { - UpdateStatusBar(NV_UPDATE_REQUIRED, FormData->SettingChangedFlag); - PrintFormTitle(FormData); - return EFI_SUCCESS; + if ((gLibIsFirstForm) || ((FormData->Attribute & HII_DISPLAY_MODAL) != 0)) { + // + // Ensure we are in Text mode + // + gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); + ClearLines (0, gScreenDimensions.RightColumn, 0, gScreenDimensions.BottomRow, KEYHELP_BACKGROUND); + gLibIsFirstForm = FALSE; } // - // Record last ClassOfVfr and Streen Information. + // Don't print frame for modal form. // - gLastClassOfVfr = gClassOfVfr; - - // - // Ensure we are in Text mode - // - gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); - - ClearLines (0, gScreenDimensions.RightColumn, 0, gScreenDimensions.BottomRow, KEYHELP_BACKGROUND); - if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) { return EFI_SUCCESS; } - if ((gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) == FORMSET_CLASS_FRONT_PAGE) { + if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) { PrintBannerInfo (FormData); } - PrintFramework (); + PrintFramework (FormData); UpdateStatusBar(NV_UPDATE_REQUIRED, FormData->SettingChangedFlag); - PrintFormTitle(FormData); - return EFI_SUCCESS; } @@ -213,7 +198,7 @@ RefreshKeyHelp ( if (!Selected) { PrintHotKeyHelpString (FormData); - if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) { + if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); } @@ -269,7 +254,7 @@ RefreshKeyHelp ( case EFI_IFR_CHECKBOX_OP: PrintHotKeyHelpString (FormData); - if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) { + if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); } @@ -287,7 +272,7 @@ RefreshKeyHelp ( if (!Selected) { PrintHotKeyHelpString (FormData); - if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) { + if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); } @@ -584,7 +569,7 @@ FormExitPolicy ( VOID ) { - return (gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) == FORMSET_CLASS_FRONT_PAGE ? FALSE : TRUE; + return gClassOfVfr == FORMSET_CLASS_FRONT_PAGE ? FALSE : TRUE; } /** @@ -883,7 +868,7 @@ ClearDisplayPage ( { gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->ClearScreen (gST->ConOut); - gLastClassOfVfr = 0; + gLibIsFirstForm = TRUE; } /** diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c index 9b6ddb517f..b6b4055b6d 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c @@ -130,20 +130,35 @@ PrintBannerInfo ( } /** + Print framework and form title for a page. - Print framework for a page. - + @param[in] FormData Form Data to be shown in Page **/ VOID PrintFramework ( - VOID + IN FORM_DISPLAY_ENGINE_FORM *FormData ) { UINTN Index; CHAR16 Character; CHAR16 *Buffer; UINTN Row; + CHAR16 *TitleStr; + if (gClassOfVfr != FORMSET_CLASS_PLATFORM_SETUP) { + // + // Only Setup page needs Framework + // + ClearLines ( + gScreenDimensions.LeftColumn, + gScreenDimensions.RightColumn, + gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, + gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 1, + KEYHELP_TEXT | KEYHELP_BACKGROUND + ); + return; + } + Buffer = AllocateZeroPool (0x10000); ASSERT (Buffer != NULL); Character = BOXDRAW_HORIZONTAL; @@ -151,108 +166,30 @@ PrintFramework ( Buffer[Index] = Character; } - ClearLines ( - gScreenDimensions.LeftColumn, - gScreenDimensions.RightColumn, - gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, - gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 1, - KEYHELP_TEXT | KEYHELP_BACKGROUND - ); - - if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) { - ClearLines ( - gScreenDimensions.LeftColumn, - gScreenDimensions.RightColumn, - gScreenDimensions.TopRow, - gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 1, - TITLE_TEXT | TITLE_BACKGROUND - ); - // - // Print Top border line - // +------------------------------------------------------------------------------+ - // ? ? - // +------------------------------------------------------------------------------+ - // - Character = BOXDRAW_DOWN_RIGHT; - - PrintCharAt ((UINTN) -1, (UINTN) -1, Character); - PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer); - - Character = BOXDRAW_DOWN_LEFT; - PrintCharAt ((UINTN) -1, (UINTN) -1, Character); - - Character = BOXDRAW_VERTICAL; - for (Row = gScreenDimensions.TopRow + 1; Row <= gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 2; Row++) { - PrintCharAt (gScreenDimensions.LeftColumn, Row, Character); - PrintCharAt (gScreenDimensions.RightColumn - 1, Row, Character); - } - - Character = BOXDRAW_UP_RIGHT; - PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 1, Character); - PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer); - - Character = BOXDRAW_UP_LEFT; - PrintCharAt ((UINTN) -1, (UINTN) -1, Character); - - // - // Print Bottom border line - // +------------------------------------------------------------------------------+ - // ? ? - // +------------------------------------------------------------------------------+ - // - Character = BOXDRAW_DOWN_RIGHT; - PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, Character); - - PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer); - - Character = BOXDRAW_DOWN_LEFT; - PrintCharAt ((UINTN) -1, (UINTN) -1, Character); - Character = BOXDRAW_VERTICAL; - for (Row = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1; - Row <= gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2; - Row++ - ) { - PrintCharAt (gScreenDimensions.LeftColumn, Row, Character); - PrintCharAt (gScreenDimensions.RightColumn - 1, Row, Character); - } - - Character = BOXDRAW_UP_RIGHT; - PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 1, Character); - - PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer); - - Character = BOXDRAW_UP_LEFT; - PrintCharAt ((UINTN) -1, (UINTN) -1, Character); - } - - FreePool (Buffer); -} - -/** - Print the form title. + // + // Print Top border line + // +------------------------------------------------------------------------------+ + // ? ? + // +------------------------------------------------------------------------------+ + // + gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | TITLE_BACKGROUND); + Character = BOXDRAW_DOWN_RIGHT; - @param[in] FormData Form Data to be shown in Page + PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.TopRow, Character); + PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer); -**/ -VOID -PrintFormTitle ( - IN FORM_DISPLAY_ENGINE_FORM *FormData - ) -{ - CHAR16 *TitleStr; + Character = BOXDRAW_DOWN_LEFT; + PrintCharAt ((UINTN) -1, (UINTN) -1, Character); - if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) != FORMSET_CLASS_PLATFORM_SETUP) { - // - // Only Setup Page need Title. - // - return; + Character = BOXDRAW_VERTICAL; + for (Row = gScreenDimensions.TopRow + 1; Row <= gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 2; Row++) { + PrintCharAt (gScreenDimensions.LeftColumn, Row, Character); + PrintCharAt (gScreenDimensions.RightColumn - 1, Row, Character); } - TitleStr = LibGetToken (FormData->FormTitle, FormData->HiiHandle); - ASSERT (TitleStr != NULL); - - gST->ConOut->SetAttribute (gST->ConOut, TITLE_TEXT | TITLE_BACKGROUND); - + // + // Print Form Title + // ClearLines ( gScreenDimensions.LeftColumn + 1, gScreenDimensions.RightColumn - 1, @@ -261,13 +198,53 @@ PrintFormTitle ( TITLE_TEXT | TITLE_BACKGROUND ); + TitleStr = LibGetToken (FormData->FormTitle, FormData->HiiHandle); + ASSERT (TitleStr != NULL); PrintStringAt ( (gScreenDimensions.RightColumn + gScreenDimensions.LeftColumn - LibGetStringWidth (TitleStr) / 2) / 2, gScreenDimensions.TopRow + 1, TitleStr ); - FreePool (TitleStr); + + Character = BOXDRAW_UP_RIGHT; + PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 1, Character); + PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer); + + Character = BOXDRAW_UP_LEFT; + PrintCharAt ((UINTN) -1, (UINTN) -1, Character); + + // + // Print Bottom border line + // +------------------------------------------------------------------------------+ + // ? ? + // +------------------------------------------------------------------------------+ + // + Character = BOXDRAW_DOWN_RIGHT; + PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, Character); + + PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer); + + Character = BOXDRAW_DOWN_LEFT; + PrintCharAt ((UINTN) -1, (UINTN) -1, Character); + Character = BOXDRAW_VERTICAL; + for (Row = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1; + Row <= gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2; + Row++ + ) { + PrintCharAt (gScreenDimensions.LeftColumn, Row, Character); + PrintCharAt (gScreenDimensions.RightColumn - 1, Row, Character); + } + + Character = BOXDRAW_UP_RIGHT; + PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 1, Character); + + PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer); + + Character = BOXDRAW_UP_LEFT; + PrintCharAt ((UINTN) -1, (UINTN) -1, Character); + + FreePool (Buffer); } /** @@ -300,7 +277,7 @@ ProcessUserOpcode( // // Only in front page form set, we care about the banner data. // - if ((gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) == FORMSET_CLASS_FRONT_PAGE) { + if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) { // // Initialize Driver private data // diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h index ab197cfe72..ccbd45f425 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h @@ -57,7 +57,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define FORMSET_CLASS_PLATFORM_SETUP 0x0001 #define FORMSET_CLASS_FRONT_PAGE 0x0002 -#define FORMSET_CLASS_MODEL_PAGE 0x0004 #define FRONT_PAGE_HEADER_HEIGHT 6 @@ -130,23 +129,12 @@ PrintBannerInfo ( ); /** - - Print framework for a page. - -**/ -VOID -PrintFramework ( - VOID - ); - -/** - Print the form title. + Print framework and form title for a page. @param[in] FormData Form Data to be shown in Page - **/ VOID -PrintFormTitle ( +PrintFramework ( IN FORM_DISPLAY_ENGINE_FORM *FormData ); -- cgit v1.2.3