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) {
1861 FreePool (OutputString
);
1867 FreePool (StringPtr
);
1871 // 4.Line number for Option string and prompt string are not equal.
1872 // Clean the column whose line number is less.
1874 if (HasOptionString(MenuOption
) && (OptionLineNum
!= PromptLineNum
)) {
1875 Col
= OptionLineNum
< PromptLineNum
? MenuOption
->OptCol
: BeginCol
;
1876 Row
= (OptionLineNum
< PromptLineNum
? OptionLineNum
: PromptLineNum
) + MenuOption
->Row
;
1877 Width
= (UINT16
) (OptionLineNum
< PromptLineNum
? gOptionBlockWidth
: PromptWidth
+ AdjustValue
+ SkipWidth
);
1878 MaxRow
= (OptionLineNum
< PromptLineNum
? PromptLineNum
: OptionLineNum
) + MenuOption
->Row
- 1;
1880 while (Row
<= MaxRow
) {
1881 DisplayMenuString (MenuOption
, Col
, Row
++, L
"", Width
, FALSE
);
1889 Display menu and wait for user to select one menu option, then return it.
1890 If AutoBoot is enabled, then if user doesn't select any option,
1891 after period of time, it will automatically return the first menu option.
1893 @param FormData The current form data info.
1895 @retval EFI_SUCESSS Process the user selection success.
1896 @retval EFI_NOT_FOUND Process option string for orderedlist/Oneof fail.
1901 IN FORM_DISPLAY_ENGINE_FORM
*FormData
1906 UINTN DistanceValue
;
1917 CHAR16
*OptionString
;
1918 CHAR16
*OutputString
;
1920 CHAR16
*HelpHeaderString
;
1921 CHAR16
*HelpBottomString
;
1930 LIST_ENTRY
*TopOfScreen
;
1931 LIST_ENTRY
*SavedListEntry
;
1932 UI_MENU_OPTION
*MenuOption
;
1933 UI_MENU_OPTION
*NextMenuOption
;
1934 UI_MENU_OPTION
*SavedMenuOption
;
1935 UI_MENU_OPTION
*PreviousMenuOption
;
1936 UI_CONTROL_FLAG ControlFlag
;
1937 UI_SCREEN_OPERATION ScreenOperation
;
1939 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1940 BROWSER_HOT_KEY
*HotKey
;
1941 UINTN HelpPageIndex
;
1942 UINTN HelpPageCount
;
1945 UINTN HelpHeaderLine
;
1946 UINTN HelpBottomLine
;
1947 BOOLEAN MultiHelpPage
;
1949 UINT16 EachLineWidth
;
1950 UINT16 HeaderLineWidth
;
1951 UINT16 BottomLineWidth
;
1952 EFI_STRING_ID HelpInfo
;
1953 UI_EVENT_TYPE EventType
;
1954 FORM_DISPLAY_ENGINE_STATEMENT
*InitialHighlight
;
1955 BOOLEAN SkipHighLight
;
1957 EventType
= UIEventNone
;
1958 Status
= EFI_SUCCESS
;
1960 HelpHeaderString
= NULL
;
1961 HelpBottomString
= NULL
;
1962 OptionString
= NULL
;
1963 ScreenOperation
= UiNoOperation
;
1972 MultiHelpPage
= FALSE
;
1974 HeaderLineWidth
= 0;
1975 BottomLineWidth
= 0;
1976 OutputString
= NULL
;
1980 SkipHighLight
= FALSE
;
1982 NextMenuOption
= NULL
;
1983 PreviousMenuOption
= NULL
;
1984 SavedMenuOption
= NULL
;
1988 gModalSkipColumn
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 6;
1989 InitialHighlight
= gFormData
->HighLightedStatement
;
1991 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
1995 // |<-.->|<-.........->|<- .........->|<-...........->|
1996 // Skip Prompt Option Help
1998 Width
= (CHAR16
) ((gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 3);
1999 gOptionBlockWidth
= Width
+ 1;
2000 gHelpBlockWidth
= (CHAR16
) (Width
- LEFT_SKIPPED_COLUMNS
);
2001 gPromptBlockWidth
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * Width
- 1);
2003 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
2004 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
- 1;
2007 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2008 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gModalSkipColumn
;
2010 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
;
2013 FindTopMenu(FormData
, &TopOfScreen
, &NewPos
, &SkipValue
);
2015 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
2017 ControlFlag
= CfInitialization
;
2019 switch (ControlFlag
) {
2020 case CfInitialization
:
2021 if ((gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
) ||
2022 (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))) {
2024 // Clear Statement range if different formset is painted.
2027 gStatementDimensions
.LeftColumn
,
2028 gStatementDimensions
.RightColumn
,
2029 TopRow
- SCROLL_ARROW_HEIGHT
,
2030 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2031 GetFieldTextColor ()
2035 ControlFlag
= CfRepaint
;
2039 ControlFlag
= CfRefreshHighLight
;
2049 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2052 // 1. Check whether need to print the arrow up.
2054 if (!ValueIsScroll (TRUE
, TopOfScreen
)) {
2058 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2059 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2061 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2064 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2066 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2067 TopRow
- SCROLL_ARROW_HEIGHT
,
2070 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2074 // 2.Paint the menu.
2076 for (Link
= TopOfScreen
; Link
!= &gMenuOption
; Link
= Link
->ForwardLink
) {
2077 MenuOption
= MENU_OPTION_FROM_LINK (Link
);
2078 MenuOption
->Row
= Row
;
2079 MenuOption
->Col
= Col
;
2080 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2081 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
+ gModalSkipColumn
;
2083 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
;
2086 if (MenuOption
->NestInStatement
) {
2087 MenuOption
->Col
+= SUBTITLE_INDENT
;
2091 // Save the highlight menu, will be used in CfRefreshHighLight case.
2093 if (Link
== NewPos
) {
2094 SavedMenuOption
= MenuOption
;
2095 SkipHighLight
= TRUE
;
2098 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2099 Status
= DisplayOneMenu (MenuOption
,
2100 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2101 gStatementDimensions
.LeftColumn
+ gModalSkipColumn
,
2102 Link
== TopOfScreen
? SkipValue
: 0,
2104 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
))
2107 Status
= DisplayOneMenu (MenuOption
,
2108 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2109 gStatementDimensions
.LeftColumn
,
2110 Link
== TopOfScreen
? SkipValue
: 0,
2112 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
))
2116 if (EFI_ERROR (Status
)) {
2120 // 3. Update the row info which will be used by next menu.
2122 if (Link
== TopOfScreen
) {
2123 Row
+= MenuOption
->Skip
- SkipValue
;
2125 Row
+= MenuOption
->Skip
;
2128 if (Row
> BottomRow
) {
2129 if (!ValueIsScroll (FALSE
, Link
)) {
2133 Row
= BottomRow
+ 1;
2139 // 3. Menus in this form may not cover all form, clean the remain field.
2141 while (Row
<= BottomRow
) {
2142 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2143 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2145 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gHelpBlockWidth
- gStatementDimensions
.LeftColumn
);
2150 // 4. Print the down arrow row.
2152 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2153 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * + gModalSkipColumn
);
2155 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2158 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2160 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2161 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2164 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2171 case CfRefreshHighLight
:
2174 // MenuOption: Last menu option that need to remove hilight
2175 // MenuOption is set to NULL in Repaint
2176 // NewPos: Current menu option that need to hilight
2178 ControlFlag
= CfUpdateHelpString
;
2180 if (SkipHighLight
) {
2181 MenuOption
= SavedMenuOption
;
2182 SkipHighLight
= FALSE
;
2183 UpdateHighlightMenuInfo (MenuOption
);
2187 if (IsListEmpty (&gMenuOption
)) {
2189 // No menu option, just update the hotkey filed.
2191 RefreshKeyHelp(gFormData
, NULL
, FALSE
);
2195 if (MenuOption
!= NULL
&& TopOfScreen
== &MenuOption
->Link
) {
2200 if (NewPos
== TopOfScreen
) {
2206 if (NewPos
!= NULL
&& (MenuOption
== NULL
|| NewPos
!= &MenuOption
->Link
)) {
2207 if (MenuOption
!= NULL
) {
2209 // Remove highlight on last Menu Option
2211 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, MenuOption
->Col
, MenuOption
->Row
);
2212 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
2213 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2214 if (OptionString
!= NULL
) {
2215 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) ||
2216 (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
2218 ProcessStringForDateTime(MenuOption
, OptionString
, FALSE
);
2221 Width
= (UINT16
) gOptionBlockWidth
- 1;
2222 OriginalRow
= MenuOption
->Row
;
2225 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2226 if ((Temp
== 0) && (MenuOption
->Row
>= TopRow
) && (MenuOption
->Row
<= BottomRow
)) {
2227 PrintStringAt (MenuOption
->OptCol
, MenuOption
->Row
, OutputString
);
2230 // If there is more string to process print on the next row and increment the Skip value
2232 if (StrLen (&OptionString
[Index
]) != 0) {
2238 FreePool (OutputString
);
2244 MenuOption
->Row
= OriginalRow
;
2246 FreePool (OptionString
);
2249 if (MenuOption
->GrayOut
) {
2250 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetGrayedTextColor ());
2251 } else if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) {
2252 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetSubTitleTextColor ());
2255 OriginalRow
= MenuOption
->Row
;
2256 Width
= GetWidth (MenuOption
, NULL
);
2259 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2260 if ((Temp
== 0) && (MenuOption
->Row
>= TopRow
) && (MenuOption
->Row
<= BottomRow
)) {
2261 PrintStringAt (MenuOption
->Col
, MenuOption
->Row
, OutputString
);
2264 // If there is more string to process print on the next row and increment the Skip value
2266 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
2272 FreePool (OutputString
);
2278 MenuOption
->Row
= OriginalRow
;
2279 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2285 // This is the current selected statement
2287 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2288 Statement
= MenuOption
->ThisTag
;
2290 UpdateHighlightMenuInfo (MenuOption
);
2292 if (!IsSelectable (MenuOption
)) {
2297 // Set reverse attribute
2299 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
2300 gST
->ConOut
->SetCursorPosition (gST
->ConOut
, MenuOption
->Col
, MenuOption
->Row
);
2302 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
2303 if (OptionString
!= NULL
) {
2304 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
2305 ProcessStringForDateTime(MenuOption
, OptionString
, FALSE
);
2307 Width
= (UINT16
) gOptionBlockWidth
- 1;
2309 OriginalRow
= MenuOption
->Row
;
2312 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2313 if ((Temp2
== 0) && (MenuOption
->Row
>= TopRow
) && (MenuOption
->Row
<= BottomRow
) ) {
2314 PrintStringAt (MenuOption
->OptCol
, MenuOption
->Row
, OutputString
);
2317 // If there is more string to process print on the next row and increment the Skip value
2319 if (StrLen (&OptionString
[Index
]) != 0) {
2325 FreePool (OutputString
);
2331 MenuOption
->Row
= OriginalRow
;
2333 FreePool (OptionString
);
2336 OriginalRow
= MenuOption
->Row
;
2338 Width
= GetWidth (MenuOption
, NULL
);
2341 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2342 if ((Temp2
== 0) && (MenuOption
->Row
>= TopRow
) && (MenuOption
->Row
<= BottomRow
) ) {
2343 PrintStringAt (MenuOption
->Col
, MenuOption
->Row
, OutputString
);
2346 // If there is more string to process print on the next row and increment the Skip value
2348 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
2354 FreePool (OutputString
);
2360 MenuOption
->Row
= OriginalRow
;
2366 // Clear reverse attribute
2368 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2372 case CfUpdateHelpString
:
2373 ControlFlag
= CfPrepareToReadKey
;
2374 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2378 if (Repaint
|| NewLine
) {
2379 if (IsListEmpty (&gMenuOption
)) {
2381 // Don't print anything if no mwnu option.
2383 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2386 // Don't print anything if it is a NULL help token
2388 ASSERT(MenuOption
!= NULL
);
2389 HelpInfo
= ((EFI_IFR_STATEMENT_HEADER
*) ((CHAR8
*)MenuOption
->ThisTag
->OpCode
+ sizeof (EFI_IFR_OP_HEADER
)))->Help
;
2390 if (HelpInfo
== 0 || !IsSelectable (MenuOption
)) {
2391 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2393 StringPtr
= GetToken (HelpInfo
, gFormData
->HiiHandle
);
2397 RowCount
= BottomRow
- TopRow
+ 1;
2400 // 1.Calculate how many line the help string need to print.
2402 if (HelpString
!= NULL
) {
2403 FreePool (HelpString
);
2406 HelpLine
= ProcessHelpString (StringPtr
, &HelpString
, &EachLineWidth
, RowCount
);
2407 FreePool (StringPtr
);
2409 if (HelpLine
> RowCount
) {
2410 MultiHelpPage
= TRUE
;
2411 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_UP
), gHiiHandle
);
2412 if (HelpHeaderString
!= NULL
) {
2413 FreePool (HelpHeaderString
);
2414 HelpHeaderString
= NULL
;
2416 HelpHeaderLine
= ProcessHelpString (StringPtr
, &HelpHeaderString
, &HeaderLineWidth
, 0);
2417 FreePool (StringPtr
);
2418 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_DOWN
), gHiiHandle
);
2419 if (HelpBottomString
!= NULL
) {
2420 FreePool (HelpBottomString
);
2421 HelpBottomString
= NULL
;
2423 HelpBottomLine
= ProcessHelpString (StringPtr
, &HelpBottomString
, &BottomLineWidth
, 0);
2424 FreePool (StringPtr
);
2426 // Calculate the help page count.
2428 if (HelpLine
> 2 * RowCount
- 2) {
2429 HelpPageCount
= (HelpLine
- RowCount
+ 1) / (RowCount
- 2) + 1;
2430 if ((HelpLine
- RowCount
+ 1) % (RowCount
- 2) > 1) {
2437 MultiHelpPage
= FALSE
;
2442 // Check whether need to show the 'More(U/u)' at the begin.
2443 // Base on current direct info, here shows aligned to the right side of the column.
2444 // If the direction is multi line and aligned to right side may have problem, so
2445 // add ASSERT code here.
2447 if (HelpPageIndex
> 0) {
2448 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2449 for (Index
= 0; Index
< HelpHeaderLine
; Index
++) {
2450 ASSERT (HelpHeaderLine
== 1);
2451 ASSERT (GetStringWidth (HelpHeaderString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2452 PrintStringAtWithWidth (
2453 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2459 gStatementDimensions
.RightColumn
- GetStringWidth (HelpHeaderString
) / 2 - 1,
2461 &HelpHeaderString
[Index
* HeaderLineWidth
]
2466 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHelpTextColor ());
2468 // Print the help string info.
2470 if (!MultiHelpPage
) {
2471 for (Index
= 0; Index
< HelpLine
; Index
++) {
2472 PrintStringAtWithWidth (
2473 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2475 &HelpString
[Index
* EachLineWidth
],
2479 for (; Index
< RowCount
; Index
++) {
2480 PrintStringAtWithWidth (
2481 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2487 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2489 if (HelpPageIndex
== 0) {
2490 for (Index
= 0; Index
< RowCount
- HelpBottomLine
; Index
++) {
2491 PrintStringAtWithWidth (
2492 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2494 &HelpString
[Index
* EachLineWidth
],
2499 for (Index
= 0; (Index
< RowCount
- HelpBottomLine
- HelpHeaderLine
) &&
2500 (Index
+ HelpPageIndex
* (RowCount
- 2) + 1 < HelpLine
); Index
++) {
2501 PrintStringAtWithWidth (
2502 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2503 Index
+ TopRow
+ HelpHeaderLine
,
2504 &HelpString
[(Index
+ HelpPageIndex
* (RowCount
- 2) + 1)* EachLineWidth
],
2508 if (HelpPageIndex
== HelpPageCount
- 1) {
2509 for (; Index
< RowCount
- HelpHeaderLine
; Index
++) {
2510 PrintStringAtWithWidth (
2511 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2512 Index
+ TopRow
+ HelpHeaderLine
,
2517 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2523 // Check whether need to print the 'More(D/d)' at the bottom.
2524 // Base on current direct info, here shows aligned to the right side of the column.
2525 // If the direction is multi line and aligned to right side may have problem, so
2526 // add ASSERT code here.
2528 if (HelpPageIndex
< HelpPageCount
- 1 && MultiHelpPage
) {
2529 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2530 for (Index
= 0; Index
< HelpBottomLine
; Index
++) {
2531 ASSERT (HelpBottomLine
== 1);
2532 ASSERT (GetStringWidth (HelpBottomString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2533 PrintStringAtWithWidth (
2534 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2535 BottomRow
+ Index
- HelpBottomLine
+ 1,
2540 gStatementDimensions
.RightColumn
- GetStringWidth (HelpBottomString
) / 2 - 1,
2541 BottomRow
+ Index
- HelpBottomLine
+ 1,
2542 &HelpBottomString
[Index
* BottomLineWidth
]
2547 // Reset this flag every time we finish using it.
2553 case CfPrepareToReadKey
:
2554 ControlFlag
= CfReadKey
;
2555 ScreenOperation
= UiNoOperation
;
2559 ControlFlag
= CfScreenOperation
;
2562 // Wait for user's selection
2565 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2566 if (!EFI_ERROR (Status
)) {
2567 EventType
= UIEventKey
;
2572 // If we encounter error, continue to read another key in.
2574 if (Status
!= EFI_NOT_READY
) {
2578 EventType
= UiWaitForEvent(gST
->ConIn
->WaitForKey
);
2579 if (EventType
== UIEventKey
) {
2580 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2585 if (EventType
== UIEventDriver
) {
2586 gUserInput
->Action
= BROWSER_ACTION_NONE
;
2587 ControlFlag
= CfExit
;
2591 if (EventType
== UIEventTimeOut
) {
2592 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2593 ControlFlag
= CfExit
;
2597 switch (Key
.UnicodeChar
) {
2598 case CHAR_CARRIAGE_RETURN
:
2599 if(MenuOption
== NULL
|| MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2600 ControlFlag
= CfReadKey
;
2604 ScreenOperation
= UiSelect
;
2609 // We will push the adjustment of these numeric values directly to the input handler
2610 // NOTE: we won't handle manual input numeric
2615 // If the screen has no menu items, and the user didn't select UiReset
2616 // ignore the selection and go back to reading keys.
2618 if(IsListEmpty (&gMenuOption
) || MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2619 ControlFlag
= CfReadKey
;
2623 ASSERT(MenuOption
!= NULL
);
2624 Statement
= MenuOption
->ThisTag
;
2625 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
)
2626 || (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
2627 || ((Statement
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (GetFieldFromNum(Statement
->OpCode
) != 0))
2629 if (Key
.UnicodeChar
== '+') {
2630 gDirection
= SCAN_RIGHT
;
2632 gDirection
= SCAN_LEFT
;
2635 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2636 if (OptionString
!= NULL
) {
2637 FreePool (OptionString
);
2639 if (EFI_ERROR (Status
)) {
2641 // Repaint to clear possible error prompt pop-up
2646 ControlFlag
= CfExit
;
2652 ScreenOperation
= UiUp
;
2657 ScreenOperation
= UiDown
;
2661 if(IsListEmpty (&gMenuOption
)) {
2662 ControlFlag
= CfReadKey
;
2666 ASSERT(MenuOption
!= NULL
);
2667 if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_CHECKBOX_OP
&& !MenuOption
->GrayOut
&& !MenuOption
->ReadOnly
) {
2668 ScreenOperation
= UiSelect
;
2674 if (!MultiHelpPage
) {
2675 ControlFlag
= CfReadKey
;
2678 ControlFlag
= CfUpdateHelpString
;
2679 HelpPageIndex
= HelpPageIndex
< HelpPageCount
- 1 ? HelpPageIndex
+ 1 : HelpPageCount
- 1;
2684 if (!MultiHelpPage
) {
2685 ControlFlag
= CfReadKey
;
2688 ControlFlag
= CfUpdateHelpString
;
2689 HelpPageIndex
= HelpPageIndex
> 0 ? HelpPageIndex
- 1 : 0;
2693 for (Index
= 0; Index
< mScanCodeNumber
; Index
++) {
2694 if (Key
.ScanCode
== gScanCodeToOperation
[Index
].ScanCode
) {
2695 ScreenOperation
= gScanCodeToOperation
[Index
].ScreenOperation
;
2700 if (((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) && (Key
.ScanCode
== SCAN_ESC
|| Index
== mScanCodeNumber
)) {
2702 // ModalForm has no ESC key and Hot Key.
2704 ControlFlag
= CfReadKey
;
2705 } else if (Index
== mScanCodeNumber
) {
2707 // Check whether Key matches the registered hot key.
2710 HotKey
= GetHotKeyFromRegisterList (&Key
);
2711 if (HotKey
!= NULL
) {
2712 ScreenOperation
= UiHotKey
;
2719 case CfScreenOperation
:
2720 if ((ScreenOperation
!= UiReset
) && (ScreenOperation
!= UiHotKey
)) {
2722 // If the screen has no menu items, and the user didn't select UiReset or UiHotKey
2723 // ignore the selection and go back to reading keys.
2725 if (IsListEmpty (&gMenuOption
)) {
2726 ControlFlag
= CfReadKey
;
2732 Index
< sizeof (gScreenOperationToControlFlag
) / sizeof (gScreenOperationToControlFlag
[0]);
2735 if (ScreenOperation
== gScreenOperationToControlFlag
[Index
].ScreenOperation
) {
2736 ControlFlag
= gScreenOperationToControlFlag
[Index
].ControlFlag
;
2743 ControlFlag
= CfRepaint
;
2745 ASSERT(MenuOption
!= NULL
);
2746 Statement
= MenuOption
->ThisTag
;
2747 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
2751 switch (Statement
->OpCode
->OpCode
) {
2752 case EFI_IFR_REF_OP
:
2753 case EFI_IFR_ACTION_OP
:
2754 case EFI_IFR_RESET_BUTTON_OP
:
2755 ControlFlag
= CfExit
;
2760 // Editable Questions: oneof, ordered list, checkbox, numeric, string, password
2762 RefreshKeyHelp (gFormData
, Statement
, TRUE
);
2763 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2765 if (OptionString
!= NULL
) {
2766 FreePool (OptionString
);
2769 if (EFI_ERROR (Status
)) {
2772 RefreshKeyHelp (gFormData
, Statement
, FALSE
);
2775 ControlFlag
= CfExit
;
2783 // We come here when someone press ESC
2784 // If the policy is not exit front page when user press ESC, process here.
2786 if (!FormExitPolicy()) {
2789 ControlFlag
= CfRepaint
;
2794 // When user press ESC, it will try to show another menu, should clean the gSequence info.
2796 if (gSequence
!= 0) {
2800 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2801 ControlFlag
= CfExit
;
2805 ControlFlag
= CfRepaint
;
2807 gUserInput
->Action
= HotKey
->Action
;
2808 ControlFlag
= CfExit
;
2812 ControlFlag
= CfRepaint
;
2813 ASSERT(MenuOption
!= NULL
);
2814 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
2815 if (MenuOption
->Sequence
!= 0) {
2817 // In the middle or tail of the Date/Time op-code set, go left.
2819 ASSERT(NewPos
!= NULL
);
2820 NewPos
= NewPos
->BackLink
;
2826 ControlFlag
= CfRepaint
;
2827 ASSERT(MenuOption
!= NULL
);
2828 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
2829 if (MenuOption
->Sequence
!= 2) {
2831 // In the middle or tail of the Date/Time op-code set, go left.
2833 ASSERT(NewPos
!= NULL
);
2834 NewPos
= NewPos
->ForwardLink
;
2840 ControlFlag
= CfRepaint
;
2842 SavedListEntry
= NewPos
;
2844 ASSERT(NewPos
!= NULL
);
2846 // Adjust Date/Time position before we advance forward.
2848 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2849 if (NewPos
->BackLink
!= &gMenuOption
) {
2850 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2851 ASSERT (MenuOption
!= NULL
);
2853 NewPos
= NewPos
->BackLink
;
2855 PreviousMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2856 if (PreviousMenuOption
->Row
== 0) {
2857 UpdateOptionSkipLines (PreviousMenuOption
);
2859 DistanceValue
= PreviousMenuOption
->Skip
;
2861 if (MenuOption
->Row
>= DistanceValue
+ TopRow
) {
2862 Difference
= MoveToNextStatement (TRUE
, &NewPos
, MenuOption
->Row
- TopRow
- DistanceValue
);
2864 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2866 if (Difference
< 0) {
2868 // We hit the begining MenuOption that can be focused
2869 // so we simply scroll to the top.
2871 if (TopOfScreen
!= gMenuOption
.ForwardLink
) {
2872 TopOfScreen
= gMenuOption
.ForwardLink
;
2876 // Scroll up to the last page when we have arrived at top page.
2878 NewPos
= &gMenuOption
;
2879 TopOfScreen
= &gMenuOption
;
2880 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
2881 ScreenOperation
= UiPageUp
;
2882 ControlFlag
= CfScreenOperation
;
2885 } else if (MenuOption
->Row
< TopRow
+ DistanceValue
+ Difference
) {
2887 // Previous focus MenuOption is above the TopOfScreen, so we need to scroll
2889 TopOfScreen
= NewPos
;
2892 } else if (!IsSelectable (NextMenuOption
)) {
2894 // Continue to go up until scroll to next page or the selectable option is found.
2896 ScreenOperation
= UiUp
;
2897 ControlFlag
= CfScreenOperation
;
2901 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
2903 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
2904 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2905 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
2906 UpdateStatusBar (INPUT_ERROR
, FALSE
);
2908 if (NewPos
->ForwardLink
== &gMenuOption
) {
2914 // Scroll up to the last page.
2916 NewPos
= &gMenuOption
;
2917 TopOfScreen
= &gMenuOption
;
2918 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
2919 ScreenOperation
= UiPageUp
;
2920 ControlFlag
= CfScreenOperation
;
2927 // SkipValue means lines is skipped when show the top menu option.
2929 ControlFlag
= CfRepaint
;
2931 ASSERT(NewPos
!= NULL
);
2933 // Already at the first menu option, Check the skip value.
2935 if (NewPos
->BackLink
== &gMenuOption
) {
2936 if (SkipValue
== 0) {
2951 // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one
2952 // form of options to be show, so just update the SkipValue to show the next
2953 // parts of options.
2955 if (SkipValue
> (INTN
) (BottomRow
- TopRow
+ 1)) {
2956 SkipValue
-= BottomRow
- TopRow
+ 1;
2962 // First minus the menu of the top screen, it's value is SkipValue.
2964 Index
= (BottomRow
+ 1) - SkipValue
;
2965 while ((Index
> TopRow
) && (Link
->BackLink
!= &gMenuOption
)) {
2966 Link
= Link
->BackLink
;
2967 PreviousMenuOption
= MENU_OPTION_FROM_LINK (Link
);
2968 if (PreviousMenuOption
->Row
== 0) {
2969 UpdateOptionSkipLines (PreviousMenuOption
);
2971 if (Index
< PreviousMenuOption
->Skip
) {
2974 Index
= Index
- PreviousMenuOption
->Skip
;
2977 if ((Link
->BackLink
== &gMenuOption
) && (Index
>= TopRow
)) {
2978 if (TopOfScreen
== &gMenuOption
) {
2979 TopOfScreen
= gMenuOption
.ForwardLink
;
2980 NewPos
= gMenuOption
.BackLink
;
2981 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
);
2982 if (Index
< PreviousMenuOption
->Skip
) {
2984 SkipValue
= PreviousMenuOption
->Skip
- (Index
- TopRow
);
2989 } else if (TopOfScreen
!= Link
) {
2992 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
2996 // Finally we know that NewPos is the last MenuOption can be focused.
2998 if (SkipValue
== 0) {
3002 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
3006 if (Index
> TopRow
) {
3008 // At here, only case "Index < PreviousMenuOption->Skip" can reach here.
3010 SkipValue
= PreviousMenuOption
->Skip
- (Index
- TopRow
);
3011 } else if (Index
== TopRow
) {
3014 SkipValue
= TopRow
- Index
;
3018 // Move to the option in Next page.
3020 if (TopOfScreen
== &gMenuOption
) {
3021 NewPos
= gMenuOption
.BackLink
;
3022 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
);
3025 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
3029 // There are more MenuOption needing scrolling up.
3036 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3037 // Don't do this when we are already in the first page.
3039 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3040 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3045 // SkipValue means lines is skipped when show the top menu option.
3047 ControlFlag
= CfRepaint
;
3049 ASSERT (NewPos
!= NULL
);
3050 if (NewPos
->ForwardLink
== &gMenuOption
) {
3051 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3052 if (SkipValue
+ BottomRow
- TopRow
+ 1 < MenuOption
->Skip
) {
3053 SkipValue
+= BottomRow
- TopRow
+ 1;
3066 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3067 Index
= TopRow
+ NextMenuOption
->Skip
- SkipValue
;
3069 // Count to the menu option which will show at the top of the next form.
3071 while ((Index
<= BottomRow
+ 1) && (Link
->ForwardLink
!= &gMenuOption
)) {
3072 Link
= Link
->ForwardLink
;
3073 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3074 Index
= Index
+ NextMenuOption
->Skip
;
3077 if ((Link
->ForwardLink
== &gMenuOption
) && (Index
<= BottomRow
+ 1)) {
3079 // Finally we know that NewPos is the last MenuOption can be focused.
3082 MoveToNextStatement (TRUE
, &Link
, Index
- TopRow
);
3085 // Calculate the skip line for top of screen menu.
3087 if (Link
== TopOfScreen
) {
3089 // The top of screen menu option occupies the entire form.
3091 SkipValue
+= BottomRow
- TopRow
+ 1;
3093 SkipValue
= NextMenuOption
->Skip
- (Index
- (BottomRow
+ 1));
3099 // Move to the Next selectable menu.
3101 MoveToNextStatement (FALSE
, &Link
, BottomRow
- TopRow
);
3105 // Save the menu as the next highlight menu.
3110 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3111 // Don't do this when we are already in the last page.
3113 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3114 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3119 // SkipValue means lines is skipped when show the top menu option.
3120 // NewPos points to the menu which is highlighted now.
3122 ControlFlag
= CfRepaint
;
3125 // Since the behavior of hitting the down arrow on a Date/Time op-code is intended
3126 // to be one that progresses to the next set of op-codes, we need to advance to the last
3127 // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate
3128 // checking can be done. The only other logic we need to introduce is that if a Date/Time
3129 // op-code is the last entry in the menu, we need to rewind back to the first op-code of
3130 // the Date/Time op-code.
3132 SavedListEntry
= NewPos
;
3133 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3135 if (NewPos
->ForwardLink
!= &gMenuOption
) {
3136 if (NewPos
== TopOfScreen
) {
3142 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3144 NewPos
= NewPos
->ForwardLink
;
3148 // Current menu not at the bottom of the form.
3150 if (BottomRow
>= MenuOption
->Row
+ MenuOption
->Skip
- Temp2
) {
3152 // Find the next selectable menu.
3154 Difference
= MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- MenuOption
->Row
- MenuOption
->Skip
+ Temp2
);
3156 // We hit the end of MenuOption that can be focused
3157 // so we simply scroll to the first page.
3159 if (Difference
< 0) {
3161 // Scroll to the first page.
3163 if (TopOfScreen
!= gMenuOption
.ForwardLink
) {
3164 TopOfScreen
= gMenuOption
.ForwardLink
;
3168 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3170 NewPos
= gMenuOption
.ForwardLink
;
3171 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
3175 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3177 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3178 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3182 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3183 if (NextMenuOption
->Row
== 0) {
3184 UpdateOptionSkipLines (NextMenuOption
);
3186 DistanceValue
= Difference
+ NextMenuOption
->Skip
- Temp2
;
3188 Temp
= MenuOption
->Row
+ MenuOption
->Skip
+ DistanceValue
- 1;
3189 if ((MenuOption
->Row
+ MenuOption
->Skip
- Temp2
== BottomRow
+ 1) &&
3190 (NextMenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
||
3191 NextMenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
3197 // If we are going to scroll, update TopOfScreen
3199 if (Temp
> BottomRow
) {
3202 // Is the current top of screen a zero-advance op-code?
3203 // If so, keep moving forward till we hit a >0 advance op-code
3205 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3208 // If bottom op-code is more than one line or top op-code is more than one line
3210 if ((DistanceValue
> 1) || (SavedMenuOption
->Skip
> 1)) {
3212 // Is the bottom op-code greater than or equal in size to the top op-code?
3214 if ((Temp
- BottomRow
) >= (SavedMenuOption
->Skip
- SkipValue
)) {
3216 // Skip the top op-code
3218 TopOfScreen
= TopOfScreen
->ForwardLink
;
3219 Difference
= (Temp
- BottomRow
) - (SavedMenuOption
->Skip
- SkipValue
);
3221 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3224 // If we have a remainder, skip that many more op-codes until we drain the remainder
3226 while (Difference
>= (INTN
) SavedMenuOption
->Skip
) {
3228 // Since the Difference is greater than or equal to this op-code's skip value, skip it
3230 Difference
= Difference
- (INTN
) SavedMenuOption
->Skip
;
3231 TopOfScreen
= TopOfScreen
->ForwardLink
;
3232 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3235 // Since we will act on this op-code in the next routine, and increment the
3236 // SkipValue, set the skips to one less than what is required.
3238 SkipValue
= Difference
- 1;
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
+= (Temp
- BottomRow
) - 1;
3247 if ((SkipValue
+ 1) == (INTN
) SavedMenuOption
->Skip
) {
3248 TopOfScreen
= TopOfScreen
->ForwardLink
;
3253 // If the op-code at the top of the screen is more than one line, let's not skip it yet
3254 // Let's set a skip flag to smoothly scroll the top of the screen.
3256 if (SavedMenuOption
->Skip
> 1) {
3257 if (SavedMenuOption
== NextMenuOption
) {
3262 } else if (SavedMenuOption
->Skip
== 1) {
3266 TopOfScreen
= TopOfScreen
->ForwardLink
;
3268 } while (SavedMenuOption
->Skip
== 0);
3271 } else if (!IsSelectable (NextMenuOption
)) {
3273 // Continue to go down until scroll to next page or the selectable option is found.
3275 ScreenOperation
= UiDown
;
3276 ControlFlag
= CfScreenOperation
;
3279 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3281 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3285 // Scroll to the first page.
3287 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3288 TopOfScreen
= gMenuOption
.ForwardLink
;
3293 // Need to remove the current highlight menu.
3294 // MenuOption saved the last highlight menu info.
3296 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3302 // Get the next highlight menu.
3304 NewPos
= gMenuOption
.ForwardLink
;
3305 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
);
3309 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3311 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3312 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3315 case CfUiNoOperation
:
3316 ControlFlag
= CfRepaint
;
3320 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
3321 if (HelpString
!= NULL
) {
3322 FreePool (HelpString
);
3324 if (HelpHeaderString
!= NULL
) {
3325 FreePool (HelpHeaderString
);
3327 if (HelpBottomString
!= NULL
) {
3328 FreePool (HelpBottomString
);
3340 Base on the browser status info to show an pop up message.
3344 BrowserStatusProcess (
3351 if (gFormData
->BrowserStatus
== BROWSER_SUCCESS
) {
3355 if (gFormData
->ErrorString
!= NULL
) {
3356 ErrorInfo
= gFormData
->ErrorString
;
3358 switch (gFormData
->BrowserStatus
) {
3359 case BROWSER_SUBMIT_FAIL
:
3360 ErrorInfo
= gSaveFailed
;
3363 case BROWSER_NO_SUBMIT_IF
:
3364 ErrorInfo
= gNoSubmitIf
;
3367 case BROWSER_FORM_NOT_FOUND
:
3368 ErrorInfo
= gFormNotFound
;
3371 case BROWSER_FORM_SUPPRESS
:
3372 ErrorInfo
= gFormSuppress
;
3375 case BROWSER_PROTOCOL_NOT_FOUND
:
3376 ErrorInfo
= gProtocolNotFound
;
3380 ErrorInfo
= gBrwoserError
;
3386 // Error occur, prompt error message.
3389 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, gPressEnter
, gEmptyString
, NULL
);
3390 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
3394 Display one form, and return user input.
3396 @param FormData Form Data to be shown.
3397 @param UserInputData User input data.
3399 @retval EFI_SUCCESS 1.Form Data is shown, and user input is got.
3400 2.Error info has show and return.
3401 @retval EFI_INVALID_PARAMETER The input screen dimension is not valid
3402 @retval EFI_NOT_FOUND New form data has some error.
3407 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
3408 OUT USER_INPUT
*UserInputData
3413 ASSERT (FormData
!= NULL
);
3414 if (FormData
== NULL
) {
3415 return EFI_INVALID_PARAMETER
;
3418 gUserInput
= UserInputData
;
3419 gFormData
= FormData
;
3422 // Process the status info first.
3424 BrowserStatusProcess();
3425 if (UserInputData
== NULL
) {
3427 // UserInputData == NULL, means only need to print the error info, return here.
3432 ConvertStatementToMenu();
3434 Status
= DisplayPageFrame (FormData
, &gStatementDimensions
);
3435 if (EFI_ERROR (Status
)) {
3440 // Check whether layout is changed.
3443 || (gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
)
3444 || (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))
3445 || (gOldFormEntry
.FormId
!= FormData
->FormId
)) {
3446 mStatementLayoutIsChanged
= TRUE
;
3448 mStatementLayoutIsChanged
= FALSE
;
3451 Status
= UiDisplayMenu(FormData
);
3454 // Backup last form info.
3456 mIsFirstForm
= FALSE
;
3457 gOldFormEntry
.HiiHandle
= FormData
->HiiHandle
;
3458 CopyGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
);
3459 gOldFormEntry
.FormId
= FormData
->FormId
;
3465 Clear Screen to the initial state.
3469 DriverClearDisplayPage (
3473 ClearDisplayPage ();
3474 mIsFirstForm
= TRUE
;
3478 Set Buffer to Value for Size bytes.
3480 @param Buffer Memory to set.
3481 @param Size Number of bytes to set
3482 @param Value Value of the set operation.
3495 while ((Size
--) != 0) {
3501 Initialize Setup Browser driver.
3503 @param ImageHandle The image handle.
3504 @param SystemTable The system table.
3506 @retval EFI_SUCCESS The Setup Browser module is initialized correctly..
3507 @return Other value if failed to initialize the Setup Browser module.
3512 InitializeDisplayEngine (
3513 IN EFI_HANDLE ImageHandle
,
3514 IN EFI_SYSTEM_TABLE
*SystemTable
3518 EFI_INPUT_KEY HotKey
;
3519 EFI_STRING NewString
;
3520 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL
*FormBrowserEx2
;
3523 // Publish our HII data
3525 gHiiHandle
= HiiAddPackages (
3526 &gDisplayEngineGuid
,
3528 DisplayEngineStrings
,
3531 ASSERT (gHiiHandle
!= NULL
);
3534 // Install Form Display protocol
3536 Status
= gBS
->InstallProtocolInterface (
3537 &mPrivateData
.Handle
,
3538 &gEdkiiFormDisplayEngineProtocolGuid
,
3539 EFI_NATIVE_INTERFACE
,
3540 &mPrivateData
.FromDisplayProt
3542 ASSERT_EFI_ERROR (Status
);
3544 InitializeDisplayStrings();
3546 ZeroMem (&gHighligthMenuInfo
, sizeof (gHighligthMenuInfo
));
3547 ZeroMem (&gOldFormEntry
, sizeof (gOldFormEntry
));
3550 // Use BrowserEx2 protocol to register HotKey.
3552 Status
= gBS
->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid
, NULL
, (VOID
**) &FormBrowserEx2
);
3553 if (!EFI_ERROR (Status
)) {
3555 // Register the default HotKey F9 and F10 again.
3557 HotKey
.UnicodeChar
= CHAR_NULL
;
3558 HotKey
.ScanCode
= SCAN_F10
;
3559 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_TEN_STRING
), NULL
);
3560 ASSERT (NewString
!= NULL
);
3561 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_SUBMIT
, 0, NewString
);
3563 HotKey
.ScanCode
= SCAN_F9
;
3564 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_NINE_STRING
), NULL
);
3565 ASSERT (NewString
!= NULL
);
3566 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_DEFAULT
, EFI_HII_DEFAULT_CLASS_STANDARD
, NewString
);
3573 This is the default unload handle for display core drivers.
3575 @param[in] ImageHandle The drivers' driver image.
3577 @retval EFI_SUCCESS The image is unloaded.
3578 @retval Others Failed to unload the image.
3583 UnloadDisplayEngine (
3584 IN EFI_HANDLE ImageHandle
3587 HiiRemovePackages(gHiiHandle
);
3589 FreeDisplayStrings ();