2 Entry and initialization module for the browser.
4 Copyright (c) 2007 - 2014, 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
*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 Find the first menu which will be show at the top.
1479 @param FormData The data info for this form.
1480 @param TopOfScreen The link_entry pointer to top menu.
1481 @param HighlightMenu The menu which will be highlight.
1482 @param SkipValue The skip value for the top menu.
1487 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
1488 OUT LIST_ENTRY
**TopOfScreen
,
1489 OUT LIST_ENTRY
**HighlightMenu
,
1490 OUT UINTN
*SkipValue
1496 UI_MENU_OPTION
*SavedMenuOption
;
1500 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
1501 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
;
1504 // If not has input highlight statement, just return the first one in this form.
1506 if (FormData
->HighLightedStatement
== NULL
) {
1507 *TopOfScreen
= gMenuOption
.ForwardLink
;
1508 *HighlightMenu
= gMenuOption
.ForwardLink
;
1509 if (!IsListEmpty (&gMenuOption
)) {
1510 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
, TRUE
);
1517 // Now base on the input highlight menu to find the top menu in this page.
1518 // Will base on the highlight menu show at the bottom to find the top menu.
1520 NewPos
= gMenuOption
.ForwardLink
;
1521 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1523 while ((SavedMenuOption
->ThisTag
!= FormData
->HighLightedStatement
) ||
1524 (SavedMenuOption
->Sequence
!= gSequence
)) {
1525 NewPos
= NewPos
->ForwardLink
;
1526 if (NewPos
== &gMenuOption
) {
1528 // Not Found it, break
1532 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1534 ASSERT (SavedMenuOption
->ThisTag
== FormData
->HighLightedStatement
);
1536 *HighlightMenu
= NewPos
;
1538 AdjustDateAndTimePosition(FALSE
, &NewPos
);
1539 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1540 UpdateOptionSkipLines (SavedMenuOption
);
1543 // FormRefreshEvent != NULL means this form will auto exit at an interval, display engine
1544 // will try to keep highlight on the current position after this form exit and re-enter.
1546 // HiiHandle + QuestionId can find the only one question in the system.
1548 // If this question has question id, save the question id info to find the question.
1549 // else save the opcode buffer to find it.
1551 if (gFormData
->FormRefreshEvent
!= NULL
&& gFormData
->HiiHandle
== gHighligthMenuInfo
.HiiHandle
) {
1552 if (gHighligthMenuInfo
.QuestionId
!= 0) {
1553 if (gHighligthMenuInfo
.QuestionId
== GetQuestionIdInfo(SavedMenuOption
->ThisTag
->OpCode
)) {
1554 BottomRow
= gHighligthMenuInfo
.DisplayRow
+ SavedMenuOption
->Skip
;
1556 // SkipValue only used for menu at the top of the form.
1557 // If Highlight menu is not at the top, this value will be update later.
1559 TmpValue
= gHighligthMenuInfo
.SkipValue
;
1561 } else if (gHighligthMenuInfo
.OpCode
!= NULL
){
1562 if (!CompareMem (gHighligthMenuInfo
.OpCode
, SavedMenuOption
->ThisTag
->OpCode
, gHighligthMenuInfo
.OpCode
->Length
)) {
1563 BottomRow
= gHighligthMenuInfo
.DisplayRow
+ SavedMenuOption
->Skip
;
1565 // SkipValue only used for menu at the top of the form.
1566 // If Highlight menu is not at the top, this value will be update later.
1568 TmpValue
= gHighligthMenuInfo
.SkipValue
;
1573 if (SavedMenuOption
->Skip
>= BottomRow
- TopRow
) {
1574 *TopOfScreen
= NewPos
;
1576 *TopOfScreen
= FindTopOfScreenMenu(NewPos
, BottomRow
- TopRow
- SavedMenuOption
->Skip
, &TmpValue
);
1578 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1580 *SkipValue
= TmpValue
;
1584 Update highlight menu info.
1586 @param MenuOption The menu opton which is highlight.
1587 @param SkipValue The skipvalue info for this menu.
1588 SkipValue only used for the menu at the top of the form.
1592 UpdateHighlightMenuInfo (
1593 IN UI_MENU_OPTION
*MenuOption
,
1597 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1600 // This is the current selected statement
1602 Statement
= MenuOption
->ThisTag
;
1605 // Get the highlight statement.
1607 gUserInput
->SelectedStatement
= Statement
;
1608 gSequence
= (UINT16
) MenuOption
->Sequence
;
1611 // FormRefreshEvent != NULL means this form will auto exit at an interval, display engine
1612 // will try to keep highlight on the current position after this form exit and re-enter.
1614 // HiiHandle + QuestionId can find the only one question in the system.
1616 // If this question has question id, base on the question id info to find the question.
1617 // else base on the opcode buffer to find it.
1619 if (gFormData
->FormRefreshEvent
!= NULL
) {
1620 gHighligthMenuInfo
.HiiHandle
= gFormData
->HiiHandle
;
1621 gHighligthMenuInfo
.QuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1624 // if question id == 0, save the opcode buffer for later use.
1626 if (gHighligthMenuInfo
.QuestionId
== 0) {
1627 if (gHighligthMenuInfo
.OpCode
!= NULL
) {
1628 FreePool (gHighligthMenuInfo
.OpCode
);
1630 gHighligthMenuInfo
.OpCode
= AllocateCopyPool (Statement
->OpCode
->Length
, Statement
->OpCode
);
1631 ASSERT (gHighligthMenuInfo
.OpCode
!= NULL
);
1633 gHighligthMenuInfo
.DisplayRow
= (UINT16
) MenuOption
->Row
;
1634 gHighligthMenuInfo
.SkipValue
= (UINT16
) SkipValue
;
1636 gHighligthMenuInfo
.HiiHandle
= NULL
;
1637 gHighligthMenuInfo
.QuestionId
= 0;
1638 if (gHighligthMenuInfo
.OpCode
!= NULL
) {
1639 FreePool (gHighligthMenuInfo
.OpCode
);
1640 gHighligthMenuInfo
.OpCode
= NULL
;
1642 gHighligthMenuInfo
.DisplayRow
= 0;
1643 gHighligthMenuInfo
.SkipValue
= 0;
1646 RefreshKeyHelp(gFormData
, Statement
, FALSE
);
1650 Update attribut for this menu.
1652 @param MenuOption The menu opton which this attribut used to.
1653 @param Highlight Whether this menu will be highlight.
1657 SetDisplayAttribute (
1658 IN UI_MENU_OPTION
*MenuOption
,
1659 IN BOOLEAN Highlight
1662 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1664 Statement
= MenuOption
->ThisTag
;
1667 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
1671 if (MenuOption
->GrayOut
) {
1672 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetGrayedTextColor ());
1674 if (Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) {
1675 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetSubTitleTextColor ());
1677 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
1683 Print string for this menu option.
1685 @param MenuOption The menu opton which this attribut used to.
1686 @param Col The column that this string will be print at.
1687 @param Row The row that this string will be print at.
1688 @param String The string which need to print.
1689 @param Width The width need to print, if string is less than the
1690 width, the block space will be used.
1691 @param Highlight Whether this menu will be highlight.
1696 IN UI_MENU_OPTION
*MenuOption
,
1701 IN BOOLEAN Highlight
1707 // Print string with normal color.
1710 PrintStringAtWithWidth (Col
, Row
, String
, Width
);
1715 // Print the highlight menu string.
1716 // First print the highlight string.
1718 SetDisplayAttribute(MenuOption
, TRUE
);
1719 Length
= PrintStringAt (Col
, Row
, String
);
1722 // Second, clean the empty after the string.
1724 SetDisplayAttribute(MenuOption
, FALSE
);
1725 PrintStringAtWithWidth (Col
+ Length
, Row
, L
"", Width
- Length
);
1729 Check whether this menu can has option string.
1731 @param MenuOption The menu opton which this attribut used to.
1733 @retval TRUE This menu option can have option string.
1734 @retval FALSE This menu option can't have option string.
1739 IN UI_MENU_OPTION
*MenuOption
1742 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1745 EFI_IFR_TEXT
*TestOp
;
1748 Statement
= MenuOption
->ThisTag
;
1751 // See if the second text parameter is really NULL
1753 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
1754 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
1755 if (TestOp
->TextTwo
!= 0) {
1756 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
1757 Size
= StrLen (String
);
1762 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
1763 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
1764 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
1765 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
1766 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
1768 // Allow a wide display if text op-code and no secondary text op-code
1770 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
1781 Print string for this menu option.
1783 @param MenuOption The menu opton which this attribut used to.
1784 @param SkipWidth The skip width between the left to the start of the prompt.
1785 @param BeginCol The begin column for one menu.
1786 @param SkipLine The skip line for this menu.
1787 @param BottomRow The bottom row for this form.
1788 @param Highlight Whether this menu will be highlight.
1789 @param UpdateCol Whether need to update the column info for Date/Time.
1791 @retval EFI_SUCESSS Process the user selection success.
1796 IN UI_MENU_OPTION
*MenuOption
,
1801 IN BOOLEAN Highlight
,
1802 IN BOOLEAN UpdateCol
1805 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1810 CHAR16
*OptionString
;
1811 CHAR16
*OutputString
;
1819 UINTN PromptLineNum
;
1820 UINTN OptionLineNum
;
1824 Statement
= MenuOption
->ThisTag
;
1834 // Set default color.
1836 SetDisplayAttribute (MenuOption
, FALSE
);
1839 // 1. Paint the option string.
1841 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
1842 if (EFI_ERROR (Status
)) {
1846 if (OptionString
!= NULL
) {
1847 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1849 // Adjust option string for date/time opcode.
1851 ProcessStringForDateTime(MenuOption
, OptionString
, UpdateCol
);
1854 Width
= (UINT16
) gOptionBlockWidth
- 1;
1855 Row
= MenuOption
->Row
;
1859 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1860 if (((Temp2
== 0)) && (Row
<= BottomRow
)) {
1861 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1863 // For date/time question, it has three menu options for this qustion.
1864 // The first/second menu options with the skip value is 0. the last one
1865 // with skip value is 1.
1867 if (MenuOption
->Skip
!= 0) {
1869 // For date/ time, print the last past (year for date and second for time)
1870 // - 7 means skip [##/##/ for date and [##:##: for time.
1872 DisplayMenuString (MenuOption
,MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1 - 7, Highlight
);
1875 // For date/ time, print the first and second past (year for date and second for time)
1876 // The OutputString has a NARROW_CHAR or WIDE_CHAR at the begin of the string,
1877 // so need to - 1 to remove it, otherwise, it will clean 1 extr char follow it.
1878 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, StrLen (OutputString
) - 1, Highlight
);
1881 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
1887 // If there is more string to process print on the next row and increment the Skip value
1889 if (StrLen (&OptionString
[Index
]) != 0) {
1893 // Since the Number of lines for this menu entry may or may not be reflected accurately
1894 // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
1895 // some testing to ensure we are keeping this in-sync.
1897 // If the difference in rows is greater than or equal to the skip value, increase the skip value
1899 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
1905 FreePool (OutputString
);
1913 FreePool (OptionString
);
1917 // 2. Paint the description.
1919 PromptWidth
= GetWidth (MenuOption
, &AdjustValue
);
1920 Row
= MenuOption
->Row
;
1924 if (MenuOption
->Description
== NULL
|| MenuOption
->Description
[0] == '\0') {
1925 PrintStringAtWithWidth (BeginCol
, Row
, L
"", PromptWidth
+ AdjustValue
+ SkipWidth
);
1928 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, PromptWidth
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1929 if ((Temp
== 0) && (Row
<= BottomRow
)) {
1931 // 1.Clean the start LEFT_SKIPPED_COLUMNS
1933 PrintStringAtWithWidth (BeginCol
, Row
, L
"", SkipWidth
);
1935 if (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
&& MenuOption
->Col
>= 2) {
1937 // Print Arrow for Goto button.
1940 MenuOption
->Col
- 2,
1942 GEOMETRICSHAPE_RIGHT_TRIANGLE
1945 DisplayMenuString (MenuOption
, MenuOption
->Col
, Row
, OutputString
, PromptWidth
+ AdjustValue
, Highlight
);
1949 // If there is more string to process print on the next row and increment the Skip value
1951 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
1957 FreePool (OutputString
);
1968 // 3. If this is a text op with secondary text information
1970 if ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
!= 0)) {
1971 StringPtr
= GetToken (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
1973 Width
= (UINT16
) gOptionBlockWidth
- 1;
1974 Row
= MenuOption
->Row
;
1978 for (Index
= 0; GetLineByWidth (StringPtr
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1979 if ((Temp3
== 0) && (Row
<= BottomRow
)) {
1980 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
1984 // If there is more string to process print on the next row and increment the Skip value
1986 if (StrLen (&StringPtr
[Index
]) != 0) {
1990 // If the rows for text two is greater than or equal to the skip value, increase the skip value
1992 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
1998 FreePool (OutputString
);
2004 FreePool (StringPtr
);
2008 // 4.Line number for Option string and prompt string are not equal.
2009 // Clean the column whose line number is less.
2011 if (HasOptionString(MenuOption
) && (OptionLineNum
!= PromptLineNum
)) {
2012 Col
= OptionLineNum
< PromptLineNum
? MenuOption
->OptCol
: BeginCol
;
2013 Row
= (OptionLineNum
< PromptLineNum
? OptionLineNum
: PromptLineNum
) + MenuOption
->Row
;
2014 Width
= (UINT16
) (OptionLineNum
< PromptLineNum
? gOptionBlockWidth
: PromptWidth
+ AdjustValue
+ SkipWidth
);
2015 MaxRow
= (OptionLineNum
< PromptLineNum
? PromptLineNum
: OptionLineNum
) + MenuOption
->Row
- 1;
2017 while (Row
<= MaxRow
) {
2018 DisplayMenuString (MenuOption
, Col
, Row
++, L
"", Width
, FALSE
);
2026 Display menu and wait for user to select one menu option, then return it.
2027 If AutoBoot is enabled, then if user doesn't select any option,
2028 after period of time, it will automatically return the first menu option.
2030 @param FormData The current form data info.
2032 @retval EFI_SUCESSS Process the user selection success.
2033 @retval EFI_NOT_FOUND Process option string for orderedlist/Oneof fail.
2038 IN FORM_DISPLAY_ENGINE_FORM
*FormData
2043 UINTN DistanceValue
;
2053 CHAR16
*OptionString
;
2054 CHAR16
*OutputString
;
2056 CHAR16
*HelpHeaderString
;
2057 CHAR16
*HelpBottomString
;
2066 LIST_ENTRY
*TopOfScreen
;
2067 LIST_ENTRY
*SavedListEntry
;
2068 UI_MENU_OPTION
*MenuOption
;
2069 UI_MENU_OPTION
*NextMenuOption
;
2070 UI_MENU_OPTION
*SavedMenuOption
;
2071 UI_MENU_OPTION
*PreviousMenuOption
;
2072 UI_CONTROL_FLAG ControlFlag
;
2073 UI_SCREEN_OPERATION ScreenOperation
;
2075 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2076 BROWSER_HOT_KEY
*HotKey
;
2077 UINTN HelpPageIndex
;
2078 UINTN HelpPageCount
;
2081 UINTN HelpHeaderLine
;
2082 UINTN HelpBottomLine
;
2083 BOOLEAN MultiHelpPage
;
2084 UINT16 EachLineWidth
;
2085 UINT16 HeaderLineWidth
;
2086 UINT16 BottomLineWidth
;
2087 EFI_STRING_ID HelpInfo
;
2088 UI_EVENT_TYPE EventType
;
2089 FORM_DISPLAY_ENGINE_STATEMENT
*InitialHighlight
;
2090 BOOLEAN SkipHighLight
;
2092 EventType
= UIEventNone
;
2093 Status
= EFI_SUCCESS
;
2095 HelpHeaderString
= NULL
;
2096 HelpBottomString
= NULL
;
2097 OptionString
= NULL
;
2098 ScreenOperation
= UiNoOperation
;
2107 MultiHelpPage
= FALSE
;
2109 HeaderLineWidth
= 0;
2110 BottomLineWidth
= 0;
2111 OutputString
= NULL
;
2115 SkipHighLight
= FALSE
;
2117 NextMenuOption
= NULL
;
2118 PreviousMenuOption
= NULL
;
2119 SavedMenuOption
= NULL
;
2123 gModalSkipColumn
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 6;
2124 InitialHighlight
= gFormData
->HighLightedStatement
;
2126 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
2130 // |<-.->|<-.........->|<- .........->|<-...........->|
2131 // Skip Prompt Option Help
2133 Width
= (CHAR16
) ((gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 3);
2134 gOptionBlockWidth
= Width
+ 1;
2135 gHelpBlockWidth
= (CHAR16
) (Width
- LEFT_SKIPPED_COLUMNS
);
2136 gPromptBlockWidth
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * Width
- 1);
2138 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
2139 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
- 1;
2142 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2143 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gModalSkipColumn
;
2145 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
;
2148 FindTopMenu(FormData
, &TopOfScreen
, &NewPos
, &SkipValue
);
2150 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
2152 ControlFlag
= CfInitialization
;
2154 switch (ControlFlag
) {
2155 case CfInitialization
:
2156 if ((gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
) ||
2157 (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))) {
2159 // Clear Statement range if different formset is painted.
2162 gStatementDimensions
.LeftColumn
,
2163 gStatementDimensions
.RightColumn
,
2164 TopRow
- SCROLL_ARROW_HEIGHT
,
2165 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2166 GetFieldTextColor ()
2170 ControlFlag
= CfRepaint
;
2174 ControlFlag
= CfRefreshHighLight
;
2184 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2187 // 1. Check whether need to print the arrow up.
2189 if (!ValueIsScroll (TRUE
, TopOfScreen
)) {
2193 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2194 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2196 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2199 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2201 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2202 TopRow
- SCROLL_ARROW_HEIGHT
,
2205 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2209 // 2.Paint the menu.
2211 for (Link
= TopOfScreen
; Link
!= &gMenuOption
; Link
= Link
->ForwardLink
) {
2212 MenuOption
= MENU_OPTION_FROM_LINK (Link
);
2213 MenuOption
->Row
= Row
;
2214 MenuOption
->Col
= Col
;
2215 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2216 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
+ gModalSkipColumn
;
2218 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
;
2221 if (MenuOption
->NestInStatement
) {
2222 MenuOption
->Col
+= SUBTITLE_INDENT
;
2226 // Save the highlight menu, will be used in CfRefreshHighLight case.
2228 if (Link
== NewPos
) {
2229 SavedMenuOption
= MenuOption
;
2230 SkipHighLight
= TRUE
;
2233 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2234 Status
= DisplayOneMenu (MenuOption
,
2235 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2236 gStatementDimensions
.LeftColumn
+ gModalSkipColumn
,
2237 Link
== TopOfScreen
? SkipValue
: 0,
2239 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2243 Status
= DisplayOneMenu (MenuOption
,
2244 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2245 gStatementDimensions
.LeftColumn
,
2246 Link
== TopOfScreen
? SkipValue
: 0,
2248 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2253 if (EFI_ERROR (Status
)) {
2257 // 3. Update the row info which will be used by next menu.
2259 if (Link
== TopOfScreen
) {
2260 Row
+= MenuOption
->Skip
- SkipValue
;
2262 Row
+= MenuOption
->Skip
;
2265 if (Row
> BottomRow
) {
2266 if (!ValueIsScroll (FALSE
, Link
)) {
2270 Row
= BottomRow
+ 1;
2276 // 3. Menus in this form may not cover all form, clean the remain field.
2278 while (Row
<= BottomRow
) {
2279 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2280 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2282 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gHelpBlockWidth
- gStatementDimensions
.LeftColumn
);
2287 // 4. Print the down arrow row.
2289 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2290 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * + gModalSkipColumn
);
2292 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2295 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2297 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2298 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2301 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2308 case CfRefreshHighLight
:
2311 // MenuOption: Last menu option that need to remove hilight
2312 // MenuOption is set to NULL in Repaint
2313 // NewPos: Current menu option that need to hilight
2315 ControlFlag
= CfUpdateHelpString
;
2317 if (SkipHighLight
) {
2318 MenuOption
= SavedMenuOption
;
2319 SkipHighLight
= FALSE
;
2320 UpdateHighlightMenuInfo (MenuOption
, TopOfScreen
== &MenuOption
->Link
? SkipValue
: 0);
2324 if (IsListEmpty (&gMenuOption
)) {
2326 // No menu option, just update the hotkey filed.
2328 RefreshKeyHelp(gFormData
, NULL
, FALSE
);
2332 if (MenuOption
!= NULL
&& TopOfScreen
== &MenuOption
->Link
) {
2337 if (NewPos
== TopOfScreen
) {
2343 if (NewPos
!= NULL
&& (MenuOption
== NULL
|| NewPos
!= &MenuOption
->Link
)) {
2344 if (MenuOption
!= NULL
) {
2346 // Remove the old highlight menu.
2348 Status
= DisplayOneMenu (MenuOption
,
2349 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2350 gStatementDimensions
.LeftColumn
,
2359 // This is the current selected statement
2361 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2362 Statement
= MenuOption
->ThisTag
;
2364 UpdateHighlightMenuInfo (MenuOption
, Temp2
);
2366 if (!IsSelectable (MenuOption
)) {
2370 Status
= DisplayOneMenu (MenuOption
,
2371 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2372 gStatementDimensions
.LeftColumn
,
2381 case CfUpdateHelpString
:
2382 ControlFlag
= CfPrepareToReadKey
;
2383 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2388 // NewLine means only update highlight menu (remove old highlight and highlith
2389 // the new one), not need to full repain the form.
2391 if (Repaint
|| NewLine
) {
2392 if (IsListEmpty (&gMenuOption
)) {
2394 // Don't print anything if no mwnu option.
2396 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2399 // Don't print anything if it is a NULL help token
2401 ASSERT(MenuOption
!= NULL
);
2402 HelpInfo
= ((EFI_IFR_STATEMENT_HEADER
*) ((CHAR8
*)MenuOption
->ThisTag
->OpCode
+ sizeof (EFI_IFR_OP_HEADER
)))->Help
;
2403 if (HelpInfo
== 0 || !IsSelectable (MenuOption
)) {
2404 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2406 StringPtr
= GetToken (HelpInfo
, gFormData
->HiiHandle
);
2410 RowCount
= BottomRow
- TopRow
+ 1;
2413 // 1.Calculate how many line the help string need to print.
2415 if (HelpString
!= NULL
) {
2416 FreePool (HelpString
);
2419 HelpLine
= ProcessHelpString (StringPtr
, &HelpString
, &EachLineWidth
, RowCount
);
2420 FreePool (StringPtr
);
2422 if (HelpLine
> RowCount
) {
2423 MultiHelpPage
= TRUE
;
2424 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_UP
), gHiiHandle
);
2425 if (HelpHeaderString
!= NULL
) {
2426 FreePool (HelpHeaderString
);
2427 HelpHeaderString
= NULL
;
2429 HelpHeaderLine
= ProcessHelpString (StringPtr
, &HelpHeaderString
, &HeaderLineWidth
, 0);
2430 FreePool (StringPtr
);
2431 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_DOWN
), gHiiHandle
);
2432 if (HelpBottomString
!= NULL
) {
2433 FreePool (HelpBottomString
);
2434 HelpBottomString
= NULL
;
2436 HelpBottomLine
= ProcessHelpString (StringPtr
, &HelpBottomString
, &BottomLineWidth
, 0);
2437 FreePool (StringPtr
);
2439 // Calculate the help page count.
2441 if (HelpLine
> 2 * RowCount
- 2) {
2442 HelpPageCount
= (HelpLine
- RowCount
+ 1) / (RowCount
- 2) + 1;
2443 if ((HelpLine
- RowCount
+ 1) % (RowCount
- 2) > 1) {
2450 MultiHelpPage
= FALSE
;
2455 // Check whether need to show the 'More(U/u)' at the begin.
2456 // Base on current direct info, here shows aligned to the right side of the column.
2457 // If the direction is multi line and aligned to right side may have problem, so
2458 // add ASSERT code here.
2460 if (HelpPageIndex
> 0) {
2461 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2462 for (Index
= 0; Index
< HelpHeaderLine
; Index
++) {
2463 ASSERT (HelpHeaderLine
== 1);
2464 ASSERT (GetStringWidth (HelpHeaderString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2465 PrintStringAtWithWidth (
2466 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2472 gStatementDimensions
.RightColumn
- GetStringWidth (HelpHeaderString
) / 2 - 1,
2474 &HelpHeaderString
[Index
* HeaderLineWidth
]
2479 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHelpTextColor ());
2481 // Print the help string info.
2483 if (!MultiHelpPage
) {
2484 for (Index
= 0; Index
< HelpLine
; Index
++) {
2485 PrintStringAtWithWidth (
2486 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2488 &HelpString
[Index
* EachLineWidth
],
2492 for (; Index
< RowCount
; Index
++) {
2493 PrintStringAtWithWidth (
2494 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2500 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2502 if (HelpPageIndex
== 0) {
2503 for (Index
= 0; Index
< RowCount
- HelpBottomLine
; Index
++) {
2504 PrintStringAtWithWidth (
2505 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2507 &HelpString
[Index
* EachLineWidth
],
2512 for (Index
= 0; (Index
< RowCount
- HelpBottomLine
- HelpHeaderLine
) &&
2513 (Index
+ HelpPageIndex
* (RowCount
- 2) + 1 < HelpLine
); Index
++) {
2514 PrintStringAtWithWidth (
2515 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2516 Index
+ TopRow
+ HelpHeaderLine
,
2517 &HelpString
[(Index
+ HelpPageIndex
* (RowCount
- 2) + 1)* EachLineWidth
],
2521 if (HelpPageIndex
== HelpPageCount
- 1) {
2522 for (; Index
< RowCount
- HelpHeaderLine
; Index
++) {
2523 PrintStringAtWithWidth (
2524 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2525 Index
+ TopRow
+ HelpHeaderLine
,
2530 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2536 // Check whether need to print the 'More(D/d)' at the bottom.
2537 // Base on current direct info, here shows aligned to the right side of the column.
2538 // If the direction is multi line and aligned to right side may have problem, so
2539 // add ASSERT code here.
2541 if (HelpPageIndex
< HelpPageCount
- 1 && MultiHelpPage
) {
2542 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2543 for (Index
= 0; Index
< HelpBottomLine
; Index
++) {
2544 ASSERT (HelpBottomLine
== 1);
2545 ASSERT (GetStringWidth (HelpBottomString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2546 PrintStringAtWithWidth (
2547 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2548 BottomRow
+ Index
- HelpBottomLine
+ 1,
2553 gStatementDimensions
.RightColumn
- GetStringWidth (HelpBottomString
) / 2 - 1,
2554 BottomRow
+ Index
- HelpBottomLine
+ 1,
2555 &HelpBottomString
[Index
* BottomLineWidth
]
2560 // Reset this flag every time we finish using it.
2566 case CfPrepareToReadKey
:
2567 ControlFlag
= CfReadKey
;
2568 ScreenOperation
= UiNoOperation
;
2572 ControlFlag
= CfScreenOperation
;
2575 // Wait for user's selection
2578 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2579 if (!EFI_ERROR (Status
)) {
2580 EventType
= UIEventKey
;
2585 // If we encounter error, continue to read another key in.
2587 if (Status
!= EFI_NOT_READY
) {
2591 EventType
= UiWaitForEvent(gST
->ConIn
->WaitForKey
);
2592 if (EventType
== UIEventKey
) {
2593 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2598 if (EventType
== UIEventDriver
) {
2599 gUserInput
->Action
= BROWSER_ACTION_NONE
;
2600 ControlFlag
= CfExit
;
2604 if (EventType
== UIEventTimeOut
) {
2605 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2606 ControlFlag
= CfExit
;
2610 switch (Key
.UnicodeChar
) {
2611 case CHAR_CARRIAGE_RETURN
:
2612 if(MenuOption
== NULL
|| MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2613 ControlFlag
= CfReadKey
;
2617 ScreenOperation
= UiSelect
;
2622 // We will push the adjustment of these numeric values directly to the input handler
2623 // NOTE: we won't handle manual input numeric
2628 // If the screen has no menu items, and the user didn't select UiReset
2629 // ignore the selection and go back to reading keys.
2631 ASSERT(MenuOption
!= NULL
);
2632 if(IsListEmpty (&gMenuOption
) || MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2633 ControlFlag
= CfReadKey
;
2637 Statement
= MenuOption
->ThisTag
;
2638 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
)
2639 || (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
2640 || ((Statement
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (GetFieldFromNum(Statement
->OpCode
) != 0))
2642 if (Key
.UnicodeChar
== '+') {
2643 gDirection
= SCAN_RIGHT
;
2645 gDirection
= SCAN_LEFT
;
2648 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2649 if (OptionString
!= NULL
) {
2650 FreePool (OptionString
);
2652 if (EFI_ERROR (Status
)) {
2654 // Repaint to clear possible error prompt pop-up
2659 ControlFlag
= CfExit
;
2665 ScreenOperation
= UiUp
;
2670 ScreenOperation
= UiDown
;
2674 if(IsListEmpty (&gMenuOption
)) {
2675 ControlFlag
= CfReadKey
;
2679 ASSERT(MenuOption
!= NULL
);
2680 if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_CHECKBOX_OP
&& !MenuOption
->GrayOut
&& !MenuOption
->ReadOnly
) {
2681 ScreenOperation
= UiSelect
;
2687 if (!MultiHelpPage
) {
2688 ControlFlag
= CfReadKey
;
2691 ControlFlag
= CfUpdateHelpString
;
2692 HelpPageIndex
= HelpPageIndex
< HelpPageCount
- 1 ? HelpPageIndex
+ 1 : HelpPageCount
- 1;
2697 if (!MultiHelpPage
) {
2698 ControlFlag
= CfReadKey
;
2701 ControlFlag
= CfUpdateHelpString
;
2702 HelpPageIndex
= HelpPageIndex
> 0 ? HelpPageIndex
- 1 : 0;
2706 for (Index
= 0; Index
< mScanCodeNumber
; Index
++) {
2707 if (Key
.ScanCode
== gScanCodeToOperation
[Index
].ScanCode
) {
2708 ScreenOperation
= gScanCodeToOperation
[Index
].ScreenOperation
;
2713 if (((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) && (Key
.ScanCode
== SCAN_ESC
|| Index
== mScanCodeNumber
)) {
2715 // ModalForm has no ESC key and Hot Key.
2717 ControlFlag
= CfReadKey
;
2718 } else if (Index
== mScanCodeNumber
) {
2720 // Check whether Key matches the registered hot key.
2723 HotKey
= GetHotKeyFromRegisterList (&Key
);
2724 if (HotKey
!= NULL
) {
2725 ScreenOperation
= UiHotKey
;
2732 case CfScreenOperation
:
2733 if ((ScreenOperation
!= UiReset
) && (ScreenOperation
!= UiHotKey
)) {
2735 // If the screen has no menu items, and the user didn't select UiReset or UiHotKey
2736 // ignore the selection and go back to reading keys.
2738 if (IsListEmpty (&gMenuOption
)) {
2739 ControlFlag
= CfReadKey
;
2745 Index
< sizeof (gScreenOperationToControlFlag
) / sizeof (gScreenOperationToControlFlag
[0]);
2748 if (ScreenOperation
== gScreenOperationToControlFlag
[Index
].ScreenOperation
) {
2749 ControlFlag
= gScreenOperationToControlFlag
[Index
].ControlFlag
;
2756 ControlFlag
= CfRepaint
;
2758 ASSERT(MenuOption
!= NULL
);
2759 Statement
= MenuOption
->ThisTag
;
2760 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
2764 switch (Statement
->OpCode
->OpCode
) {
2765 case EFI_IFR_REF_OP
:
2766 case EFI_IFR_ACTION_OP
:
2767 case EFI_IFR_RESET_BUTTON_OP
:
2768 ControlFlag
= CfExit
;
2773 // Editable Questions: oneof, ordered list, checkbox, numeric, string, password
2775 RefreshKeyHelp (gFormData
, Statement
, TRUE
);
2776 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2778 if (OptionString
!= NULL
) {
2779 FreePool (OptionString
);
2782 if (EFI_ERROR (Status
)) {
2785 RefreshKeyHelp (gFormData
, Statement
, FALSE
);
2788 ControlFlag
= CfExit
;
2796 // We come here when someone press ESC
2797 // If the policy is not exit front page when user press ESC, process here.
2799 if (!FormExitPolicy()) {
2802 ControlFlag
= CfRepaint
;
2807 // When user press ESC, it will try to show another menu, should clean the gSequence info.
2809 if (gSequence
!= 0) {
2813 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2814 ControlFlag
= CfExit
;
2818 ControlFlag
= CfRepaint
;
2820 ASSERT (HotKey
!= NULL
);
2821 gUserInput
->Action
= HotKey
->Action
;
2822 ControlFlag
= CfExit
;
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
!= 0) {
2831 // In the middle or tail of the Date/Time op-code set, go left.
2833 ASSERT(NewPos
!= NULL
);
2834 NewPos
= NewPos
->BackLink
;
2840 ControlFlag
= CfRepaint
;
2841 ASSERT(MenuOption
!= NULL
);
2842 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
2843 if (MenuOption
->Sequence
!= 2) {
2845 // In the middle or tail of the Date/Time op-code set, go left.
2847 ASSERT(NewPos
!= NULL
);
2848 NewPos
= NewPos
->ForwardLink
;
2854 ControlFlag
= CfRepaint
;
2857 SavedListEntry
= NewPos
;
2858 ASSERT(NewPos
!= NULL
);
2860 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2861 ASSERT (MenuOption
!= NULL
);
2864 // Adjust Date/Time position before we advance forward.
2866 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2868 NewPos
= NewPos
->BackLink
;
2870 // Find next selectable menu or the first menu beyond current form.
2872 Difference
= MoveToNextStatement (TRUE
, &NewPos
, MenuOption
->Row
- TopRow
, FALSE
);
2873 if (Difference
< 0) {
2875 // We hit the begining MenuOption that can be focused
2876 // so we simply scroll to the top.
2879 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
2880 TopOfScreen
= gMenuOption
.ForwardLink
;
2881 NewPos
= SavedListEntry
;
2885 // Scroll up to the last page when we have arrived at top page.
2887 TopOfScreen
= FindTopOfScreenMenu (gMenuOption
.BackLink
, BottomRow
- TopRow
, &SkipValue
);
2888 NewPos
= gMenuOption
.BackLink
;
2889 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
2892 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2894 if (MenuOption
->Row
< TopRow
+ Difference
+ NextMenuOption
->Skip
) {
2896 // Previous focus MenuOption is above the TopOfScreen, so we need to scroll
2898 TopOfScreen
= NewPos
;
2904 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
2906 // BottomRow - TopRow + 1 means the total rows current forms supported.
2907 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
2908 // and new top menu. New top menu will all shows in next form, but last highlight menu
2909 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
2910 // last highlight menu.
2912 if (!IsSelectable(NextMenuOption
) && IsSelectable(MenuOption
) &&
2913 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
2914 NewPos
= SavedListEntry
;
2918 UpdateStatusBar (INPUT_ERROR
, FALSE
);
2921 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
2923 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
2924 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2929 // SkipValue means lines is skipped when show the top menu option.
2931 ControlFlag
= CfRepaint
;
2937 // First minus the menu of the top screen, it's value is SkipValue.
2939 if (SkipValue
>= BottomRow
- TopRow
+ 1) {
2941 // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one
2942 // form of options to be show, so just update the SkipValue to show the next
2943 // parts of options.
2945 SkipValue
-= BottomRow
- TopRow
+ 1;
2946 NewPos
= TopOfScreen
;
2949 Index
= (BottomRow
+ 1) - SkipValue
- TopRow
;
2952 TopOfScreen
= FindTopOfScreenMenu(TopOfScreen
, Index
, &SkipValue
);
2953 NewPos
= TopOfScreen
;
2954 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, FALSE
);
2956 UpdateStatusBar (INPUT_ERROR
, FALSE
);
2959 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
2960 // Don't do this when we are already in the first page.
2962 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
2963 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2968 // SkipValue means lines is skipped when show the top menu option.
2970 ControlFlag
= CfRepaint
;
2975 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
2976 Index
= TopRow
+ NextMenuOption
->Skip
- SkipValue
;
2978 // Count to the menu option which will show at the top of the next form.
2980 while ((Index
<= BottomRow
+ 1) && (Link
->ForwardLink
!= &gMenuOption
)) {
2981 Link
= Link
->ForwardLink
;
2982 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
2983 Index
= Index
+ NextMenuOption
->Skip
;
2986 if ((Link
->ForwardLink
== &gMenuOption
) && (Index
<= BottomRow
+ 1)) {
2988 // Highlight on the last menu which can be highlight.
2991 MoveToNextStatement (TRUE
, &Link
, Index
- TopRow
, TRUE
);
2994 // Calculate the skip line for top of screen menu.
2996 if (Link
== TopOfScreen
) {
2998 // The top of screen menu option occupies the entire form.
3000 SkipValue
+= BottomRow
- TopRow
+ 1;
3002 SkipValue
= NextMenuOption
->Skip
- (Index
- (BottomRow
+ 1));
3007 // Move to the Next selectable menu.
3009 MoveToNextStatement (FALSE
, &Link
, BottomRow
- TopRow
, TRUE
);
3013 // Save the menu as the next highlight menu.
3017 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3020 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3021 // Don't do this when we are already in the last page.
3023 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3024 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3029 // SkipValue means lines is skipped when show the top menu option.
3030 // NewPos points to the menu which is highlighted now.
3032 ControlFlag
= CfRepaint
;
3035 if (NewPos
== TopOfScreen
) {
3041 SavedListEntry
= NewPos
;
3043 // Since the behavior of hitting the down arrow on a Date/Time op-code is intended
3044 // to be one that progresses to the next set of op-codes, we need to advance to the last
3045 // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate
3046 // checking can be done. The only other logic we need to introduce is that if a Date/Time
3047 // op-code is the last entry in the menu, we need to rewind back to the first op-code of
3048 // the Date/Time op-code.
3050 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3052 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3053 NewPos
= NewPos
->ForwardLink
;
3055 // Find the next selectable menu.
3057 if (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
> BottomRow
+ 1) {
3058 if (gMenuOption
.ForwardLink
== NewPos
|| &gMenuOption
== NewPos
) {
3064 Difference
= MoveToNextStatement (FALSE
, &NewPos
, BottomRow
+ 1 - (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
), FALSE
);
3066 if (Difference
< 0) {
3068 // Scroll to the first page.
3070 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3071 TopOfScreen
= gMenuOption
.ForwardLink
;
3075 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3077 NewPos
= gMenuOption
.ForwardLink
;
3078 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
3082 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3084 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3085 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3090 // Get next selected menu info.
3092 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3093 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3094 if (NextMenuOption
->Row
== 0) {
3095 UpdateOptionSkipLines (NextMenuOption
);
3099 // Calculate new highlight menu end row.
3101 Temp
= (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
) + Difference
+ NextMenuOption
->Skip
- 1;
3102 if (Temp
> BottomRow
) {
3104 // Get the top screen menu info.
3106 AdjustDateAndTimePosition (FALSE
, &TopOfScreen
);
3107 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3110 // Current Top screen menu occupy (SavedMenuOption->Skip - SkipValue) rows.
3111 // Full shows the new selected menu need to skip (Temp - BottomRow - 1) rows.
3113 if ((Temp
- BottomRow
) >= (SavedMenuOption
->Skip
- SkipValue
)) {
3115 // Skip the top op-code
3117 TopOfScreen
= TopOfScreen
->ForwardLink
;
3118 DistanceValue
= (Temp
- BottomRow
) - (SavedMenuOption
->Skip
- SkipValue
);
3120 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3123 // If we have a remainder, skip that many more op-codes until we drain the remainder
3124 // Special case is the selected highlight menu has more than one form of menus.
3126 while (DistanceValue
>= SavedMenuOption
->Skip
&& TopOfScreen
!= NewPos
) {
3128 // Since the Difference is greater than or equal to this op-code's skip value, skip it
3130 DistanceValue
= DistanceValue
- (INTN
) SavedMenuOption
->Skip
;
3131 TopOfScreen
= TopOfScreen
->ForwardLink
;
3132 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3135 // Since we will act on this op-code in the next routine, and increment the
3136 // SkipValue, set the skips to one less than what is required.
3138 if (TopOfScreen
!= NewPos
) {
3139 SkipValue
= DistanceValue
;
3145 // Since we will act on this op-code in the next routine, and increment the
3146 // SkipValue, set the skips to one less than what is required.
3148 SkipValue
+= Temp
- BottomRow
;
3151 } else if (!IsSelectable (NextMenuOption
)) {
3153 // Continue to go down until scroll to next page or the selectable option is found.
3155 ScreenOperation
= UiDown
;
3156 ControlFlag
= CfScreenOperation
;
3160 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3163 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
3165 // BottomRow - TopRow + 1 means the total rows current forms supported.
3166 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
3167 // and new top menu. New top menu will all shows in next form, but last highlight menu
3168 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
3169 // last highlight menu.
3171 if (!IsSelectable (NextMenuOption
) && IsSelectable (MenuOption
) &&
3172 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
3173 NewPos
= SavedListEntry
;
3176 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3179 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3181 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3182 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3185 case CfUiNoOperation
:
3186 ControlFlag
= CfRepaint
;
3190 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
3191 if (HelpString
!= NULL
) {
3192 FreePool (HelpString
);
3194 if (HelpHeaderString
!= NULL
) {
3195 FreePool (HelpHeaderString
);
3197 if (HelpBottomString
!= NULL
) {
3198 FreePool (HelpBottomString
);
3210 Base on the browser status info to show an pop up message.
3214 BrowserStatusProcess (
3220 EFI_EVENT WaitList
[2];
3221 EFI_EVENT RefreshIntervalEvent
;
3222 EFI_EVENT TimeOutEvent
;
3226 WARNING_IF_CONTEXT EventContext
;
3227 EFI_IFR_OP_HEADER
*OpCodeBuf
;
3228 EFI_STRING_ID StringToken
;
3229 CHAR16 DiscardChange
;
3230 CHAR16 JumpToFormSet
;
3231 CHAR16
*PrintString
;
3233 if (gFormData
->BrowserStatus
== BROWSER_SUCCESS
) {
3238 TimeOutEvent
= NULL
;
3239 RefreshIntervalEvent
= NULL
;
3241 if (gFormData
->HighLightedStatement
!= NULL
) {
3242 OpCodeBuf
= gFormData
->HighLightedStatement
->OpCode
;
3245 if (gFormData
->BrowserStatus
== (BROWSER_WARNING_IF
)) {
3246 ASSERT (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_WARNING_IF_OP
);
3248 TimeOut
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->TimeOut
;
3249 StringToken
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->Warning
;
3252 if ((gFormData
->BrowserStatus
== (BROWSER_NO_SUBMIT_IF
)) &&
3253 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_NO_SUBMIT_IF_OP
)) {
3254 StringToken
= ((EFI_IFR_NO_SUBMIT_IF
*) OpCodeBuf
)->Error
;
3255 } else if ((gFormData
->BrowserStatus
== (BROWSER_INCONSISTENT_IF
)) &&
3256 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_INCONSISTENT_IF_OP
)) {
3257 StringToken
= ((EFI_IFR_INCONSISTENT_IF
*) OpCodeBuf
)->Error
;
3261 if (StringToken
!= 0) {
3262 ErrorInfo
= GetToken (StringToken
, gFormData
->HiiHandle
);
3263 } else if (gFormData
->ErrorString
!= NULL
) {
3265 // Only used to compatible with old setup browser.
3266 // Not use this field in new browser core.
3268 ErrorInfo
= gFormData
->ErrorString
;
3270 switch (gFormData
->BrowserStatus
) {
3271 case BROWSER_SUBMIT_FAIL
:
3272 ErrorInfo
= gSaveFailed
;
3275 case BROWSER_FORM_NOT_FOUND
:
3276 ErrorInfo
= gFormNotFound
;
3279 case BROWSER_FORM_SUPPRESS
:
3280 ErrorInfo
= gFormSuppress
;
3283 case BROWSER_PROTOCOL_NOT_FOUND
:
3284 ErrorInfo
= gProtocolNotFound
;
3287 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3288 ErrorInfo
= gNoSubmitIfFailed
;
3292 ErrorInfo
= gBrwoserError
;
3297 switch (gFormData
->BrowserStatus
) {
3298 case BROWSER_SUBMIT_FAIL
:
3299 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3300 ASSERT (gUserInput
!= NULL
);
3301 if (gFormData
->BrowserStatus
== (BROWSER_SUBMIT_FAIL
)) {
3302 PrintString
= gSaveProcess
;
3303 JumpToFormSet
= gJumpToFormSet
[0];
3305 PrintString
= gSaveNoSubmitProcess
;
3306 JumpToFormSet
= gCheckError
[0];
3308 DiscardChange
= gDiscardChange
[0];
3311 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, PrintString
, gEmptyString
, NULL
);
3312 } while (((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) &&
3313 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (JumpToFormSet
| UPPER_LOWER_CASE_OFFSET
)));
3315 if ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) == (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) {
3316 gUserInput
->Action
= BROWSER_ACTION_DISCARD
;
3318 gUserInput
->Action
= BROWSER_ACTION_GOTO
;
3325 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, gPressEnter
, gEmptyString
, NULL
);
3326 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
3328 Status
= gBS
->CreateEvent (EVT_NOTIFY_WAIT
, TPL_CALLBACK
, EmptyEventProcess
, NULL
, &TimeOutEvent
);
3329 ASSERT_EFI_ERROR (Status
);
3331 EventContext
.SyncEvent
= TimeOutEvent
;
3332 EventContext
.TimeOut
= &TimeOut
;
3333 EventContext
.ErrorInfo
= ErrorInfo
;
3335 Status
= gBS
->CreateEvent (EVT_TIMER
| EVT_NOTIFY_SIGNAL
, TPL_CALLBACK
, RefreshTimeOutProcess
, &EventContext
, &RefreshIntervalEvent
);
3336 ASSERT_EFI_ERROR (Status
);
3339 // Show the dialog first to avoid long time not reaction.
3341 gBS
->SignalEvent (RefreshIntervalEvent
);
3343 Status
= gBS
->SetTimer (RefreshIntervalEvent
, TimerPeriodic
, ONE_SECOND
);
3344 ASSERT_EFI_ERROR (Status
);
3347 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
3348 if (!EFI_ERROR (Status
) && Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
3352 if (Status
!= EFI_NOT_READY
) {
3356 WaitList
[0] = TimeOutEvent
;
3357 WaitList
[1] = gST
->ConIn
->WaitForKey
;
3359 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
3360 ASSERT_EFI_ERROR (Status
);
3364 // Timeout occur, close the hoot time out event.
3370 gBS
->CloseEvent (TimeOutEvent
);
3371 gBS
->CloseEvent (RefreshIntervalEvent
);
3376 if (StringToken
!= 0) {
3377 FreePool (ErrorInfo
);
3382 Display one form, and return user input.
3384 @param FormData Form Data to be shown.
3385 @param UserInputData User input data.
3387 @retval EFI_SUCCESS 1.Form Data is shown, and user input is got.
3388 2.Error info has show and return.
3389 @retval EFI_INVALID_PARAMETER The input screen dimension is not valid
3390 @retval EFI_NOT_FOUND New form data has some error.
3395 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
3396 OUT USER_INPUT
*UserInputData
3401 ASSERT (FormData
!= NULL
);
3402 if (FormData
== NULL
) {
3403 return EFI_INVALID_PARAMETER
;
3406 gUserInput
= UserInputData
;
3407 gFormData
= FormData
;
3410 // Process the status info first.
3412 BrowserStatusProcess();
3413 if (gFormData
->BrowserStatus
!= BROWSER_SUCCESS
) {
3415 // gFormData->BrowserStatus != BROWSER_SUCCESS, means only need to print the error info, return here.
3420 ConvertStatementToMenu();
3422 Status
= DisplayPageFrame (FormData
, &gStatementDimensions
);
3423 if (EFI_ERROR (Status
)) {
3428 // Check whether layout is changed.
3431 || (gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
)
3432 || (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))
3433 || (gOldFormEntry
.FormId
!= FormData
->FormId
)) {
3434 mStatementLayoutIsChanged
= TRUE
;
3436 mStatementLayoutIsChanged
= FALSE
;
3439 Status
= UiDisplayMenu(FormData
);
3442 // Backup last form info.
3444 mIsFirstForm
= FALSE
;
3445 gOldFormEntry
.HiiHandle
= FormData
->HiiHandle
;
3446 CopyGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
);
3447 gOldFormEntry
.FormId
= FormData
->FormId
;
3453 Clear Screen to the initial state.
3457 DriverClearDisplayPage (
3461 ClearDisplayPage ();
3462 mIsFirstForm
= TRUE
;
3466 Set Buffer to Value for Size bytes.
3468 @param Buffer Memory to set.
3469 @param Size Number of bytes to set
3470 @param Value Value of the set operation.
3483 while ((Size
--) != 0) {
3489 Initialize Setup Browser driver.
3491 @param ImageHandle The image handle.
3492 @param SystemTable The system table.
3494 @retval EFI_SUCCESS The Setup Browser module is initialized correctly..
3495 @return Other value if failed to initialize the Setup Browser module.
3500 InitializeDisplayEngine (
3501 IN EFI_HANDLE ImageHandle
,
3502 IN EFI_SYSTEM_TABLE
*SystemTable
3506 EFI_INPUT_KEY HotKey
;
3507 EFI_STRING NewString
;
3508 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL
*FormBrowserEx2
;
3511 // Publish our HII data
3513 gHiiHandle
= HiiAddPackages (
3514 &gDisplayEngineGuid
,
3516 DisplayEngineStrings
,
3519 ASSERT (gHiiHandle
!= NULL
);
3522 // Install Form Display protocol
3524 Status
= gBS
->InstallProtocolInterface (
3525 &mPrivateData
.Handle
,
3526 &gEdkiiFormDisplayEngineProtocolGuid
,
3527 EFI_NATIVE_INTERFACE
,
3528 &mPrivateData
.FromDisplayProt
3530 ASSERT_EFI_ERROR (Status
);
3532 InitializeDisplayStrings();
3534 ZeroMem (&gHighligthMenuInfo
, sizeof (gHighligthMenuInfo
));
3535 ZeroMem (&gOldFormEntry
, sizeof (gOldFormEntry
));
3538 // Use BrowserEx2 protocol to register HotKey.
3540 Status
= gBS
->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid
, NULL
, (VOID
**) &FormBrowserEx2
);
3541 if (!EFI_ERROR (Status
)) {
3543 // Register the default HotKey F9 and F10 again.
3545 HotKey
.UnicodeChar
= CHAR_NULL
;
3546 HotKey
.ScanCode
= SCAN_F10
;
3547 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_TEN_STRING
), NULL
);
3548 ASSERT (NewString
!= NULL
);
3549 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_SUBMIT
, 0, NewString
);
3551 HotKey
.ScanCode
= SCAN_F9
;
3552 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_NINE_STRING
), NULL
);
3553 ASSERT (NewString
!= NULL
);
3554 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_DEFAULT
, EFI_HII_DEFAULT_CLASS_STANDARD
, NewString
);
3561 This is the default unload handle for display core drivers.
3563 @param[in] ImageHandle The drivers' driver image.
3565 @retval EFI_SUCCESS The image is unloaded.
3566 @retval Others Failed to unload the image.
3571 UnloadDisplayEngine (
3572 IN EFI_HANDLE ImageHandle
3575 HiiRemovePackages(gHiiHandle
);
3577 FreeDisplayStrings ();
3579 if (gHighligthMenuInfo
.OpCode
!= NULL
) {
3580 FreePool (gHighligthMenuInfo
.OpCode
);