2 Entry and initialization module for the browser.
4 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "FormDisplay.h"
19 // Search table for UiDisplayMenu()
21 SCAN_CODE_TO_SCREEN_OPERATION gScanCodeToOperation
[] = {
52 UINTN mScanCodeNumber
= sizeof (gScanCodeToOperation
) / sizeof (gScanCodeToOperation
[0]);
54 SCREEN_OPERATION_T0_CONTROL_FLAG gScreenOperationToControlFlag
[] = {
97 EFI_GUID gDisplayEngineGuid
= {
98 0xE38C1029, 0xE38F, 0x45b9, {0x8F, 0x0D, 0xE2, 0xE6, 0x0B, 0xC9, 0xB2, 0x62}
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
*gNoSubmitIfFailed
;
121 CHAR16
*gSaveProcess
;
122 CHAR16
*gSaveNoSubmitProcess
;
123 CHAR16
*gDiscardChange
;
124 CHAR16
*gJumpToFormSet
;
126 CHAR16
*gPromptForData
;
127 CHAR16
*gPromptForPassword
;
128 CHAR16
*gPromptForNewPassword
;
129 CHAR16
*gConfirmPassword
;
130 CHAR16
*gConfirmError
;
131 CHAR16
*gPassowordInvalid
;
133 CHAR16
*gEmptyString
;
135 CHAR16
*gOptionMismatch
;
136 CHAR16
*gFormSuppress
;
137 CHAR16
*gProtocolNotFound
;
139 CHAR16 gModalSkipColumn
;
140 CHAR16 gPromptBlockWidth
;
141 CHAR16 gOptionBlockWidth
;
142 CHAR16 gHelpBlockWidth
;
143 CHAR16
*mUnknownString
;
145 FORM_DISPLAY_DRIVER_PRIVATE_DATA mPrivateData
= {
146 FORM_DISPLAY_DRIVER_SIGNATURE
,
150 DriverClearDisplayPage
,
157 Get the string based on the StringId and HII Package List Handle.
159 @param Token The String's ID.
160 @param HiiHandle The package list in the HII database to search for
161 the specified string.
163 @return The output string.
168 IN EFI_STRING_ID Token
,
169 IN EFI_HII_HANDLE HiiHandle
174 String
= HiiGetString (HiiHandle
, Token
, NULL
);
175 if (String
== NULL
) {
176 String
= AllocateCopyPool (StrSize (mUnknownString
), mUnknownString
);
177 ASSERT (String
!= NULL
);
180 return (CHAR16
*) String
;
185 Initialize the HII String Token to the correct values.
189 InitializeDisplayStrings (
193 mUnknownString
= GetToken (STRING_TOKEN (UNKNOWN_STRING
), gHiiHandle
);
194 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
195 gNoSubmitIfFailed
= GetToken (STRING_TOKEN (NO_SUBMIT_IF_CHECK_FAILED
), gHiiHandle
);
196 gSaveProcess
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP
), gHiiHandle
);
197 gSaveNoSubmitProcess
= GetToken (STRING_TOKEN (DISCARD_OR_CHECK
), gHiiHandle
);
198 gDiscardChange
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP_DISCARD
), gHiiHandle
);
199 gJumpToFormSet
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP_JUMP
), gHiiHandle
);
200 gCheckError
= GetToken (STRING_TOKEN (DISCARD_OR_CHECK_CHECK
), gHiiHandle
);
201 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
202 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
203 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
204 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
205 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
206 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
207 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
208 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
209 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
210 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
211 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
212 gProtocolNotFound
= GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND
), gHiiHandle
);
213 gFormNotFound
= GetToken (STRING_TOKEN (STATUS_BROWSER_FORM_NOT_FOUND
), gHiiHandle
);
214 gNoSubmitIf
= GetToken (STRING_TOKEN (STATUS_BROWSER_NO_SUBMIT_IF
), gHiiHandle
);
215 gBrwoserError
= GetToken (STRING_TOKEN (STATUS_BROWSER_ERROR
), gHiiHandle
);
219 Free up the resource allocated for all strings required
228 FreePool (mUnknownString
);
229 FreePool (gEmptyString
);
230 FreePool (gSaveFailed
);
231 FreePool (gNoSubmitIfFailed
);
232 FreePool (gSaveProcess
);
233 FreePool (gSaveNoSubmitProcess
);
234 FreePool (gDiscardChange
);
235 FreePool (gJumpToFormSet
);
236 FreePool (gCheckError
);
237 FreePool (gPromptForData
);
238 FreePool (gPromptForPassword
);
239 FreePool (gPromptForNewPassword
);
240 FreePool (gConfirmPassword
);
241 FreePool (gConfirmError
);
242 FreePool (gPassowordInvalid
);
243 FreePool (gPressEnter
);
244 FreePool (gMiniString
);
245 FreePool (gOptionMismatch
);
246 FreePool (gFormSuppress
);
247 FreePool (gProtocolNotFound
);
248 FreePool (gBrwoserError
);
249 FreePool (gNoSubmitIf
);
250 FreePool (gFormNotFound
);
254 Get prompt string id from the opcode data buffer.
256 @param OpCode The input opcode buffer.
258 @return The prompt string id.
263 IN EFI_IFR_OP_HEADER
*OpCode
266 EFI_IFR_STATEMENT_HEADER
*Header
;
268 if (OpCode
->Length
<= sizeof (EFI_IFR_OP_HEADER
)) {
272 Header
= (EFI_IFR_STATEMENT_HEADER
*) (OpCode
+ 1);
274 return Header
->Prompt
;
278 Get the supported width for a particular op-code
280 @param MenuOption The menu option.
281 @param AdjustWidth The width which is saved for the space.
283 @return Returns the number of CHAR16 characters that is support.
288 IN UI_MENU_OPTION
*MenuOption
,
289 OUT UINT16
*AdjustWidth
294 EFI_IFR_TEXT
*TestOp
;
296 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
298 Statement
= MenuOption
->ThisTag
;
301 // For modal form, clean the entire row.
303 if ((gFormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
304 if (AdjustWidth
!= NULL
) {
305 *AdjustWidth
= LEFT_SKIPPED_COLUMNS
;
307 return (UINT16
)(gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gModalSkipColumn
+ LEFT_SKIPPED_COLUMNS
));
313 // See if the second text parameter is really NULL
315 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
316 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
317 if (TestOp
->TextTwo
!= 0) {
318 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
319 Size
= StrLen (String
);
324 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
325 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
326 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
327 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
328 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
330 // Allow a wide display if text op-code and no secondary text op-code
332 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
336 // Return the space width.
338 if (AdjustWidth
!= NULL
) {
342 // Keep consistent with current behavior.
344 ReturnWidth
= (UINT16
) (gPromptBlockWidth
+ gOptionBlockWidth
- 2);
346 if (AdjustWidth
!= NULL
) {
350 ReturnWidth
= (UINT16
) (gPromptBlockWidth
- 1);
354 // For nest in statement, should the subtitle indent.
356 if (MenuOption
->NestInStatement
) {
357 ReturnWidth
-= SUBTITLE_INDENT
;
364 Will copy LineWidth amount of a string in the OutputString buffer and return the
365 number of CHAR16 characters that were copied into the OutputString buffer.
366 The output string format is:
367 Glyph Info + String info + '\0'.
369 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
371 @param InputString String description for this option.
372 @param LineWidth Width of the desired string to extract in CHAR16
374 @param GlyphWidth The glyph width of the begin of the char in the string.
375 @param Index Where in InputString to start the copy process
376 @param OutputString Buffer to copy the string into
378 @return Returns the number of CHAR16 characters that were copied into the OutputString
379 buffer, include extra glyph info and '\0' info.
384 IN CHAR16
*InputString
,
386 IN OUT UINT16
*GlyphWidth
,
388 OUT CHAR16
**OutputString
393 UINT16 OriginalGlyphWidth
;
395 UINT16 LastSpaceOffset
;
396 UINT16 LastGlyphWidth
;
398 if (InputString
== NULL
|| Index
== NULL
|| OutputString
== NULL
) {
402 if (LineWidth
== 0 || *GlyphWidth
== 0) {
407 // Save original glyph width.
409 OriginalGlyphWidth
= *GlyphWidth
;
410 LastGlyphWidth
= OriginalGlyphWidth
;
415 // 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.
416 // To avoid displaying this empty line in screen, just skip the two CHARs here.
418 if ((InputString
[*Index
] == NARROW_CHAR
) && (InputString
[*Index
+ 1] == CHAR_CARRIAGE_RETURN
)) {
423 // Fast-forward the string and see if there is a carriage-return in the string
425 for (StrOffset
= 0, GlyphOffset
= 0; GlyphOffset
<= LineWidth
; StrOffset
++) {
426 switch (InputString
[*Index
+ StrOffset
]) {
435 case CHAR_CARRIAGE_RETURN
:
442 GlyphOffset
= GlyphOffset
+ *GlyphWidth
;
445 // Record the last space info in this line. Will be used in rewind.
447 if ((InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) && (GlyphOffset
<= LineWidth
)) {
448 LastSpaceOffset
= StrOffset
;
449 LastGlyphWidth
= *GlyphWidth
;
460 // Rewind the string from the maximum size until we see a space to break the line
462 if (GlyphOffset
> LineWidth
) {
464 // Rewind the string to last space char in this line.
466 if (LastSpaceOffset
!= 0) {
467 StrOffset
= LastSpaceOffset
;
468 *GlyphWidth
= LastGlyphWidth
;
471 // Roll back to last char in the line width.
478 // The CHAR_NULL has process last time, this time just return 0 to stand for the end.
480 if (StrOffset
== 0 && (InputString
[*Index
+ StrOffset
] == CHAR_NULL
)) {
485 // Need extra glyph info and '\0' info, so +2.
487 *OutputString
= AllocateZeroPool (((UINTN
) (StrOffset
+ 2) * sizeof(CHAR16
)));
488 if (*OutputString
== NULL
) {
493 // Save the glyph info at the begin of the string, will used by Print function.
495 if (OriginalGlyphWidth
== 1) {
496 *(*OutputString
) = NARROW_CHAR
;
498 *(*OutputString
) = WIDE_CHAR
;
501 CopyMem ((*OutputString
) + 1, &InputString
[*Index
], StrOffset
* sizeof(CHAR16
));
503 if (InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) {
505 // Skip the space info at the begin of next line.
507 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
508 } else if (InputString
[*Index
+ StrOffset
] == CHAR_LINEFEED
) {
510 // Skip the /n or /n/r info.
512 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_CARRIAGE_RETURN
) {
513 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
515 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
517 } else if (InputString
[*Index
+ StrOffset
] == CHAR_CARRIAGE_RETURN
) {
519 // Skip the /r or /r/n info.
521 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_LINEFEED
) {
522 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
524 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
527 *Index
= (UINT16
) (*Index
+ StrOffset
);
531 // Include extra glyph info and '\0' info, so +2.
533 return StrOffset
+ 2;
537 Add one menu option by specified description and context.
539 @param Statement Statement of this Menu Option.
540 @param MenuItemCount The index for this Option in the Menu.
541 @param NestIn Whether this statement is nest in another statement.
546 IN FORM_DISPLAY_ENGINE_STATEMENT
*Statement
,
547 IN UINT16
*MenuItemCount
,
551 UI_MENU_OPTION
*MenuOption
;
555 UINT16 NumberOfLines
;
559 CHAR16
*OutputString
;
560 EFI_STRING_ID PromptId
;
568 PromptId
= GetPrompt (Statement
->OpCode
);
569 ASSERT (PromptId
!= 0);
571 String
= GetToken (PromptId
, gFormData
->HiiHandle
);
572 ASSERT (String
!= NULL
);
574 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
578 for (Index
= 0; Index
< Count
; Index
++) {
579 MenuOption
= AllocateZeroPool (sizeof (UI_MENU_OPTION
));
582 MenuOption
->Signature
= UI_MENU_OPTION_SIGNATURE
;
583 MenuOption
->Description
= String
;
584 MenuOption
->Handle
= gFormData
->HiiHandle
;
585 MenuOption
->ThisTag
= Statement
;
586 MenuOption
->NestInStatement
= NestIn
;
587 MenuOption
->EntryNumber
= *MenuItemCount
;
589 MenuOption
->Sequence
= Index
;
591 if ((Statement
->Attribute
& HII_DISPLAY_GRAYOUT
) != 0) {
592 MenuOption
->GrayOut
= TRUE
;
594 MenuOption
->GrayOut
= FALSE
;
597 if ((Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
598 MenuOption
->GrayOut
= TRUE
;
602 // If the form or the question has the lock attribute, deal same as grayout.
604 if ((gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
605 MenuOption
->GrayOut
= TRUE
;
608 switch (Statement
->OpCode
->OpCode
) {
609 case EFI_IFR_ORDERED_LIST_OP
:
610 case EFI_IFR_ONE_OF_OP
:
611 case EFI_IFR_NUMERIC_OP
:
612 case EFI_IFR_TIME_OP
:
613 case EFI_IFR_DATE_OP
:
614 case EFI_IFR_CHECKBOX_OP
:
615 case EFI_IFR_PASSWORD_OP
:
616 case EFI_IFR_STRING_OP
:
618 // User could change the value of these items
620 MenuOption
->IsQuestion
= TRUE
;
622 case EFI_IFR_TEXT_OP
:
623 if (FeaturePcdGet (PcdBrowserGrayOutTextStatement
)) {
625 // Initializing GrayOut option as TRUE for Text setup options
626 // so that those options will be Gray in colour and un selectable.
628 MenuOption
->GrayOut
= TRUE
;
632 MenuOption
->IsQuestion
= FALSE
;
636 if ((Statement
->Attribute
& HII_DISPLAY_READONLY
) != 0) {
637 MenuOption
->ReadOnly
= TRUE
;
638 if (FeaturePcdGet (PcdBrowerGrayOutReadOnlyMenu
)) {
639 MenuOption
->GrayOut
= TRUE
;
644 (Statement
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
645 (Statement
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
646 Width
= GetWidth (MenuOption
, NULL
);
647 for (; GetLineByWidth (String
, Width
, &GlyphWidth
,&ArrayEntry
, &OutputString
) != 0x0000;) {
649 // If there is more string to process print on the next row and increment the Skip value
651 if (StrLen (&String
[ArrayEntry
]) != 0) {
654 FreePool (OutputString
);
658 // Add three MenuOptions for Date/Time
659 // Data format : [01/02/2004] [11:22:33]
660 // Line number : 0 0 1 0 0 1
667 // Override LineNumber for the MenuOption in Date/Time sequence
669 MenuOption
->Skip
= 1;
671 MenuOption
->Skip
= NumberOfLines
;
674 InsertTailList (&gMenuOption
, &MenuOption
->Link
);
681 Create the menu list base on the form data info.
685 ConvertStatementToMenu (
689 UINT16 MenuItemCount
;
691 LIST_ENTRY
*NestLink
;
692 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
693 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
696 InitializeListHead (&gMenuOption
);
698 Link
= GetFirstNode (&gFormData
->StatementListHead
);
699 while (!IsNull (&gFormData
->StatementListHead
, Link
)) {
700 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
701 Link
= GetNextNode (&gFormData
->StatementListHead
, Link
);
704 // Skip the opcode not recognized by Display core.
706 if (Statement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
710 UiAddMenuOption (Statement
, &MenuItemCount
, FALSE
);
713 // Check the statement nest in this host statement.
715 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
716 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
717 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
718 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
721 // Skip the opcode not recognized by Display core.
723 if (NestStatement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
727 UiAddMenuOption (NestStatement
, &MenuItemCount
, TRUE
);
733 Count the storage space of a Unicode string.
735 This function handles the Unicode string with NARROW_CHAR
736 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
737 does not count in the resultant output. If a WIDE_CHAR is
738 hit, then 2 Unicode character will consume an output storage
739 space with size of CHAR16 till a NARROW_CHAR is hit.
741 If String is NULL, then ASSERT ().
743 @param String The input string to be counted.
745 @return Storage space for the input string.
755 UINTN IncrementValue
;
757 ASSERT (String
!= NULL
);
758 if (String
== NULL
) {
768 // Advance to the null-terminator or to the first width directive
771 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
772 Index
++, Count
= Count
+ IncrementValue
777 // We hit the null-terminator, we now have a count
779 if (String
[Index
] == 0) {
783 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
784 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
786 if (String
[Index
] == NARROW_CHAR
) {
788 // Skip to the next character
794 // Skip to the next character
799 } while (String
[Index
] != 0);
802 // Increment by one to include the null-terminator in the size
806 return Count
* sizeof (CHAR16
);
810 Base on the input option string to update the skip value for a menu option.
812 @param MenuOption The MenuOption to be checked.
813 @param OptionString The input option string.
817 UpdateSkipInfoForMenu (
818 IN UI_MENU_OPTION
*MenuOption
,
819 IN CHAR16
*OptionString
825 CHAR16
*OutputString
;
828 Width
= (UINT16
) gOptionBlockWidth
;
832 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
833 if (StrLen (&OptionString
[Index
]) != 0) {
837 FreePool (OutputString
);
840 if ((Row
> MenuOption
->Skip
) &&
841 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
842 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
843 MenuOption
->Skip
= Row
;
848 Update display lines for a Menu Option.
850 @param MenuOption The MenuOption to be checked.
854 UpdateOptionSkipLines (
855 IN UI_MENU_OPTION
*MenuOption
858 CHAR16
*OptionString
;
862 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
863 if (OptionString
!= NULL
) {
864 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
866 FreePool (OptionString
);
869 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
870 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
872 if (OptionString
!= NULL
) {
873 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
875 FreePool (OptionString
);
881 Check whether this Menu Option could be print.
883 Check Prompt string, option string or text two string not NULL.
885 This is an internal function.
887 @param MenuOption The MenuOption to be checked.
889 @retval TRUE This Menu Option is printable.
890 @retval FALSE This Menu Option could not be printable.
895 UI_MENU_OPTION
*MenuOption
899 EFI_STRING OptionString
;
903 if (MenuOption
->Description
[0] != '\0') {
907 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
908 if (EFI_ERROR (Status
)) {
911 if (OptionString
!= NULL
&& OptionString
[0] != '\0') {
912 FreePool (OptionString
);
916 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
917 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
918 ASSERT (OptionString
!= NULL
);
919 if (OptionString
[0] != '\0'){
920 FreePool (OptionString
);
929 Check whether this Menu Option could be highlighted.
931 This is an internal function.
933 @param MenuOption The MenuOption to be checked.
935 @retval TRUE This Menu Option is selectable.
936 @retval FALSE This Menu Option could not be selected.
941 UI_MENU_OPTION
*MenuOption
944 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
945 MenuOption
->GrayOut
|| MenuOption
->ReadOnly
|| !PrintableMenu (MenuOption
)) {
953 Move to next selectable statement.
955 This is an internal function.
957 @param GoUp The navigation direction. TRUE: up, FALSE: down.
958 @param CurrentPosition Current position.
959 @param GapToTop Gap position to top or bottom.
960 @param FindInForm Whether find menu in current form or beyond.
962 @return The row distance from current MenuOption to next selectable MenuOption.
964 @retval -1 Reach the begin of the menu, still can't find the selectable menu.
965 @retval Value Find the selectable menu, maybe the truly selectable, maybe the
966 first menu showing beyond current form or last menu showing in
968 The value is the line number between the new selected menu and the
969 current select menu, not include the new selected menu.
973 MoveToNextStatement (
975 IN OUT LIST_ENTRY
**CurrentPosition
,
977 IN BOOLEAN FindInForm
982 UI_MENU_OPTION
*NextMenuOption
;
983 UI_MENU_OPTION
*PreMenuOption
;
986 Pos
= *CurrentPosition
;
988 if (Pos
== &gMenuOption
) {
992 PreMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
995 NextMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
997 // NextMenuOption->Row == 0 means this menu has not calculate
998 // the NextMenuOption->Skip value yet, just calculate here.
1000 if (NextMenuOption
->Row
== 0) {
1001 UpdateOptionSkipLines (NextMenuOption
);
1004 if (IsSelectable (NextMenuOption
)) {
1009 // In this case, still can't find the selectable menu,
1010 // return the first one beyond the showing form.
1012 if ((UINTN
) Distance
+ NextMenuOption
->Skip
> GapToTop
) {
1014 NextMenuOption
= PreMenuOption
;
1019 Distance
+= NextMenuOption
->Skip
;
1022 // Arrive at begin of the menu list.
1024 if ((GoUp
? Pos
->BackLink
: Pos
->ForwardLink
) == &gMenuOption
) {
1029 Pos
= (GoUp
? Pos
->BackLink
: Pos
->ForwardLink
);
1030 PreMenuOption
= NextMenuOption
;
1033 *CurrentPosition
= &NextMenuOption
->Link
;
1039 Process option string for date/time opcode.
1041 @param MenuOption Menu option point to date/time.
1042 @param OptionString Option string input for process.
1043 @param AddOptCol Whether need to update MenuOption->OptCol.
1047 ProcessStringForDateTime (
1048 UI_MENU_OPTION
*MenuOption
,
1049 CHAR16
*OptionString
,
1055 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1059 ASSERT (MenuOption
!= NULL
&& OptionString
!= NULL
);
1061 Statement
= MenuOption
->ThisTag
;
1064 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1065 Date
= (EFI_IFR_DATE
*) Statement
->OpCode
;
1066 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1067 Time
= (EFI_IFR_TIME
*) Statement
->OpCode
;
1071 // If leading spaces on OptionString - remove the spaces
1073 for (Index
= 0; OptionString
[Index
] == L
' '; Index
++) {
1075 // Base on the blockspace to get the option column info.
1078 MenuOption
->OptCol
++;
1082 for (Count
= 0; OptionString
[Index
] != CHAR_NULL
; Index
++) {
1083 OptionString
[Count
] = OptionString
[Index
];
1086 OptionString
[Count
] = CHAR_NULL
;
1089 // Enable to suppress field in the opcode base on the flag.
1091 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1093 // OptionString format is: <**: **: ****>
1097 if ((Date
->Flags
& EFI_QF_DATE_MONTH_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1099 // At this point, only "<**:" in the optionstring.
1100 // Clean the day's ** field, after clean, the format is "< :"
1102 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1103 } else if ((Date
->Flags
& EFI_QF_DATE_DAY_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1105 // At this point, only "**:" in the optionstring.
1106 // Clean the month's "**" field, after clean, the format is " :"
1108 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1109 } else if ((Date
->Flags
& EFI_QF_DATE_YEAR_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1111 // At this point, only "****>" in the optionstring.
1112 // Clean the year's "****" field, after clean, the format is " >"
1114 SetUnicodeMem (&OptionString
[0], 4, L
' ');
1116 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1118 // OptionString format is: <**: **: **>
1119 // |hour|minute|second|
1122 if ((Time
->Flags
& QF_TIME_HOUR_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1124 // At this point, only "<**:" in the optionstring.
1125 // Clean the hour's ** field, after clean, the format is "< :"
1127 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1128 } else if ((Time
->Flags
& QF_TIME_MINUTE_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1130 // At this point, only "**:" in the optionstring.
1131 // Clean the minute's "**" field, after clean, the format is " :"
1133 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1134 } else if ((Time
->Flags
& QF_TIME_SECOND_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1136 // At this point, only "**>" in the optionstring.
1137 // Clean the second's "**" field, after clean, the format is " >"
1139 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1146 Adjust Data and Time position accordingly.
1147 Data format : [01/02/2004] [11:22:33]
1148 Line number : 0 0 1 0 0 1
1150 This is an internal function.
1152 @param DirectionUp the up or down direction. False is down. True is
1154 @param CurrentPosition Current position. On return: Point to the last
1155 Option (Year or Second) if up; Point to the first
1156 Option (Month or Hour) if down.
1158 @return Return line number to pad. It is possible that we stand on a zero-advance
1159 @return data or time opcode, so pad one line when we judge if we are going to scroll outside.
1163 AdjustDateAndTimePosition (
1164 IN BOOLEAN DirectionUp
,
1165 IN OUT LIST_ENTRY
**CurrentPosition
1169 LIST_ENTRY
*NewPosition
;
1170 UI_MENU_OPTION
*MenuOption
;
1171 UINTN PadLineNumber
;
1174 NewPosition
= *CurrentPosition
;
1175 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1177 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) ||
1178 (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
1180 // Calculate the distance from current position to the last Date/Time MenuOption
1183 while (MenuOption
->Skip
== 0) {
1185 NewPosition
= NewPosition
->ForwardLink
;
1186 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1190 NewPosition
= *CurrentPosition
;
1193 // Since the behavior of hitting the up arrow on a Date/Time MenuOption is intended
1194 // to be one that back to the previous set of MenuOptions, we need to advance to the first
1195 // Date/Time MenuOption and leave the remaining logic in CfUiUp intact so the appropriate
1196 // checking can be done.
1198 while (Count
++ < 2) {
1199 NewPosition
= NewPosition
->BackLink
;
1203 // Since the behavior of hitting the down arrow on a Date/Time MenuOption is intended
1204 // to be one that progresses to the next set of MenuOptions, we need to advance to the last
1205 // Date/Time MenuOption and leave the remaining logic in CfUiDown intact so the appropriate
1206 // checking can be done.
1208 while (Count
-- > 0) {
1209 NewPosition
= NewPosition
->ForwardLink
;
1213 *CurrentPosition
= NewPosition
;
1216 return PadLineNumber
;
1220 Get step info from numeric opcode.
1222 @param[in] OpCode The input numeric op code.
1224 @return step info for this opcode.
1228 IN EFI_IFR_OP_HEADER
*OpCode
1231 EFI_IFR_NUMERIC
*NumericOp
;
1234 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
1236 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1237 case EFI_IFR_NUMERIC_SIZE_1
:
1238 Step
= NumericOp
->data
.u8
.Step
;
1241 case EFI_IFR_NUMERIC_SIZE_2
:
1242 Step
= NumericOp
->data
.u16
.Step
;
1245 case EFI_IFR_NUMERIC_SIZE_4
:
1246 Step
= NumericOp
->data
.u32
.Step
;
1249 case EFI_IFR_NUMERIC_SIZE_8
:
1250 Step
= NumericOp
->data
.u64
.Step
;
1262 Find the registered HotKey based on KeyData.
1264 @param[in] KeyData A pointer to a buffer that describes the keystroke
1265 information for the hot key.
1267 @return The registered HotKey context. If no found, NULL will return.
1270 GetHotKeyFromRegisterList (
1271 IN EFI_INPUT_KEY
*KeyData
1275 BROWSER_HOT_KEY
*HotKey
;
1277 Link
= GetFirstNode (&gFormData
->HotKeyListHead
);
1278 while (!IsNull (&gFormData
->HotKeyListHead
, Link
)) {
1279 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
1281 if (HotKey
->KeyData
->ScanCode
== KeyData
->ScanCode
) {
1285 Link
= GetNextNode (&gFormData
->HotKeyListHead
, Link
);
1293 Determine if the menu is the last menu that can be selected.
1295 This is an internal function.
1297 @param Direction The scroll direction. False is down. True is up.
1298 @param CurrentPos The current focus.
1300 @return FALSE -- the menu isn't the last menu that can be selected.
1301 @return TRUE -- the menu is the last menu that can be selected.
1306 IN BOOLEAN Direction
,
1307 IN LIST_ENTRY
*CurrentPos
1312 Temp
= Direction
? CurrentPos
->BackLink
: CurrentPos
->ForwardLink
;
1314 if (Temp
== &gMenuOption
) {
1322 Wait for a given event to fire, or for an optional timeout to expire.
1324 @param Event The event to wait for
1326 @retval UI_EVENT_TYPE The type of the event which is trigged.
1338 EFI_EVENT TimerEvent
;
1339 EFI_EVENT WaitList
[3];
1340 UI_EVENT_TYPE EventType
;
1343 Timeout
= FormExitTimeout(gFormData
);
1346 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
1349 // Set the timer event
1358 WaitList
[0] = Event
;
1360 if (gFormData
->FormRefreshEvent
!= NULL
) {
1361 WaitList
[EventNum
] = gFormData
->FormRefreshEvent
;
1366 WaitList
[EventNum
] = TimerEvent
;
1370 Status
= gBS
->WaitForEvent (EventNum
, WaitList
, &Index
);
1371 ASSERT_EFI_ERROR (Status
);
1375 EventType
= UIEventKey
;
1379 if (gFormData
->FormRefreshEvent
!= NULL
) {
1380 EventType
= UIEventDriver
;
1382 ASSERT (Timeout
!= 0 && EventNum
== 2);
1383 EventType
= UIEventTimeOut
;
1388 ASSERT (Index
== 2 && EventNum
== 3);
1389 EventType
= UIEventTimeOut
;
1394 gBS
->CloseEvent (TimerEvent
);
1401 Get question id info from the input opcode header.
1403 @param OpCode The input opcode header pointer.
1405 @retval The question id for this opcode.
1410 IN EFI_IFR_OP_HEADER
*OpCode
1413 EFI_IFR_QUESTION_HEADER
*QuestionHeader
;
1415 if (OpCode
->Length
< sizeof (EFI_IFR_OP_HEADER
) + sizeof (EFI_IFR_QUESTION_HEADER
)) {
1419 QuestionHeader
= (EFI_IFR_QUESTION_HEADER
*)((UINT8
*) OpCode
+ sizeof(EFI_IFR_OP_HEADER
));
1421 return QuestionHeader
->QuestionId
;
1426 Find the top of screen menu base on the current menu.
1428 @param CurPos Current input menu.
1429 @param Rows Totol screen rows.
1430 @param SkipValue SkipValue for this new form.
1432 @retval TopOfScreen Top of screen menu for the new form.
1436 FindTopOfScreenMenu (
1437 IN LIST_ENTRY
*CurPos
,
1439 OUT UINTN
*SkipValue
1443 LIST_ENTRY
*TopOfScreen
;
1444 UI_MENU_OPTION
*PreviousMenuOption
;
1447 PreviousMenuOption
= NULL
;
1449 while (Link
->BackLink
!= &gMenuOption
) {
1450 Link
= Link
->BackLink
;
1451 PreviousMenuOption
= MENU_OPTION_FROM_LINK (Link
);
1452 if (PreviousMenuOption
->Row
== 0) {
1453 UpdateOptionSkipLines (PreviousMenuOption
);
1455 if (Rows
<= PreviousMenuOption
->Skip
) {
1458 Rows
= Rows
- PreviousMenuOption
->Skip
;
1461 if (Link
->BackLink
== &gMenuOption
) {
1462 TopOfScreen
= gMenuOption
.ForwardLink
;
1463 if (PreviousMenuOption
!= NULL
&& Rows
< PreviousMenuOption
->Skip
) {
1464 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1470 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1477 Get the index info for this opcode.
1479 @param OpCode The input opcode for the statement.
1481 @retval The index of this statement.
1485 GetIndexInfoForOpcode (
1486 IN EFI_IFR_OP_HEADER
*OpCode
1490 UI_MENU_OPTION
*MenuOption
;
1493 NewPos
= gMenuOption
.ForwardLink
;
1496 for (NewPos
= gMenuOption
.ForwardLink
; NewPos
!= &gMenuOption
; NewPos
= NewPos
->ForwardLink
){
1497 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1499 if (CompareMem (MenuOption
->ThisTag
->OpCode
, OpCode
, OpCode
->Length
) == 0) {
1500 if (MenuOption
->ThisTag
->OpCode
== OpCode
) {
1512 Is this the saved highlight statement.
1514 @param HighLightedStatement The input highlight statement.
1516 @retval TRUE This is the highlight statement.
1517 @retval FALSE This is not the highlight statement.
1521 IsSavedHighlightStatement (
1522 IN FORM_DISPLAY_ENGINE_STATEMENT
*HighLightedStatement
1525 if ((gFormData
->HiiHandle
== gHighligthMenuInfo
.HiiHandle
) &&
1526 (gFormData
->FormId
== gHighligthMenuInfo
.FormId
)) {
1527 if (gHighligthMenuInfo
.HLTQuestionId
!= 0) {
1528 return (gHighligthMenuInfo
.HLTQuestionId
== GetQuestionIdInfo (HighLightedStatement
->OpCode
));
1530 if (CompareMem (gHighligthMenuInfo
.HLTOpCode
, HighLightedStatement
->OpCode
, gHighligthMenuInfo
.HLTOpCode
->Length
) == 0) {
1531 if (gHighligthMenuInfo
.HLTIndex
== 0 || gHighligthMenuInfo
.HLTIndex
== GetIndexInfoForOpcode(HighLightedStatement
->OpCode
)) {
1544 Is this the highlight menu.
1546 @param MenuOption The input Menu option.
1548 @retval TRUE This is the highlight menu option.
1549 @retval FALSE This is not the highlight menu option.
1553 IsHighLightMenuOption (
1554 IN UI_MENU_OPTION
*MenuOption
1557 if (gHighligthMenuInfo
.HLTQuestionId
!= 0) {
1558 if (GetQuestionIdInfo(MenuOption
->ThisTag
->OpCode
) == gHighligthMenuInfo
.HLTQuestionId
) {
1559 return (MenuOption
->Sequence
== gHighligthMenuInfo
.HLTSequence
);
1562 if(CompareMem (gHighligthMenuInfo
.HLTOpCode
, MenuOption
->ThisTag
->OpCode
, gHighligthMenuInfo
.HLTOpCode
->Length
) == 0) {
1563 if (gHighligthMenuInfo
.HLTIndex
== 0 || gHighligthMenuInfo
.HLTIndex
== GetIndexInfoForOpcode(MenuOption
->ThisTag
->OpCode
)) {
1564 return (MenuOption
->Sequence
== gHighligthMenuInfo
.HLTSequence
);
1575 Find the highlight menu.
1577 If the input is NULL, base on the record highlight info in
1578 gHighligthMenuInfo to find the last highlight menu.
1580 @param HighLightedStatement The input highlight statement.
1582 @retval The highlight menu index.
1586 FindHighLightMenuOption (
1587 IN FORM_DISPLAY_ENGINE_STATEMENT
*HighLightedStatement
1591 UI_MENU_OPTION
*MenuOption
;
1593 NewPos
= gMenuOption
.ForwardLink
;
1594 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1596 if (HighLightedStatement
!= NULL
) {
1597 while (MenuOption
->ThisTag
!= HighLightedStatement
) {
1598 NewPos
= NewPos
->ForwardLink
;
1599 if (NewPos
== &gMenuOption
) {
1601 // Not Found it, break
1605 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1609 // Must find the highlight statement.
1611 ASSERT (NewPos
!= &gMenuOption
);
1614 while (!IsHighLightMenuOption (MenuOption
)) {
1615 NewPos
= NewPos
->ForwardLink
;
1616 if (NewPos
== &gMenuOption
) {
1618 // Not Found it, break
1622 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1626 // Highlight statement has disappear (suppressed/disableed)
1628 if (NewPos
== &gMenuOption
) {
1637 Is this the Top of screen menu.
1639 @param MenuOption The input Menu option.
1641 @retval TRUE This is the Top of screen menu option.
1642 @retval FALSE This is not the Top of screen menu option.
1646 IsTopOfScreeMenuOption (
1647 IN UI_MENU_OPTION
*MenuOption
1650 if (gHighligthMenuInfo
.TOSQuestionId
!= 0) {
1651 return (GetQuestionIdInfo(MenuOption
->ThisTag
->OpCode
) == gHighligthMenuInfo
.TOSQuestionId
);
1654 if(CompareMem (gHighligthMenuInfo
.TOSOpCode
, MenuOption
->ThisTag
->OpCode
, gHighligthMenuInfo
.TOSOpCode
->Length
) == 0) {
1655 if (gHighligthMenuInfo
.TOSIndex
== 0 || gHighligthMenuInfo
.TOSIndex
== GetIndexInfoForOpcode(MenuOption
->ThisTag
->OpCode
)) {
1666 Find the Top of screen menu.
1668 If the input is NULL, base on the record highlight info in
1669 gHighligthMenuInfo to find the last highlight menu.
1671 @param HighLightedStatement The input highlight statement.
1673 @retval The highlight menu index.
1677 FindTopOfScreenMenuOption (
1682 UI_MENU_OPTION
*MenuOption
;
1684 NewPos
= gMenuOption
.ForwardLink
;
1685 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1687 while (!IsTopOfScreeMenuOption(MenuOption
)) {
1688 NewPos
= NewPos
->ForwardLink
;
1689 if (NewPos
== &gMenuOption
) {
1691 // Not Found it, break
1695 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1699 // Last time top of screen menu has disappeared.
1701 if (NewPos
== &gMenuOption
) {
1709 Find the first menu which will be show at the top.
1711 @param FormData The data info for this form.
1712 @param TopOfScreen The link_entry pointer to top menu.
1713 @param HighlightMenu The menu which will be highlight.
1714 @param SkipValue The skip value for the top menu.
1719 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
1720 OUT LIST_ENTRY
**TopOfScreen
,
1721 OUT LIST_ENTRY
**HighlightMenu
,
1722 OUT UINTN
*SkipValue
1727 UI_MENU_OPTION
*MenuOption
;
1730 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
1731 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
;
1735 // Reenter caused by option mismatch or auto exit caused by refresh form(refresh interval/guid),
1736 // base on the record highlight info to find the highlight menu.
1738 ASSERT (gFormData
->HiiHandle
== gHighligthMenuInfo
.HiiHandle
&&
1739 gFormData
->FormId
== gHighligthMenuInfo
.FormId
);
1741 *HighlightMenu
= FindHighLightMenuOption(NULL
);
1742 if (*HighlightMenu
!= NULL
) {
1744 // Update skip info for this highlight menu.
1746 MenuOption
= MENU_OPTION_FROM_LINK (*HighlightMenu
);
1747 UpdateOptionSkipLines (MenuOption
);
1750 // Found the last time highlight menu.
1752 *TopOfScreen
= FindTopOfScreenMenuOption();
1753 if (*TopOfScreen
!= NULL
) {
1755 // Found the last time selectable top of screen menu.
1757 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1758 MenuOption
= MENU_OPTION_FROM_LINK (*TopOfScreen
);
1759 UpdateOptionSkipLines (MenuOption
);
1761 *SkipValue
= gHighligthMenuInfo
.SkipValue
;
1764 // Not found last time top of screen menu, so base on current highlight menu
1765 // to find the new top of screen menu.
1766 // Make the current highlight menu at the bottom of the form to calculate the
1767 // top of screen menu.
1769 if (MenuOption
->Skip
>= BottomRow
- TopRow
) {
1770 *TopOfScreen
= *HighlightMenu
;
1773 *TopOfScreen
= FindTopOfScreenMenu(*HighlightMenu
, BottomRow
- TopRow
- MenuOption
->Skip
, &TmpValue
);
1776 *SkipValue
= TmpValue
;
1780 // Last time highlight menu has disappear, find the first highlightable menu as the defalut one.
1782 *HighlightMenu
= gMenuOption
.ForwardLink
;
1783 if (!IsListEmpty (&gMenuOption
)) {
1784 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
, TRUE
);
1786 *TopOfScreen
= gMenuOption
.ForwardLink
;
1791 } else if (FormData
->HighLightedStatement
!= NULL
) {
1792 if (IsSavedHighlightStatement (FormData
->HighLightedStatement
)) {
1794 // Input highlight menu is same as last time highlight menu.
1795 // Base on last time highlight menu to set the top of screen menu and highlight menu.
1797 *HighlightMenu
= FindHighLightMenuOption(NULL
);
1798 ASSERT (*HighlightMenu
!= NULL
);
1801 // Update skip info for this highlight menu.
1803 MenuOption
= MENU_OPTION_FROM_LINK (*HighlightMenu
);
1804 UpdateOptionSkipLines (MenuOption
);
1806 *TopOfScreen
= FindTopOfScreenMenuOption();
1807 if (*TopOfScreen
== NULL
) {
1809 // Not found last time top of screen menu, so base on current highlight menu
1810 // to find the new top of screen menu.
1811 // Make the current highlight menu at the bottom of the form to calculate the
1812 // top of screen menu.
1814 if (MenuOption
->Skip
>= BottomRow
- TopRow
) {
1815 *TopOfScreen
= *HighlightMenu
;
1818 *TopOfScreen
= FindTopOfScreenMenu(*HighlightMenu
, BottomRow
- TopRow
- MenuOption
->Skip
, &TmpValue
);
1821 *SkipValue
= TmpValue
;
1823 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1824 MenuOption
= MENU_OPTION_FROM_LINK (*TopOfScreen
);
1825 UpdateOptionSkipLines (MenuOption
);
1827 *SkipValue
= gHighligthMenuInfo
.SkipValue
;
1829 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1832 // Input highlight menu is not save as last time highlight menu.
1834 *HighlightMenu
= FindHighLightMenuOption(FormData
->HighLightedStatement
);
1835 MenuOption
= MENU_OPTION_FROM_LINK (*HighlightMenu
);
1836 UpdateOptionSkipLines (MenuOption
);
1839 // Make the current highlight menu at the bottom of the form to calculate the
1840 // top of screen menu.
1842 if (MenuOption
->Skip
>= BottomRow
- TopRow
) {
1843 *TopOfScreen
= *HighlightMenu
;
1846 *TopOfScreen
= FindTopOfScreenMenu(*HighlightMenu
, BottomRow
- TopRow
- MenuOption
->Skip
, &TmpValue
);
1849 *SkipValue
= TmpValue
;
1851 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1854 // If not has input highlight statement, just return the first one in this form.
1856 *TopOfScreen
= gMenuOption
.ForwardLink
;
1857 *HighlightMenu
= gMenuOption
.ForwardLink
;
1858 if (!IsListEmpty (&gMenuOption
)) {
1859 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
, TRUE
);
1866 Record the highlight menu and top of screen menu info.
1868 @param Highlight The menu opton which is highlight.
1869 @param TopOfScreen The menu opton which is at the top of the form.
1870 @param SkipValue The skip line info for the top of screen menu.
1874 UpdateHighlightMenuInfo (
1875 IN LIST_ENTRY
*Highlight
,
1876 IN LIST_ENTRY
*TopOfScreen
,
1880 UI_MENU_OPTION
*MenuOption
;
1881 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1883 gHighligthMenuInfo
.HiiHandle
= gFormData
->HiiHandle
;
1884 gHighligthMenuInfo
.FormId
= gFormData
->FormId
;
1885 gHighligthMenuInfo
.SkipValue
= (UINT16
)SkipValue
;
1887 if (!IsListEmpty (&gMenuOption
)) {
1888 MenuOption
= MENU_OPTION_FROM_LINK (Highlight
);
1889 Statement
= MenuOption
->ThisTag
;
1891 gUserInput
->SelectedStatement
= Statement
;
1893 gHighligthMenuInfo
.HLTSequence
= MenuOption
->Sequence
;
1894 gHighligthMenuInfo
.HLTQuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1895 if (gHighligthMenuInfo
.HLTQuestionId
== 0) {
1897 // if question id == 0, save the opcode buffer..
1899 if (gHighligthMenuInfo
.HLTOpCode
!= NULL
) {
1900 FreePool (gHighligthMenuInfo
.HLTOpCode
);
1902 gHighligthMenuInfo
.HLTOpCode
= AllocateCopyPool (Statement
->OpCode
->Length
, Statement
->OpCode
);
1903 ASSERT (gHighligthMenuInfo
.HLTOpCode
!= NULL
);
1905 gHighligthMenuInfo
.HLTIndex
= GetIndexInfoForOpcode(Statement
->OpCode
);
1908 MenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
1909 Statement
= MenuOption
->ThisTag
;
1911 gHighligthMenuInfo
.TOSQuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1912 if (gHighligthMenuInfo
.TOSQuestionId
== 0) {
1914 // if question id == 0, save the opcode buffer..
1916 if (gHighligthMenuInfo
.TOSOpCode
!= NULL
) {
1917 FreePool (gHighligthMenuInfo
.TOSOpCode
);
1919 gHighligthMenuInfo
.TOSOpCode
= AllocateCopyPool (Statement
->OpCode
->Length
, Statement
->OpCode
);
1920 ASSERT (gHighligthMenuInfo
.TOSOpCode
!= NULL
);
1922 gHighligthMenuInfo
.TOSIndex
= GetIndexInfoForOpcode(Statement
->OpCode
);
1925 gUserInput
->SelectedStatement
= NULL
;
1927 gHighligthMenuInfo
.HLTSequence
= 0;
1928 gHighligthMenuInfo
.HLTQuestionId
= 0;
1929 if (gHighligthMenuInfo
.HLTOpCode
!= NULL
) {
1930 FreePool (gHighligthMenuInfo
.HLTOpCode
);
1932 gHighligthMenuInfo
.HLTOpCode
= NULL
;
1933 gHighligthMenuInfo
.HLTIndex
= 0;
1935 gHighligthMenuInfo
.TOSQuestionId
= 0;
1936 if (gHighligthMenuInfo
.TOSOpCode
!= NULL
) {
1937 FreePool (gHighligthMenuInfo
.TOSOpCode
);
1939 gHighligthMenuInfo
.TOSOpCode
= NULL
;
1940 gHighligthMenuInfo
.TOSIndex
= 0;
1945 Update attribut for this menu.
1947 @param MenuOption The menu opton which this attribut used to.
1948 @param Highlight Whether this menu will be highlight.
1952 SetDisplayAttribute (
1953 IN UI_MENU_OPTION
*MenuOption
,
1954 IN BOOLEAN Highlight
1957 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1959 Statement
= MenuOption
->ThisTag
;
1962 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
1966 if (MenuOption
->GrayOut
) {
1967 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetGrayedTextColor ());
1969 if (Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) {
1970 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetSubTitleTextColor ());
1972 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
1978 Print string for this menu option.
1980 @param MenuOption The menu opton which this attribut used to.
1981 @param Col The column that this string will be print at.
1982 @param Row The row that this string will be print at.
1983 @param String The string which need to print.
1984 @param Width The width need to print, if string is less than the
1985 width, the block space will be used.
1986 @param Highlight Whether this menu will be highlight.
1991 IN UI_MENU_OPTION
*MenuOption
,
1996 IN BOOLEAN Highlight
2002 // Print string with normal color.
2005 PrintStringAtWithWidth (Col
, Row
, String
, Width
);
2010 // Print the highlight menu string.
2011 // First print the highlight string.
2013 SetDisplayAttribute(MenuOption
, TRUE
);
2014 Length
= PrintStringAt (Col
, Row
, String
);
2017 // Second, clean the empty after the string.
2019 SetDisplayAttribute(MenuOption
, FALSE
);
2020 PrintStringAtWithWidth (Col
+ Length
, Row
, L
"", Width
- Length
);
2024 Check whether this menu can has option string.
2026 @param MenuOption The menu opton which this attribut used to.
2028 @retval TRUE This menu option can have option string.
2029 @retval FALSE This menu option can't have option string.
2034 IN UI_MENU_OPTION
*MenuOption
2037 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2040 EFI_IFR_TEXT
*TestOp
;
2043 Statement
= MenuOption
->ThisTag
;
2046 // See if the second text parameter is really NULL
2048 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
2049 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
2050 if (TestOp
->TextTwo
!= 0) {
2051 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
2052 Size
= StrLen (String
);
2057 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
2058 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
2059 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
2060 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
2061 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
2063 // Allow a wide display if text op-code and no secondary text op-code
2065 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
2076 Print string for this menu option.
2078 @param MenuOption The menu opton which this attribut used to.
2079 @param SkipWidth The skip width between the left to the start of the prompt.
2080 @param BeginCol The begin column for one menu.
2081 @param SkipLine The skip line for this menu.
2082 @param BottomRow The bottom row for this form.
2083 @param Highlight Whether this menu will be highlight.
2084 @param UpdateCol Whether need to update the column info for Date/Time.
2086 @retval EFI_SUCESSS Process the user selection success.
2091 IN UI_MENU_OPTION
*MenuOption
,
2096 IN BOOLEAN Highlight
,
2097 IN BOOLEAN UpdateCol
2100 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2105 CHAR16
*OptionString
;
2106 CHAR16
*OutputString
;
2114 UINTN PromptLineNum
;
2115 UINTN OptionLineNum
;
2119 Statement
= MenuOption
->ThisTag
;
2129 // Set default color.
2131 SetDisplayAttribute (MenuOption
, FALSE
);
2134 // 1. Paint the option string.
2136 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
2137 if (EFI_ERROR (Status
)) {
2141 if (OptionString
!= NULL
) {
2142 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
2144 // Adjust option string for date/time opcode.
2146 ProcessStringForDateTime(MenuOption
, OptionString
, UpdateCol
);
2149 Width
= (UINT16
) gOptionBlockWidth
- 1;
2150 Row
= MenuOption
->Row
;
2154 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2155 if (((Temp2
== 0)) && (Row
<= BottomRow
)) {
2156 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
2158 // For date/time question, it has three menu options for this qustion.
2159 // The first/second menu options with the skip value is 0. the last one
2160 // with skip value is 1.
2162 if (MenuOption
->Skip
!= 0) {
2164 // For date/ time, print the last past (year for date and second for time)
2165 // - 7 means skip [##/##/ for date and [##:##: for time.
2167 DisplayMenuString (MenuOption
,MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1 - 7, Highlight
);
2170 // For date/ time, print the first and second past (year for date and second for time)
2171 // The OutputString has a NARROW_CHAR or WIDE_CHAR at the begin of the string,
2172 // so need to - 1 to remove it, otherwise, it will clean 1 extr char follow it.
2173 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, StrLen (OutputString
) - 1, Highlight
);
2176 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
2182 // If there is more string to process print on the next row and increment the Skip value
2184 if (StrLen (&OptionString
[Index
]) != 0) {
2188 // Since the Number of lines for this menu entry may or may not be reflected accurately
2189 // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
2190 // some testing to ensure we are keeping this in-sync.
2192 // If the difference in rows is greater than or equal to the skip value, increase the skip value
2194 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
2200 FreePool (OutputString
);
2208 FreePool (OptionString
);
2212 // 2. Paint the description.
2214 PromptWidth
= GetWidth (MenuOption
, &AdjustValue
);
2215 Row
= MenuOption
->Row
;
2219 if (MenuOption
->Description
== NULL
|| MenuOption
->Description
[0] == '\0') {
2220 PrintStringAtWithWidth (BeginCol
, Row
, L
"", PromptWidth
+ AdjustValue
+ SkipWidth
);
2223 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, PromptWidth
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2224 if ((Temp
== 0) && (Row
<= BottomRow
)) {
2226 // 1.Clean the start LEFT_SKIPPED_COLUMNS
2228 PrintStringAtWithWidth (BeginCol
, Row
, L
"", SkipWidth
);
2230 if (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
&& MenuOption
->Col
>= 2) {
2232 // Print Arrow for Goto button.
2235 MenuOption
->Col
- 2,
2237 GEOMETRICSHAPE_RIGHT_TRIANGLE
2240 DisplayMenuString (MenuOption
, MenuOption
->Col
, Row
, OutputString
, PromptWidth
+ AdjustValue
, Highlight
);
2244 // If there is more string to process print on the next row and increment the Skip value
2246 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
2252 FreePool (OutputString
);
2263 // 3. If this is a text op with secondary text information
2265 if ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
!= 0)) {
2266 StringPtr
= GetToken (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
2268 Width
= (UINT16
) gOptionBlockWidth
- 1;
2269 Row
= MenuOption
->Row
;
2273 for (Index
= 0; GetLineByWidth (StringPtr
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2274 if ((Temp3
== 0) && (Row
<= BottomRow
)) {
2275 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
2279 // If there is more string to process print on the next row and increment the Skip value
2281 if (StrLen (&StringPtr
[Index
]) != 0) {
2285 // If the rows for text two is greater than or equal to the skip value, increase the skip value
2287 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
2293 FreePool (OutputString
);
2299 FreePool (StringPtr
);
2303 // 4.Line number for Option string and prompt string are not equal.
2304 // Clean the column whose line number is less.
2306 if (HasOptionString(MenuOption
) && (OptionLineNum
!= PromptLineNum
)) {
2307 Col
= OptionLineNum
< PromptLineNum
? MenuOption
->OptCol
: BeginCol
;
2308 Row
= (OptionLineNum
< PromptLineNum
? OptionLineNum
: PromptLineNum
) + MenuOption
->Row
;
2309 Width
= (UINT16
) (OptionLineNum
< PromptLineNum
? gOptionBlockWidth
: PromptWidth
+ AdjustValue
+ SkipWidth
);
2310 MaxRow
= (OptionLineNum
< PromptLineNum
? PromptLineNum
: OptionLineNum
) + MenuOption
->Row
- 1;
2312 while (Row
<= MaxRow
) {
2313 DisplayMenuString (MenuOption
, Col
, Row
++, L
"", Width
, FALSE
);
2321 Display menu and wait for user to select one menu option, then return it.
2322 If AutoBoot is enabled, then if user doesn't select any option,
2323 after period of time, it will automatically return the first menu option.
2325 @param FormData The current form data info.
2327 @retval EFI_SUCESSS Process the user selection success.
2328 @retval EFI_NOT_FOUND Process option string for orderedlist/Oneof fail.
2333 IN FORM_DISPLAY_ENGINE_FORM
*FormData
2338 UINTN DistanceValue
;
2347 CHAR16
*OptionString
;
2349 CHAR16
*HelpHeaderString
;
2350 CHAR16
*HelpBottomString
;
2359 LIST_ENTRY
*TopOfScreen
;
2360 LIST_ENTRY
*SavedListEntry
;
2361 UI_MENU_OPTION
*MenuOption
;
2362 UI_MENU_OPTION
*NextMenuOption
;
2363 UI_MENU_OPTION
*SavedMenuOption
;
2364 UI_CONTROL_FLAG ControlFlag
;
2365 UI_SCREEN_OPERATION ScreenOperation
;
2366 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2367 BROWSER_HOT_KEY
*HotKey
;
2368 UINTN HelpPageIndex
;
2369 UINTN HelpPageCount
;
2372 UINTN HelpHeaderLine
;
2373 UINTN HelpBottomLine
;
2374 BOOLEAN MultiHelpPage
;
2375 UINT16 EachLineWidth
;
2376 UINT16 HeaderLineWidth
;
2377 UINT16 BottomLineWidth
;
2378 EFI_STRING_ID HelpInfo
;
2379 UI_EVENT_TYPE EventType
;
2380 BOOLEAN SkipHighLight
;
2382 EventType
= UIEventNone
;
2383 Status
= EFI_SUCCESS
;
2385 HelpHeaderString
= NULL
;
2386 HelpBottomString
= NULL
;
2387 OptionString
= NULL
;
2388 ScreenOperation
= UiNoOperation
;
2396 MultiHelpPage
= FALSE
;
2398 HeaderLineWidth
= 0;
2399 BottomLineWidth
= 0;
2403 SkipHighLight
= FALSE
;
2405 NextMenuOption
= NULL
;
2406 SavedMenuOption
= NULL
;
2410 gModalSkipColumn
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 6;
2412 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
2414 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
2415 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
- 1;
2418 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2419 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gModalSkipColumn
;
2421 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
;
2424 FindTopMenu(FormData
, &TopOfScreen
, &NewPos
, &SkipValue
);
2425 if (!IsListEmpty (&gMenuOption
)) {
2426 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2427 gUserInput
->SelectedStatement
= NextMenuOption
->ThisTag
;
2430 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
2432 ControlFlag
= CfInitialization
;
2434 switch (ControlFlag
) {
2435 case CfInitialization
:
2436 if ((gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
) ||
2437 (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))) {
2439 // Clear Statement range if different formset is painted.
2442 gStatementDimensions
.LeftColumn
,
2443 gStatementDimensions
.RightColumn
,
2444 TopRow
- SCROLL_ARROW_HEIGHT
,
2445 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2446 GetFieldTextColor ()
2450 ControlFlag
= CfRepaint
;
2454 ControlFlag
= CfRefreshHighLight
;
2464 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2467 // 1. Check whether need to print the arrow up.
2469 if (!ValueIsScroll (TRUE
, TopOfScreen
)) {
2473 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2474 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2476 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2479 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2481 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2482 TopRow
- SCROLL_ARROW_HEIGHT
,
2485 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2489 // 2.Paint the menu.
2491 for (Link
= TopOfScreen
; Link
!= &gMenuOption
; Link
= Link
->ForwardLink
) {
2492 MenuOption
= MENU_OPTION_FROM_LINK (Link
);
2493 MenuOption
->Row
= Row
;
2494 MenuOption
->Col
= Col
;
2495 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2496 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
+ gModalSkipColumn
;
2498 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
;
2501 if (MenuOption
->NestInStatement
) {
2502 MenuOption
->Col
+= SUBTITLE_INDENT
;
2506 // Save the highlight menu, will be used in CfRefreshHighLight case.
2508 if (Link
== NewPos
) {
2509 SavedMenuOption
= MenuOption
;
2510 SkipHighLight
= TRUE
;
2513 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2514 Status
= DisplayOneMenu (MenuOption
,
2515 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2516 gStatementDimensions
.LeftColumn
+ gModalSkipColumn
,
2517 Link
== TopOfScreen
? SkipValue
: 0,
2519 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2523 Status
= DisplayOneMenu (MenuOption
,
2524 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2525 gStatementDimensions
.LeftColumn
,
2526 Link
== TopOfScreen
? SkipValue
: 0,
2528 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2533 if (EFI_ERROR (Status
)) {
2541 // 3. Update the row info which will be used by next menu.
2543 if (Link
== TopOfScreen
) {
2544 Row
+= MenuOption
->Skip
- SkipValue
;
2546 Row
+= MenuOption
->Skip
;
2549 if (Row
> BottomRow
) {
2550 if (!ValueIsScroll (FALSE
, Link
)) {
2554 Row
= BottomRow
+ 1;
2560 // 3. Menus in this form may not cover all form, clean the remain field.
2562 while (Row
<= BottomRow
) {
2563 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2564 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2566 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gHelpBlockWidth
- gStatementDimensions
.LeftColumn
);
2571 // 4. Print the down arrow row.
2573 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2574 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * + gModalSkipColumn
);
2576 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2579 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2581 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2582 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2585 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2592 case CfRefreshHighLight
:
2595 // MenuOption: Last menu option that need to remove hilight
2596 // MenuOption is set to NULL in Repaint
2597 // NewPos: Current menu option that need to hilight
2599 ControlFlag
= CfUpdateHelpString
;
2601 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
2603 if (SkipHighLight
) {
2604 SkipHighLight
= FALSE
;
2605 MenuOption
= SavedMenuOption
;
2606 RefreshKeyHelp(gFormData
, SavedMenuOption
->ThisTag
, FALSE
);
2610 if (IsListEmpty (&gMenuOption
)) {
2612 // No menu option, just update the hotkey filed.
2614 RefreshKeyHelp(gFormData
, NULL
, FALSE
);
2618 if (MenuOption
!= NULL
&& TopOfScreen
== &MenuOption
->Link
) {
2623 if (NewPos
== TopOfScreen
) {
2629 if (NewPos
!= NULL
&& (MenuOption
== NULL
|| NewPos
!= &MenuOption
->Link
)) {
2630 if (MenuOption
!= NULL
) {
2632 // Remove the old highlight menu.
2634 Status
= DisplayOneMenu (MenuOption
,
2635 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2636 gStatementDimensions
.LeftColumn
,
2645 // This is the current selected statement
2647 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2648 RefreshKeyHelp(gFormData
, MenuOption
->ThisTag
, FALSE
);
2650 if (!IsSelectable (MenuOption
)) {
2654 Status
= DisplayOneMenu (MenuOption
,
2655 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2656 gStatementDimensions
.LeftColumn
,
2665 case CfUpdateHelpString
:
2666 ControlFlag
= CfPrepareToReadKey
;
2667 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2672 // NewLine means only update highlight menu (remove old highlight and highlith
2673 // the new one), not need to full repain the form.
2675 if (Repaint
|| NewLine
) {
2676 if (IsListEmpty (&gMenuOption
)) {
2678 // Don't print anything if no mwnu option.
2680 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2683 // Don't print anything if it is a NULL help token
2685 ASSERT(MenuOption
!= NULL
);
2686 HelpInfo
= ((EFI_IFR_STATEMENT_HEADER
*) ((CHAR8
*)MenuOption
->ThisTag
->OpCode
+ sizeof (EFI_IFR_OP_HEADER
)))->Help
;
2687 if (HelpInfo
== 0 || !IsSelectable (MenuOption
)) {
2688 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2690 StringPtr
= GetToken (HelpInfo
, gFormData
->HiiHandle
);
2694 RowCount
= BottomRow
- TopRow
+ 1;
2697 // 1.Calculate how many line the help string need to print.
2699 if (HelpString
!= NULL
) {
2700 FreePool (HelpString
);
2703 HelpLine
= ProcessHelpString (StringPtr
, &HelpString
, &EachLineWidth
, RowCount
);
2704 FreePool (StringPtr
);
2706 if (HelpLine
> RowCount
) {
2707 MultiHelpPage
= TRUE
;
2708 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_UP
), gHiiHandle
);
2709 if (HelpHeaderString
!= NULL
) {
2710 FreePool (HelpHeaderString
);
2711 HelpHeaderString
= NULL
;
2713 HelpHeaderLine
= ProcessHelpString (StringPtr
, &HelpHeaderString
, &HeaderLineWidth
, 0);
2714 FreePool (StringPtr
);
2715 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_DOWN
), gHiiHandle
);
2716 if (HelpBottomString
!= NULL
) {
2717 FreePool (HelpBottomString
);
2718 HelpBottomString
= NULL
;
2720 HelpBottomLine
= ProcessHelpString (StringPtr
, &HelpBottomString
, &BottomLineWidth
, 0);
2721 FreePool (StringPtr
);
2723 // Calculate the help page count.
2725 if (HelpLine
> 2 * RowCount
- 2) {
2726 HelpPageCount
= (HelpLine
- RowCount
+ 1) / (RowCount
- 2) + 1;
2727 if ((HelpLine
- RowCount
+ 1) % (RowCount
- 2) > 1) {
2734 MultiHelpPage
= FALSE
;
2739 // Check whether need to show the 'More(U/u)' at the begin.
2740 // Base on current direct info, here shows aligned to the right side of the column.
2741 // If the direction is multi line and aligned to right side may have problem, so
2742 // add ASSERT code here.
2744 if (HelpPageIndex
> 0) {
2745 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2746 for (Index
= 0; Index
< HelpHeaderLine
; Index
++) {
2747 ASSERT (HelpHeaderLine
== 1);
2748 ASSERT (GetStringWidth (HelpHeaderString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2749 PrintStringAtWithWidth (
2750 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2756 gStatementDimensions
.RightColumn
- GetStringWidth (HelpHeaderString
) / 2 - 1,
2758 &HelpHeaderString
[Index
* HeaderLineWidth
]
2763 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHelpTextColor ());
2765 // Print the help string info.
2767 if (!MultiHelpPage
) {
2768 for (Index
= 0; Index
< HelpLine
; Index
++) {
2769 PrintStringAtWithWidth (
2770 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2772 &HelpString
[Index
* EachLineWidth
],
2776 for (; Index
< RowCount
; Index
++) {
2777 PrintStringAtWithWidth (
2778 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2784 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2786 if (HelpPageIndex
== 0) {
2787 for (Index
= 0; Index
< RowCount
- HelpBottomLine
; Index
++) {
2788 PrintStringAtWithWidth (
2789 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2791 &HelpString
[Index
* EachLineWidth
],
2796 for (Index
= 0; (Index
< RowCount
- HelpBottomLine
- HelpHeaderLine
) &&
2797 (Index
+ HelpPageIndex
* (RowCount
- 2) + 1 < HelpLine
); Index
++) {
2798 PrintStringAtWithWidth (
2799 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2800 Index
+ TopRow
+ HelpHeaderLine
,
2801 &HelpString
[(Index
+ HelpPageIndex
* (RowCount
- 2) + 1)* EachLineWidth
],
2805 if (HelpPageIndex
== HelpPageCount
- 1) {
2806 for (; Index
< RowCount
- HelpHeaderLine
; Index
++) {
2807 PrintStringAtWithWidth (
2808 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2809 Index
+ TopRow
+ HelpHeaderLine
,
2814 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2820 // Check whether need to print the 'More(D/d)' at the bottom.
2821 // Base on current direct info, here shows aligned to the right side of the column.
2822 // If the direction is multi line and aligned to right side may have problem, so
2823 // add ASSERT code here.
2825 if (HelpPageIndex
< HelpPageCount
- 1 && MultiHelpPage
) {
2826 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2827 for (Index
= 0; Index
< HelpBottomLine
; Index
++) {
2828 ASSERT (HelpBottomLine
== 1);
2829 ASSERT (GetStringWidth (HelpBottomString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2830 PrintStringAtWithWidth (
2831 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2832 BottomRow
+ Index
- HelpBottomLine
+ 1,
2837 gStatementDimensions
.RightColumn
- GetStringWidth (HelpBottomString
) / 2 - 1,
2838 BottomRow
+ Index
- HelpBottomLine
+ 1,
2839 &HelpBottomString
[Index
* BottomLineWidth
]
2844 // Reset this flag every time we finish using it.
2850 case CfPrepareToReadKey
:
2851 ControlFlag
= CfReadKey
;
2852 ScreenOperation
= UiNoOperation
;
2856 ControlFlag
= CfScreenOperation
;
2859 // Wait for user's selection
2862 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2863 if (!EFI_ERROR (Status
)) {
2864 EventType
= UIEventKey
;
2869 // If we encounter error, continue to read another key in.
2871 if (Status
!= EFI_NOT_READY
) {
2875 EventType
= UiWaitForEvent(gST
->ConIn
->WaitForKey
);
2876 if (EventType
== UIEventKey
) {
2877 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2882 if (EventType
== UIEventDriver
) {
2884 gUserInput
->Action
= BROWSER_ACTION_NONE
;
2885 ControlFlag
= CfExit
;
2889 if (EventType
== UIEventTimeOut
) {
2890 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2891 ControlFlag
= CfExit
;
2895 switch (Key
.UnicodeChar
) {
2896 case CHAR_CARRIAGE_RETURN
:
2897 if(MenuOption
== NULL
|| MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2898 ControlFlag
= CfReadKey
;
2902 ScreenOperation
= UiSelect
;
2907 // We will push the adjustment of these numeric values directly to the input handler
2908 // NOTE: we won't handle manual input numeric
2913 // If the screen has no menu items, and the user didn't select UiReset
2914 // ignore the selection and go back to reading keys.
2916 ASSERT(MenuOption
!= NULL
);
2917 if(IsListEmpty (&gMenuOption
) || MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2918 ControlFlag
= CfReadKey
;
2922 Statement
= MenuOption
->ThisTag
;
2923 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
)
2924 || (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
2925 || ((Statement
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (GetFieldFromNum(Statement
->OpCode
) != 0))
2927 if (Key
.UnicodeChar
== '+') {
2928 gDirection
= SCAN_RIGHT
;
2930 gDirection
= SCAN_LEFT
;
2933 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2934 if (OptionString
!= NULL
) {
2935 FreePool (OptionString
);
2937 if (EFI_ERROR (Status
)) {
2939 // Repaint to clear possible error prompt pop-up
2944 ControlFlag
= CfExit
;
2950 ScreenOperation
= UiUp
;
2955 ScreenOperation
= UiDown
;
2959 if(IsListEmpty (&gMenuOption
)) {
2960 ControlFlag
= CfReadKey
;
2964 ASSERT(MenuOption
!= NULL
);
2965 if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_CHECKBOX_OP
&& !MenuOption
->GrayOut
&& !MenuOption
->ReadOnly
) {
2966 ScreenOperation
= UiSelect
;
2972 if (!MultiHelpPage
) {
2973 ControlFlag
= CfReadKey
;
2976 ControlFlag
= CfUpdateHelpString
;
2977 HelpPageIndex
= HelpPageIndex
< HelpPageCount
- 1 ? HelpPageIndex
+ 1 : HelpPageCount
- 1;
2982 if (!MultiHelpPage
) {
2983 ControlFlag
= CfReadKey
;
2986 ControlFlag
= CfUpdateHelpString
;
2987 HelpPageIndex
= HelpPageIndex
> 0 ? HelpPageIndex
- 1 : 0;
2991 for (Index
= 0; Index
< mScanCodeNumber
; Index
++) {
2992 if (Key
.ScanCode
== gScanCodeToOperation
[Index
].ScanCode
) {
2993 ScreenOperation
= gScanCodeToOperation
[Index
].ScreenOperation
;
2998 if (((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) && (Key
.ScanCode
== SCAN_ESC
|| Index
== mScanCodeNumber
)) {
3000 // ModalForm has no ESC key and Hot Key.
3002 ControlFlag
= CfReadKey
;
3003 } else if (Index
== mScanCodeNumber
) {
3005 // Check whether Key matches the registered hot key.
3008 HotKey
= GetHotKeyFromRegisterList (&Key
);
3009 if (HotKey
!= NULL
) {
3010 ScreenOperation
= UiHotKey
;
3017 case CfScreenOperation
:
3018 if ((ScreenOperation
!= UiReset
) && (ScreenOperation
!= UiHotKey
)) {
3020 // If the screen has no menu items, and the user didn't select UiReset or UiHotKey
3021 // ignore the selection and go back to reading keys.
3023 if (IsListEmpty (&gMenuOption
)) {
3024 ControlFlag
= CfReadKey
;
3030 Index
< sizeof (gScreenOperationToControlFlag
) / sizeof (gScreenOperationToControlFlag
[0]);
3033 if (ScreenOperation
== gScreenOperationToControlFlag
[Index
].ScreenOperation
) {
3034 ControlFlag
= gScreenOperationToControlFlag
[Index
].ControlFlag
;
3041 ControlFlag
= CfRepaint
;
3043 ASSERT(MenuOption
!= NULL
);
3044 Statement
= MenuOption
->ThisTag
;
3045 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
3049 switch (Statement
->OpCode
->OpCode
) {
3050 case EFI_IFR_REF_OP
:
3051 case EFI_IFR_ACTION_OP
:
3052 case EFI_IFR_RESET_BUTTON_OP
:
3053 ControlFlag
= CfExit
;
3058 // Editable Questions: oneof, ordered list, checkbox, numeric, string, password
3060 RefreshKeyHelp (gFormData
, Statement
, TRUE
);
3061 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
3063 if (OptionString
!= NULL
) {
3064 FreePool (OptionString
);
3067 if (EFI_ERROR (Status
)) {
3070 RefreshKeyHelp (gFormData
, Statement
, FALSE
);
3073 ControlFlag
= CfExit
;
3081 // We come here when someone press ESC
3082 // If the policy is not exit front page when user press ESC, process here.
3084 if (!FormExitPolicy()) {
3087 ControlFlag
= CfRepaint
;
3091 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
3092 ControlFlag
= CfExit
;
3096 ControlFlag
= CfRepaint
;
3098 ASSERT (HotKey
!= NULL
);
3099 gUserInput
->Action
= HotKey
->Action
;
3100 ControlFlag
= CfExit
;
3104 ControlFlag
= CfRepaint
;
3105 ASSERT(MenuOption
!= NULL
);
3106 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
3107 if (MenuOption
->Sequence
!= 0) {
3109 // In the middle or tail of the Date/Time op-code set, go left.
3111 ASSERT(NewPos
!= NULL
);
3112 NewPos
= NewPos
->BackLink
;
3118 ControlFlag
= CfRepaint
;
3119 ASSERT(MenuOption
!= NULL
);
3120 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
3121 if (MenuOption
->Sequence
!= 2) {
3123 // In the middle or tail of the Date/Time op-code set, go left.
3125 ASSERT(NewPos
!= NULL
);
3126 NewPos
= NewPos
->ForwardLink
;
3132 ControlFlag
= CfRepaint
;
3135 SavedListEntry
= NewPos
;
3136 ASSERT(NewPos
!= NULL
);
3138 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3139 ASSERT (MenuOption
!= NULL
);
3142 // Adjust Date/Time position before we advance forward.
3144 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3146 NewPos
= NewPos
->BackLink
;
3148 // Find next selectable menu or the first menu beyond current form.
3150 Difference
= MoveToNextStatement (TRUE
, &NewPos
, MenuOption
->Row
- TopRow
, FALSE
);
3151 if (Difference
< 0) {
3153 // We hit the begining MenuOption that can be focused
3154 // so we simply scroll to the top.
3157 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3158 TopOfScreen
= gMenuOption
.ForwardLink
;
3159 NewPos
= SavedListEntry
;
3163 // Scroll up to the last page when we have arrived at top page.
3165 TopOfScreen
= FindTopOfScreenMenu (gMenuOption
.BackLink
, BottomRow
- TopRow
, &SkipValue
);
3166 NewPos
= gMenuOption
.BackLink
;
3167 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
3170 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3172 if (MenuOption
->Row
< TopRow
+ Difference
+ NextMenuOption
->Skip
) {
3174 // Previous focus MenuOption is above the TopOfScreen, so we need to scroll
3176 TopOfScreen
= NewPos
;
3182 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
3184 // BottomRow - TopRow + 1 means the total rows current forms supported.
3185 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
3186 // and new top menu. New top menu will all shows in next form, but last highlight menu
3187 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
3188 // last highlight menu.
3190 if (!IsSelectable(NextMenuOption
) && IsSelectable(MenuOption
) &&
3191 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
3192 NewPos
= SavedListEntry
;
3196 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3199 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3201 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3202 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3204 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3209 // SkipValue means lines is skipped when show the top menu option.
3211 ControlFlag
= CfRepaint
;
3217 // First minus the menu of the top screen, it's value is SkipValue.
3219 if (SkipValue
>= BottomRow
- TopRow
+ 1) {
3221 // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one
3222 // form of options to be show, so just update the SkipValue to show the next
3223 // parts of options.
3225 SkipValue
-= BottomRow
- TopRow
+ 1;
3226 NewPos
= TopOfScreen
;
3229 Index
= (BottomRow
+ 1) - SkipValue
- TopRow
;
3232 TopOfScreen
= FindTopOfScreenMenu(TopOfScreen
, Index
, &SkipValue
);
3233 NewPos
= TopOfScreen
;
3234 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, FALSE
);
3236 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3239 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3240 // Don't do this when we are already in the first page.
3242 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3243 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3245 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3250 // SkipValue means lines is skipped when show the top menu option.
3252 ControlFlag
= CfRepaint
;
3257 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3258 Index
= TopRow
+ NextMenuOption
->Skip
- SkipValue
;
3260 // Count to the menu option which will show at the top of the next form.
3262 while ((Index
<= BottomRow
+ 1) && (Link
->ForwardLink
!= &gMenuOption
)) {
3263 Link
= Link
->ForwardLink
;
3264 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3265 Index
= Index
+ NextMenuOption
->Skip
;
3268 if ((Link
->ForwardLink
== &gMenuOption
) && (Index
<= BottomRow
+ 1)) {
3270 // Highlight on the last menu which can be highlight.
3273 MoveToNextStatement (TRUE
, &Link
, Index
- TopRow
, TRUE
);
3276 // Calculate the skip line for top of screen menu.
3278 if (Link
== TopOfScreen
) {
3280 // The top of screen menu option occupies the entire form.
3282 SkipValue
+= BottomRow
- TopRow
+ 1;
3284 SkipValue
= NextMenuOption
->Skip
- (Index
- (BottomRow
+ 1));
3289 // Move to the Next selectable menu.
3291 MoveToNextStatement (FALSE
, &Link
, BottomRow
- TopRow
, TRUE
);
3295 // Save the menu as the next highlight menu.
3299 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3302 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3303 // Don't do this when we are already in the last page.
3305 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3306 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3308 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3313 // SkipValue means lines is skipped when show the top menu option.
3314 // NewPos points to the menu which is highlighted now.
3316 ControlFlag
= CfRepaint
;
3319 if (NewPos
== TopOfScreen
) {
3325 SavedListEntry
= NewPos
;
3327 // Since the behavior of hitting the down arrow on a Date/Time op-code is intended
3328 // to be one that progresses to the next set of op-codes, we need to advance to the last
3329 // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate
3330 // checking can be done. The only other logic we need to introduce is that if a Date/Time
3331 // op-code is the last entry in the menu, we need to rewind back to the first op-code of
3332 // the Date/Time op-code.
3334 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3336 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3337 NewPos
= NewPos
->ForwardLink
;
3339 // Find the next selectable menu.
3341 if (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
> BottomRow
+ 1) {
3342 if (gMenuOption
.ForwardLink
== NewPos
|| &gMenuOption
== NewPos
) {
3348 Difference
= MoveToNextStatement (FALSE
, &NewPos
, BottomRow
+ 1 - (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
), FALSE
);
3350 if (Difference
< 0) {
3352 // Scroll to the first page.
3354 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3355 TopOfScreen
= gMenuOption
.ForwardLink
;
3359 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3361 NewPos
= gMenuOption
.ForwardLink
;
3362 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
3366 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3368 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3369 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3371 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3376 // Get next selected menu info.
3378 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3379 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3380 if (NextMenuOption
->Row
== 0) {
3381 UpdateOptionSkipLines (NextMenuOption
);
3385 // Calculate new highlight menu end row.
3387 Temp
= (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
) + Difference
+ NextMenuOption
->Skip
- 1;
3388 if (Temp
> BottomRow
) {
3390 // Get the top screen menu info.
3392 AdjustDateAndTimePosition (FALSE
, &TopOfScreen
);
3393 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3396 // Current Top screen menu occupy (SavedMenuOption->Skip - SkipValue) rows.
3397 // Full shows the new selected menu need to skip (Temp - BottomRow - 1) rows.
3399 if ((Temp
- BottomRow
) >= (SavedMenuOption
->Skip
- SkipValue
)) {
3401 // Skip the top op-code
3403 TopOfScreen
= TopOfScreen
->ForwardLink
;
3404 DistanceValue
= (Temp
- BottomRow
) - (SavedMenuOption
->Skip
- SkipValue
);
3406 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3409 // If we have a remainder, skip that many more op-codes until we drain the remainder
3410 // Special case is the selected highlight menu has more than one form of menus.
3412 while (DistanceValue
>= SavedMenuOption
->Skip
&& TopOfScreen
!= NewPos
) {
3414 // Since the Difference is greater than or equal to this op-code's skip value, skip it
3416 DistanceValue
= DistanceValue
- (INTN
) SavedMenuOption
->Skip
;
3417 TopOfScreen
= TopOfScreen
->ForwardLink
;
3418 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3421 // Since we will act on this op-code in the next routine, and increment the
3422 // SkipValue, set the skips to one less than what is required.
3424 if (TopOfScreen
!= NewPos
) {
3425 SkipValue
= DistanceValue
;
3431 // Since we will act on this op-code in the next routine, and increment the
3432 // SkipValue, set the skips to one less than what is required.
3434 SkipValue
+= Temp
- BottomRow
;
3437 } else if (!IsSelectable (NextMenuOption
)) {
3439 // Continue to go down until scroll to next page or the selectable option is found.
3441 ScreenOperation
= UiDown
;
3442 ControlFlag
= CfScreenOperation
;
3446 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3449 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
3451 // BottomRow - TopRow + 1 means the total rows current forms supported.
3452 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
3453 // and new top menu. New top menu will all shows in next form, but last highlight menu
3454 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
3455 // last highlight menu.
3457 if (!IsSelectable (NextMenuOption
) && IsSelectable (MenuOption
) &&
3458 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
3459 NewPos
= SavedListEntry
;
3462 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3465 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3467 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3468 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3470 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3473 case CfUiNoOperation
:
3474 ControlFlag
= CfRepaint
;
3478 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
3479 if (HelpString
!= NULL
) {
3480 FreePool (HelpString
);
3482 if (HelpHeaderString
!= NULL
) {
3483 FreePool (HelpHeaderString
);
3485 if (HelpBottomString
!= NULL
) {
3486 FreePool (HelpBottomString
);
3498 Base on the browser status info to show an pop up message.
3502 BrowserStatusProcess (
3508 EFI_EVENT WaitList
[2];
3509 EFI_EVENT RefreshIntervalEvent
;
3510 EFI_EVENT TimeOutEvent
;
3514 WARNING_IF_CONTEXT EventContext
;
3515 EFI_IFR_OP_HEADER
*OpCodeBuf
;
3516 EFI_STRING_ID StringToken
;
3517 CHAR16 DiscardChange
;
3518 CHAR16 JumpToFormSet
;
3519 CHAR16
*PrintString
;
3521 if (gFormData
->BrowserStatus
== BROWSER_SUCCESS
) {
3526 TimeOutEvent
= NULL
;
3527 RefreshIntervalEvent
= NULL
;
3529 if (gFormData
->HighLightedStatement
!= NULL
) {
3530 OpCodeBuf
= gFormData
->HighLightedStatement
->OpCode
;
3533 if (gFormData
->BrowserStatus
== (BROWSER_WARNING_IF
)) {
3534 ASSERT (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_WARNING_IF_OP
);
3536 TimeOut
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->TimeOut
;
3537 StringToken
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->Warning
;
3540 if ((gFormData
->BrowserStatus
== (BROWSER_NO_SUBMIT_IF
)) &&
3541 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_NO_SUBMIT_IF_OP
)) {
3542 StringToken
= ((EFI_IFR_NO_SUBMIT_IF
*) OpCodeBuf
)->Error
;
3543 } else if ((gFormData
->BrowserStatus
== (BROWSER_INCONSISTENT_IF
)) &&
3544 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_INCONSISTENT_IF_OP
)) {
3545 StringToken
= ((EFI_IFR_INCONSISTENT_IF
*) OpCodeBuf
)->Error
;
3549 if (StringToken
!= 0) {
3550 ErrorInfo
= GetToken (StringToken
, gFormData
->HiiHandle
);
3551 } else if (gFormData
->ErrorString
!= NULL
) {
3553 // Only used to compatible with old setup browser.
3554 // Not use this field in new browser core.
3556 ErrorInfo
= gFormData
->ErrorString
;
3558 switch (gFormData
->BrowserStatus
) {
3559 case BROWSER_SUBMIT_FAIL
:
3560 ErrorInfo
= gSaveFailed
;
3563 case BROWSER_FORM_NOT_FOUND
:
3564 ErrorInfo
= gFormNotFound
;
3567 case BROWSER_FORM_SUPPRESS
:
3568 ErrorInfo
= gFormSuppress
;
3571 case BROWSER_PROTOCOL_NOT_FOUND
:
3572 ErrorInfo
= gProtocolNotFound
;
3575 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3576 ErrorInfo
= gNoSubmitIfFailed
;
3580 ErrorInfo
= gBrwoserError
;
3585 switch (gFormData
->BrowserStatus
) {
3586 case BROWSER_SUBMIT_FAIL
:
3587 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3588 ASSERT (gUserInput
!= NULL
);
3589 if (gFormData
->BrowserStatus
== (BROWSER_SUBMIT_FAIL
)) {
3590 PrintString
= gSaveProcess
;
3591 JumpToFormSet
= gJumpToFormSet
[0];
3593 PrintString
= gSaveNoSubmitProcess
;
3594 JumpToFormSet
= gCheckError
[0];
3596 DiscardChange
= gDiscardChange
[0];
3599 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, PrintString
, gEmptyString
, NULL
);
3600 } while (((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) &&
3601 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (JumpToFormSet
| UPPER_LOWER_CASE_OFFSET
)));
3603 if ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) == (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) {
3604 gUserInput
->Action
= BROWSER_ACTION_DISCARD
;
3606 gUserInput
->Action
= BROWSER_ACTION_GOTO
;
3613 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, gPressEnter
, gEmptyString
, NULL
);
3614 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
3616 Status
= gBS
->CreateEvent (EVT_NOTIFY_WAIT
, TPL_CALLBACK
, EmptyEventProcess
, NULL
, &TimeOutEvent
);
3617 ASSERT_EFI_ERROR (Status
);
3619 EventContext
.SyncEvent
= TimeOutEvent
;
3620 EventContext
.TimeOut
= &TimeOut
;
3621 EventContext
.ErrorInfo
= ErrorInfo
;
3623 Status
= gBS
->CreateEvent (EVT_TIMER
| EVT_NOTIFY_SIGNAL
, TPL_CALLBACK
, RefreshTimeOutProcess
, &EventContext
, &RefreshIntervalEvent
);
3624 ASSERT_EFI_ERROR (Status
);
3627 // Show the dialog first to avoid long time not reaction.
3629 gBS
->SignalEvent (RefreshIntervalEvent
);
3631 Status
= gBS
->SetTimer (RefreshIntervalEvent
, TimerPeriodic
, ONE_SECOND
);
3632 ASSERT_EFI_ERROR (Status
);
3635 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
3636 if (!EFI_ERROR (Status
) && Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
3640 if (Status
!= EFI_NOT_READY
) {
3644 WaitList
[0] = TimeOutEvent
;
3645 WaitList
[1] = gST
->ConIn
->WaitForKey
;
3647 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
3648 ASSERT_EFI_ERROR (Status
);
3652 // Timeout occur, close the hoot time out event.
3658 gBS
->CloseEvent (TimeOutEvent
);
3659 gBS
->CloseEvent (RefreshIntervalEvent
);
3664 if (StringToken
!= 0) {
3665 FreePool (ErrorInfo
);
3670 Display one form, and return user input.
3672 @param FormData Form Data to be shown.
3673 @param UserInputData User input data.
3675 @retval EFI_SUCCESS 1.Form Data is shown, and user input is got.
3676 2.Error info has show and return.
3677 @retval EFI_INVALID_PARAMETER The input screen dimension is not valid
3678 @retval EFI_NOT_FOUND New form data has some error.
3683 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
3684 OUT USER_INPUT
*UserInputData
3689 ASSERT (FormData
!= NULL
);
3690 if (FormData
== NULL
) {
3691 return EFI_INVALID_PARAMETER
;
3694 gUserInput
= UserInputData
;
3695 gFormData
= FormData
;
3698 // Process the status info first.
3700 BrowserStatusProcess();
3701 if (gFormData
->BrowserStatus
!= BROWSER_SUCCESS
) {
3703 // gFormData->BrowserStatus != BROWSER_SUCCESS, means only need to print the error info, return here.
3708 Status
= DisplayPageFrame (FormData
, &gStatementDimensions
);
3709 if (EFI_ERROR (Status
)) {
3714 // Global Widths should be initialized before any MenuOption creation
3715 // or the GetWidth() used in UiAddMenuOption() will return incorrect value.
3719 // |<-.->|<-.........->|<- .........->|<-...........->|
3720 // Skip Prompt Option Help
3722 gOptionBlockWidth
= (CHAR16
) ((gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 3) + 1;
3723 gHelpBlockWidth
= (CHAR16
) (gOptionBlockWidth
- 1 - LEFT_SKIPPED_COLUMNS
);
3724 gPromptBlockWidth
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gOptionBlockWidth
- 1) - 1);
3726 ConvertStatementToMenu();
3729 // Check whether layout is changed.
3732 || (gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
)
3733 || (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))
3734 || (gOldFormEntry
.FormId
!= FormData
->FormId
)) {
3735 mStatementLayoutIsChanged
= TRUE
;
3737 mStatementLayoutIsChanged
= FALSE
;
3740 Status
= UiDisplayMenu(FormData
);
3743 // Backup last form info.
3745 mIsFirstForm
= FALSE
;
3746 gOldFormEntry
.HiiHandle
= FormData
->HiiHandle
;
3747 CopyGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
);
3748 gOldFormEntry
.FormId
= FormData
->FormId
;
3754 Clear Screen to the initial state.
3758 DriverClearDisplayPage (
3762 ClearDisplayPage ();
3763 mIsFirstForm
= TRUE
;
3767 Set Buffer to Value for Size bytes.
3769 @param Buffer Memory to set.
3770 @param Size Number of bytes to set
3771 @param Value Value of the set operation.
3784 while ((Size
--) != 0) {
3790 Initialize Setup Browser driver.
3792 @param ImageHandle The image handle.
3793 @param SystemTable The system table.
3795 @retval EFI_SUCCESS The Setup Browser module is initialized correctly..
3796 @return Other value if failed to initialize the Setup Browser module.
3801 InitializeDisplayEngine (
3802 IN EFI_HANDLE ImageHandle
,
3803 IN EFI_SYSTEM_TABLE
*SystemTable
3807 EFI_INPUT_KEY HotKey
;
3808 EFI_STRING NewString
;
3809 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL
*FormBrowserEx2
;
3812 // Publish our HII data
3814 gHiiHandle
= HiiAddPackages (
3815 &gDisplayEngineGuid
,
3817 DisplayEngineStrings
,
3820 ASSERT (gHiiHandle
!= NULL
);
3823 // Install Form Display protocol
3825 Status
= gBS
->InstallProtocolInterface (
3826 &mPrivateData
.Handle
,
3827 &gEdkiiFormDisplayEngineProtocolGuid
,
3828 EFI_NATIVE_INTERFACE
,
3829 &mPrivateData
.FromDisplayProt
3831 ASSERT_EFI_ERROR (Status
);
3833 InitializeDisplayStrings();
3835 ZeroMem (&gHighligthMenuInfo
, sizeof (gHighligthMenuInfo
));
3836 ZeroMem (&gOldFormEntry
, sizeof (gOldFormEntry
));
3839 // Use BrowserEx2 protocol to register HotKey.
3841 Status
= gBS
->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid
, NULL
, (VOID
**) &FormBrowserEx2
);
3842 if (!EFI_ERROR (Status
)) {
3844 // Register the default HotKey F9 and F10 again.
3846 HotKey
.UnicodeChar
= CHAR_NULL
;
3847 HotKey
.ScanCode
= SCAN_F10
;
3848 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_TEN_STRING
), NULL
);
3849 ASSERT (NewString
!= NULL
);
3850 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_SUBMIT
, 0, NewString
);
3852 HotKey
.ScanCode
= SCAN_F9
;
3853 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_NINE_STRING
), NULL
);
3854 ASSERT (NewString
!= NULL
);
3855 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_DEFAULT
, EFI_HII_DEFAULT_CLASS_STANDARD
, NewString
);
3862 This is the default unload handle for display core drivers.
3864 @param[in] ImageHandle The drivers' driver image.
3866 @retval EFI_SUCCESS The image is unloaded.
3867 @retval Others Failed to unload the image.
3872 UnloadDisplayEngine (
3873 IN EFI_HANDLE ImageHandle
3876 HiiRemovePackages(gHiiHandle
);
3878 FreeDisplayStrings ();
3880 if (gHighligthMenuInfo
.HLTOpCode
!= NULL
) {
3881 FreePool (gHighligthMenuInfo
.HLTOpCode
);
3884 if (gHighligthMenuInfo
.TOSOpCode
!= NULL
) {
3885 FreePool (gHighligthMenuInfo
.TOSOpCode
);