2 Entry and initialization module for the browser.
4 Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "FormDisplay.h"
18 // Search table for UiDisplayMenu()
20 SCAN_CODE_TO_SCREEN_OPERATION gScanCodeToOperation
[] = {
51 UINTN mScanCodeNumber
= sizeof (gScanCodeToOperation
) / sizeof (gScanCodeToOperation
[0]);
53 SCREEN_OPERATION_T0_CONTROL_FLAG gScreenOperationToControlFlag
[] = {
96 EFI_GUID gDisplayEngineGuid
= {
97 0xE38C1029, 0xE38F, 0x45b9, {0x8F, 0x0D, 0xE2, 0xE6, 0x0B, 0xC9, 0xB2, 0x62}
100 FORM_ENTRY_INFO gFormEntryInfo
;
102 EFI_SCREEN_DESCRIPTOR gStatementDimensions
;
103 BOOLEAN mStatementLayoutIsChanged
= TRUE
;
104 USER_INPUT
*gUserInput
;
105 FORM_DISPLAY_ENGINE_FORM
*gFormData
;
106 EFI_HII_HANDLE gHiiHandle
;
108 LIST_ENTRY gMenuOption
;
109 DISPLAY_HIGHLIGHT_MENU_INFO gHighligthMenuInfo
= {0};
110 BOOLEAN mIsFirstForm
= TRUE
;
111 FORM_ENTRY_INFO gOldFormEntry
= {0};
114 // Browser Global Strings
116 CHAR16
*gFormNotFound
;
118 CHAR16
*gBrwoserError
;
120 CHAR16
*gPromptForData
;
121 CHAR16
*gPromptForPassword
;
122 CHAR16
*gPromptForNewPassword
;
123 CHAR16
*gConfirmPassword
;
124 CHAR16
*gConfirmError
;
125 CHAR16
*gPassowordInvalid
;
127 CHAR16
*gEmptyString
;
129 CHAR16
*gOptionMismatch
;
130 CHAR16
*gFormSuppress
;
131 CHAR16
*gProtocolNotFound
;
133 CHAR16 gModalSkipColumn
;
134 CHAR16 gPromptBlockWidth
;
135 CHAR16 gOptionBlockWidth
;
136 CHAR16 gHelpBlockWidth
;
137 CHAR16
*mUnknownString
;
139 FORM_DISPLAY_DRIVER_PRIVATE_DATA mPrivateData
= {
140 FORM_DISPLAY_DRIVER_SIGNATURE
,
144 DriverClearDisplayPage
,
151 Get the string based on the StringId and HII Package List Handle.
153 @param Token The String's ID.
154 @param HiiHandle The package list in the HII database to search for
155 the specified string.
157 @return The output string.
162 IN EFI_STRING_ID Token
,
163 IN EFI_HII_HANDLE HiiHandle
168 String
= HiiGetString (HiiHandle
, Token
, NULL
);
169 if (String
== NULL
) {
170 String
= AllocateCopyPool (StrSize (mUnknownString
), mUnknownString
);
171 ASSERT (String
!= NULL
);
174 return (CHAR16
*) String
;
179 Initialize the HII String Token to the correct values.
183 InitializeDisplayStrings (
187 mUnknownString
= GetToken (STRING_TOKEN (UNKNOWN_STRING
), gHiiHandle
);
188 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
189 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
190 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
191 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
192 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
193 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
194 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
195 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
196 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
197 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
198 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
199 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
200 gProtocolNotFound
= GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND
), gHiiHandle
);
201 gFormNotFound
= GetToken (STRING_TOKEN (STATUS_BROWSER_FORM_NOT_FOUND
), gHiiHandle
);
202 gNoSubmitIf
= GetToken (STRING_TOKEN (STATUS_BROWSER_NO_SUBMIT_IF
), gHiiHandle
);
203 gBrwoserError
= GetToken (STRING_TOKEN (STATUS_BROWSER_ERROR
), gHiiHandle
);
207 Free up the resource allocated for all strings required
216 FreePool (mUnknownString
);
217 FreePool (gEmptyString
);
218 FreePool (gSaveFailed
);
219 FreePool (gPromptForData
);
220 FreePool (gPromptForPassword
);
221 FreePool (gPromptForNewPassword
);
222 FreePool (gConfirmPassword
);
223 FreePool (gConfirmError
);
224 FreePool (gPassowordInvalid
);
225 FreePool (gPressEnter
);
226 FreePool (gMiniString
);
227 FreePool (gOptionMismatch
);
228 FreePool (gFormSuppress
);
229 FreePool (gProtocolNotFound
);
230 FreePool (gBrwoserError
);
231 FreePool (gNoSubmitIf
);
232 FreePool (gFormNotFound
);
236 Get prompt string id from the opcode data buffer.
238 @param OpCode The input opcode buffer.
240 @return The prompt string id.
245 IN EFI_IFR_OP_HEADER
*OpCode
248 EFI_IFR_STATEMENT_HEADER
*Header
;
250 if (OpCode
->Length
<= sizeof (EFI_IFR_OP_HEADER
)) {
254 Header
= (EFI_IFR_STATEMENT_HEADER
*) (OpCode
+ 1);
256 return Header
->Prompt
;
260 Get the supported width for a particular op-code
262 @param MenuOption The menu option.
263 @param AdjustWidth The width which is saved for the space.
265 @return Returns the number of CHAR16 characters that is support.
270 IN UI_MENU_OPTION
*MenuOption
,
271 OUT UINT16
*AdjustWidth
276 EFI_IFR_TEXT
*TestOp
;
278 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
280 Statement
= MenuOption
->ThisTag
;
283 // For modal form, clean the entire row.
285 if ((gFormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
286 if (AdjustWidth
!= NULL
) {
287 *AdjustWidth
= LEFT_SKIPPED_COLUMNS
;
289 return (UINT16
)(gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gModalSkipColumn
+ LEFT_SKIPPED_COLUMNS
));
295 // See if the second text parameter is really NULL
297 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
298 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
299 if (TestOp
->TextTwo
!= 0) {
300 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
301 Size
= StrLen (String
);
306 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
307 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
308 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
309 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
310 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
312 // Allow a wide display if text op-code and no secondary text op-code
314 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
318 // Return the space width.
320 if (AdjustWidth
!= NULL
) {
324 // Keep consistent with current behavior.
326 ReturnWidth
= (UINT16
) (gPromptBlockWidth
+ gOptionBlockWidth
- 2);
328 if (AdjustWidth
!= NULL
) {
332 ReturnWidth
= (UINT16
) (gPromptBlockWidth
- 1);
336 // For nest in statement, should the subtitle indent.
338 if (MenuOption
->NestInStatement
) {
339 ReturnWidth
-= SUBTITLE_INDENT
;
346 Will copy LineWidth amount of a string in the OutputString buffer and return the
347 number of CHAR16 characters that were copied into the OutputString buffer.
348 The output string format is:
349 Glyph Info + String info + '\0'.
351 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
353 @param InputString String description for this option.
354 @param LineWidth Width of the desired string to extract in CHAR16
356 @param GlyphWidth The glyph width of the begin of the char in the string.
357 @param Index Where in InputString to start the copy process
358 @param OutputString Buffer to copy the string into
360 @return Returns the number of CHAR16 characters that were copied into the OutputString
361 buffer, include extra glyph info and '\0' info.
366 IN CHAR16
*InputString
,
368 IN OUT UINT16
*GlyphWidth
,
370 OUT CHAR16
**OutputString
375 UINT16 OriginalGlyphWidth
;
377 UINT16 LastSpaceOffset
;
378 UINT16 LastGlyphWidth
;
380 if (InputString
== NULL
|| Index
== NULL
|| OutputString
== NULL
) {
384 if (LineWidth
== 0 || *GlyphWidth
== 0) {
389 // Save original glyph width.
391 OriginalGlyphWidth
= *GlyphWidth
;
392 LastGlyphWidth
= OriginalGlyphWidth
;
397 // NARROW_CHAR can not be printed in screen, so if a line only contain the two CHARs: 'NARROW_CHAR + CHAR_CARRIAGE_RETURN' , it is a empty line in Screen.
398 // To avoid displaying this empty line in screen, just skip the two CHARs here.
400 if ((InputString
[*Index
] == NARROW_CHAR
) && (InputString
[*Index
+ 1] == CHAR_CARRIAGE_RETURN
)) {
405 // Fast-forward the string and see if there is a carriage-return in the string
407 for (StrOffset
= 0, GlyphOffset
= 0; GlyphOffset
<= LineWidth
; StrOffset
++) {
408 switch (InputString
[*Index
+ StrOffset
]) {
417 case CHAR_CARRIAGE_RETURN
:
424 GlyphOffset
= GlyphOffset
+ *GlyphWidth
;
427 // Record the last space info in this line. Will be used in rewind.
429 if ((InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) && (GlyphOffset
<= LineWidth
)) {
430 LastSpaceOffset
= StrOffset
;
431 LastGlyphWidth
= *GlyphWidth
;
442 // Rewind the string from the maximum size until we see a space to break the line
444 if (GlyphOffset
> LineWidth
) {
446 // Rewind the string to last space char in this line.
448 if (LastSpaceOffset
!= 0) {
449 StrOffset
= LastSpaceOffset
;
450 *GlyphWidth
= LastGlyphWidth
;
453 // Roll back to last char in the line width.
460 // The CHAR_NULL has process last time, this time just return 0 to stand for the end.
462 if (StrOffset
== 0 && (InputString
[*Index
+ StrOffset
] == CHAR_NULL
)) {
467 // Need extra glyph info and '\0' info, so +2.
469 *OutputString
= AllocateZeroPool (((UINTN
) (StrOffset
+ 2) * sizeof(CHAR16
)));
470 if (*OutputString
== NULL
) {
475 // Save the glyph info at the begin of the string, will used by Print function.
477 if (OriginalGlyphWidth
== 1) {
478 *(*OutputString
) = NARROW_CHAR
;
480 *(*OutputString
) = WIDE_CHAR
;
483 CopyMem ((*OutputString
) + 1, &InputString
[*Index
], StrOffset
* sizeof(CHAR16
));
485 if (InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) {
487 // Skip the space info at the begin of next line.
489 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
490 } else if (InputString
[*Index
+ StrOffset
] == CHAR_LINEFEED
) {
492 // Skip the /n or /n/r info.
494 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_CARRIAGE_RETURN
) {
495 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
497 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
499 } else if (InputString
[*Index
+ StrOffset
] == CHAR_CARRIAGE_RETURN
) {
501 // Skip the /r or /r/n info.
503 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_LINEFEED
) {
504 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
506 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
509 *Index
= (UINT16
) (*Index
+ StrOffset
);
513 // Include extra glyph info and '\0' info, so +2.
515 return StrOffset
+ 2;
519 Add one menu option by specified description and context.
521 @param Statement Statement of this Menu Option.
522 @param MenuItemCount The index for this Option in the Menu.
523 @param NestIn Whether this statement is nest in another statement.
528 IN FORM_DISPLAY_ENGINE_STATEMENT
*Statement
,
529 IN UINT16
*MenuItemCount
,
533 UI_MENU_OPTION
*MenuOption
;
537 UINT16 NumberOfLines
;
541 CHAR16
*OutputString
;
542 EFI_STRING_ID PromptId
;
550 PromptId
= GetPrompt (Statement
->OpCode
);
551 ASSERT (PromptId
!= 0);
553 String
= GetToken (PromptId
, gFormData
->HiiHandle
);
554 ASSERT (String
!= NULL
);
556 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
560 for (Index
= 0; Index
< Count
; Index
++) {
561 MenuOption
= AllocateZeroPool (sizeof (UI_MENU_OPTION
));
564 MenuOption
->Signature
= UI_MENU_OPTION_SIGNATURE
;
565 MenuOption
->Description
= String
;
566 MenuOption
->Handle
= gFormData
->HiiHandle
;
567 MenuOption
->ThisTag
= Statement
;
568 MenuOption
->NestInStatement
= NestIn
;
569 MenuOption
->EntryNumber
= *MenuItemCount
;
571 MenuOption
->Sequence
= Index
;
573 if ((Statement
->Attribute
& HII_DISPLAY_GRAYOUT
) != 0) {
574 MenuOption
->GrayOut
= TRUE
;
576 MenuOption
->GrayOut
= FALSE
;
579 if ((Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
580 MenuOption
->GrayOut
= TRUE
;
584 // If the form or the question has the lock attribute, deal same as grayout.
586 if ((gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
587 MenuOption
->GrayOut
= TRUE
;
590 switch (Statement
->OpCode
->OpCode
) {
591 case EFI_IFR_ORDERED_LIST_OP
:
592 case EFI_IFR_ONE_OF_OP
:
593 case EFI_IFR_NUMERIC_OP
:
594 case EFI_IFR_TIME_OP
:
595 case EFI_IFR_DATE_OP
:
596 case EFI_IFR_CHECKBOX_OP
:
597 case EFI_IFR_PASSWORD_OP
:
598 case EFI_IFR_STRING_OP
:
600 // User could change the value of these items
602 MenuOption
->IsQuestion
= TRUE
;
604 case EFI_IFR_TEXT_OP
:
605 if (FeaturePcdGet (PcdBrowserGrayOutTextStatement
)) {
607 // Initializing GrayOut option as TRUE for Text setup options
608 // so that those options will be Gray in colour and un selectable.
610 MenuOption
->GrayOut
= TRUE
;
614 MenuOption
->IsQuestion
= FALSE
;
618 if ((Statement
->Attribute
& HII_DISPLAY_READONLY
) != 0) {
619 MenuOption
->ReadOnly
= TRUE
;
620 if (FeaturePcdGet (PcdBrowerGrayOutReadOnlyMenu
)) {
621 MenuOption
->GrayOut
= TRUE
;
626 (Statement
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
627 (Statement
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
628 Width
= GetWidth (MenuOption
, NULL
);
629 for (; GetLineByWidth (String
, Width
, &GlyphWidth
,&ArrayEntry
, &OutputString
) != 0x0000;) {
631 // If there is more string to process print on the next row and increment the Skip value
633 if (StrLen (&String
[ArrayEntry
]) != 0) {
636 FreePool (OutputString
);
640 // Add three MenuOptions for Date/Time
641 // Data format : [01/02/2004] [11:22:33]
642 // Line number : 0 0 1 0 0 1
649 // Override LineNumber for the MenuOption in Date/Time sequence
651 MenuOption
->Skip
= 1;
653 MenuOption
->Skip
= NumberOfLines
;
656 InsertTailList (&gMenuOption
, &MenuOption
->Link
);
663 Create the menu list base on the form data info.
667 ConvertStatementToMenu (
671 UINT16 MenuItemCount
;
673 LIST_ENTRY
*NestLink
;
674 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
675 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
678 InitializeListHead (&gMenuOption
);
680 Link
= GetFirstNode (&gFormData
->StatementListHead
);
681 while (!IsNull (&gFormData
->StatementListHead
, Link
)) {
682 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
683 Link
= GetNextNode (&gFormData
->StatementListHead
, Link
);
686 // Skip the opcode not recognized by Display core.
688 if (Statement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
692 UiAddMenuOption (Statement
, &MenuItemCount
, FALSE
);
695 // Check the statement nest in this host statement.
697 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
698 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
699 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
700 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
702 UiAddMenuOption (NestStatement
, &MenuItemCount
, TRUE
);
708 Count the storage space of a Unicode string.
710 This function handles the Unicode string with NARROW_CHAR
711 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
712 does not count in the resultant output. If a WIDE_CHAR is
713 hit, then 2 Unicode character will consume an output storage
714 space with size of CHAR16 till a NARROW_CHAR is hit.
716 If String is NULL, then ASSERT ().
718 @param String The input string to be counted.
720 @return Storage space for the input string.
730 UINTN IncrementValue
;
732 ASSERT (String
!= NULL
);
733 if (String
== NULL
) {
743 // Advance to the null-terminator or to the first width directive
746 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
747 Index
++, Count
= Count
+ IncrementValue
752 // We hit the null-terminator, we now have a count
754 if (String
[Index
] == 0) {
758 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
759 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
761 if (String
[Index
] == NARROW_CHAR
) {
763 // Skip to the next character
769 // Skip to the next character
774 } while (String
[Index
] != 0);
777 // Increment by one to include the null-terminator in the size
781 return Count
* sizeof (CHAR16
);
785 Base on the input option string to update the skip value for a menu option.
787 @param MenuOption The MenuOption to be checked.
788 @param OptionString The input option string.
792 UpdateSkipInfoForMenu (
793 IN UI_MENU_OPTION
*MenuOption
,
794 IN CHAR16
*OptionString
800 CHAR16
*OutputString
;
803 Width
= (UINT16
) gOptionBlockWidth
;
807 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
808 if (StrLen (&OptionString
[Index
]) != 0) {
812 FreePool (OutputString
);
815 if ((Row
> MenuOption
->Skip
) &&
816 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
817 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
818 MenuOption
->Skip
= Row
;
823 Update display lines for a Menu Option.
825 @param MenuOption The MenuOption to be checked.
829 UpdateOptionSkipLines (
830 IN UI_MENU_OPTION
*MenuOption
833 CHAR16
*OptionString
;
837 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
838 if (OptionString
!= NULL
) {
839 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
841 FreePool (OptionString
);
844 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
845 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
847 if (OptionString
!= NULL
) {
848 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
850 FreePool (OptionString
);
856 Check whether this Menu Option could be highlighted.
858 This is an internal function.
860 @param MenuOption The MenuOption to be checked.
862 @retval TRUE This Menu Option is selectable.
863 @retval FALSE This Menu Option could not be selected.
868 UI_MENU_OPTION
*MenuOption
871 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
872 MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
880 Move to next selectable statement.
882 This is an internal function.
884 @param GoUp The navigation direction. TRUE: up, FALSE: down.
885 @param CurrentPosition Current position.
886 @param GapToTop Gap position to top or bottom.
888 @return The row distance from current MenuOption to next selectable MenuOption.
890 @retval -1 Reach the begin of the menu, still can't find the selectable menu.
891 @retval Value Find the selectable menu, maybe the truly selectable, maybe the l
892 last menu showing at current form.
896 MoveToNextStatement (
898 IN OUT LIST_ENTRY
**CurrentPosition
,
904 UI_MENU_OPTION
*NextMenuOption
;
905 UI_MENU_OPTION
*PreMenuOption
;
908 Pos
= *CurrentPosition
;
909 PreMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
912 NextMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
914 // NextMenuOption->Row == 0 means this menu has not calculate
915 // the NextMenuOption->Skip value yet, just calculate here.
917 if (NextMenuOption
->Row
== 0) {
918 UpdateOptionSkipLines (NextMenuOption
);
921 if (GoUp
&& (PreMenuOption
!= NextMenuOption
)) {
923 // In this case, still can't find the selectable menu,
924 // return the last one in the showing form.
926 if ((UINTN
) Distance
+ NextMenuOption
->Skip
> GapToTop
) {
927 NextMenuOption
= PreMenuOption
;
932 // Current Position doesn't need to be caculated when go up.
933 // Caculate distanct at first when go up
935 Distance
+= NextMenuOption
->Skip
;
938 if (IsSelectable (NextMenuOption
)) {
943 // Arrive at begin of the menu list.
945 if ((GoUp
? Pos
->BackLink
: Pos
->ForwardLink
) == &gMenuOption
) {
952 // In this case, still can't find the selectable menu,
953 // return the last one in the showing form.
955 if ((UINTN
) Distance
+ NextMenuOption
->Skip
> GapToTop
) {
956 NextMenuOption
= PreMenuOption
;
960 Distance
+= NextMenuOption
->Skip
;
963 PreMenuOption
= NextMenuOption
;
964 Pos
= (GoUp
? Pos
->BackLink
: Pos
->ForwardLink
);
967 *CurrentPosition
= &NextMenuOption
->Link
;
973 Process option string for date/time opcode.
975 @param MenuOption Menu option point to date/time.
976 @param OptionString Option string input for process.
977 @param AddOptCol Whether need to update MenuOption->OptCol.
981 ProcessStringForDateTime (
982 UI_MENU_OPTION
*MenuOption
,
983 CHAR16
*OptionString
,
989 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
993 ASSERT (MenuOption
!= NULL
&& OptionString
!= NULL
);
995 Statement
= MenuOption
->ThisTag
;
998 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
999 Date
= (EFI_IFR_DATE
*) Statement
->OpCode
;
1000 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1001 Time
= (EFI_IFR_TIME
*) Statement
->OpCode
;
1005 // If leading spaces on OptionString - remove the spaces
1007 for (Index
= 0; OptionString
[Index
] == L
' '; Index
++) {
1009 // Base on the blockspace to get the option column info.
1012 MenuOption
->OptCol
++;
1016 for (Count
= 0; OptionString
[Index
] != CHAR_NULL
; Index
++) {
1017 OptionString
[Count
] = OptionString
[Index
];
1020 OptionString
[Count
] = CHAR_NULL
;
1023 // Enable to suppress field in the opcode base on the flag.
1025 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1027 // OptionString format is: <**: **: ****>
1031 if ((Date
->Flags
& EFI_QF_DATE_MONTH_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1033 // At this point, only "<**:" in the optionstring.
1034 // Clean the day's ** field, after clean, the format is "< :"
1036 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1037 } else if ((Date
->Flags
& EFI_QF_DATE_DAY_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1039 // At this point, only "**:" in the optionstring.
1040 // Clean the month's "**" field, after clean, the format is " :"
1042 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1043 } else if ((Date
->Flags
& EFI_QF_DATE_YEAR_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1045 // At this point, only "****>" in the optionstring.
1046 // Clean the year's "****" field, after clean, the format is " >"
1048 SetUnicodeMem (&OptionString
[0], 4, L
' ');
1050 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1052 // OptionString format is: <**: **: **>
1053 // |hour|minute|second|
1056 if ((Time
->Flags
& QF_TIME_HOUR_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1058 // At this point, only "<**:" in the optionstring.
1059 // Clean the hour's ** field, after clean, the format is "< :"
1061 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1062 } else if ((Time
->Flags
& QF_TIME_MINUTE_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1064 // At this point, only "**:" in the optionstring.
1065 // Clean the minute's "**" field, after clean, the format is " :"
1067 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1068 } else if ((Time
->Flags
& QF_TIME_SECOND_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1070 // At this point, only "**>" in the optionstring.
1071 // Clean the second's "**" field, after clean, the format is " >"
1073 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1080 Adjust Data and Time position accordingly.
1081 Data format : [01/02/2004] [11:22:33]
1082 Line number : 0 0 1 0 0 1
1084 This is an internal function.
1086 @param DirectionUp the up or down direction. False is down. True is
1088 @param CurrentPosition Current position. On return: Point to the last
1089 Option (Year or Second) if up; Point to the first
1090 Option (Month or Hour) if down.
1092 @return Return line number to pad. It is possible that we stand on a zero-advance
1093 @return data or time opcode, so pad one line when we judge if we are going to scroll outside.
1097 AdjustDateAndTimePosition (
1098 IN BOOLEAN DirectionUp
,
1099 IN OUT LIST_ENTRY
**CurrentPosition
1103 LIST_ENTRY
*NewPosition
;
1104 UI_MENU_OPTION
*MenuOption
;
1105 UINTN PadLineNumber
;
1108 NewPosition
= *CurrentPosition
;
1109 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1111 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) ||
1112 (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
1114 // Calculate the distance from current position to the last Date/Time MenuOption
1117 while (MenuOption
->Skip
== 0) {
1119 NewPosition
= NewPosition
->ForwardLink
;
1120 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1124 NewPosition
= *CurrentPosition
;
1127 // Since the behavior of hitting the up arrow on a Date/Time MenuOption is intended
1128 // to be one that back to the previous set of MenuOptions, we need to advance to the first
1129 // Date/Time MenuOption and leave the remaining logic in CfUiUp intact so the appropriate
1130 // checking can be done.
1132 while (Count
++ < 2) {
1133 NewPosition
= NewPosition
->BackLink
;
1137 // Since the behavior of hitting the down arrow on a Date/Time MenuOption is intended
1138 // to be one that progresses to the next set of MenuOptions, we need to advance to the last
1139 // Date/Time MenuOption and leave the remaining logic in CfUiDown intact so the appropriate
1140 // checking can be done.
1142 while (Count
-- > 0) {
1143 NewPosition
= NewPosition
->ForwardLink
;
1147 *CurrentPosition
= NewPosition
;
1150 return PadLineNumber
;
1154 Get step info from numeric opcode.
1156 @param[in] OpCode The input numeric op code.
1158 @return step info for this opcode.
1162 IN EFI_IFR_OP_HEADER
*OpCode
1165 EFI_IFR_NUMERIC
*NumericOp
;
1168 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
1170 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1171 case EFI_IFR_NUMERIC_SIZE_1
:
1172 Step
= NumericOp
->data
.u8
.Step
;
1175 case EFI_IFR_NUMERIC_SIZE_2
:
1176 Step
= NumericOp
->data
.u16
.Step
;
1179 case EFI_IFR_NUMERIC_SIZE_4
:
1180 Step
= NumericOp
->data
.u32
.Step
;
1183 case EFI_IFR_NUMERIC_SIZE_8
:
1184 Step
= NumericOp
->data
.u64
.Step
;
1196 Find the registered HotKey based on KeyData.
1198 @param[in] KeyData A pointer to a buffer that describes the keystroke
1199 information for the hot key.
1201 @return The registered HotKey context. If no found, NULL will return.
1204 GetHotKeyFromRegisterList (
1205 IN EFI_INPUT_KEY
*KeyData
1209 BROWSER_HOT_KEY
*HotKey
;
1211 Link
= GetFirstNode (&gFormData
->HotKeyListHead
);
1212 while (!IsNull (&gFormData
->HotKeyListHead
, Link
)) {
1213 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
1215 if (HotKey
->KeyData
->ScanCode
== KeyData
->ScanCode
) {
1219 Link
= GetNextNode (&gFormData
->HotKeyListHead
, Link
);
1227 Determine if the menu is the last menu that can be selected.
1229 This is an internal function.
1231 @param Direction The scroll direction. False is down. True is up.
1232 @param CurrentPos The current focus.
1234 @return FALSE -- the menu isn't the last menu that can be selected.
1235 @return TRUE -- the menu is the last menu that can be selected.
1240 IN BOOLEAN Direction
,
1241 IN LIST_ENTRY
*CurrentPos
1246 Temp
= Direction
? CurrentPos
->BackLink
: CurrentPos
->ForwardLink
;
1248 if (Temp
== &gMenuOption
) {
1256 Wait for a given event to fire, or for an optional timeout to expire.
1258 @param Event The event to wait for
1260 @retval UI_EVENT_TYPE The type of the event which is trigged.
1272 EFI_EVENT TimerEvent
;
1273 EFI_EVENT WaitList
[3];
1274 UI_EVENT_TYPE EventType
;
1277 Timeout
= FormExitTimeout(gFormData
);
1280 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
1283 // Set the timer event
1292 WaitList
[0] = Event
;
1294 if (gFormData
->FormRefreshEvent
!= NULL
) {
1295 WaitList
[EventNum
] = gFormData
->FormRefreshEvent
;
1300 WaitList
[EventNum
] = TimerEvent
;
1304 Status
= gBS
->WaitForEvent (EventNum
, WaitList
, &Index
);
1305 ASSERT_EFI_ERROR (Status
);
1309 EventType
= UIEventKey
;
1313 if (gFormData
->FormRefreshEvent
!= NULL
) {
1314 EventType
= UIEventDriver
;
1316 ASSERT (Timeout
!= 0 && EventNum
== 2);
1317 EventType
= UIEventTimeOut
;
1322 ASSERT (Index
== 2 && EventNum
== 3);
1323 EventType
= UIEventTimeOut
;
1328 gBS
->CloseEvent (TimerEvent
);
1335 Get question id info from the input opcode header.
1337 @param OpCode The input opcode header pointer.
1339 @retval The question id for this opcode.
1344 IN EFI_IFR_OP_HEADER
*OpCode
1347 EFI_IFR_QUESTION_HEADER
*QuestionHeader
;
1349 if (OpCode
->Length
< sizeof (EFI_IFR_OP_HEADER
) + sizeof (EFI_IFR_QUESTION_HEADER
)) {
1353 QuestionHeader
= (EFI_IFR_QUESTION_HEADER
*)((UINT8
*) OpCode
+ sizeof(EFI_IFR_OP_HEADER
));
1355 return QuestionHeader
->QuestionId
;
1359 Find the first menu which will be show at the top.
1361 @param FormData The data info for this form.
1362 @param TopOfScreen The link_entry pointer to top menu.
1363 @param HighlightMenu The menu which will be highlight.
1364 @param SkipValue The skip value for the top menu.
1369 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
1370 OUT LIST_ENTRY
**TopOfScreen
,
1371 OUT LIST_ENTRY
**HighlightMenu
,
1380 UI_MENU_OPTION
*SavedMenuOption
;
1383 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
1384 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
;
1387 // If not has input highlight statement, just return the first one in this form.
1389 if (FormData
->HighLightedStatement
== NULL
) {
1390 *TopOfScreen
= gMenuOption
.ForwardLink
;
1391 *HighlightMenu
= gMenuOption
.ForwardLink
;
1392 if (!IsListEmpty (&gMenuOption
)) {
1393 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
);
1400 // Now base on the input highlight menu to find the top menu in this page.
1401 // Will base on the highlight menu show at the bottom to find the top menu.
1403 NewPos
= gMenuOption
.ForwardLink
;
1404 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1406 while ((SavedMenuOption
->ThisTag
!= FormData
->HighLightedStatement
) ||
1407 (SavedMenuOption
->Sequence
!= gSequence
)) {
1408 NewPos
= NewPos
->ForwardLink
;
1409 if (NewPos
== &gMenuOption
) {
1411 // Not Found it, break
1415 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1417 ASSERT (SavedMenuOption
->ThisTag
== FormData
->HighLightedStatement
);
1419 *HighlightMenu
= NewPos
;
1421 AdjustDateAndTimePosition(FALSE
, &NewPos
);
1422 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1423 UpdateOptionSkipLines (SavedMenuOption
);
1426 // If highlight opcode is date/time, keep the highlight row info not change.
1428 if ((SavedMenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| SavedMenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) &&
1429 (gHighligthMenuInfo
.QuestionId
!= 0) &&
1430 (gHighligthMenuInfo
.QuestionId
== GetQuestionIdInfo(SavedMenuOption
->ThisTag
->OpCode
))) {
1432 // Still show the highlight menu before exit from display engine.
1434 EndRow
= gHighligthMenuInfo
.DisplayRow
+ SavedMenuOption
->Skip
;
1440 // Base on the selected menu will show at the bottome of next page,
1441 // select the menu show at the top of the next page.
1444 for (Index
= TopRow
+ SavedMenuOption
->Skip
; Index
<= EndRow
; ) {
1445 Link
= Link
->BackLink
;
1447 // Already find the first menu in this form, means highlight menu
1448 // will show in first page of this form.
1450 if (Link
== &gMenuOption
) {
1451 *TopOfScreen
= gMenuOption
.ForwardLink
;
1455 SavedMenuOption
= MENU_OPTION_FROM_LINK (Link
);
1456 UpdateOptionSkipLines (SavedMenuOption
);
1457 Index
+= SavedMenuOption
->Skip
;
1461 // Found the menu which will show at the top of the page.
1463 if (Link
== NewPos
) {
1465 // The menu can show more than one pages, just show the menu at the top of the page.
1468 *TopOfScreen
= Link
;
1471 // Check whether need to skip some line for menu shows at the top of the page.
1473 *SkipValue
= Index
- EndRow
;
1474 if (*SkipValue
> 0 && *SkipValue
< (INTN
) SavedMenuOption
->Skip
) {
1475 *TopOfScreen
= Link
;
1478 *TopOfScreen
= Link
->ForwardLink
;
1484 Update highlight menu info.
1486 @param MenuOption The menu opton which is highlight.
1490 UpdateHighlightMenuInfo (
1491 IN UI_MENU_OPTION
*MenuOption
1494 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1497 // This is the current selected statement
1499 Statement
= MenuOption
->ThisTag
;
1502 // Get the highlight statement.
1504 gUserInput
->SelectedStatement
= Statement
;
1505 gSequence
= (UINT16
) MenuOption
->Sequence
;
1508 // Record highlight row info for date/time opcode.
1510 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1511 gHighligthMenuInfo
.QuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1512 gHighligthMenuInfo
.DisplayRow
= (UINT16
) MenuOption
->Row
;
1514 gHighligthMenuInfo
.QuestionId
= 0;
1515 gHighligthMenuInfo
.DisplayRow
= 0;
1518 RefreshKeyHelp(gFormData
, Statement
, FALSE
);
1522 Update attribut for this menu.
1524 @param MenuOption The menu opton which this attribut used to.
1525 @param Highlight Whether this menu will be highlight.
1529 SetDisplayAttribute (
1530 IN UI_MENU_OPTION
*MenuOption
,
1531 IN BOOLEAN Highlight
1534 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1536 Statement
= MenuOption
->ThisTag
;
1539 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
1543 if (MenuOption
->GrayOut
) {
1544 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetGrayedTextColor ());
1546 if (Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) {
1547 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetSubTitleTextColor ());
1549 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
1555 Print string for this menu option.
1557 @param MenuOption The menu opton which this attribut used to.
1558 @param Col The column that this string will be print at.
1559 @param Row The row that this string will be print at.
1560 @param String The string which need to print.
1561 @param Width The width need to print, if string is less than the
1562 width, the block space will be used.
1563 @param Highlight Whether this menu will be highlight.
1568 IN UI_MENU_OPTION
*MenuOption
,
1573 IN BOOLEAN Highlight
1579 // Print string with normal color.
1582 PrintStringAtWithWidth (Col
, Row
, String
, Width
);
1587 // Print the highlight menu string.
1588 // First print the highlight string.
1590 SetDisplayAttribute(MenuOption
, TRUE
);
1591 Length
= PrintStringAt (Col
, Row
, String
);
1594 // Second, clean the empty after the string.
1596 SetDisplayAttribute(MenuOption
, FALSE
);
1597 PrintStringAtWithWidth (Col
+ Length
, Row
, L
"", Width
- Length
);
1601 Check whether this menu can has option string.
1603 @param MenuOption The menu opton which this attribut used to.
1605 @retval TRUE This menu option can have option string.
1606 @retval FALSE This menu option can't have option string.
1611 IN UI_MENU_OPTION
*MenuOption
1614 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1617 EFI_IFR_TEXT
*TestOp
;
1620 Statement
= MenuOption
->ThisTag
;
1623 // See if the second text parameter is really NULL
1625 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
1626 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
1627 if (TestOp
->TextTwo
!= 0) {
1628 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
1629 Size
= StrLen (String
);
1634 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
1635 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
1636 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
1637 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
1638 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
1640 // Allow a wide display if text op-code and no secondary text op-code
1642 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
1653 Print string for this menu option.
1655 @param MenuOption The menu opton which this attribut used to.
1656 @param SkipWidth The skip width between the left to the start of the prompt.
1657 @param BeginCol The begin column for one menu.
1658 @param SkipLine The skip line for this menu.
1659 @param BottomRow The bottom row for this form.
1660 @param Highlight Whether this menu will be highlight.
1662 @retval EFI_SUCESSS Process the user selection success.
1667 IN UI_MENU_OPTION
*MenuOption
,
1672 IN BOOLEAN Highlight
1675 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1680 CHAR16
*OptionString
;
1681 CHAR16
*OutputString
;
1689 UINTN PromptLineNum
;
1690 UINTN OptionLineNum
;
1694 Statement
= MenuOption
->ThisTag
;
1704 // Set default color.
1706 SetDisplayAttribute (MenuOption
, FALSE
);
1709 // 1. Paint the option string.
1711 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
1712 if (EFI_ERROR (Status
)) {
1716 if (OptionString
!= NULL
) {
1717 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1719 // Adjust option string for date/time opcode.
1721 ProcessStringForDateTime(MenuOption
, OptionString
, TRUE
);
1724 Width
= (UINT16
) gOptionBlockWidth
- 1;
1725 Row
= MenuOption
->Row
;
1729 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1730 if (((Temp2
== 0)) && (Row
<= BottomRow
)) {
1731 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1733 // For date/time question, it has three menu options for this qustion.
1734 // The first/second menu options with the skip value is 0. the last one
1735 // with skip value is 1.
1737 if (MenuOption
->Skip
!= 0) {
1739 // For date/ time, print the last past (year for date and second for time)
1740 // - 7 means skip [##/##/ for date and [##:##: for time.
1742 DisplayMenuString (MenuOption
,MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1 - 7, Highlight
);
1745 // For date/ time, print the first and second past (year for date and second for time)
1747 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, StrLen (OutputString
), Highlight
);
1750 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
1756 // If there is more string to process print on the next row and increment the Skip value
1758 if (StrLen (&OptionString
[Index
]) != 0) {
1762 // Since the Number of lines for this menu entry may or may not be reflected accurately
1763 // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
1764 // some testing to ensure we are keeping this in-sync.
1766 // If the difference in rows is greater than or equal to the skip value, increase the skip value
1768 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
1774 FreePool (OutputString
);
1782 FreePool (OptionString
);
1786 // 2. Paint the description.
1788 PromptWidth
= GetWidth (MenuOption
, &AdjustValue
);
1789 Row
= MenuOption
->Row
;
1793 if (MenuOption
->Description
== NULL
|| MenuOption
->Description
[0] == '\0') {
1794 PrintStringAtWithWidth (BeginCol
, Row
, L
"", PromptWidth
+ AdjustValue
+ SkipWidth
);
1797 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, PromptWidth
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1798 if ((Temp
== 0) && (Row
<= BottomRow
)) {
1800 // 1.Clean the start LEFT_SKIPPED_COLUMNS
1802 PrintStringAtWithWidth (BeginCol
, Row
, L
"", SkipWidth
);
1804 if (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
&& MenuOption
->Col
>= 2) {
1806 // Print Arrow for Goto button.
1809 MenuOption
->Col
- 2,
1811 GEOMETRICSHAPE_RIGHT_TRIANGLE
1814 DisplayMenuString (MenuOption
, MenuOption
->Col
, Row
, OutputString
, PromptWidth
+ AdjustValue
, Highlight
);
1818 // If there is more string to process print on the next row and increment the Skip value
1820 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
1826 FreePool (OutputString
);
1837 // 3. If this is a text op with secondary text information
1839 if ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
!= 0)) {
1840 StringPtr
= GetToken (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
1842 Width
= (UINT16
) gOptionBlockWidth
- 1;
1843 Row
= MenuOption
->Row
;
1847 for (Index
= 0; GetLineByWidth (StringPtr
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1848 if ((Temp3
== 0) && (Row
<= BottomRow
)) {
1849 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
1853 // If there is more string to process print on the next row and increment the Skip value
1855 if (StrLen (&StringPtr
[Index
]) != 0) {
1859 // If the rows for text two is greater than or equal to the skip value, increase the skip value
1861 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
1867 FreePool (OutputString
);
1873 FreePool (StringPtr
);
1877 // 4.Line number for Option string and prompt string are not equal.
1878 // Clean the column whose line number is less.
1880 if (HasOptionString(MenuOption
) && (OptionLineNum
!= PromptLineNum
)) {
1881 Col
= OptionLineNum
< PromptLineNum
? MenuOption
->OptCol
: BeginCol
;
1882 Row
= (OptionLineNum
< PromptLineNum
? OptionLineNum
: PromptLineNum
) + MenuOption
->Row
;
1883 Width
= (UINT16
) (OptionLineNum
< PromptLineNum
? gOptionBlockWidth
: PromptWidth
+ AdjustValue
+ SkipWidth
);
1884 MaxRow
= (OptionLineNum
< PromptLineNum
? PromptLineNum
: OptionLineNum
) + MenuOption
->Row
- 1;
1886 while (Row
<= MaxRow
) {
1887 DisplayMenuString (MenuOption
, Col
, Row
++, L
"", Width
, FALSE
);
1895 Display menu and wait for user to select one menu option, then return it.
1896 If AutoBoot is enabled, then if user doesn't select any option,
1897 after period of time, it will automatically return the first menu option.
1899 @param FormData The current form data info.
1901 @retval EFI_SUCESSS Process the user selection success.
1902 @retval EFI_NOT_FOUND Process option string for orderedlist/Oneof fail.
1907 IN FORM_DISPLAY_ENGINE_FORM
*FormData
1912 UINTN DistanceValue
;
1923 CHAR16
*OptionString
;
1924 CHAR16
*OutputString
;
1926 CHAR16
*HelpHeaderString
;
1927 CHAR16
*HelpBottomString
;
1936 LIST_ENTRY
*TopOfScreen
;
1937 LIST_ENTRY
*SavedListEntry
;
1938 UI_MENU_OPTION
*MenuOption
;
1939 UI_MENU_OPTION
*NextMenuOption
;
1940 UI_MENU_OPTION
*SavedMenuOption
;
1941 UI_MENU_OPTION
*PreviousMenuOption
;
1942 UI_CONTROL_FLAG ControlFlag
;
1943 UI_SCREEN_OPERATION ScreenOperation
;
1945 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1946 BROWSER_HOT_KEY
*HotKey
;
1947 UINTN HelpPageIndex
;
1948 UINTN HelpPageCount
;
1951 UINTN HelpHeaderLine
;
1952 UINTN HelpBottomLine
;
1953 BOOLEAN MultiHelpPage
;
1955 UINT16 EachLineWidth
;
1956 UINT16 HeaderLineWidth
;
1957 UINT16 BottomLineWidth
;
1958 EFI_STRING_ID HelpInfo
;
1959 UI_EVENT_TYPE EventType
;
1960 FORM_DISPLAY_ENGINE_STATEMENT
*InitialHighlight
;
1961 BOOLEAN SkipHighLight
;
1963 EventType
= UIEventNone
;
1964 Status
= EFI_SUCCESS
;
1966 HelpHeaderString
= NULL
;
1967 HelpBottomString
= NULL
;
1968 OptionString
= NULL
;
1969 ScreenOperation
= UiNoOperation
;
1978 MultiHelpPage
= FALSE
;
1980 HeaderLineWidth
= 0;
1981 BottomLineWidth
= 0;
1982 OutputString
= NULL
;
1986 SkipHighLight
= FALSE
;
1988 NextMenuOption
= NULL
;
1989 PreviousMenuOption
= NULL
;
1990 SavedMenuOption
= NULL
;
1994 gModalSkipColumn
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 6;
1995 InitialHighlight
= gFormData
->HighLightedStatement
;
1997 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
2001 // |<-.->|<-.........->|<- .........->|<-...........->|
2002 // Skip Prompt Option Help
2004 Width
= (CHAR16
) ((gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 3);
2005 gOptionBlockWidth
= Width
+ 1;
2006 gHelpBlockWidth
= (CHAR16
) (Width
- LEFT_SKIPPED_COLUMNS
);
2007 gPromptBlockWidth
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * Width
- 1);
2009 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
2010 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
- 1;
2013 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2014 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gModalSkipColumn
;
2016 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
;
2019 FindTopMenu(FormData
, &TopOfScreen
, &NewPos
, &SkipValue
);
2021 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
2023 ControlFlag
= CfInitialization
;
2025 switch (ControlFlag
) {
2026 case CfInitialization
:
2027 if ((gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
) ||
2028 (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))) {
2030 // Clear Statement range if different formset is painted.
2033 gStatementDimensions
.LeftColumn
,
2034 gStatementDimensions
.RightColumn
,
2035 TopRow
- SCROLL_ARROW_HEIGHT
,
2036 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2037 GetFieldTextColor ()
2041 ControlFlag
= CfRepaint
;
2045 ControlFlag
= CfRefreshHighLight
;
2055 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2058 // 1. Check whether need to print the arrow up.
2060 if (!ValueIsScroll (TRUE
, TopOfScreen
)) {
2064 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2065 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2067 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2070 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2072 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2073 TopRow
- SCROLL_ARROW_HEIGHT
,
2076 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2080 // 2.Paint the menu.
2082 for (Link
= TopOfScreen
; Link
!= &gMenuOption
; Link
= Link
->ForwardLink
) {
2083 MenuOption
= MENU_OPTION_FROM_LINK (Link
);
2084 MenuOption
->Row
= Row
;
2085 MenuOption
->Col
= Col
;
2086 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2087 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
+ gModalSkipColumn
;
2089 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
;
2092 if (MenuOption
->NestInStatement
) {
2093 MenuOption
->Col
+= SUBTITLE_INDENT
;
2097 // Save the highlight menu, will be used in CfRefreshHighLight case.
2099 if (Link
== NewPos
) {
2100 SavedMenuOption
= MenuOption
;
2101 SkipHighLight
= TRUE
;
2104 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2105 Status
= DisplayOneMenu (MenuOption
,
2106 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2107 gStatementDimensions
.LeftColumn
+ gModalSkipColumn
,
2108 Link
== TopOfScreen
? SkipValue
: 0,
2110 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
))
2113 Status
= DisplayOneMenu (MenuOption
,
2114 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2115 gStatementDimensions
.LeftColumn
,
2116 Link
== TopOfScreen
? SkipValue
: 0,
2118 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
))
2122 if (EFI_ERROR (Status
)) {
2126 // 3. Update the row info which will be used by next menu.
2128 if (Link
== TopOfScreen
) {
2129 Row
+= MenuOption
->Skip
- SkipValue
;
2131 Row
+= MenuOption
->Skip
;
2134 if (Row
> BottomRow
) {
2135 if (!ValueIsScroll (FALSE
, Link
)) {
2139 Row
= BottomRow
+ 1;
2145 // 3. Menus in this form may not cover all form, clean the remain field.
2147 while (Row
<= BottomRow
) {
2148 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2149 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2151 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gHelpBlockWidth
- gStatementDimensions
.LeftColumn
);
2156 // 4. Print the down arrow row.
2158 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2159 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * + gModalSkipColumn
);
2161 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2164 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2166 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2167 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2170 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2177 case CfRefreshHighLight
:
2180 // MenuOption: Last menu option that need to remove hilight
2181 // MenuOption is set to NULL in Repaint
2182 // NewPos: Current menu option that need to hilight
2184 ControlFlag
= CfUpdateHelpString
;
2186 if (SkipHighLight
) {
2187 MenuOption
= SavedMenuOption
;
2188 SkipHighLight
= FALSE
;
2189 UpdateHighlightMenuInfo (MenuOption
);
2193 if (IsListEmpty (&gMenuOption
)) {
2195 // No menu option, just update the hotkey filed.
2197 RefreshKeyHelp(gFormData
, NULL
, FALSE
);
2201 if (MenuOption
!= NULL
&& TopOfScreen
== &MenuOption
->Link
) {
2206 if (NewPos
== TopOfScreen
) {
2212 if (NewPos
!= NULL
&& (MenuOption
== NULL
|| NewPos
!= &MenuOption
->Link
)) {
2213 if (MenuOption
!= NULL
) {
2215 // Remove highlight on last Menu Option
2217 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, MenuOption
->Col
, MenuOption
->Row
);
2218 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
2219 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2220 if (OptionString
!= NULL
) {
2221 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) ||
2222 (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
2224 ProcessStringForDateTime(MenuOption
, OptionString
, FALSE
);
2227 Width
= (UINT16
) gOptionBlockWidth
- 1;
2228 OriginalRow
= MenuOption
->Row
;
2231 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2232 if ((Temp
== 0) && (MenuOption
->Row
>= TopRow
) && (MenuOption
->Row
<= BottomRow
)) {
2233 PrintStringAt (MenuOption
->OptCol
, MenuOption
->Row
, OutputString
);
2236 // If there is more string to process print on the next row and increment the Skip value
2238 if (StrLen (&OptionString
[Index
]) != 0) {
2244 FreePool (OutputString
);
2250 MenuOption
->Row
= OriginalRow
;
2252 FreePool (OptionString
);
2255 if (MenuOption
->GrayOut
) {
2256 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetGrayedTextColor ());
2257 } else if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) {
2258 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetSubTitleTextColor ());
2261 OriginalRow
= MenuOption
->Row
;
2262 Width
= GetWidth (MenuOption
, NULL
);
2265 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2266 if ((Temp
== 0) && (MenuOption
->Row
>= TopRow
) && (MenuOption
->Row
<= BottomRow
)) {
2267 PrintStringAt (MenuOption
->Col
, MenuOption
->Row
, OutputString
);
2270 // If there is more string to process print on the next row and increment the Skip value
2272 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
2278 FreePool (OutputString
);
2284 MenuOption
->Row
= OriginalRow
;
2285 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2291 // This is the current selected statement
2293 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2294 Statement
= MenuOption
->ThisTag
;
2296 UpdateHighlightMenuInfo (MenuOption
);
2298 if (!IsSelectable (MenuOption
)) {
2303 // Set reverse attribute
2305 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
2306 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, MenuOption
->Col
, MenuOption
->Row
);
2308 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
2309 if (OptionString
!= NULL
) {
2310 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
2311 ProcessStringForDateTime(MenuOption
, OptionString
, FALSE
);
2313 Width
= (UINT16
) gOptionBlockWidth
- 1;
2315 OriginalRow
= MenuOption
->Row
;
2318 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2319 if ((Temp2
== 0) && (MenuOption
->Row
>= TopRow
) && (MenuOption
->Row
<= BottomRow
) ) {
2320 PrintStringAt (MenuOption
->OptCol
, MenuOption
->Row
, OutputString
);
2323 // If there is more string to process print on the next row and increment the Skip value
2325 if (StrLen (&OptionString
[Index
]) != 0) {
2331 FreePool (OutputString
);
2337 MenuOption
->Row
= OriginalRow
;
2339 FreePool (OptionString
);
2342 OriginalRow
= MenuOption
->Row
;
2344 Width
= GetWidth (MenuOption
, NULL
);
2347 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2348 if ((Temp2
== 0) && (MenuOption
->Row
>= TopRow
) && (MenuOption
->Row
<= BottomRow
) ) {
2349 PrintStringAt (MenuOption
->Col
, MenuOption
->Row
, OutputString
);
2352 // If there is more string to process print on the next row and increment the Skip value
2354 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
2360 FreePool (OutputString
);
2366 MenuOption
->Row
= OriginalRow
;
2372 // Clear reverse attribute
2374 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2378 case CfUpdateHelpString
:
2379 ControlFlag
= CfPrepareToReadKey
;
2380 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2384 if (Repaint
|| NewLine
) {
2385 if (IsListEmpty (&gMenuOption
)) {
2387 // Don't print anything if no mwnu option.
2389 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2392 // Don't print anything if it is a NULL help token
2394 ASSERT(MenuOption
!= NULL
);
2395 HelpInfo
= ((EFI_IFR_STATEMENT_HEADER
*) ((CHAR8
*)MenuOption
->ThisTag
->OpCode
+ sizeof (EFI_IFR_OP_HEADER
)))->Help
;
2396 if (HelpInfo
== 0 || !IsSelectable (MenuOption
)) {
2397 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2399 StringPtr
= GetToken (HelpInfo
, gFormData
->HiiHandle
);
2403 RowCount
= BottomRow
- TopRow
+ 1;
2406 // 1.Calculate how many line the help string need to print.
2408 if (HelpString
!= NULL
) {
2409 FreePool (HelpString
);
2412 HelpLine
= ProcessHelpString (StringPtr
, &HelpString
, &EachLineWidth
, RowCount
);
2413 FreePool (StringPtr
);
2415 if (HelpLine
> RowCount
) {
2416 MultiHelpPage
= TRUE
;
2417 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_UP
), gHiiHandle
);
2418 if (HelpHeaderString
!= NULL
) {
2419 FreePool (HelpHeaderString
);
2420 HelpHeaderString
= NULL
;
2422 HelpHeaderLine
= ProcessHelpString (StringPtr
, &HelpHeaderString
, &HeaderLineWidth
, 0);
2423 FreePool (StringPtr
);
2424 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_DOWN
), gHiiHandle
);
2425 if (HelpBottomString
!= NULL
) {
2426 FreePool (HelpBottomString
);
2427 HelpBottomString
= NULL
;
2429 HelpBottomLine
= ProcessHelpString (StringPtr
, &HelpBottomString
, &BottomLineWidth
, 0);
2430 FreePool (StringPtr
);
2432 // Calculate the help page count.
2434 if (HelpLine
> 2 * RowCount
- 2) {
2435 HelpPageCount
= (HelpLine
- RowCount
+ 1) / (RowCount
- 2) + 1;
2436 if ((HelpLine
- RowCount
+ 1) % (RowCount
- 2) > 1) {
2443 MultiHelpPage
= FALSE
;
2448 // Check whether need to show the 'More(U/u)' at the begin.
2449 // Base on current direct info, here shows aligned to the right side of the column.
2450 // If the direction is multi line and aligned to right side may have problem, so
2451 // add ASSERT code here.
2453 if (HelpPageIndex
> 0) {
2454 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2455 for (Index
= 0; Index
< HelpHeaderLine
; Index
++) {
2456 ASSERT (HelpHeaderLine
== 1);
2457 ASSERT (GetStringWidth (HelpHeaderString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2458 PrintStringAtWithWidth (
2459 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2465 gStatementDimensions
.RightColumn
- GetStringWidth (HelpHeaderString
) / 2 - 1,
2467 &HelpHeaderString
[Index
* HeaderLineWidth
]
2472 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHelpTextColor ());
2474 // Print the help string info.
2476 if (!MultiHelpPage
) {
2477 for (Index
= 0; Index
< HelpLine
; Index
++) {
2478 PrintStringAtWithWidth (
2479 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2481 &HelpString
[Index
* EachLineWidth
],
2485 for (; Index
< RowCount
; Index
++) {
2486 PrintStringAtWithWidth (
2487 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2493 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2495 if (HelpPageIndex
== 0) {
2496 for (Index
= 0; Index
< RowCount
- HelpBottomLine
; Index
++) {
2497 PrintStringAtWithWidth (
2498 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2500 &HelpString
[Index
* EachLineWidth
],
2505 for (Index
= 0; (Index
< RowCount
- HelpBottomLine
- HelpHeaderLine
) &&
2506 (Index
+ HelpPageIndex
* (RowCount
- 2) + 1 < HelpLine
); Index
++) {
2507 PrintStringAtWithWidth (
2508 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2509 Index
+ TopRow
+ HelpHeaderLine
,
2510 &HelpString
[(Index
+ HelpPageIndex
* (RowCount
- 2) + 1)* EachLineWidth
],
2514 if (HelpPageIndex
== HelpPageCount
- 1) {
2515 for (; Index
< RowCount
- HelpHeaderLine
; Index
++) {
2516 PrintStringAtWithWidth (
2517 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2518 Index
+ TopRow
+ HelpHeaderLine
,
2523 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2529 // Check whether need to print the 'More(D/d)' at the bottom.
2530 // Base on current direct info, here shows aligned to the right side of the column.
2531 // If the direction is multi line and aligned to right side may have problem, so
2532 // add ASSERT code here.
2534 if (HelpPageIndex
< HelpPageCount
- 1 && MultiHelpPage
) {
2535 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2536 for (Index
= 0; Index
< HelpBottomLine
; Index
++) {
2537 ASSERT (HelpBottomLine
== 1);
2538 ASSERT (GetStringWidth (HelpBottomString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2539 PrintStringAtWithWidth (
2540 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2541 BottomRow
+ Index
- HelpBottomLine
+ 1,
2546 gStatementDimensions
.RightColumn
- GetStringWidth (HelpBottomString
) / 2 - 1,
2547 BottomRow
+ Index
- HelpBottomLine
+ 1,
2548 &HelpBottomString
[Index
* BottomLineWidth
]
2553 // Reset this flag every time we finish using it.
2559 case CfPrepareToReadKey
:
2560 ControlFlag
= CfReadKey
;
2561 ScreenOperation
= UiNoOperation
;
2565 ControlFlag
= CfScreenOperation
;
2568 // Wait for user's selection
2571 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2572 if (!EFI_ERROR (Status
)) {
2573 EventType
= UIEventKey
;
2578 // If we encounter error, continue to read another key in.
2580 if (Status
!= EFI_NOT_READY
) {
2584 EventType
= UiWaitForEvent(gST
->ConIn
->WaitForKey
);
2585 if (EventType
== UIEventKey
) {
2586 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2591 if (EventType
== UIEventDriver
) {
2592 gUserInput
->Action
= BROWSER_ACTION_NONE
;
2593 ControlFlag
= CfExit
;
2597 if (EventType
== UIEventTimeOut
) {
2598 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2599 ControlFlag
= CfExit
;
2603 switch (Key
.UnicodeChar
) {
2604 case CHAR_CARRIAGE_RETURN
:
2605 if(MenuOption
== NULL
|| MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2606 ControlFlag
= CfReadKey
;
2610 ScreenOperation
= UiSelect
;
2615 // We will push the adjustment of these numeric values directly to the input handler
2616 // NOTE: we won't handle manual input numeric
2621 // If the screen has no menu items, and the user didn't select UiReset
2622 // ignore the selection and go back to reading keys.
2624 if(IsListEmpty (&gMenuOption
) || MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2625 ControlFlag
= CfReadKey
;
2629 ASSERT(MenuOption
!= NULL
);
2630 Statement
= MenuOption
->ThisTag
;
2631 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
)
2632 || (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
2633 || ((Statement
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (GetFieldFromNum(Statement
->OpCode
) != 0))
2635 if (Key
.UnicodeChar
== '+') {
2636 gDirection
= SCAN_RIGHT
;
2638 gDirection
= SCAN_LEFT
;
2641 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2642 if (OptionString
!= NULL
) {
2643 FreePool (OptionString
);
2645 if (EFI_ERROR (Status
)) {
2647 // Repaint to clear possible error prompt pop-up
2652 ControlFlag
= CfExit
;
2658 ScreenOperation
= UiUp
;
2663 ScreenOperation
= UiDown
;
2667 if(IsListEmpty (&gMenuOption
)) {
2668 ControlFlag
= CfReadKey
;
2672 ASSERT(MenuOption
!= NULL
);
2673 if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_CHECKBOX_OP
&& !MenuOption
->GrayOut
&& !MenuOption
->ReadOnly
) {
2674 ScreenOperation
= UiSelect
;
2680 if (!MultiHelpPage
) {
2681 ControlFlag
= CfReadKey
;
2684 ControlFlag
= CfUpdateHelpString
;
2685 HelpPageIndex
= HelpPageIndex
< HelpPageCount
- 1 ? HelpPageIndex
+ 1 : HelpPageCount
- 1;
2690 if (!MultiHelpPage
) {
2691 ControlFlag
= CfReadKey
;
2694 ControlFlag
= CfUpdateHelpString
;
2695 HelpPageIndex
= HelpPageIndex
> 0 ? HelpPageIndex
- 1 : 0;
2699 for (Index
= 0; Index
< mScanCodeNumber
; Index
++) {
2700 if (Key
.ScanCode
== gScanCodeToOperation
[Index
].ScanCode
) {
2701 ScreenOperation
= gScanCodeToOperation
[Index
].ScreenOperation
;
2706 if (((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) && (Key
.ScanCode
== SCAN_ESC
|| Index
== mScanCodeNumber
)) {
2708 // ModalForm has no ESC key and Hot Key.
2710 ControlFlag
= CfReadKey
;
2711 } else if (Index
== mScanCodeNumber
) {
2713 // Check whether Key matches the registered hot key.
2716 HotKey
= GetHotKeyFromRegisterList (&Key
);
2717 if (HotKey
!= NULL
) {
2718 ScreenOperation
= UiHotKey
;
2725 case CfScreenOperation
:
2726 if ((ScreenOperation
!= UiReset
) && (ScreenOperation
!= UiHotKey
)) {
2728 // If the screen has no menu items, and the user didn't select UiReset or UiHotKey
2729 // ignore the selection and go back to reading keys.
2731 if (IsListEmpty (&gMenuOption
)) {
2732 ControlFlag
= CfReadKey
;
2738 Index
< sizeof (gScreenOperationToControlFlag
) / sizeof (gScreenOperationToControlFlag
[0]);
2741 if (ScreenOperation
== gScreenOperationToControlFlag
[Index
].ScreenOperation
) {
2742 ControlFlag
= gScreenOperationToControlFlag
[Index
].ControlFlag
;
2749 ControlFlag
= CfRepaint
;
2751 ASSERT(MenuOption
!= NULL
);
2752 Statement
= MenuOption
->ThisTag
;
2753 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
2757 switch (Statement
->OpCode
->OpCode
) {
2758 case EFI_IFR_REF_OP
:
2759 case EFI_IFR_ACTION_OP
:
2760 case EFI_IFR_RESET_BUTTON_OP
:
2761 ControlFlag
= CfExit
;
2766 // Editable Questions: oneof, ordered list, checkbox, numeric, string, password
2768 RefreshKeyHelp (gFormData
, Statement
, TRUE
);
2769 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2771 if (OptionString
!= NULL
) {
2772 FreePool (OptionString
);
2775 if (EFI_ERROR (Status
)) {
2778 RefreshKeyHelp (gFormData
, Statement
, FALSE
);
2781 ControlFlag
= CfExit
;
2789 // We come here when someone press ESC
2790 // If the policy is not exit front page when user press ESC, process here.
2792 if (!FormExitPolicy()) {
2795 ControlFlag
= CfRepaint
;
2800 // When user press ESC, it will try to show another menu, should clean the gSequence info.
2802 if (gSequence
!= 0) {
2806 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2807 ControlFlag
= CfExit
;
2811 ControlFlag
= CfRepaint
;
2813 gUserInput
->Action
= HotKey
->Action
;
2814 ControlFlag
= CfExit
;
2818 ControlFlag
= CfRepaint
;
2819 ASSERT(MenuOption
!= NULL
);
2820 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
2821 if (MenuOption
->Sequence
!= 0) {
2823 // In the middle or tail of the Date/Time op-code set, go left.
2825 ASSERT(NewPos
!= NULL
);
2826 NewPos
= NewPos
->BackLink
;
2832 ControlFlag
= CfRepaint
;
2833 ASSERT(MenuOption
!= NULL
);
2834 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
2835 if (MenuOption
->Sequence
!= 2) {
2837 // In the middle or tail of the Date/Time op-code set, go left.
2839 ASSERT(NewPos
!= NULL
);
2840 NewPos
= NewPos
->ForwardLink
;
2846 ControlFlag
= CfRepaint
;
2848 SavedListEntry
= NewPos
;
2850 ASSERT(NewPos
!= NULL
);
2852 // Adjust Date/Time position before we advance forward.
2854 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2855 if (NewPos
->BackLink
!= &gMenuOption
) {
2856 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2857 ASSERT (MenuOption
!= NULL
);
2859 NewPos
= NewPos
->BackLink
;
2861 PreviousMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2862 if (PreviousMenuOption
->Row
== 0) {
2863 UpdateOptionSkipLines (PreviousMenuOption
);
2865 DistanceValue
= PreviousMenuOption
->Skip
;
2867 if (MenuOption
->Row
>= DistanceValue
+ TopRow
) {
2868 Difference
= MoveToNextStatement (TRUE
, &NewPos
, MenuOption
->Row
- TopRow
- DistanceValue
);
2870 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2872 if (Difference
< 0) {
2874 // We hit the begining MenuOption that can be focused
2875 // so we simply scroll to the top.
2877 if (TopOfScreen
!= gMenuOption
.ForwardLink
) {
2878 TopOfScreen
= gMenuOption
.ForwardLink
;
2882 // Scroll up to the last page when we have arrived at top page.
2884 NewPos
= &gMenuOption
;
2885 TopOfScreen
= &gMenuOption
;
2886 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
2887 ScreenOperation
= UiPageUp
;
2888 ControlFlag
= CfScreenOperation
;
2891 } else if (MenuOption
->Row
< TopRow
+ DistanceValue
+ Difference
) {
2893 // Previous focus MenuOption is above the TopOfScreen, so we need to scroll
2895 TopOfScreen
= NewPos
;
2898 } else if (!IsSelectable (NextMenuOption
)) {
2900 // Continue to go up until scroll to next page or the selectable option is found.
2902 ScreenOperation
= UiUp
;
2903 ControlFlag
= CfScreenOperation
;
2907 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
2909 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
2910 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2911 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
2912 UpdateStatusBar (INPUT_ERROR
, FALSE
);
2914 if (NewPos
->ForwardLink
== &gMenuOption
) {
2920 // Scroll up to the last page.
2922 NewPos
= &gMenuOption
;
2923 TopOfScreen
= &gMenuOption
;
2924 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
2925 ScreenOperation
= UiPageUp
;
2926 ControlFlag
= CfScreenOperation
;
2933 // SkipValue means lines is skipped when show the top menu option.
2935 ControlFlag
= CfRepaint
;
2937 ASSERT(NewPos
!= NULL
);
2939 // Already at the first menu option, Check the skip value.
2941 if (NewPos
->BackLink
== &gMenuOption
) {
2942 if (SkipValue
== 0) {
2957 // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one
2958 // form of options to be show, so just update the SkipValue to show the next
2959 // parts of options.
2961 if (SkipValue
> (INTN
) (BottomRow
- TopRow
+ 1)) {
2962 SkipValue
-= BottomRow
- TopRow
+ 1;
2968 // First minus the menu of the top screen, it's value is SkipValue.
2970 Index
= (BottomRow
+ 1) - SkipValue
;
2971 while ((Index
> TopRow
) && (Link
->BackLink
!= &gMenuOption
)) {
2972 Link
= Link
->BackLink
;
2973 PreviousMenuOption
= MENU_OPTION_FROM_LINK (Link
);
2974 if (PreviousMenuOption
->Row
== 0) {
2975 UpdateOptionSkipLines (PreviousMenuOption
);
2977 if (Index
< PreviousMenuOption
->Skip
) {
2980 Index
= Index
- PreviousMenuOption
->Skip
;
2983 if ((Link
->BackLink
== &gMenuOption
) && (Index
>= TopRow
)) {
2984 if (TopOfScreen
== &gMenuOption
) {
2985 TopOfScreen
= gMenuOption
.ForwardLink
;
2986 NewPos
= gMenuOption
.BackLink
;
2987 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
);
2988 if (Index
< PreviousMenuOption
->Skip
) {
2990 SkipValue
= PreviousMenuOption
->Skip
- (Index
- TopRow
);
2995 } else if (TopOfScreen
!= Link
) {
2998 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
3002 // Finally we know that NewPos is the last MenuOption can be focused.
3004 if (SkipValue
== 0) {
3008 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
3012 if (Index
> TopRow
) {
3014 // At here, only case "Index < PreviousMenuOption->Skip" can reach here.
3016 SkipValue
= PreviousMenuOption
->Skip
- (Index
- TopRow
);
3017 } else if (Index
== TopRow
) {
3020 SkipValue
= TopRow
- Index
;
3024 // Move to the option in Next page.
3026 if (TopOfScreen
== &gMenuOption
) {
3027 NewPos
= gMenuOption
.BackLink
;
3028 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
);
3031 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
3035 // There are more MenuOption needing scrolling up.
3042 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3043 // Don't do this when we are already in the first page.
3045 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3046 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3051 // SkipValue means lines is skipped when show the top menu option.
3053 ControlFlag
= CfRepaint
;
3055 ASSERT (NewPos
!= NULL
);
3056 if (NewPos
->ForwardLink
== &gMenuOption
) {
3057 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3058 if (SkipValue
+ BottomRow
- TopRow
+ 1 < MenuOption
->Skip
) {
3059 SkipValue
+= BottomRow
- TopRow
+ 1;
3072 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3073 Index
= TopRow
+ NextMenuOption
->Skip
- SkipValue
;
3075 // Count to the menu option which will show at the top of the next form.
3077 while ((Index
<= BottomRow
+ 1) && (Link
->ForwardLink
!= &gMenuOption
)) {
3078 Link
= Link
->ForwardLink
;
3079 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3080 Index
= Index
+ NextMenuOption
->Skip
;
3083 if ((Link
->ForwardLink
== &gMenuOption
) && (Index
<= BottomRow
+ 1)) {
3085 // Finally we know that NewPos is the last MenuOption can be focused.
3088 MoveToNextStatement (TRUE
, &Link
, Index
- TopRow
);
3091 // Calculate the skip line for top of screen menu.
3093 if (Link
== TopOfScreen
) {
3095 // The top of screen menu option occupies the entire form.
3097 SkipValue
+= BottomRow
- TopRow
+ 1;
3099 SkipValue
= NextMenuOption
->Skip
- (Index
- (BottomRow
+ 1));
3105 // Move to the Next selectable menu.
3107 MoveToNextStatement (FALSE
, &Link
, BottomRow
- TopRow
);
3111 // Save the menu as the next highlight menu.
3116 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3117 // Don't do this when we are already in the last page.
3119 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3120 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3125 // SkipValue means lines is skipped when show the top menu option.
3126 // NewPos points to the menu which is highlighted now.
3128 ControlFlag
= CfRepaint
;
3131 // Since the behavior of hitting the down arrow on a Date/Time op-code is intended
3132 // to be one that progresses to the next set of op-codes, we need to advance to the last
3133 // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate
3134 // checking can be done. The only other logic we need to introduce is that if a Date/Time
3135 // op-code is the last entry in the menu, we need to rewind back to the first op-code of
3136 // the Date/Time op-code.
3138 SavedListEntry
= NewPos
;
3139 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3141 if (NewPos
->ForwardLink
!= &gMenuOption
) {
3142 if (NewPos
== TopOfScreen
) {
3148 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3150 NewPos
= NewPos
->ForwardLink
;
3154 // Current menu not at the bottom of the form.
3156 if (BottomRow
>= MenuOption
->Row
+ MenuOption
->Skip
- Temp2
) {
3158 // Find the next selectable menu.
3160 Difference
= MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- MenuOption
->Row
- MenuOption
->Skip
+ Temp2
);
3162 // We hit the end of MenuOption that can be focused
3163 // so we simply scroll to the first page.
3165 if (Difference
< 0) {
3167 // Scroll to the first page.
3169 if (TopOfScreen
!= gMenuOption
.ForwardLink
) {
3170 TopOfScreen
= gMenuOption
.ForwardLink
;
3174 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3176 NewPos
= gMenuOption
.ForwardLink
;
3177 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
3181 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3183 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3184 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3188 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3189 if (NextMenuOption
->Row
== 0) {
3190 UpdateOptionSkipLines (NextMenuOption
);
3192 DistanceValue
= Difference
+ NextMenuOption
->Skip
- Temp2
;
3194 Temp
= MenuOption
->Row
+ MenuOption
->Skip
+ DistanceValue
- 1;
3195 if ((MenuOption
->Row
+ MenuOption
->Skip
- Temp2
== BottomRow
+ 1) &&
3196 (NextMenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
||
3197 NextMenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
3203 // If we are going to scroll, update TopOfScreen
3205 if (Temp
> BottomRow
) {
3208 // Is the current top of screen a zero-advance op-code?
3209 // If so, keep moving forward till we hit a >0 advance op-code
3211 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3214 // If bottom op-code is more than one line or top op-code is more than one line
3216 if ((DistanceValue
> 1) || (SavedMenuOption
->Skip
> 1)) {
3218 // Is the bottom op-code greater than or equal in size to the top op-code?
3220 if ((Temp
- BottomRow
) >= (SavedMenuOption
->Skip
- SkipValue
)) {
3222 // Skip the top op-code
3224 TopOfScreen
= TopOfScreen
->ForwardLink
;
3225 Difference
= (Temp
- BottomRow
) - (SavedMenuOption
->Skip
- SkipValue
);
3227 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3230 // If we have a remainder, skip that many more op-codes until we drain the remainder
3232 while (Difference
>= (INTN
) SavedMenuOption
->Skip
) {
3234 // Since the Difference is greater than or equal to this op-code's skip value, skip it
3236 Difference
= Difference
- (INTN
) SavedMenuOption
->Skip
;
3237 TopOfScreen
= TopOfScreen
->ForwardLink
;
3238 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3241 // Since we will act on this op-code in the next routine, and increment the
3242 // SkipValue, set the skips to one less than what is required.
3244 SkipValue
= Difference
- 1;
3247 // Since we will act on this op-code in the next routine, and increment the
3248 // SkipValue, set the skips to one less than what is required.
3250 SkipValue
+= (Temp
- BottomRow
) - 1;
3253 if ((SkipValue
+ 1) == (INTN
) SavedMenuOption
->Skip
) {
3254 TopOfScreen
= TopOfScreen
->ForwardLink
;
3259 // If the op-code at the top of the screen is more than one line, let's not skip it yet
3260 // Let's set a skip flag to smoothly scroll the top of the screen.
3262 if (SavedMenuOption
->Skip
> 1) {
3263 if (SavedMenuOption
== NextMenuOption
) {
3268 } else if (SavedMenuOption
->Skip
== 1) {
3272 TopOfScreen
= TopOfScreen
->ForwardLink
;
3274 } while (SavedMenuOption
->Skip
== 0);
3277 } else if (!IsSelectable (NextMenuOption
)) {
3279 // Continue to go down until scroll to next page or the selectable option is found.
3281 ScreenOperation
= UiDown
;
3282 ControlFlag
= CfScreenOperation
;
3285 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3287 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3291 // Scroll to the first page.
3293 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3294 TopOfScreen
= gMenuOption
.ForwardLink
;
3299 // Need to remove the current highlight menu.
3300 // MenuOption saved the last highlight menu info.
3302 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3308 // Get the next highlight menu.
3310 NewPos
= gMenuOption
.ForwardLink
;
3311 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
3315 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3317 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3318 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3321 case CfUiNoOperation
:
3322 ControlFlag
= CfRepaint
;
3326 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
3327 if (HelpString
!= NULL
) {
3328 FreePool (HelpString
);
3330 if (HelpHeaderString
!= NULL
) {
3331 FreePool (HelpHeaderString
);
3333 if (HelpBottomString
!= NULL
) {
3334 FreePool (HelpBottomString
);
3346 Base on the browser status info to show an pop up message.
3350 BrowserStatusProcess (
3357 if (gFormData
->BrowserStatus
== BROWSER_SUCCESS
) {
3361 if (gFormData
->ErrorString
!= NULL
) {
3362 ErrorInfo
= gFormData
->ErrorString
;
3364 switch (gFormData
->BrowserStatus
) {
3365 case BROWSER_SUBMIT_FAIL
:
3366 ErrorInfo
= gSaveFailed
;
3369 case BROWSER_NO_SUBMIT_IF
:
3370 ErrorInfo
= gNoSubmitIf
;
3373 case BROWSER_FORM_NOT_FOUND
:
3374 ErrorInfo
= gFormNotFound
;
3377 case BROWSER_FORM_SUPPRESS
:
3378 ErrorInfo
= gFormSuppress
;
3381 case BROWSER_PROTOCOL_NOT_FOUND
:
3382 ErrorInfo
= gProtocolNotFound
;
3386 ErrorInfo
= gBrwoserError
;
3392 // Error occur, prompt error message.
3395 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, gPressEnter
, gEmptyString
, NULL
);
3396 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
3400 Display one form, and return user input.
3402 @param FormData Form Data to be shown.
3403 @param UserInputData User input data.
3405 @retval EFI_SUCCESS 1.Form Data is shown, and user input is got.
3406 2.Error info has show and return.
3407 @retval EFI_INVALID_PARAMETER The input screen dimension is not valid
3408 @retval EFI_NOT_FOUND New form data has some error.
3413 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
3414 OUT USER_INPUT
*UserInputData
3419 ASSERT (FormData
!= NULL
);
3420 if (FormData
== NULL
) {
3421 return EFI_INVALID_PARAMETER
;
3424 gUserInput
= UserInputData
;
3425 gFormData
= FormData
;
3428 // Process the status info first.
3430 BrowserStatusProcess();
3431 if (UserInputData
== NULL
) {
3433 // UserInputData == NULL, means only need to print the error info, return here.
3438 ConvertStatementToMenu();
3440 Status
= DisplayPageFrame (FormData
, &gStatementDimensions
);
3441 if (EFI_ERROR (Status
)) {
3446 // Check whether layout is changed.
3449 || (gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
)
3450 || (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))
3451 || (gOldFormEntry
.FormId
!= FormData
->FormId
)) {
3452 mStatementLayoutIsChanged
= TRUE
;
3454 mStatementLayoutIsChanged
= FALSE
;
3457 Status
= UiDisplayMenu(FormData
);
3460 // Backup last form info.
3462 mIsFirstForm
= FALSE
;
3463 gOldFormEntry
.HiiHandle
= FormData
->HiiHandle
;
3464 CopyGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
);
3465 gOldFormEntry
.FormId
= FormData
->FormId
;
3471 Clear Screen to the initial state.
3475 DriverClearDisplayPage (
3479 ClearDisplayPage ();
3480 mIsFirstForm
= TRUE
;
3484 Set Buffer to Value for Size bytes.
3486 @param Buffer Memory to set.
3487 @param Size Number of bytes to set
3488 @param Value Value of the set operation.
3501 while ((Size
--) != 0) {
3507 Initialize Setup Browser driver.
3509 @param ImageHandle The image handle.
3510 @param SystemTable The system table.
3512 @retval EFI_SUCCESS The Setup Browser module is initialized correctly..
3513 @return Other value if failed to initialize the Setup Browser module.
3518 InitializeDisplayEngine (
3519 IN EFI_HANDLE ImageHandle
,
3520 IN EFI_SYSTEM_TABLE
*SystemTable
3524 EFI_INPUT_KEY HotKey
;
3525 EFI_STRING NewString
;
3526 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL
*FormBrowserEx2
;
3529 // Publish our HII data
3531 gHiiHandle
= HiiAddPackages (
3532 &gDisplayEngineGuid
,
3534 DisplayEngineStrings
,
3537 ASSERT (gHiiHandle
!= NULL
);
3540 // Install Form Display protocol
3542 Status
= gBS
->InstallProtocolInterface (
3543 &mPrivateData
.Handle
,
3544 &gEdkiiFormDisplayEngineProtocolGuid
,
3545 EFI_NATIVE_INTERFACE
,
3546 &mPrivateData
.FromDisplayProt
3548 ASSERT_EFI_ERROR (Status
);
3550 InitializeDisplayStrings();
3552 ZeroMem (&gHighligthMenuInfo
, sizeof (gHighligthMenuInfo
));
3553 ZeroMem (&gOldFormEntry
, sizeof (gOldFormEntry
));
3556 // Use BrowserEx2 protocol to register HotKey.
3558 Status
= gBS
->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid
, NULL
, (VOID
**) &FormBrowserEx2
);
3559 if (!EFI_ERROR (Status
)) {
3561 // Register the default HotKey F9 and F10 again.
3563 HotKey
.UnicodeChar
= CHAR_NULL
;
3564 HotKey
.ScanCode
= SCAN_F10
;
3565 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_TEN_STRING
), NULL
);
3566 ASSERT (NewString
!= NULL
);
3567 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_SUBMIT
, 0, NewString
);
3569 HotKey
.ScanCode
= SCAN_F9
;
3570 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_NINE_STRING
), NULL
);
3571 ASSERT (NewString
!= NULL
);
3572 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_DEFAULT
, EFI_HII_DEFAULT_CLASS_STANDARD
, NewString
);
3579 This is the default unload handle for display core drivers.
3581 @param[in] ImageHandle The drivers' driver image.
3583 @retval EFI_SUCCESS The image is unloaded.
3584 @retval Others Failed to unload the image.
3589 UnloadDisplayEngine (
3590 IN EFI_HANDLE ImageHandle
3593 HiiRemovePackages(gHiiHandle
);
3595 FreeDisplayStrings ();