X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FDisplayEngineDxe%2FFormDisplay.c;h=0db450e078d1f7a750730bcd4969c59a87715691;hb=c4866c7710c250b83018de6a1fcde6433f87ff3e;hp=2407c7ea6ad70677813fc7cc4f5bcc336e841a1d;hpb=ae4f5746efc0dde9bb64b537f3a41e66c8729f4d;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c index 2407c7ea6a..0db450e078 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c @@ -1,7 +1,8 @@ /** @file Entry and initialization module for the browser. -Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -117,6 +118,12 @@ CHAR16 *gFormNotFound; CHAR16 *gNoSubmitIf; CHAR16 *gBrwoserError; CHAR16 *gSaveFailed; +CHAR16 *gNoSubmitIfFailed; +CHAR16 *gSaveProcess; +CHAR16 *gSaveNoSubmitProcess; +CHAR16 *gDiscardChange; +CHAR16 *gJumpToFormSet; +CHAR16 *gCheckError; CHAR16 *gPromptForData; CHAR16 *gPromptForPassword; CHAR16 *gPromptForNewPassword; @@ -186,6 +193,12 @@ InitializeDisplayStrings ( { mUnknownString = GetToken (STRING_TOKEN (UNKNOWN_STRING), gHiiHandle); gSaveFailed = GetToken (STRING_TOKEN (SAVE_FAILED), gHiiHandle); + gNoSubmitIfFailed = GetToken (STRING_TOKEN (NO_SUBMIT_IF_CHECK_FAILED), gHiiHandle); + gSaveProcess = GetToken (STRING_TOKEN (DISCARD_OR_JUMP), gHiiHandle); + gSaveNoSubmitProcess = GetToken (STRING_TOKEN (DISCARD_OR_CHECK), gHiiHandle); + gDiscardChange = GetToken (STRING_TOKEN (DISCARD_OR_JUMP_DISCARD), gHiiHandle); + gJumpToFormSet = GetToken (STRING_TOKEN (DISCARD_OR_JUMP_JUMP), gHiiHandle); + gCheckError = GetToken (STRING_TOKEN (DISCARD_OR_CHECK_CHECK), gHiiHandle); gPromptForData = GetToken (STRING_TOKEN (PROMPT_FOR_DATA), gHiiHandle); gPromptForPassword = GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD), gHiiHandle); gPromptForNewPassword = GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD), gHiiHandle); @@ -216,6 +229,12 @@ FreeDisplayStrings ( FreePool (mUnknownString); FreePool (gEmptyString); FreePool (gSaveFailed); + FreePool (gNoSubmitIfFailed); + FreePool (gSaveProcess); + FreePool (gSaveNoSubmitProcess); + FreePool (gDiscardChange); + FreePool (gJumpToFormSet); + FreePool (gCheckError); FreePool (gPromptForData); FreePool (gPromptForPassword); FreePool (gPromptForNewPassword); @@ -259,7 +278,7 @@ GetPrompt ( /** Get the supported width for a particular op-code - @param Statement The curent statement. + @param MenuOption The menu option. @param AdjustWidth The width which is saved for the space. @return Returns the number of CHAR16 characters that is support. @@ -267,13 +286,17 @@ GetPrompt ( **/ UINT16 GetWidth ( - IN FORM_DISPLAY_ENGINE_STATEMENT *Statement, - OUT UINT16 *AdjustWidth + IN UI_MENU_OPTION *MenuOption, + OUT UINT16 *AdjustWidth ) { - CHAR16 *String; - UINTN Size; - EFI_IFR_TEXT *TestOp; + CHAR16 *String; + UINTN Size; + EFI_IFR_TEXT *TestOp; + UINT16 ReturnWidth; + FORM_DISPLAY_ENGINE_STATEMENT *Statement; + + Statement = MenuOption->ThisTag; // // For modal form, clean the entire row. @@ -319,13 +342,23 @@ GetWidth ( // // Keep consistent with current behavior. // - return (UINT16) (gPromptBlockWidth + gOptionBlockWidth - 2); + ReturnWidth = (UINT16) (gPromptBlockWidth + gOptionBlockWidth - 2); + } else { + if (AdjustWidth != NULL) { + *AdjustWidth = 1; + } + + ReturnWidth = (UINT16) (gPromptBlockWidth - 1); } - if (AdjustWidth != NULL) { - *AdjustWidth = 1; + // + // For nest in statement, should the subtitle indent. + // + if (MenuOption->NestInStatement) { + ReturnWidth -= SUBTITLE_INDENT; } - return (UINT16) (gPromptBlockWidth - 1); + + return ReturnWidth; } /** @@ -539,24 +572,7 @@ UiAddMenuOption ( String = GetToken (PromptId, gFormData->HiiHandle); ASSERT (String != NULL); - Width = GetWidth (Statement, NULL); - for (; GetLineByWidth (String, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) { - // - // If there is more string to process print on the next row and increment the Skip value - // - if (StrLen (&String[ArrayEntry]) != 0) { - NumberOfLines++; - } - FreePool (OutputString); - } - if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) { - // - // Add three MenuOptions for Date/Time - // Data format : [01/02/2004] [11:22:33] - // Line number : 0 0 1 0 0 1 - // - NumberOfLines = 0; Count = 3; } @@ -571,14 +587,6 @@ UiAddMenuOption ( MenuOption->NestInStatement = NestIn; MenuOption->EntryNumber = *MenuItemCount; - if (Index == 2) { - // - // Override LineNumber for the MenuOption in Date/Time sequence - // - MenuOption->Skip = 1; - } else { - MenuOption->Skip = NumberOfLines; - } MenuOption->Sequence = Index; if ((Statement->Attribute & HII_DISPLAY_GRAYOUT) != 0) { @@ -633,6 +641,37 @@ UiAddMenuOption ( } } + if (Index == 0 && + (Statement->OpCode->OpCode != EFI_IFR_DATE_OP) && + (Statement->OpCode->OpCode != EFI_IFR_TIME_OP)) { + Width = GetWidth (MenuOption, NULL); + for (; GetLineByWidth (String, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) { + // + // If there is more string to process print on the next row and increment the Skip value + // + if (StrLen (&String[ArrayEntry]) != 0) { + NumberOfLines++; + } + FreePool (OutputString); + } + } else { + // + // Add three MenuOptions for Date/Time + // Data format : [01/02/2004] [11:22:33] + // Line number : 0 0 1 0 0 1 + // + NumberOfLines = 0; + } + + if (Index == 2) { + // + // Override LineNumber for the MenuOption in Date/Time sequence + // + MenuOption->Skip = 1; + } else { + MenuOption->Skip = NumberOfLines; + } + InsertTailList (&gMenuOption, &MenuOption->Link); } @@ -679,6 +718,13 @@ ConvertStatementToMenu ( NestStatement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink); NestLink = GetNextNode (&Statement->NestStatementList, NestLink); + // + // Skip the opcode not recognized by Display core. + // + if (NestStatement->OpCode->OpCode == EFI_IFR_GUID_OP) { + continue; + } + UiAddMenuOption (NestStatement, &MenuItemCount, TRUE); } } @@ -832,6 +878,54 @@ UpdateOptionSkipLines ( } } +/** + Check whether this Menu Option could be print. + + Check Prompt string, option string or text two string not NULL. + + This is an internal function. + + @param MenuOption The MenuOption to be checked. + + @retval TRUE This Menu Option is printable. + @retval FALSE This Menu Option could not be printable. + +**/ +BOOLEAN +PrintableMenu ( + UI_MENU_OPTION *MenuOption + ) +{ + EFI_STATUS Status; + EFI_STRING OptionString; + + OptionString = NULL; + + if (MenuOption->Description[0] != '\0') { + return TRUE; + } + + Status = ProcessOptions (MenuOption, FALSE, &OptionString, FALSE); + if (EFI_ERROR (Status)) { + return FALSE; + } + if (OptionString != NULL && OptionString[0] != '\0') { + FreePool (OptionString); + return TRUE; + } + + if ((MenuOption->ThisTag->OpCode->OpCode == EFI_IFR_TEXT_OP) && (((EFI_IFR_TEXT*)MenuOption->ThisTag->OpCode)->TextTwo != 0)) { + OptionString = GetToken (((EFI_IFR_TEXT*)MenuOption->ThisTag->OpCode)->TextTwo, gFormData->HiiHandle); + ASSERT (OptionString != NULL); + if (OptionString[0] != '\0'){ + FreePool (OptionString); + return TRUE; + } + } + + return FALSE; +} + /** Check whether this Menu Option could be highlighted. @@ -849,7 +943,7 @@ IsSelectable ( ) { if ((MenuOption->ThisTag->OpCode->OpCode == EFI_IFR_SUBTITLE_OP) || - MenuOption->GrayOut || MenuOption->ReadOnly) { + MenuOption->GrayOut || MenuOption->ReadOnly || !PrintableMenu (MenuOption)) { return FALSE; } else { return TRUE; @@ -864,19 +958,24 @@ IsSelectable ( @param GoUp The navigation direction. TRUE: up, FALSE: down. @param CurrentPosition Current position. @param GapToTop Gap position to top or bottom. + @param FindInForm Whether find menu in current form or beyond. @return The row distance from current MenuOption to next selectable MenuOption. @retval -1 Reach the begin of the menu, still can't find the selectable menu. - @retval Value Find the selectable menu, maybe the truly selectable, maybe the l - last menu showing at current form. + @retval Value Find the selectable menu, maybe the truly selectable, maybe the + first menu showing beyond current form or last menu showing in + current form. + The value is the line number between the new selected menu and the + current select menu, not include the new selected menu. **/ INTN MoveToNextStatement ( IN BOOLEAN GoUp, IN OUT LIST_ENTRY **CurrentPosition, - IN UINTN GapToTop + IN UINTN GapToTop, + IN BOOLEAN FindInForm ) { INTN Distance; @@ -886,6 +985,11 @@ MoveToNextStatement ( Distance = 0; Pos = *CurrentPosition; + + if (Pos == &gMenuOption) { + return -1; + } + PreMenuOption = MENU_OPTION_FROM_LINK (Pos); while (TRUE) { @@ -897,28 +1001,24 @@ MoveToNextStatement ( if (NextMenuOption->Row == 0) { UpdateOptionSkipLines (NextMenuOption); } - - if (GoUp && (PreMenuOption != NextMenuOption)) { - // - // In this case, still can't find the selectable menu, - // return the last one in the showing form. - // - if ((UINTN) Distance + NextMenuOption->Skip > GapToTop) { - NextMenuOption = PreMenuOption; - break; - } - // - // Current Position doesn't need to be caculated when go up. - // Caculate distanct at first when go up - // - Distance += NextMenuOption->Skip; + if (IsSelectable (NextMenuOption)) { + break; } - if (IsSelectable (NextMenuOption)) { + // + // In this case, still can't find the selectable menu, + // return the first one beyond the showing form. + // + if ((UINTN) Distance + NextMenuOption->Skip > GapToTop) { + if (FindInForm) { + NextMenuOption = PreMenuOption; + } break; } + Distance += NextMenuOption->Skip; + // // Arrive at begin of the menu list. // @@ -927,21 +1027,8 @@ MoveToNextStatement ( break; } - if (!GoUp) { - // - // In this case, still can't find the selectable menu, - // return the last one in the showing form. - // - if ((UINTN) Distance + NextMenuOption->Skip > GapToTop) { - NextMenuOption = PreMenuOption; - break; - } - - Distance += NextMenuOption->Skip; - } - - PreMenuOption = NextMenuOption; Pos = (GoUp ? Pos->BackLink : Pos->ForwardLink); + PreMenuOption = NextMenuOption; } *CurrentPosition = &NextMenuOption->Link; @@ -1335,6 +1422,58 @@ GetQuestionIdInfo ( return QuestionHeader->QuestionId; } + +/** + Find the top of screen menu base on the current menu. + + @param CurPos Current input menu. + @param Rows Totol screen rows. + @param SkipValue SkipValue for this new form. + + @retval TopOfScreen Top of screen menu for the new form. + +**/ +LIST_ENTRY * +FindTopOfScreenMenu ( + IN LIST_ENTRY *CurPos, + IN UINTN Rows, + OUT UINTN *SkipValue + ) +{ + LIST_ENTRY *Link; + LIST_ENTRY *TopOfScreen; + UI_MENU_OPTION *PreviousMenuOption; + + Link = CurPos; + PreviousMenuOption = NULL; + + while (Link->BackLink != &gMenuOption) { + Link = Link->BackLink; + PreviousMenuOption = MENU_OPTION_FROM_LINK (Link); + if (PreviousMenuOption->Row == 0) { + UpdateOptionSkipLines (PreviousMenuOption); + } + if (Rows <= PreviousMenuOption->Skip) { + break; + } + Rows = Rows - PreviousMenuOption->Skip; + } + + if (Link->BackLink == &gMenuOption) { + TopOfScreen = gMenuOption.ForwardLink; + if (PreviousMenuOption != NULL && Rows < PreviousMenuOption->Skip) { + *SkipValue = PreviousMenuOption->Skip - Rows; + } else { + *SkipValue = 0; + } + } else { + TopOfScreen = Link; + *SkipValue = PreviousMenuOption->Skip - Rows; + } + + return TopOfScreen; +} + /** Find the first menu which will be show at the top. @@ -1349,17 +1488,16 @@ FindTopMenu ( IN FORM_DISPLAY_ENGINE_FORM *FormData, OUT LIST_ENTRY **TopOfScreen, OUT LIST_ENTRY **HighlightMenu, - OUT INTN *SkipValue + OUT UINTN *SkipValue ) { - LIST_ENTRY *Link; LIST_ENTRY *NewPos; UINTN TopRow; UINTN BottomRow; - UINTN Index; UI_MENU_OPTION *SavedMenuOption; - UINTN EndRow; + UINTN TmpValue; + TmpValue = 0; TopRow = gStatementDimensions.TopRow + SCROLL_ARROW_HEIGHT; BottomRow = gStatementDimensions.BottomRow - SCROLL_ARROW_HEIGHT; @@ -1370,7 +1508,7 @@ FindTopMenu ( *TopOfScreen = gMenuOption.ForwardLink; *HighlightMenu = gMenuOption.ForwardLink; if (!IsListEmpty (&gMenuOption)) { - MoveToNextStatement (FALSE, HighlightMenu, BottomRow - TopRow); + MoveToNextStatement (FALSE, HighlightMenu, BottomRow - TopRow, TRUE); } *SkipValue = 0; return; @@ -1403,72 +1541,58 @@ FindTopMenu ( UpdateOptionSkipLines (SavedMenuOption); // - // If highlight opcode is date/time, keep the highlight row info not change. + // FormRefreshEvent != NULL means this form will auto exit at an interval, display engine + // will try to keep highlight on the current position after this form exit and re-enter. // - if ((SavedMenuOption->ThisTag->OpCode->OpCode == EFI_IFR_DATE_OP || SavedMenuOption->ThisTag->OpCode->OpCode == EFI_IFR_TIME_OP) && - (gHighligthMenuInfo.QuestionId != 0) && - (gHighligthMenuInfo.QuestionId == GetQuestionIdInfo(SavedMenuOption->ThisTag->OpCode))) { - // - // Still show the highlight menu before exit from display engine. - // - EndRow = gHighligthMenuInfo.DisplayRow + SavedMenuOption->Skip; - } else { - EndRow = BottomRow; - } - + // HiiHandle + QuestionId can find the only one question in the system. // - // Base on the selected menu will show at the bottome of next page, - // select the menu show at the top of the next page. + // If this question has question id, save the question id info to find the question. + // else save the opcode buffer to find it. // - Link = NewPos; - for (Index = TopRow + SavedMenuOption->Skip; Index <= EndRow; ) { - Link = Link->BackLink; - // - // Already find the first menu in this form, means highlight menu - // will show in first page of this form. - // - if (Link == &gMenuOption) { - *TopOfScreen = gMenuOption.ForwardLink; - *SkipValue = 0; - return; + if (gFormData->FormRefreshEvent != NULL && gFormData->HiiHandle == gHighligthMenuInfo.HiiHandle) { + if (gHighligthMenuInfo.QuestionId != 0) { + if (gHighligthMenuInfo.QuestionId == GetQuestionIdInfo(SavedMenuOption->ThisTag->OpCode)) { + BottomRow = gHighligthMenuInfo.DisplayRow + SavedMenuOption->Skip; + // + // SkipValue only used for menu at the top of the form. + // If Highlight menu is not at the top, this value will be update later. + // + TmpValue = gHighligthMenuInfo.SkipValue; + } + } else if (gHighligthMenuInfo.OpCode != NULL){ + if (!CompareMem (gHighligthMenuInfo.OpCode, SavedMenuOption->ThisTag->OpCode, gHighligthMenuInfo.OpCode->Length)) { + BottomRow = gHighligthMenuInfo.DisplayRow + SavedMenuOption->Skip; + // + // SkipValue only used for menu at the top of the form. + // If Highlight menu is not at the top, this value will be update later. + // + TmpValue = gHighligthMenuInfo.SkipValue; + } } - SavedMenuOption = MENU_OPTION_FROM_LINK (Link); - UpdateOptionSkipLines (SavedMenuOption); - Index += SavedMenuOption->Skip; } - // - // Found the menu which will show at the top of the page. - // - if (Link == NewPos) { - // - // The menu can show more than one pages, just show the menu at the top of the page. - // - *SkipValue = 0; - *TopOfScreen = Link; + if (SavedMenuOption->Skip >= BottomRow - TopRow) { + *TopOfScreen = NewPos; } else { - // - // Check whether need to skip some line for menu shows at the top of the page. - // - *SkipValue = Index - EndRow; - if (*SkipValue > 0 && *SkipValue < (INTN) SavedMenuOption->Skip) { - *TopOfScreen = Link; - } else { - *SkipValue = 0; - *TopOfScreen = Link->ForwardLink; - } + *TopOfScreen = FindTopOfScreenMenu(NewPos, BottomRow - TopRow - SavedMenuOption->Skip, &TmpValue); } + AdjustDateAndTimePosition(TRUE, TopOfScreen); + + *SkipValue = TmpValue; } /** Update highlight menu info. @param MenuOption The menu opton which is highlight. + @param SkipValue The skipvalue info for this menu. + SkipValue only used for the menu at the top of the form. **/ VOID UpdateHighlightMenuInfo ( - IN UI_MENU_OPTION *MenuOption + IN UI_MENU_OPTION *MenuOption, + IN UINTN SkipValue ) { FORM_DISPLAY_ENGINE_STATEMENT *Statement; @@ -1485,14 +1609,39 @@ UpdateHighlightMenuInfo ( gSequence = (UINT16) MenuOption->Sequence; // - // Record highlight row info for date/time opcode. + // FormRefreshEvent != NULL means this form will auto exit at an interval, display engine + // will try to keep highlight on the current position after this form exit and re-enter. // - if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) { + // HiiHandle + QuestionId can find the only one question in the system. + // + // If this question has question id, base on the question id info to find the question. + // else base on the opcode buffer to find it. + // + if (gFormData->FormRefreshEvent != NULL) { + gHighligthMenuInfo.HiiHandle = gFormData->HiiHandle; gHighligthMenuInfo.QuestionId = GetQuestionIdInfo(Statement->OpCode); + + // + // if question id == 0, save the opcode buffer for later use. + // + if (gHighligthMenuInfo.QuestionId == 0) { + if (gHighligthMenuInfo.OpCode != NULL) { + FreePool (gHighligthMenuInfo.OpCode); + } + gHighligthMenuInfo.OpCode = AllocateCopyPool (Statement->OpCode->Length, Statement->OpCode); + ASSERT (gHighligthMenuInfo.OpCode != NULL); + } gHighligthMenuInfo.DisplayRow = (UINT16) MenuOption->Row; + gHighligthMenuInfo.SkipValue = (UINT16) SkipValue; } else { + gHighligthMenuInfo.HiiHandle = NULL; gHighligthMenuInfo.QuestionId = 0; + if (gHighligthMenuInfo.OpCode != NULL) { + FreePool (gHighligthMenuInfo.OpCode); + gHighligthMenuInfo.OpCode = NULL; + } gHighligthMenuInfo.DisplayRow = 0; + gHighligthMenuInfo.SkipValue = 0; } RefreshKeyHelp(gFormData, Statement, FALSE); @@ -1577,6 +1726,58 @@ DisplayMenuString ( PrintStringAtWithWidth (Col + Length, Row, L"", Width - Length); } +/** + Check whether this menu can has option string. + + @param MenuOption The menu opton which this attribut used to. + + @retval TRUE This menu option can have option string. + @retval FALSE This menu option can't have option string. + +**/ +BOOLEAN +HasOptionString ( + IN UI_MENU_OPTION *MenuOption + ) +{ + FORM_DISPLAY_ENGINE_STATEMENT *Statement; + CHAR16 *String; + UINTN Size; + EFI_IFR_TEXT *TestOp; + + Size = 0; + Statement = MenuOption->ThisTag; + + // + // See if the second text parameter is really NULL + // + if (Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) { + TestOp = (EFI_IFR_TEXT *) Statement->OpCode; + if (TestOp->TextTwo != 0) { + String = GetToken (TestOp->TextTwo, gFormData->HiiHandle); + Size = StrLen (String); + FreePool (String); + } + } + + if ((Statement->OpCode->OpCode == EFI_IFR_SUBTITLE_OP) || + (Statement->OpCode->OpCode == EFI_IFR_REF_OP) || + (Statement->OpCode->OpCode == EFI_IFR_PASSWORD_OP) || + (Statement->OpCode->OpCode == EFI_IFR_ACTION_OP) || + (Statement->OpCode->OpCode == EFI_IFR_RESET_BUTTON_OP) || + // + // Allow a wide display if text op-code and no secondary text op-code + // + ((Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) && (Size == 0)) + ) { + + return FALSE; + } + + return TRUE; +} + + /** Print string for this menu option. @@ -1586,6 +1787,7 @@ DisplayMenuString ( @param SkipLine The skip line for this menu. @param BottomRow The bottom row for this form. @param Highlight Whether this menu will be highlight. + @param UpdateCol Whether need to update the column info for Date/Time. @retval EFI_SUCESSS Process the user selection success. @@ -1597,7 +1799,8 @@ DisplayOneMenu ( IN UINTN BeginCol, IN UINTN SkipLine, IN UINTN BottomRow, - IN BOOLEAN Highlight + IN BOOLEAN Highlight, + IN BOOLEAN UpdateCol ) { FORM_DISPLAY_ENGINE_STATEMENT *Statement; @@ -1607,7 +1810,6 @@ DisplayOneMenu ( CHAR16 *StringPtr; CHAR16 *OptionString; CHAR16 *OutputString; - UINTN OriginalRow; UINT16 GlyphWidth; UINTN Temp; UINTN Temp2; @@ -1616,15 +1818,18 @@ DisplayOneMenu ( UINTN Row; UINTN Col; UINTN PromptLineNum; + UINTN OptionLineNum; CHAR16 AdjustValue; + UINTN MaxRow; Statement = MenuOption->ThisTag; - Col = MenuOption->Col; - Row = MenuOption->Row; Temp = SkipLine; Temp2 = SkipLine; Temp3 = SkipLine; - AdjustValue = 0; + AdjustValue = 0; + PromptLineNum = 0; + OptionLineNum = 0; + MaxRow = 0; // // Set default color. @@ -1644,12 +1849,13 @@ DisplayOneMenu ( // // Adjust option string for date/time opcode. // - ProcessStringForDateTime(MenuOption, OptionString, TRUE); + ProcessStringForDateTime(MenuOption, OptionString, UpdateCol); } Width = (UINT16) gOptionBlockWidth - 1; - OriginalRow = Row; + Row = MenuOption->Row; GlyphWidth = 1; + OptionLineNum = 0; for (Index = 0; GetLineByWidth (OptionString, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { if (((Temp2 == 0)) && (Row <= BottomRow)) { @@ -1668,12 +1874,14 @@ DisplayOneMenu ( } else { // // For date/ time, print the first and second past (year for date and second for time) - // - DisplayMenuString (MenuOption, MenuOption->OptCol, Row, OutputString, StrLen (OutputString), Highlight); + // The OutputString has a NARROW_CHAR or WIDE_CHAR at the begin of the string, + // so need to - 1 to remove it, otherwise, it will clean 1 extr char follow it. + DisplayMenuString (MenuOption, MenuOption->OptCol, Row, OutputString, StrLen (OutputString) - 1, Highlight); } } else { DisplayMenuString (MenuOption, MenuOption->OptCol, Row, OutputString, Width + 1, Highlight); } + OptionLineNum++; } // @@ -1689,7 +1897,7 @@ DisplayOneMenu ( // // If the difference in rows is greater than or equal to the skip value, increase the skip value // - if ((Row - OriginalRow) >= MenuOption->Skip) { + if ((Row - MenuOption->Row) >= MenuOption->Skip) { MenuOption->Skip++; } } @@ -1701,50 +1909,22 @@ DisplayOneMenu ( } } - Row = OriginalRow; Highlight = FALSE; FreePool (OptionString); } - Temp2 = 0; - - - // - // 2. Pre calculate the skip value. - // - if ((Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) && (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo != 0)) { - StringPtr = GetToken (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo, gFormData->HiiHandle); - - Width = (UINT16) gOptionBlockWidth - 1; - OriginalRow = Row; - GlyphWidth = 1; - for (Index = 0; GetLineByWidth (StringPtr, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { - if (StrLen (&StringPtr[Index]) != 0) { - Row++; - if ((Row - OriginalRow) >= MenuOption->Skip) { - MenuOption->Skip++; - } - } - FreePool (OutputString); - } - - Row = OriginalRow; - FreePool (StringPtr); - } - // - // 3. Paint the description. + // 2. Paint the description. // - PromptWidth = GetWidth (Statement, &AdjustValue); - OriginalRow = Row; + PromptWidth = GetWidth (MenuOption, &AdjustValue); + Row = MenuOption->Row; GlyphWidth = 1; PromptLineNum = 0; if (MenuOption->Description == NULL || MenuOption->Description[0] == '\0') { - while (Temp++ < MenuOption->Skip) { - PrintStringAtWithWidth (BeginCol, Row++, L"", PromptWidth + AdjustValue + SkipWidth); - } + PrintStringAtWithWidth (BeginCol, Row, L"", PromptWidth + AdjustValue + SkipWidth); + PromptLineNum++; } else { for (Index = 0; GetLineByWidth (MenuOption->Description, PromptWidth, &GlyphWidth, &Index, &OutputString) != 0x0000;) { if ((Temp == 0) && (Row <= BottomRow)) { @@ -1782,34 +1962,24 @@ DisplayOneMenu ( } Highlight = FALSE; - - // - // Clean the empty prompt line. - // These line is used by option string but not prompt, so clean them here. - // - Row = OriginalRow + PromptLineNum; - while (PromptLineNum + SkipLine < MenuOption->Skip && Row <= BottomRow) { - PrintStringAtWithWidth (BeginCol, Row, L"", PromptWidth + AdjustValue + SkipWidth); - PromptLineNum ++; - Row ++; - } } - Row = OriginalRow; // - // 4. If this is a text op with secondary text information + // 3. If this is a text op with secondary text information // if ((Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) && (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo != 0)) { StringPtr = GetToken (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo, gFormData->HiiHandle); Width = (UINT16) gOptionBlockWidth - 1; - OriginalRow = Row; + Row = MenuOption->Row; GlyphWidth = 1; + OptionLineNum = 0; for (Index = 0; GetLineByWidth (StringPtr, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { if ((Temp3 == 0) && (Row <= BottomRow)) { DisplayMenuString (MenuOption, MenuOption->OptCol, Row, OutputString, Width + 1, Highlight); + OptionLineNum++; } // // If there is more string to process print on the next row and increment the Skip value @@ -1817,6 +1987,12 @@ DisplayOneMenu ( if (StrLen (&StringPtr[Index]) != 0) { if (Temp3 == 0) { Row++; + // + // If the rows for text two is greater than or equal to the skip value, increase the skip value + // + if ((Row - MenuOption->Row) >= MenuOption->Skip) { + MenuOption->Skip++; + } } } @@ -1825,11 +2001,25 @@ DisplayOneMenu ( Temp3--; } } - - Row = OriginalRow; + FreePool (StringPtr); } + // + // 4.Line number for Option string and prompt string are not equal. + // Clean the column whose line number is less. + // + if (HasOptionString(MenuOption) && (OptionLineNum != PromptLineNum)) { + Col = OptionLineNum < PromptLineNum ? MenuOption->OptCol : BeginCol; + Row = (OptionLineNum < PromptLineNum ? OptionLineNum : PromptLineNum) + MenuOption->Row; + Width = (UINT16) (OptionLineNum < PromptLineNum ? gOptionBlockWidth : PromptWidth + AdjustValue + SkipWidth); + MaxRow = (OptionLineNum < PromptLineNum ? PromptLineNum : OptionLineNum) + MenuOption->Row - 1; + + while (Row <= MaxRow) { + DisplayMenuString (MenuOption, Col, Row++, L"", Width, FALSE); + } + } + return EFI_SUCCESS; } @@ -1849,7 +2039,7 @@ UiDisplayMenu ( IN FORM_DISPLAY_ENGINE_FORM *FormData ) { - INTN SkipValue; + UINTN SkipValue; INTN Difference; UINTN DistanceValue; UINTN Row; @@ -1858,7 +2048,6 @@ UiDisplayMenu ( UINTN Temp2; UINTN TopRow; UINTN BottomRow; - UINTN OriginalRow; UINTN Index; UINT16 Width; CHAR16 *StringPtr; @@ -1893,7 +2082,6 @@ UiDisplayMenu ( UINTN HelpHeaderLine; UINTN HelpBottomLine; BOOLEAN MultiHelpPage; - UINT16 GlyphWidth; UINT16 EachLineWidth; UINT16 HeaderLineWidth; UINT16 BottomLineWidth; @@ -1938,16 +2126,7 @@ UiDisplayMenu ( ZeroMem (&Key, sizeof (EFI_INPUT_KEY)); - // - // Left right - // |<-.->|<-.........->|<- .........->|<-...........->| - // Skip Prompt Option Help - // - Width = (CHAR16) ((gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn) / 3); - gOptionBlockWidth = Width + 1; - gHelpBlockWidth = (CHAR16) (Width - LEFT_SKIPPED_COLUMNS); - gPromptBlockWidth = (CHAR16) (gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn - 2 * Width - 1); - + Width = (UINT16)gOptionBlockWidth - 1; TopRow = gStatementDimensions.TopRow + SCROLL_ARROW_HEIGHT; BottomRow = gStatementDimensions.BottomRow - SCROLL_ARROW_HEIGHT - 1; @@ -2044,23 +2223,28 @@ UiDisplayMenu ( } if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) { - DisplayOneMenu (MenuOption, - LEFT_SKIPPED_COLUMNS, + Status = DisplayOneMenu (MenuOption, + MenuOption->Col - gStatementDimensions.LeftColumn, gStatementDimensions.LeftColumn + gModalSkipColumn, Link == TopOfScreen ? SkipValue : 0, BottomRow, - Link == NewPos && IsSelectable(MenuOption) + (BOOLEAN) ((Link == NewPos) && IsSelectable(MenuOption)), + TRUE ); } else { - DisplayOneMenu (MenuOption, - LEFT_SKIPPED_COLUMNS, + Status = DisplayOneMenu (MenuOption, + MenuOption->Col - gStatementDimensions.LeftColumn, gStatementDimensions.LeftColumn, Link == TopOfScreen ? SkipValue : 0, BottomRow, - Link == NewPos && IsSelectable(MenuOption) - ); + (BOOLEAN) ((Link == NewPos) && IsSelectable(MenuOption)), + TRUE + ); } + if (EFI_ERROR (Status)) { + return Status; + } // // 3. Update the row info which will be used by next menu. // @@ -2110,10 +2294,6 @@ UiDisplayMenu ( } MenuOption = NULL; - - if (IsListEmpty (&gMenuOption)) { - ControlFlag = CfReadKey; - } } break; @@ -2129,14 +2309,22 @@ UiDisplayMenu ( if (SkipHighLight) { MenuOption = SavedMenuOption; SkipHighLight = FALSE; - UpdateHighlightMenuInfo (MenuOption); + UpdateHighlightMenuInfo (MenuOption, TopOfScreen == &MenuOption->Link ? SkipValue : 0); break; } - if (MenuOption != NULL && TopOfScreen == &MenuOption->Link) { - Temp = SkipValue; - } else { - Temp = 0; + if (IsListEmpty (&gMenuOption)) { + // + // No menu option, just update the hotkey filed. + // + RefreshKeyHelp(gFormData, NULL, FALSE); + break; + } + + if (MenuOption != NULL && TopOfScreen == &MenuOption->Link) { + Temp = SkipValue; + } else { + Temp = 0; } if (NewPos == TopOfScreen) { Temp2 = SkipValue; @@ -2147,79 +2335,16 @@ UiDisplayMenu ( if (NewPos != NULL && (MenuOption == NULL || NewPos != &MenuOption->Link)) { if (MenuOption != NULL) { // - // Remove highlight on last Menu Option + // Remove the old highlight menu. // - gST->ConOut->SetCursorPosition (gST->ConOut, MenuOption->Col, MenuOption->Row); - ProcessOptions (MenuOption, FALSE, &OptionString, TRUE); - gST->ConOut->SetAttribute (gST->ConOut, GetFieldTextColor ()); - if (OptionString != NULL) { - if ((MenuOption->ThisTag->OpCode->OpCode == EFI_IFR_DATE_OP) || - (MenuOption->ThisTag->OpCode->OpCode == EFI_IFR_TIME_OP) - ) { - ProcessStringForDateTime(MenuOption, OptionString, FALSE); - } - - Width = (UINT16) gOptionBlockWidth; - OriginalRow = MenuOption->Row; - GlyphWidth = 1; - - for (Index = 0; GetLineByWidth (OptionString, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { - if ((Temp == 0) && (MenuOption->Row >= TopRow) && (MenuOption->Row <= BottomRow)) { - PrintStringAt (MenuOption->OptCol, MenuOption->Row, OutputString); - } - // - // If there is more string to process print on the next row and increment the Skip value - // - if (StrLen (&OptionString[Index]) != 0) { - if (Temp == 0) { - MenuOption->Row++; - } - } - - FreePool (OutputString); - if (Temp != 0) { - Temp--; - } - } - - MenuOption->Row = OriginalRow; - - FreePool (OptionString); - } else { - if (NewLine) { - if (MenuOption->GrayOut) { - gST->ConOut->SetAttribute (gST->ConOut, GetGrayedTextColor ()); - } else if (MenuOption->ThisTag->OpCode->OpCode == EFI_IFR_SUBTITLE_OP) { - gST->ConOut->SetAttribute (gST->ConOut, GetSubTitleTextColor ()); - } - - OriginalRow = MenuOption->Row; - Width = GetWidth (MenuOption->ThisTag, NULL); - GlyphWidth = 1; - - for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { - if ((Temp == 0) && (MenuOption->Row >= TopRow) && (MenuOption->Row <= BottomRow)) { - PrintStringAt (MenuOption->Col, MenuOption->Row, OutputString); - } - // - // If there is more string to process print on the next row and increment the Skip value - // - if (StrLen (&MenuOption->Description[Index]) != 0) { - if (Temp == 0) { - MenuOption->Row++; - } - } - - FreePool (OutputString); - if (Temp != 0) { - Temp--; - } - } - - MenuOption->Row = OriginalRow; - gST->ConOut->SetAttribute (gST->ConOut, GetFieldTextColor ()); - } - } + Status = DisplayOneMenu (MenuOption, + MenuOption->Col - gStatementDimensions.LeftColumn, + gStatementDimensions.LeftColumn, + Temp, + BottomRow, + FALSE, + FALSE + ); } // @@ -2228,85 +2353,20 @@ UiDisplayMenu ( MenuOption = MENU_OPTION_FROM_LINK (NewPos); Statement = MenuOption->ThisTag; - UpdateHighlightMenuInfo (MenuOption); + UpdateHighlightMenuInfo (MenuOption, Temp2); if (!IsSelectable (MenuOption)) { break; } - // - // Set reverse attribute - // - gST->ConOut->SetAttribute (gST->ConOut, GetHighlightTextColor ()); - gST->ConOut->SetCursorPosition (gST->ConOut, MenuOption->Col, MenuOption->Row); - - ProcessOptions (MenuOption, FALSE, &OptionString, TRUE); - if (OptionString != NULL) { - if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) { - ProcessStringForDateTime(MenuOption, OptionString, FALSE); - } - Width = (UINT16) gOptionBlockWidth; - - OriginalRow = MenuOption->Row; - GlyphWidth = 1; - - for (Index = 0; GetLineByWidth (OptionString, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { - if ((Temp2 == 0) && (MenuOption->Row >= TopRow) && (MenuOption->Row <= BottomRow) ) { - PrintStringAt (MenuOption->OptCol, MenuOption->Row, OutputString); - } - // - // If there is more string to process print on the next row and increment the Skip value - // - if (StrLen (&OptionString[Index]) != 0) { - if (Temp2 == 0) { - MenuOption->Row++; - } - } - - FreePool (OutputString); - if (Temp2 != 0) { - Temp2--; - } - } - - MenuOption->Row = OriginalRow; - - FreePool (OptionString); - } else { - if (NewLine) { - OriginalRow = MenuOption->Row; - - Width = GetWidth (Statement, NULL); - GlyphWidth = 1; - - for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { - if ((Temp2 == 0) && (MenuOption->Row >= TopRow) && (MenuOption->Row <= BottomRow) ) { - PrintStringAt (MenuOption->Col, MenuOption->Row, OutputString); - } - // - // If there is more string to process print on the next row and increment the Skip value - // - if (StrLen (&MenuOption->Description[Index]) != 0) { - if (Temp2 == 0) { - MenuOption->Row++; - } - } - - FreePool (OutputString); - if (Temp2 != 0) { - Temp2--; - } - } - - MenuOption->Row = OriginalRow; - - } - } - - // - // Clear reverse attribute - // - gST->ConOut->SetAttribute (gST->ConOut, GetFieldTextColor ()); + Status = DisplayOneMenu (MenuOption, + MenuOption->Col - gStatementDimensions.LeftColumn, + gStatementDimensions.LeftColumn, + Temp2, + BottomRow, + TRUE, + FALSE + ); } break; @@ -2316,16 +2376,27 @@ UiDisplayMenu ( break; } + // + // NewLine means only update highlight menu (remove old highlight and highlith + // the new one), not need to full repain the form. + // if (Repaint || NewLine) { - // - // Don't print anything if it is a NULL help token - // - ASSERT(MenuOption != NULL); - HelpInfo = ((EFI_IFR_STATEMENT_HEADER *) ((CHAR8 *)MenuOption->ThisTag->OpCode + sizeof (EFI_IFR_OP_HEADER)))->Help; - if (HelpInfo == 0 || !IsSelectable (MenuOption)) { + if (IsListEmpty (&gMenuOption)) { + // + // Don't print anything if no mwnu option. + // StringPtr = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle); } else { - StringPtr = GetToken (HelpInfo, gFormData->HiiHandle); + // + // Don't print anything if it is a NULL help token + // + ASSERT(MenuOption != NULL); + HelpInfo = ((EFI_IFR_STATEMENT_HEADER *) ((CHAR8 *)MenuOption->ThisTag->OpCode + sizeof (EFI_IFR_OP_HEADER)))->Help; + if (HelpInfo == 0 || !IsSelectable (MenuOption)) { + StringPtr = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle); + } else { + StringPtr = GetToken (HelpInfo, gFormData->HiiHandle); + } } RowCount = BottomRow - TopRow + 1; @@ -2549,12 +2620,12 @@ UiDisplayMenu ( // If the screen has no menu items, and the user didn't select UiReset // ignore the selection and go back to reading keys. // + ASSERT(MenuOption != NULL); if(IsListEmpty (&gMenuOption) || MenuOption->GrayOut || MenuOption->ReadOnly) { ControlFlag = CfReadKey; break; } - ASSERT(MenuOption != NULL); Statement = MenuOption->ThisTag; if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP) || (Statement->OpCode->OpCode == EFI_IFR_TIME_OP) @@ -2651,9 +2722,9 @@ UiDisplayMenu ( break; case CfScreenOperation: - if (ScreenOperation != UiReset) { + if ((ScreenOperation != UiReset) && (ScreenOperation != UiHotKey)) { // - // If the screen has no menu items, and the user didn't select UiReset + // If the screen has no menu items, and the user didn't select UiReset or UiHotKey // ignore the selection and go back to reading keys. // if (IsListEmpty (&gMenuOption)) { @@ -2737,7 +2808,8 @@ UiDisplayMenu ( case CfUiHotKey: ControlFlag = CfRepaint; - + + ASSERT (HotKey != NULL); gUserInput->Action = HotKey->Action; ControlFlag = CfExit; break; @@ -2772,184 +2844,108 @@ UiDisplayMenu ( case CfUiUp: ControlFlag = CfRepaint; + NewLine = TRUE; SavedListEntry = NewPos; - ASSERT(NewPos != NULL); + + MenuOption = MENU_OPTION_FROM_LINK (NewPos); + ASSERT (MenuOption != NULL); + // // Adjust Date/Time position before we advance forward. // AdjustDateAndTimePosition (TRUE, &NewPos); - if (NewPos->BackLink != &gMenuOption) { - MenuOption = MENU_OPTION_FROM_LINK (NewPos); - ASSERT (MenuOption != NULL); - NewLine = TRUE; - NewPos = NewPos->BackLink; - PreviousMenuOption = MENU_OPTION_FROM_LINK (NewPos); - if (PreviousMenuOption->Row == 0) { - UpdateOptionSkipLines (PreviousMenuOption); - } - DistanceValue = PreviousMenuOption->Skip; - Difference = 0; - if (MenuOption->Row >= DistanceValue + TopRow) { - Difference = MoveToNextStatement (TRUE, &NewPos, MenuOption->Row - TopRow - DistanceValue); - } - NextMenuOption = MENU_OPTION_FROM_LINK (NewPos); - - if (Difference < 0) { + NewPos = NewPos->BackLink; + // + // Find next selectable menu or the first menu beyond current form. + // + Difference = MoveToNextStatement (TRUE, &NewPos, MenuOption->Row - TopRow, FALSE); + if (Difference < 0) { + // + // We hit the begining MenuOption that can be focused + // so we simply scroll to the top. + // + Repaint = TRUE; + if (TopOfScreen != gMenuOption.ForwardLink || SkipValue != 0) { + TopOfScreen = gMenuOption.ForwardLink; + NewPos = SavedListEntry; + SkipValue = 0; + } else { // - // We hit the begining MenuOption that can be focused - // so we simply scroll to the top. + // Scroll up to the last page when we have arrived at top page. // - if (TopOfScreen != gMenuOption.ForwardLink) { - TopOfScreen = gMenuOption.ForwardLink; - Repaint = TRUE; - } else { - // - // Scroll up to the last page when we have arrived at top page. - // - NewPos = &gMenuOption; - TopOfScreen = &gMenuOption; - MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry); - ScreenOperation = UiPageUp; - ControlFlag = CfScreenOperation; - break; - } - } else if (MenuOption->Row < TopRow + DistanceValue + Difference) { + TopOfScreen = FindTopOfScreenMenu (gMenuOption.BackLink, BottomRow - TopRow, &SkipValue); + NewPos = gMenuOption.BackLink; + MoveToNextStatement (TRUE, &NewPos, BottomRow - TopRow, TRUE); + } + } else { + NextMenuOption = MENU_OPTION_FROM_LINK (NewPos); + + if (MenuOption->Row < TopRow + Difference + NextMenuOption->Skip) { // // Previous focus MenuOption is above the TopOfScreen, so we need to scroll // TopOfScreen = NewPos; Repaint = TRUE; - SkipValue = 0; - } else if (!IsSelectable (NextMenuOption)) { - // - // Continue to go up until scroll to next page or the selectable option is found. - // - ScreenOperation = UiUp; - ControlFlag = CfScreenOperation; + SkipValue = 0; } // - // If we encounter a Date/Time op-code set, rewind to the first op-code of the set. - // - AdjustDateAndTimePosition (TRUE, &TopOfScreen); - AdjustDateAndTimePosition (TRUE, &NewPos); - MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry); - UpdateStatusBar (INPUT_ERROR, FALSE); - } else { - // - // Scroll up to the last page. + // Check whether new highlight menu is selectable, if not, keep highlight on the old one. // - NewPos = &gMenuOption; - TopOfScreen = &gMenuOption; - MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry); - ScreenOperation = UiPageUp; - ControlFlag = CfScreenOperation; + // BottomRow - TopRow + 1 means the total rows current forms supported. + // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu + // and new top menu. New top menu will all shows in next form, but last highlight menu + // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the + // last highlight menu. + // + if (!IsSelectable(NextMenuOption) && IsSelectable(MenuOption) && + (BottomRow - TopRow + 1 >= Difference + NextMenuOption->Skip + 1)) { + NewPos = SavedListEntry; + } } - break; - case CfUiPageUp: - // - // SkipValue means lines is skipped when show the top menu option. - // - ControlFlag = CfRepaint; + UpdateStatusBar (INPUT_ERROR, FALSE); - ASSERT(NewPos != NULL); // - // Already at the first menu option, Check the skip value. + // If we encounter a Date/Time op-code set, rewind to the first op-code of the set. // - if (NewPos->BackLink == &gMenuOption) { - if (SkipValue == 0) { - NewLine = FALSE; - Repaint = FALSE; - } else { - NewLine = TRUE; - Repaint = TRUE; - SkipValue = 0; - } - break; - } - - NewLine = TRUE; - Repaint = TRUE; + AdjustDateAndTimePosition (TRUE, &TopOfScreen); + AdjustDateAndTimePosition (TRUE, &NewPos); + break; + case CfUiPageUp: // - // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one - // form of options to be show, so just update the SkipValue to show the next - // parts of options. + // SkipValue means lines is skipped when show the top menu option. // - if (SkipValue > (INTN) (BottomRow - TopRow + 1)) { - SkipValue -= BottomRow - TopRow + 1; - break; - } + ControlFlag = CfRepaint; + NewLine = TRUE; + Repaint = TRUE; Link = TopOfScreen; // // First minus the menu of the top screen, it's value is SkipValue. // - Index = (BottomRow + 1) - SkipValue; - while ((Index > TopRow) && (Link->BackLink != &gMenuOption)) { - Link = Link->BackLink; - PreviousMenuOption = MENU_OPTION_FROM_LINK (Link); - if (PreviousMenuOption->Row == 0) { - UpdateOptionSkipLines (PreviousMenuOption); - } - if (Index < PreviousMenuOption->Skip) { - break; - } - Index = Index - PreviousMenuOption->Skip; - } - - if ((Link->BackLink == &gMenuOption) && (Index >= TopRow)) { - SkipValue = 0; - if (TopOfScreen == &gMenuOption) { - TopOfScreen = gMenuOption.ForwardLink; - NewPos = gMenuOption.BackLink; - MoveToNextStatement (TRUE, &NewPos, BottomRow - TopRow); - Repaint = FALSE; - } else if (TopOfScreen != Link) { - TopOfScreen = Link; - NewPos = Link; - MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow); - } else { - // - // Finally we know that NewPos is the last MenuOption can be focused. - // - Repaint = FALSE; - NewPos = Link; - MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow); - } - } else { - if (Index > TopRow) { - // - // At here, only case "Index < PreviousMenuOption->Skip" can reach here. - // - SkipValue = PreviousMenuOption->Skip - (Index - TopRow); - } else if (Index == TopRow) { - SkipValue = 0; - } else { - SkipValue = TopRow - Index; - } - - // - // Move to the option in Next page. + if (SkipValue >= BottomRow - TopRow + 1) { // - if (TopOfScreen == &gMenuOption) { - NewPos = gMenuOption.BackLink; - MoveToNextStatement (TRUE, &NewPos, BottomRow - TopRow); - } else { - NewPos = Link; - MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow); - } - - // - // There are more MenuOption needing scrolling up. + // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one + // form of options to be show, so just update the SkipValue to show the next + // parts of options. // - TopOfScreen = Link; - MenuOption = NULL; + SkipValue -= BottomRow - TopRow + 1; + NewPos = TopOfScreen; + break; + } else { + Index = (BottomRow + 1) - SkipValue - TopRow; } + + TopOfScreen = FindTopOfScreenMenu(TopOfScreen, Index, &SkipValue); + NewPos = TopOfScreen; + MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow, FALSE); + + UpdateStatusBar (INPUT_ERROR, FALSE); // // If we encounter a Date/Time op-code set, rewind to the first op-code of the set. @@ -2963,17 +2959,10 @@ UiDisplayMenu ( // // SkipValue means lines is skipped when show the top menu option. // - ControlFlag = CfRepaint; - - ASSERT (NewPos != NULL); - if (NewPos->ForwardLink == &gMenuOption) { - NewLine = FALSE; - Repaint = FALSE; - break; - } + ControlFlag = CfRepaint; + NewLine = TRUE; + Repaint = TRUE; - NewLine = TRUE; - Repaint = TRUE; Link = TopOfScreen; NextMenuOption = MENU_OPTION_FROM_LINK (Link); Index = TopRow + NextMenuOption->Skip - SkipValue; @@ -2988,10 +2977,10 @@ UiDisplayMenu ( if ((Link->ForwardLink == &gMenuOption) && (Index <= BottomRow + 1)) { // - // Finally we know that NewPos is the last MenuOption can be focused. + // Highlight on the last menu which can be highlight. // Repaint = FALSE; - MoveToNextStatement (TRUE, &Link, Index - TopRow); + MoveToNextStatement (TRUE, &Link, Index - TopRow, TRUE); } else { // // Calculate the skip line for top of screen menu. @@ -3004,13 +2993,12 @@ UiDisplayMenu ( } else { SkipValue = NextMenuOption->Skip - (Index - (BottomRow + 1)); } - TopOfScreen = Link; MenuOption = NULL; // // Move to the Next selectable menu. // - MoveToNextStatement (FALSE, &Link, BottomRow - TopRow); + MoveToNextStatement (FALSE, &Link, BottomRow - TopRow, TRUE); } // @@ -3018,6 +3006,8 @@ UiDisplayMenu ( // NewPos = Link; + UpdateStatusBar (INPUT_ERROR, FALSE); + // // If we encounter a Date/Time op-code set, rewind to the first op-code of the set. // Don't do this when we are already in the last page. @@ -3032,7 +3022,15 @@ UiDisplayMenu ( // NewPos points to the menu which is highlighted now. // ControlFlag = CfRepaint; + NewLine = TRUE; + if (NewPos == TopOfScreen) { + Temp2 = SkipValue; + } else { + Temp2 = 0; + } + + SavedListEntry = NewPos; // // Since the behavior of hitting the down arrow on a Date/Time op-code is intended // to be one that progresses to the next set of op-codes, we need to advance to the last @@ -3041,176 +3039,134 @@ UiDisplayMenu ( // op-code is the last entry in the menu, we need to rewind back to the first op-code of // the Date/Time op-code. // - SavedListEntry = NewPos; AdjustDateAndTimePosition (FALSE, &NewPos); - if (NewPos->ForwardLink != &gMenuOption) { - MenuOption = MENU_OPTION_FROM_LINK (NewPos); - NewLine = TRUE; - NewPos = NewPos->ForwardLink; - - Difference = 0; + MenuOption = MENU_OPTION_FROM_LINK (NewPos); + NewPos = NewPos->ForwardLink; + // + // Find the next selectable menu. + // + if (MenuOption->Row + MenuOption->Skip - Temp2 > BottomRow + 1) { + if (gMenuOption.ForwardLink == NewPos || &gMenuOption == NewPos) { + Difference = -1; + } else { + Difference = 0; + } + } else { + Difference = MoveToNextStatement (FALSE, &NewPos, BottomRow + 1 - (MenuOption->Row + MenuOption->Skip - Temp2), FALSE); + } + if (Difference < 0) { // - // Current menu not at the bottom of the form. + // Scroll to the first page. // - if (BottomRow >= MenuOption->Row + MenuOption->Skip) { - // - // Find the next selectable menu. - // - Difference = MoveToNextStatement (FALSE, &NewPos, BottomRow - MenuOption->Row - MenuOption->Skip); - // - // We hit the end of MenuOption that can be focused - // so we simply scroll to the first page. - // - if (Difference < 0) { - // - // Scroll to the first page. - // - if (TopOfScreen != gMenuOption.ForwardLink) { - TopOfScreen = gMenuOption.ForwardLink; - Repaint = TRUE; - MenuOption = NULL; - } else { - MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry); - } - NewPos = gMenuOption.ForwardLink; - MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow); - - SkipValue = 0; - // - // If we are at the end of the list and sitting on a Date/Time op, rewind to the head. - // - AdjustDateAndTimePosition (TRUE, &TopOfScreen); - AdjustDateAndTimePosition (TRUE, &NewPos); - break; - } - } - NextMenuOption = MENU_OPTION_FROM_LINK (NewPos); - if (NextMenuOption->Row == 0) { - UpdateOptionSkipLines (NextMenuOption); - } - DistanceValue = Difference + NextMenuOption->Skip; - - Temp = MenuOption->Row + MenuOption->Skip + DistanceValue - 1; - if ((MenuOption->Row + MenuOption->Skip == BottomRow + 1) && - (NextMenuOption->ThisTag->OpCode->OpCode == EFI_IFR_DATE_OP || - NextMenuOption->ThisTag->OpCode->OpCode == EFI_IFR_TIME_OP) - ) { - Temp ++; + if (TopOfScreen != gMenuOption.ForwardLink || SkipValue != 0) { + TopOfScreen = gMenuOption.ForwardLink; + Repaint = TRUE; + MenuOption = NULL; + } else { + MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry); } + NewPos = gMenuOption.ForwardLink; + MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow, TRUE); + SkipValue = 0; // - // If we are going to scroll, update TopOfScreen + // If we are at the end of the list and sitting on a Date/Time op, rewind to the head. // - if (Temp > BottomRow) { - do { - // - // Is the current top of screen a zero-advance op-code? - // If so, keep moving forward till we hit a >0 advance op-code - // - SavedMenuOption = MENU_OPTION_FROM_LINK (TopOfScreen); + AdjustDateAndTimePosition (TRUE, &TopOfScreen); + AdjustDateAndTimePosition (TRUE, &NewPos); + break; + } - // - // If bottom op-code is more than one line or top op-code is more than one line - // - if ((DistanceValue > 1) || (SavedMenuOption->Skip > 1)) { - // - // Is the bottom op-code greater than or equal in size to the top op-code? - // - if ((Temp - BottomRow) >= (SavedMenuOption->Skip - SkipValue)) { - // - // Skip the top op-code - // - TopOfScreen = TopOfScreen->ForwardLink; - Difference = (Temp - BottomRow) - (SavedMenuOption->Skip - SkipValue); - - SavedMenuOption = MENU_OPTION_FROM_LINK (TopOfScreen); - - // - // If we have a remainder, skip that many more op-codes until we drain the remainder - // - while (Difference >= (INTN) SavedMenuOption->Skip) { - // - // Since the Difference is greater than or equal to this op-code's skip value, skip it - // - Difference = Difference - (INTN) SavedMenuOption->Skip; - TopOfScreen = TopOfScreen->ForwardLink; - SavedMenuOption = MENU_OPTION_FROM_LINK (TopOfScreen); - } - // - // Since we will act on this op-code in the next routine, and increment the - // SkipValue, set the skips to one less than what is required. - // - SkipValue = Difference - 1; - } else { - // - // Since we will act on this op-code in the next routine, and increment the - // SkipValue, set the skips to one less than what is required. - // - SkipValue += (Temp - BottomRow) - 1; - } - } else { - if ((SkipValue + 1) == (INTN) SavedMenuOption->Skip) { - TopOfScreen = TopOfScreen->ForwardLink; - break; - } - } - // - // If the op-code at the top of the screen is more than one line, let's not skip it yet - // Let's set a skip flag to smoothly scroll the top of the screen. - // - if (SavedMenuOption->Skip > 1) { - if (SavedMenuOption == NextMenuOption) { - SkipValue = 0; - } else { - SkipValue++; - } - } else if (SavedMenuOption->Skip == 1) { - SkipValue = 0; - } else { - SkipValue = 0; - TopOfScreen = TopOfScreen->ForwardLink; - } - } while (SavedMenuOption->Skip == 0); + // + // Get next selected menu info. + // + AdjustDateAndTimePosition (FALSE, &NewPos); + NextMenuOption = MENU_OPTION_FROM_LINK (NewPos); + if (NextMenuOption->Row == 0) { + UpdateOptionSkipLines (NextMenuOption); + } + + // + // Calculate new highlight menu end row. + // + Temp = (MenuOption->Row + MenuOption->Skip - Temp2) + Difference + NextMenuOption->Skip - 1; + if (Temp > BottomRow) { + // + // Get the top screen menu info. + // + AdjustDateAndTimePosition (FALSE, &TopOfScreen); + SavedMenuOption = MENU_OPTION_FROM_LINK (TopOfScreen); - Repaint = TRUE; - } else if (!IsSelectable (NextMenuOption)) { + // + // Current Top screen menu occupy (SavedMenuOption->Skip - SkipValue) rows. + // Full shows the new selected menu need to skip (Temp - BottomRow - 1) rows. + // + if ((Temp - BottomRow) >= (SavedMenuOption->Skip - SkipValue)) { // - // Continue to go down until scroll to next page or the selectable option is found. + // Skip the top op-code // - ScreenOperation = UiDown; - ControlFlag = CfScreenOperation; - } + TopOfScreen = TopOfScreen->ForwardLink; + DistanceValue = (Temp - BottomRow) - (SavedMenuOption->Skip - SkipValue); - MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry); + SavedMenuOption = MENU_OPTION_FROM_LINK (TopOfScreen); - UpdateStatusBar (INPUT_ERROR, FALSE); - - } else { - // - // Scroll to the first page. - // - if (TopOfScreen != gMenuOption.ForwardLink) { - TopOfScreen = gMenuOption.ForwardLink; - Repaint = TRUE; - MenuOption = NULL; + // + // If we have a remainder, skip that many more op-codes until we drain the remainder + // Special case is the selected highlight menu has more than one form of menus. + // + while (DistanceValue >= SavedMenuOption->Skip && TopOfScreen != NewPos) { + // + // Since the Difference is greater than or equal to this op-code's skip value, skip it + // + DistanceValue = DistanceValue - (INTN) SavedMenuOption->Skip; + TopOfScreen = TopOfScreen->ForwardLink; + SavedMenuOption = MENU_OPTION_FROM_LINK (TopOfScreen); + } + // + // Since we will act on this op-code in the next routine, and increment the + // SkipValue, set the skips to one less than what is required. + // + if (TopOfScreen != NewPos) { + SkipValue = DistanceValue; + } else { + SkipValue = 0; + } } else { // - // Need to remove the current highlight menu. - // MenuOption saved the last highlight menu info. + // Since we will act on this op-code in the next routine, and increment the + // SkipValue, set the skips to one less than what is required. // - MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry); + SkipValue += Temp - BottomRow; } - - SkipValue = 0; - NewLine = TRUE; + Repaint = TRUE; + } else if (!IsSelectable (NextMenuOption)) { // - // Get the next highlight menu. + // Continue to go down until scroll to next page or the selectable option is found. // - NewPos = gMenuOption.ForwardLink; - MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow); + ScreenOperation = UiDown; + ControlFlag = CfScreenOperation; + break; + } + + MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry); + + // + // Check whether new highlight menu is selectable, if not, keep highlight on the old one. + // + // BottomRow - TopRow + 1 means the total rows current forms supported. + // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu + // and new top menu. New top menu will all shows in next form, but last highlight menu + // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the + // last highlight menu. + // + if (!IsSelectable (NextMenuOption) && IsSelectable (MenuOption) && + (BottomRow - TopRow + 1 >= Difference + NextMenuOption->Skip + 1)) { + NewPos = SavedListEntry; } + UpdateStatusBar (INPUT_ERROR, FALSE); + // // If we are at the end of the list and sitting on a Date/Time op, rewind to the head. // @@ -3251,14 +3207,56 @@ BrowserStatusProcess ( VOID ) { - CHAR16 *ErrorInfo; - EFI_INPUT_KEY Key; + CHAR16 *ErrorInfo; + EFI_INPUT_KEY Key; + EFI_EVENT WaitList[2]; + EFI_EVENT RefreshIntervalEvent; + EFI_EVENT TimeOutEvent; + UINT8 TimeOut; + EFI_STATUS Status; + UINTN Index; + WARNING_IF_CONTEXT EventContext; + EFI_IFR_OP_HEADER *OpCodeBuf; + EFI_STRING_ID StringToken; + CHAR16 DiscardChange; + CHAR16 JumpToFormSet; + CHAR16 *PrintString; if (gFormData->BrowserStatus == BROWSER_SUCCESS) { return; } - if (gFormData->ErrorString != NULL) { + StringToken = 0; + TimeOutEvent = NULL; + RefreshIntervalEvent = NULL; + OpCodeBuf = NULL; + if (gFormData->HighLightedStatement != NULL) { + OpCodeBuf = gFormData->HighLightedStatement->OpCode; + } + + if (gFormData->BrowserStatus == (BROWSER_WARNING_IF)) { + ASSERT (OpCodeBuf != NULL && OpCodeBuf->OpCode == EFI_IFR_WARNING_IF_OP); + + TimeOut = ((EFI_IFR_WARNING_IF *) OpCodeBuf)->TimeOut; + StringToken = ((EFI_IFR_WARNING_IF *) OpCodeBuf)->Warning; + } else { + TimeOut = 0; + if ((gFormData->BrowserStatus == (BROWSER_NO_SUBMIT_IF)) && + (OpCodeBuf != NULL && OpCodeBuf->OpCode == EFI_IFR_NO_SUBMIT_IF_OP)) { + StringToken = ((EFI_IFR_NO_SUBMIT_IF *) OpCodeBuf)->Error; + } else if ((gFormData->BrowserStatus == (BROWSER_INCONSISTENT_IF)) && + (OpCodeBuf != NULL && OpCodeBuf->OpCode == EFI_IFR_INCONSISTENT_IF_OP)) { + StringToken = ((EFI_IFR_INCONSISTENT_IF *) OpCodeBuf)->Error; + } + } + + if (StringToken != 0) { + ErrorInfo = GetToken (StringToken, gFormData->HiiHandle); + } else if (gFormData->ErrorString != NULL) { + // + // Only used to compatible with old setup browser. + // Not use this field in new browser core. + // ErrorInfo = gFormData->ErrorString; } else { switch (gFormData->BrowserStatus) { @@ -3266,10 +3264,6 @@ BrowserStatusProcess ( ErrorInfo = gSaveFailed; break; - case BROWSER_NO_SUBMIT_IF: - ErrorInfo = gNoSubmitIf; - break; - case BROWSER_FORM_NOT_FOUND: ErrorInfo = gFormNotFound; break; @@ -3282,18 +3276,98 @@ BrowserStatusProcess ( ErrorInfo = gProtocolNotFound; break; + case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF: + ErrorInfo = gNoSubmitIfFailed; + break; + default: ErrorInfo = gBrwoserError; break; } } - // - // Error occur, prompt error message. - // - do { - CreateDialog (&Key, gEmptyString, ErrorInfo, gPressEnter, gEmptyString, NULL); - } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); + switch (gFormData->BrowserStatus) { + case BROWSER_SUBMIT_FAIL: + case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF: + ASSERT (gUserInput != NULL); + if (gFormData->BrowserStatus == (BROWSER_SUBMIT_FAIL)) { + PrintString = gSaveProcess; + JumpToFormSet = gJumpToFormSet[0]; + } else { + PrintString = gSaveNoSubmitProcess; + JumpToFormSet = gCheckError[0]; + } + DiscardChange = gDiscardChange[0]; + + do { + CreateDialog (&Key, gEmptyString, ErrorInfo, PrintString, gEmptyString, NULL); + } while (((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (DiscardChange | UPPER_LOWER_CASE_OFFSET)) && + ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (JumpToFormSet | UPPER_LOWER_CASE_OFFSET))); + + if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (DiscardChange | UPPER_LOWER_CASE_OFFSET)) { + gUserInput->Action = BROWSER_ACTION_DISCARD; + } else { + gUserInput->Action = BROWSER_ACTION_GOTO; + } + break; + + default: + if (TimeOut == 0) { + do { + CreateDialog (&Key, gEmptyString, ErrorInfo, gPressEnter, gEmptyString, NULL); + } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); + } else { + Status = gBS->CreateEvent (EVT_NOTIFY_WAIT, TPL_CALLBACK, EmptyEventProcess, NULL, &TimeOutEvent); + ASSERT_EFI_ERROR (Status); + + EventContext.SyncEvent = TimeOutEvent; + EventContext.TimeOut = &TimeOut; + EventContext.ErrorInfo = ErrorInfo; + + Status = gBS->CreateEvent (EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, RefreshTimeOutProcess, &EventContext, &RefreshIntervalEvent); + ASSERT_EFI_ERROR (Status); + + // + // Show the dialog first to avoid long time not reaction. + // + gBS->SignalEvent (RefreshIntervalEvent); + + Status = gBS->SetTimer (RefreshIntervalEvent, TimerPeriodic, ONE_SECOND); + ASSERT_EFI_ERROR (Status); + + while (TRUE) { + Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); + if (!EFI_ERROR (Status) && Key.UnicodeChar == CHAR_CARRIAGE_RETURN) { + break; + } + + if (Status != EFI_NOT_READY) { + continue; + } + + WaitList[0] = TimeOutEvent; + WaitList[1] = gST->ConIn->WaitForKey; + + Status = gBS->WaitForEvent (2, WaitList, &Index); + ASSERT_EFI_ERROR (Status); + + if (Index == 0) { + // + // Timeout occur, close the hoot time out event. + // + break; + } + } + + gBS->CloseEvent (TimeOutEvent); + gBS->CloseEvent (RefreshIntervalEvent); + } + break; + } + + if (StringToken != 0) { + FreePool (ErrorInfo); + } } /** @@ -3328,20 +3402,33 @@ FormDisplay ( // Process the status info first. // BrowserStatusProcess(); - if (UserInputData == NULL) { + if (gFormData->BrowserStatus != BROWSER_SUCCESS) { // - // UserInputData == NULL, means only need to print the error info, return here. + // gFormData->BrowserStatus != BROWSER_SUCCESS, means only need to print the error info, return here. // return EFI_SUCCESS; } - ConvertStatementToMenu(); - Status = DisplayPageFrame (FormData, &gStatementDimensions); if (EFI_ERROR (Status)) { return Status; } + // + // Global Widths should be initialized before any MenuOption creation + // or the GetWidth() used in UiAddMenuOption() will return incorrect value. + // + // + // Left right + // |<-.->|<-.........->|<- .........->|<-...........->| + // Skip Prompt Option Help + // + gOptionBlockWidth = (CHAR16) ((gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn) / 3) + 1; + gHelpBlockWidth = (CHAR16) (gOptionBlockWidth - 1 - LEFT_SKIPPED_COLUMNS); + gPromptBlockWidth = (CHAR16) (gStatementDimensions.RightColumn - gStatementDimensions.LeftColumn - 2 * (gOptionBlockWidth - 1) - 1); + + ConvertStatementToMenu(); + // // Check whether layout is changed. // @@ -3494,5 +3581,9 @@ UnloadDisplayEngine ( FreeDisplayStrings (); + if (gHighligthMenuInfo.OpCode != NULL) { + FreePool (gHighligthMenuInfo.OpCode); + } + return EFI_SUCCESS; }