2 Entry and initialization module for the browser.
4 Copyright (c) 2007 - 2015, 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
;
138 CHAR16
*gConfirmDefaultMsg
;
139 CHAR16
*gConfirmSubmitMsg
;
140 CHAR16
*gConfirmDiscardMsg
;
141 CHAR16
*gConfirmResetMsg
;
142 CHAR16
*gConfirmExitMsg
;
143 CHAR16
*gConfirmSubmitMsg2nd
;
144 CHAR16
*gConfirmDefaultMsg2nd
;
145 CHAR16
*gConfirmResetMsg2nd
;
146 CHAR16
*gConfirmExitMsg2nd
;
148 CHAR16
*gConfirmOptYes
;
149 CHAR16
*gConfirmOptNo
;
150 CHAR16
*gConfirmMsgConnect
;
151 CHAR16
*gConfirmMsgEnd
;
152 CHAR16 gModalSkipColumn
;
153 CHAR16 gPromptBlockWidth
;
154 CHAR16 gOptionBlockWidth
;
155 CHAR16 gHelpBlockWidth
;
156 CHAR16
*mUnknownString
;
158 FORM_DISPLAY_DRIVER_PRIVATE_DATA mPrivateData
= {
159 FORM_DISPLAY_DRIVER_SIGNATURE
,
163 DriverClearDisplayPage
,
170 Get the string based on the StringId and HII Package List Handle.
172 @param Token The String's ID.
173 @param HiiHandle The package list in the HII database to search for
174 the specified string.
176 @return The output string.
181 IN EFI_STRING_ID Token
,
182 IN EFI_HII_HANDLE HiiHandle
187 String
= HiiGetString (HiiHandle
, Token
, NULL
);
188 if (String
== NULL
) {
189 String
= AllocateCopyPool (StrSize (mUnknownString
), mUnknownString
);
190 ASSERT (String
!= NULL
);
193 return (CHAR16
*) String
;
198 Initialize the HII String Token to the correct values.
202 InitializeDisplayStrings (
206 mUnknownString
= GetToken (STRING_TOKEN (UNKNOWN_STRING
), gHiiHandle
);
207 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
208 gNoSubmitIfFailed
= GetToken (STRING_TOKEN (NO_SUBMIT_IF_CHECK_FAILED
), gHiiHandle
);
209 gSaveProcess
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP
), gHiiHandle
);
210 gSaveNoSubmitProcess
= GetToken (STRING_TOKEN (DISCARD_OR_CHECK
), gHiiHandle
);
211 gDiscardChange
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP_DISCARD
), gHiiHandle
);
212 gJumpToFormSet
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP_JUMP
), gHiiHandle
);
213 gCheckError
= GetToken (STRING_TOKEN (DISCARD_OR_CHECK_CHECK
), gHiiHandle
);
214 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
215 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
216 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
217 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
218 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
219 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
220 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
221 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
222 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
223 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
224 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
225 gProtocolNotFound
= GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND
), gHiiHandle
);
226 gFormNotFound
= GetToken (STRING_TOKEN (STATUS_BROWSER_FORM_NOT_FOUND
), gHiiHandle
);
227 gNoSubmitIf
= GetToken (STRING_TOKEN (STATUS_BROWSER_NO_SUBMIT_IF
), gHiiHandle
);
228 gBrwoserError
= GetToken (STRING_TOKEN (STATUS_BROWSER_ERROR
), gHiiHandle
);
229 gConfirmDefaultMsg
= GetToken (STRING_TOKEN (CONFIRM_DEFAULT_MESSAGE
), gHiiHandle
);
230 gConfirmDiscardMsg
= GetToken (STRING_TOKEN (CONFIRM_DISCARD_MESSAGE
), gHiiHandle
);
231 gConfirmSubmitMsg
= GetToken (STRING_TOKEN (CONFIRM_SUBMIT_MESSAGE
), gHiiHandle
);
232 gConfirmResetMsg
= GetToken (STRING_TOKEN (CONFIRM_RESET_MESSAGE
), gHiiHandle
);
233 gConfirmExitMsg
= GetToken (STRING_TOKEN (CONFIRM_EXIT_MESSAGE
), gHiiHandle
);
234 gConfirmDefaultMsg2nd
= GetToken (STRING_TOKEN (CONFIRM_DEFAULT_MESSAGE_2ND
), gHiiHandle
);
235 gConfirmSubmitMsg2nd
= GetToken (STRING_TOKEN (CONFIRM_SUBMIT_MESSAGE_2ND
), gHiiHandle
);
236 gConfirmResetMsg2nd
= GetToken (STRING_TOKEN (CONFIRM_RESET_MESSAGE_2ND
), gHiiHandle
);
237 gConfirmExitMsg2nd
= GetToken (STRING_TOKEN (CONFIRM_EXIT_MESSAGE_2ND
), gHiiHandle
);
238 gConfirmOpt
= GetToken (STRING_TOKEN (CONFIRM_OPTION
), gHiiHandle
);
239 gConfirmOptYes
= GetToken (STRING_TOKEN (CONFIRM_OPTION_YES
), gHiiHandle
);
240 gConfirmOptNo
= GetToken (STRING_TOKEN (CONFIRM_OPTION_NO
), gHiiHandle
);
241 gConfirmMsgConnect
= GetToken (STRING_TOKEN (CONFIRM_OPTION_CONNECT
), gHiiHandle
);
242 gConfirmMsgEnd
= GetToken (STRING_TOKEN (CONFIRM_OPTION_END
), gHiiHandle
);
246 Free up the resource allocated for all strings required
255 FreePool (mUnknownString
);
256 FreePool (gEmptyString
);
257 FreePool (gSaveFailed
);
258 FreePool (gNoSubmitIfFailed
);
259 FreePool (gSaveProcess
);
260 FreePool (gSaveNoSubmitProcess
);
261 FreePool (gDiscardChange
);
262 FreePool (gJumpToFormSet
);
263 FreePool (gCheckError
);
264 FreePool (gPromptForData
);
265 FreePool (gPromptForPassword
);
266 FreePool (gPromptForNewPassword
);
267 FreePool (gConfirmPassword
);
268 FreePool (gConfirmError
);
269 FreePool (gPassowordInvalid
);
270 FreePool (gPressEnter
);
271 FreePool (gMiniString
);
272 FreePool (gOptionMismatch
);
273 FreePool (gFormSuppress
);
274 FreePool (gProtocolNotFound
);
275 FreePool (gBrwoserError
);
276 FreePool (gNoSubmitIf
);
277 FreePool (gFormNotFound
);
278 FreePool (gConfirmDefaultMsg
);
279 FreePool (gConfirmSubmitMsg
);
280 FreePool (gConfirmDiscardMsg
);
281 FreePool (gConfirmResetMsg
);
282 FreePool (gConfirmExitMsg
);
283 FreePool (gConfirmDefaultMsg2nd
);
284 FreePool (gConfirmSubmitMsg2nd
);
285 FreePool (gConfirmResetMsg2nd
);
286 FreePool (gConfirmExitMsg2nd
);
287 FreePool (gConfirmOpt
);
288 FreePool (gConfirmOptYes
);
289 FreePool (gConfirmOptNo
);
290 FreePool (gConfirmMsgConnect
);
291 FreePool (gConfirmMsgEnd
);
295 Get prompt string id from the opcode data buffer.
297 @param OpCode The input opcode buffer.
299 @return The prompt string id.
304 IN EFI_IFR_OP_HEADER
*OpCode
307 EFI_IFR_STATEMENT_HEADER
*Header
;
309 if (OpCode
->Length
<= sizeof (EFI_IFR_OP_HEADER
)) {
313 Header
= (EFI_IFR_STATEMENT_HEADER
*) (OpCode
+ 1);
315 return Header
->Prompt
;
319 Get the supported width for a particular op-code
321 @param MenuOption The menu option.
322 @param AdjustWidth The width which is saved for the space.
324 @return Returns the number of CHAR16 characters that is support.
329 IN UI_MENU_OPTION
*MenuOption
,
330 OUT UINT16
*AdjustWidth
335 EFI_IFR_TEXT
*TestOp
;
337 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
339 Statement
= MenuOption
->ThisTag
;
342 // For modal form, clean the entire row.
344 if ((gFormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
345 if (AdjustWidth
!= NULL
) {
346 *AdjustWidth
= LEFT_SKIPPED_COLUMNS
;
348 return (UINT16
)(gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gModalSkipColumn
+ LEFT_SKIPPED_COLUMNS
));
354 // See if the second text parameter is really NULL
356 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
357 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
358 if (TestOp
->TextTwo
!= 0) {
359 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
360 Size
= StrLen (String
);
365 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
366 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
367 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
368 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
369 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
371 // Allow a wide display if text op-code and no secondary text op-code
373 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
377 // Return the space width.
379 if (AdjustWidth
!= NULL
) {
383 // Keep consistent with current behavior.
385 ReturnWidth
= (UINT16
) (gPromptBlockWidth
+ gOptionBlockWidth
- 2);
387 if (AdjustWidth
!= NULL
) {
391 ReturnWidth
= (UINT16
) (gPromptBlockWidth
- 1);
395 // For nest in statement, should the subtitle indent.
397 if (MenuOption
->NestInStatement
) {
398 ReturnWidth
-= SUBTITLE_INDENT
;
405 Will copy LineWidth amount of a string in the OutputString buffer and return the
406 number of CHAR16 characters that were copied into the OutputString buffer.
407 The output string format is:
408 Glyph Info + String info + '\0'.
410 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
412 @param InputString String description for this option.
413 @param LineWidth Width of the desired string to extract in CHAR16
415 @param GlyphWidth The glyph width of the begin of the char in the string.
416 @param Index Where in InputString to start the copy process
417 @param OutputString Buffer to copy the string into
419 @return Returns the number of CHAR16 characters that were copied into the OutputString
420 buffer, include extra glyph info and '\0' info.
425 IN CHAR16
*InputString
,
427 IN OUT UINT16
*GlyphWidth
,
429 OUT CHAR16
**OutputString
434 UINT16 OriginalGlyphWidth
;
436 UINT16 LastSpaceOffset
;
437 UINT16 LastGlyphWidth
;
439 if (InputString
== NULL
|| Index
== NULL
|| OutputString
== NULL
) {
443 if (LineWidth
== 0 || *GlyphWidth
== 0) {
448 // Save original glyph width.
450 OriginalGlyphWidth
= *GlyphWidth
;
451 LastGlyphWidth
= OriginalGlyphWidth
;
456 // 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.
457 // To avoid displaying this empty line in screen, just skip the two CHARs here.
459 if ((InputString
[*Index
] == NARROW_CHAR
) && (InputString
[*Index
+ 1] == CHAR_CARRIAGE_RETURN
)) {
464 // Fast-forward the string and see if there is a carriage-return in the string
466 for (StrOffset
= 0, GlyphOffset
= 0; GlyphOffset
<= LineWidth
; StrOffset
++) {
467 switch (InputString
[*Index
+ StrOffset
]) {
476 case CHAR_CARRIAGE_RETURN
:
483 GlyphOffset
= GlyphOffset
+ *GlyphWidth
;
486 // Record the last space info in this line. Will be used in rewind.
488 if ((InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) && (GlyphOffset
<= LineWidth
)) {
489 LastSpaceOffset
= StrOffset
;
490 LastGlyphWidth
= *GlyphWidth
;
501 // Rewind the string from the maximum size until we see a space to break the line
503 if (GlyphOffset
> LineWidth
) {
505 // Rewind the string to last space char in this line.
507 if (LastSpaceOffset
!= 0) {
508 StrOffset
= LastSpaceOffset
;
509 *GlyphWidth
= LastGlyphWidth
;
512 // Roll back to last char in the line width.
519 // The CHAR_NULL has process last time, this time just return 0 to stand for the end.
521 if (StrOffset
== 0 && (InputString
[*Index
+ StrOffset
] == CHAR_NULL
)) {
526 // Need extra glyph info and '\0' info, so +2.
528 *OutputString
= AllocateZeroPool (((UINTN
) (StrOffset
+ 2) * sizeof(CHAR16
)));
529 if (*OutputString
== NULL
) {
534 // Save the glyph info at the begin of the string, will used by Print function.
536 if (OriginalGlyphWidth
== 1) {
537 *(*OutputString
) = NARROW_CHAR
;
539 *(*OutputString
) = WIDE_CHAR
;
542 CopyMem ((*OutputString
) + 1, &InputString
[*Index
], StrOffset
* sizeof(CHAR16
));
544 if (InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) {
546 // Skip the space info at the begin of next line.
548 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
549 } else if (InputString
[*Index
+ StrOffset
] == CHAR_LINEFEED
) {
551 // Skip the /n or /n/r info.
553 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_CARRIAGE_RETURN
) {
554 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
556 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
558 } else if (InputString
[*Index
+ StrOffset
] == CHAR_CARRIAGE_RETURN
) {
560 // Skip the /r or /r/n info.
562 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_LINEFEED
) {
563 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
565 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
568 *Index
= (UINT16
) (*Index
+ StrOffset
);
572 // Include extra glyph info and '\0' info, so +2.
574 return StrOffset
+ 2;
578 Add one menu option by specified description and context.
580 @param Statement Statement of this Menu Option.
581 @param MenuItemCount The index for this Option in the Menu.
582 @param NestIn Whether this statement is nest in another statement.
587 IN FORM_DISPLAY_ENGINE_STATEMENT
*Statement
,
588 IN UINT16
*MenuItemCount
,
592 UI_MENU_OPTION
*MenuOption
;
596 UINT16 NumberOfLines
;
600 CHAR16
*OutputString
;
601 EFI_STRING_ID PromptId
;
609 PromptId
= GetPrompt (Statement
->OpCode
);
610 ASSERT (PromptId
!= 0);
612 String
= GetToken (PromptId
, gFormData
->HiiHandle
);
613 ASSERT (String
!= NULL
);
615 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
619 for (Index
= 0; Index
< Count
; Index
++) {
620 MenuOption
= AllocateZeroPool (sizeof (UI_MENU_OPTION
));
623 MenuOption
->Signature
= UI_MENU_OPTION_SIGNATURE
;
624 MenuOption
->Description
= String
;
625 MenuOption
->Handle
= gFormData
->HiiHandle
;
626 MenuOption
->ThisTag
= Statement
;
627 MenuOption
->NestInStatement
= NestIn
;
628 MenuOption
->EntryNumber
= *MenuItemCount
;
630 MenuOption
->Sequence
= Index
;
632 if ((Statement
->Attribute
& HII_DISPLAY_GRAYOUT
) != 0) {
633 MenuOption
->GrayOut
= TRUE
;
635 MenuOption
->GrayOut
= FALSE
;
638 if ((Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
639 MenuOption
->GrayOut
= TRUE
;
643 // If the form or the question has the lock attribute, deal same as grayout.
645 if ((gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
646 MenuOption
->GrayOut
= TRUE
;
649 switch (Statement
->OpCode
->OpCode
) {
650 case EFI_IFR_ORDERED_LIST_OP
:
651 case EFI_IFR_ONE_OF_OP
:
652 case EFI_IFR_NUMERIC_OP
:
653 case EFI_IFR_TIME_OP
:
654 case EFI_IFR_DATE_OP
:
655 case EFI_IFR_CHECKBOX_OP
:
656 case EFI_IFR_PASSWORD_OP
:
657 case EFI_IFR_STRING_OP
:
659 // User could change the value of these items
661 MenuOption
->IsQuestion
= TRUE
;
663 case EFI_IFR_TEXT_OP
:
664 if (FeaturePcdGet (PcdBrowserGrayOutTextStatement
)) {
666 // Initializing GrayOut option as TRUE for Text setup options
667 // so that those options will be Gray in colour and un selectable.
669 MenuOption
->GrayOut
= TRUE
;
673 MenuOption
->IsQuestion
= FALSE
;
677 if ((Statement
->Attribute
& HII_DISPLAY_READONLY
) != 0) {
678 MenuOption
->ReadOnly
= TRUE
;
679 if (FeaturePcdGet (PcdBrowerGrayOutReadOnlyMenu
)) {
680 MenuOption
->GrayOut
= TRUE
;
685 (Statement
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
686 (Statement
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
687 Width
= GetWidth (MenuOption
, NULL
);
688 for (; GetLineByWidth (String
, Width
, &GlyphWidth
,&ArrayEntry
, &OutputString
) != 0x0000;) {
690 // If there is more string to process print on the next row and increment the Skip value
692 if (StrLen (&String
[ArrayEntry
]) != 0) {
695 FreePool (OutputString
);
699 // Add three MenuOptions for Date/Time
700 // Data format : [01/02/2004] [11:22:33]
701 // Line number : 0 0 1 0 0 1
708 // Override LineNumber for the MenuOption in Date/Time sequence
710 MenuOption
->Skip
= 1;
712 MenuOption
->Skip
= NumberOfLines
;
715 InsertTailList (&gMenuOption
, &MenuOption
->Link
);
722 Create the menu list base on the form data info.
726 ConvertStatementToMenu (
730 UINT16 MenuItemCount
;
732 LIST_ENTRY
*NestLink
;
733 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
734 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
737 InitializeListHead (&gMenuOption
);
739 Link
= GetFirstNode (&gFormData
->StatementListHead
);
740 while (!IsNull (&gFormData
->StatementListHead
, Link
)) {
741 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
742 Link
= GetNextNode (&gFormData
->StatementListHead
, Link
);
745 // Skip the opcode not recognized by Display core.
747 if (Statement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
751 UiAddMenuOption (Statement
, &MenuItemCount
, FALSE
);
754 // Check the statement nest in this host statement.
756 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
757 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
758 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
759 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
762 // Skip the opcode not recognized by Display core.
764 if (NestStatement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
768 UiAddMenuOption (NestStatement
, &MenuItemCount
, TRUE
);
774 Count the storage space of a Unicode string.
776 This function handles the Unicode string with NARROW_CHAR
777 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
778 does not count in the resultant output. If a WIDE_CHAR is
779 hit, then 2 Unicode character will consume an output storage
780 space with size of CHAR16 till a NARROW_CHAR is hit.
782 If String is NULL, then ASSERT ().
784 @param String The input string to be counted.
786 @return Storage space for the input string.
796 UINTN IncrementValue
;
798 ASSERT (String
!= NULL
);
799 if (String
== NULL
) {
809 // Advance to the null-terminator or to the first width directive
812 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
813 Index
++, Count
= Count
+ IncrementValue
818 // We hit the null-terminator, we now have a count
820 if (String
[Index
] == 0) {
824 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
825 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
827 if (String
[Index
] == NARROW_CHAR
) {
829 // Skip to the next character
835 // Skip to the next character
840 } while (String
[Index
] != 0);
843 // Increment by one to include the null-terminator in the size
847 return Count
* sizeof (CHAR16
);
851 Base on the input option string to update the skip value for a menu option.
853 @param MenuOption The MenuOption to be checked.
854 @param OptionString The input option string.
858 UpdateSkipInfoForMenu (
859 IN UI_MENU_OPTION
*MenuOption
,
860 IN CHAR16
*OptionString
866 CHAR16
*OutputString
;
869 Width
= (UINT16
) gOptionBlockWidth
;
873 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
874 if (StrLen (&OptionString
[Index
]) != 0) {
878 FreePool (OutputString
);
881 if ((Row
> MenuOption
->Skip
) &&
882 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
883 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
884 MenuOption
->Skip
= Row
;
889 Update display lines for a Menu Option.
891 @param MenuOption The MenuOption to be checked.
895 UpdateOptionSkipLines (
896 IN UI_MENU_OPTION
*MenuOption
899 CHAR16
*OptionString
;
903 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
904 if (OptionString
!= NULL
) {
905 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
907 FreePool (OptionString
);
910 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
911 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
913 if (OptionString
!= NULL
) {
914 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
916 FreePool (OptionString
);
922 Check whether this Menu Option could be print.
924 Check Prompt string, option string or text two string not NULL.
926 This is an internal function.
928 @param MenuOption The MenuOption to be checked.
930 @retval TRUE This Menu Option is printable.
931 @retval FALSE This Menu Option could not be printable.
936 UI_MENU_OPTION
*MenuOption
940 EFI_STRING OptionString
;
944 if (MenuOption
->Description
[0] != '\0') {
948 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
949 if (EFI_ERROR (Status
)) {
952 if (OptionString
!= NULL
&& OptionString
[0] != '\0') {
953 FreePool (OptionString
);
957 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
958 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
959 ASSERT (OptionString
!= NULL
);
960 if (OptionString
[0] != '\0'){
961 FreePool (OptionString
);
970 Check whether this Menu Option could be highlighted.
972 This is an internal function.
974 @param MenuOption The MenuOption to be checked.
976 @retval TRUE This Menu Option is selectable.
977 @retval FALSE This Menu Option could not be selected.
982 UI_MENU_OPTION
*MenuOption
985 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
986 MenuOption
->GrayOut
|| MenuOption
->ReadOnly
|| !PrintableMenu (MenuOption
)) {
994 Move to next selectable statement.
996 This is an internal function.
998 @param GoUp The navigation direction. TRUE: up, FALSE: down.
999 @param CurrentPosition Current position.
1000 @param GapToTop Gap position to top or bottom.
1001 @param FindInForm Whether find menu in current form or beyond.
1003 @return The row distance from current MenuOption to next selectable MenuOption.
1005 @retval -1 Reach the begin of the menu, still can't find the selectable menu.
1006 @retval Value Find the selectable menu, maybe the truly selectable, maybe the
1007 first menu showing beyond current form or last menu showing in
1009 The value is the line number between the new selected menu and the
1010 current select menu, not include the new selected menu.
1014 MoveToNextStatement (
1016 IN OUT LIST_ENTRY
**CurrentPosition
,
1018 IN BOOLEAN FindInForm
1023 UI_MENU_OPTION
*NextMenuOption
;
1024 UI_MENU_OPTION
*PreMenuOption
;
1027 Pos
= *CurrentPosition
;
1029 if (Pos
== &gMenuOption
) {
1033 PreMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
1036 NextMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
1038 // NextMenuOption->Row == 0 means this menu has not calculate
1039 // the NextMenuOption->Skip value yet, just calculate here.
1041 if (NextMenuOption
->Row
== 0) {
1042 UpdateOptionSkipLines (NextMenuOption
);
1045 if (IsSelectable (NextMenuOption
)) {
1050 // In this case, still can't find the selectable menu,
1051 // return the first one beyond the showing form.
1053 if ((UINTN
) Distance
+ NextMenuOption
->Skip
> GapToTop
) {
1055 NextMenuOption
= PreMenuOption
;
1060 Distance
+= NextMenuOption
->Skip
;
1063 // Arrive at begin of the menu list.
1065 if ((GoUp
? Pos
->BackLink
: Pos
->ForwardLink
) == &gMenuOption
) {
1070 Pos
= (GoUp
? Pos
->BackLink
: Pos
->ForwardLink
);
1071 PreMenuOption
= NextMenuOption
;
1074 *CurrentPosition
= &NextMenuOption
->Link
;
1080 Process option string for date/time opcode.
1082 @param MenuOption Menu option point to date/time.
1083 @param OptionString Option string input for process.
1084 @param AddOptCol Whether need to update MenuOption->OptCol.
1088 ProcessStringForDateTime (
1089 UI_MENU_OPTION
*MenuOption
,
1090 CHAR16
*OptionString
,
1096 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1100 ASSERT (MenuOption
!= NULL
&& OptionString
!= NULL
);
1102 Statement
= MenuOption
->ThisTag
;
1105 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1106 Date
= (EFI_IFR_DATE
*) Statement
->OpCode
;
1107 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1108 Time
= (EFI_IFR_TIME
*) Statement
->OpCode
;
1112 // If leading spaces on OptionString - remove the spaces
1114 for (Index
= 0; OptionString
[Index
] == L
' '; Index
++) {
1116 // Base on the blockspace to get the option column info.
1119 MenuOption
->OptCol
++;
1123 for (Count
= 0; OptionString
[Index
] != CHAR_NULL
; Index
++) {
1124 OptionString
[Count
] = OptionString
[Index
];
1127 OptionString
[Count
] = CHAR_NULL
;
1130 // Enable to suppress field in the opcode base on the flag.
1132 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1134 // OptionString format is: <**: **: ****>
1138 if ((Date
->Flags
& EFI_QF_DATE_MONTH_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1140 // At this point, only "<**:" in the optionstring.
1141 // Clean the day's ** field, after clean, the format is "< :"
1143 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1144 } else if ((Date
->Flags
& EFI_QF_DATE_DAY_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1146 // At this point, only "**:" in the optionstring.
1147 // Clean the month's "**" field, after clean, the format is " :"
1149 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1150 } else if ((Date
->Flags
& EFI_QF_DATE_YEAR_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1152 // At this point, only "****>" in the optionstring.
1153 // Clean the year's "****" field, after clean, the format is " >"
1155 SetUnicodeMem (&OptionString
[0], 4, L
' ');
1157 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1159 // OptionString format is: <**: **: **>
1160 // |hour|minute|second|
1163 if ((Time
->Flags
& QF_TIME_HOUR_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1165 // At this point, only "<**:" in the optionstring.
1166 // Clean the hour's ** field, after clean, the format is "< :"
1168 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1169 } else if ((Time
->Flags
& QF_TIME_MINUTE_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1171 // At this point, only "**:" in the optionstring.
1172 // Clean the minute's "**" field, after clean, the format is " :"
1174 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1175 } else if ((Time
->Flags
& QF_TIME_SECOND_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1177 // At this point, only "**>" in the optionstring.
1178 // Clean the second's "**" field, after clean, the format is " >"
1180 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1187 Adjust Data and Time position accordingly.
1188 Data format : [01/02/2004] [11:22:33]
1189 Line number : 0 0 1 0 0 1
1191 This is an internal function.
1193 @param DirectionUp the up or down direction. False is down. True is
1195 @param CurrentPosition Current position. On return: Point to the last
1196 Option (Year or Second) if up; Point to the first
1197 Option (Month or Hour) if down.
1199 @return Return line number to pad. It is possible that we stand on a zero-advance
1200 @return data or time opcode, so pad one line when we judge if we are going to scroll outside.
1204 AdjustDateAndTimePosition (
1205 IN BOOLEAN DirectionUp
,
1206 IN OUT LIST_ENTRY
**CurrentPosition
1210 LIST_ENTRY
*NewPosition
;
1211 UI_MENU_OPTION
*MenuOption
;
1212 UINTN PadLineNumber
;
1215 NewPosition
= *CurrentPosition
;
1216 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1218 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) ||
1219 (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
1221 // Calculate the distance from current position to the last Date/Time MenuOption
1224 while (MenuOption
->Skip
== 0) {
1226 NewPosition
= NewPosition
->ForwardLink
;
1227 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1231 NewPosition
= *CurrentPosition
;
1234 // Since the behavior of hitting the up arrow on a Date/Time MenuOption is intended
1235 // to be one that back to the previous set of MenuOptions, we need to advance to the first
1236 // Date/Time MenuOption and leave the remaining logic in CfUiUp intact so the appropriate
1237 // checking can be done.
1239 while (Count
++ < 2) {
1240 NewPosition
= NewPosition
->BackLink
;
1244 // Since the behavior of hitting the down arrow on a Date/Time MenuOption is intended
1245 // to be one that progresses to the next set of MenuOptions, we need to advance to the last
1246 // Date/Time MenuOption and leave the remaining logic in CfUiDown intact so the appropriate
1247 // checking can be done.
1249 while (Count
-- > 0) {
1250 NewPosition
= NewPosition
->ForwardLink
;
1254 *CurrentPosition
= NewPosition
;
1257 return PadLineNumber
;
1261 Get step info from numeric opcode.
1263 @param[in] OpCode The input numeric op code.
1265 @return step info for this opcode.
1269 IN EFI_IFR_OP_HEADER
*OpCode
1272 EFI_IFR_NUMERIC
*NumericOp
;
1275 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
1277 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1278 case EFI_IFR_NUMERIC_SIZE_1
:
1279 Step
= NumericOp
->data
.u8
.Step
;
1282 case EFI_IFR_NUMERIC_SIZE_2
:
1283 Step
= NumericOp
->data
.u16
.Step
;
1286 case EFI_IFR_NUMERIC_SIZE_4
:
1287 Step
= NumericOp
->data
.u32
.Step
;
1290 case EFI_IFR_NUMERIC_SIZE_8
:
1291 Step
= NumericOp
->data
.u64
.Step
;
1303 Find the registered HotKey based on KeyData.
1305 @param[in] KeyData A pointer to a buffer that describes the keystroke
1306 information for the hot key.
1308 @return The registered HotKey context. If no found, NULL will return.
1311 GetHotKeyFromRegisterList (
1312 IN EFI_INPUT_KEY
*KeyData
1316 BROWSER_HOT_KEY
*HotKey
;
1318 Link
= GetFirstNode (&gFormData
->HotKeyListHead
);
1319 while (!IsNull (&gFormData
->HotKeyListHead
, Link
)) {
1320 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
1322 if (HotKey
->KeyData
->ScanCode
== KeyData
->ScanCode
) {
1326 Link
= GetNextNode (&gFormData
->HotKeyListHead
, Link
);
1334 Determine if the menu is the last menu that can be selected.
1336 This is an internal function.
1338 @param Direction The scroll direction. False is down. True is up.
1339 @param CurrentPos The current focus.
1341 @return FALSE -- the menu isn't the last menu that can be selected.
1342 @return TRUE -- the menu is the last menu that can be selected.
1347 IN BOOLEAN Direction
,
1348 IN LIST_ENTRY
*CurrentPos
1353 Temp
= Direction
? CurrentPos
->BackLink
: CurrentPos
->ForwardLink
;
1355 if (Temp
== &gMenuOption
) {
1363 Wait for a given event to fire, or for an optional timeout to expire.
1365 @param Event The event to wait for
1367 @retval UI_EVENT_TYPE The type of the event which is trigged.
1379 EFI_EVENT TimerEvent
;
1380 EFI_EVENT WaitList
[3];
1381 UI_EVENT_TYPE EventType
;
1384 Timeout
= FormExitTimeout(gFormData
);
1387 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
1390 // Set the timer event
1399 WaitList
[0] = Event
;
1401 if (gFormData
->FormRefreshEvent
!= NULL
) {
1402 WaitList
[EventNum
] = gFormData
->FormRefreshEvent
;
1407 WaitList
[EventNum
] = TimerEvent
;
1411 Status
= gBS
->WaitForEvent (EventNum
, WaitList
, &Index
);
1412 ASSERT_EFI_ERROR (Status
);
1416 EventType
= UIEventKey
;
1420 if (gFormData
->FormRefreshEvent
!= NULL
) {
1421 EventType
= UIEventDriver
;
1423 ASSERT (Timeout
!= 0 && EventNum
== 2);
1424 EventType
= UIEventTimeOut
;
1429 ASSERT (Index
== 2 && EventNum
== 3);
1430 EventType
= UIEventTimeOut
;
1435 gBS
->CloseEvent (TimerEvent
);
1442 Get question id info from the input opcode header.
1444 @param OpCode The input opcode header pointer.
1446 @retval The question id for this opcode.
1451 IN EFI_IFR_OP_HEADER
*OpCode
1454 EFI_IFR_QUESTION_HEADER
*QuestionHeader
;
1456 if (OpCode
->Length
< sizeof (EFI_IFR_OP_HEADER
) + sizeof (EFI_IFR_QUESTION_HEADER
)) {
1460 QuestionHeader
= (EFI_IFR_QUESTION_HEADER
*)((UINT8
*) OpCode
+ sizeof(EFI_IFR_OP_HEADER
));
1462 return QuestionHeader
->QuestionId
;
1467 Find the top of screen menu base on the current menu.
1469 @param CurPos Current input menu.
1470 @param Rows Totol screen rows.
1471 @param SkipValue SkipValue for this new form.
1473 @retval TopOfScreen Top of screen menu for the new form.
1477 FindTopOfScreenMenu (
1478 IN LIST_ENTRY
*CurPos
,
1480 OUT UINTN
*SkipValue
1484 LIST_ENTRY
*TopOfScreen
;
1485 UI_MENU_OPTION
*PreviousMenuOption
;
1488 PreviousMenuOption
= NULL
;
1490 while (Link
->BackLink
!= &gMenuOption
) {
1491 Link
= Link
->BackLink
;
1492 PreviousMenuOption
= MENU_OPTION_FROM_LINK (Link
);
1493 if (PreviousMenuOption
->Row
== 0) {
1494 UpdateOptionSkipLines (PreviousMenuOption
);
1496 if (Rows
<= PreviousMenuOption
->Skip
) {
1499 Rows
= Rows
- PreviousMenuOption
->Skip
;
1502 if (Link
->BackLink
== &gMenuOption
) {
1503 TopOfScreen
= gMenuOption
.ForwardLink
;
1504 if (PreviousMenuOption
!= NULL
&& Rows
< PreviousMenuOption
->Skip
) {
1505 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1511 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1518 Get the index info for this opcode.
1520 @param OpCode The input opcode for the statement.
1522 @retval The index of this statement.
1526 GetIndexInfoForOpcode (
1527 IN EFI_IFR_OP_HEADER
*OpCode
1531 UI_MENU_OPTION
*MenuOption
;
1534 NewPos
= gMenuOption
.ForwardLink
;
1537 for (NewPos
= gMenuOption
.ForwardLink
; NewPos
!= &gMenuOption
; NewPos
= NewPos
->ForwardLink
){
1538 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1540 if (CompareMem (MenuOption
->ThisTag
->OpCode
, OpCode
, OpCode
->Length
) == 0) {
1541 if (MenuOption
->ThisTag
->OpCode
== OpCode
) {
1553 Is this the saved highlight statement.
1555 @param HighLightedStatement The input highlight statement.
1557 @retval TRUE This is the highlight statement.
1558 @retval FALSE This is not the highlight statement.
1562 IsSavedHighlightStatement (
1563 IN FORM_DISPLAY_ENGINE_STATEMENT
*HighLightedStatement
1566 if ((gFormData
->HiiHandle
== gHighligthMenuInfo
.HiiHandle
) &&
1567 (gFormData
->FormId
== gHighligthMenuInfo
.FormId
)) {
1568 if (gHighligthMenuInfo
.HLTQuestionId
!= 0) {
1569 return (BOOLEAN
) (gHighligthMenuInfo
.HLTQuestionId
== GetQuestionIdInfo (HighLightedStatement
->OpCode
));
1571 if (CompareMem (gHighligthMenuInfo
.HLTOpCode
, HighLightedStatement
->OpCode
, gHighligthMenuInfo
.HLTOpCode
->Length
) == 0) {
1572 if (gHighligthMenuInfo
.HLTIndex
== 0 || gHighligthMenuInfo
.HLTIndex
== GetIndexInfoForOpcode(HighLightedStatement
->OpCode
)) {
1585 Is this the highlight menu.
1587 @param MenuOption The input Menu option.
1589 @retval TRUE This is the highlight menu option.
1590 @retval FALSE This is not the highlight menu option.
1594 IsHighLightMenuOption (
1595 IN UI_MENU_OPTION
*MenuOption
1598 if (gHighligthMenuInfo
.HLTQuestionId
!= 0) {
1599 if (GetQuestionIdInfo(MenuOption
->ThisTag
->OpCode
) == gHighligthMenuInfo
.HLTQuestionId
) {
1600 return (BOOLEAN
) (MenuOption
->Sequence
== gHighligthMenuInfo
.HLTSequence
);
1603 if(CompareMem (gHighligthMenuInfo
.HLTOpCode
, MenuOption
->ThisTag
->OpCode
, gHighligthMenuInfo
.HLTOpCode
->Length
) == 0) {
1604 if (gHighligthMenuInfo
.HLTIndex
== 0 || gHighligthMenuInfo
.HLTIndex
== GetIndexInfoForOpcode(MenuOption
->ThisTag
->OpCode
)) {
1605 return (BOOLEAN
) (MenuOption
->Sequence
== gHighligthMenuInfo
.HLTSequence
);
1616 Find the highlight menu.
1618 If the input is NULL, base on the record highlight info in
1619 gHighligthMenuInfo to find the last highlight menu.
1621 @param HighLightedStatement The input highlight statement.
1623 @retval The highlight menu index.
1627 FindHighLightMenuOption (
1628 IN FORM_DISPLAY_ENGINE_STATEMENT
*HighLightedStatement
1632 UI_MENU_OPTION
*MenuOption
;
1634 NewPos
= gMenuOption
.ForwardLink
;
1635 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1637 if (HighLightedStatement
!= NULL
) {
1638 while (MenuOption
->ThisTag
!= HighLightedStatement
) {
1639 NewPos
= NewPos
->ForwardLink
;
1640 if (NewPos
== &gMenuOption
) {
1642 // Not Found it, break
1646 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1650 // Must find the highlight statement.
1652 ASSERT (NewPos
!= &gMenuOption
);
1655 while (!IsHighLightMenuOption (MenuOption
)) {
1656 NewPos
= NewPos
->ForwardLink
;
1657 if (NewPos
== &gMenuOption
) {
1659 // Not Found it, break
1663 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1667 // Highlight statement has disappear (suppressed/disableed)
1669 if (NewPos
== &gMenuOption
) {
1678 Is this the Top of screen menu.
1680 @param MenuOption The input Menu option.
1682 @retval TRUE This is the Top of screen menu option.
1683 @retval FALSE This is not the Top of screen menu option.
1687 IsTopOfScreeMenuOption (
1688 IN UI_MENU_OPTION
*MenuOption
1691 if (gHighligthMenuInfo
.TOSQuestionId
!= 0) {
1692 return (BOOLEAN
) (GetQuestionIdInfo(MenuOption
->ThisTag
->OpCode
) == gHighligthMenuInfo
.TOSQuestionId
);
1695 if(CompareMem (gHighligthMenuInfo
.TOSOpCode
, MenuOption
->ThisTag
->OpCode
, gHighligthMenuInfo
.TOSOpCode
->Length
) == 0) {
1696 if (gHighligthMenuInfo
.TOSIndex
== 0 || gHighligthMenuInfo
.TOSIndex
== GetIndexInfoForOpcode(MenuOption
->ThisTag
->OpCode
)) {
1707 Find the Top of screen menu.
1709 If the input is NULL, base on the record highlight info in
1710 gHighligthMenuInfo to find the last highlight menu.
1712 @param HighLightedStatement The input highlight statement.
1714 @retval The highlight menu index.
1718 FindTopOfScreenMenuOption (
1723 UI_MENU_OPTION
*MenuOption
;
1725 NewPos
= gMenuOption
.ForwardLink
;
1726 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1728 while (!IsTopOfScreeMenuOption(MenuOption
)) {
1729 NewPos
= NewPos
->ForwardLink
;
1730 if (NewPos
== &gMenuOption
) {
1732 // Not Found it, break
1736 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1740 // Last time top of screen menu has disappeared.
1742 if (NewPos
== &gMenuOption
) {
1750 Find the first menu which will be show at the top.
1752 @param FormData The data info for this form.
1753 @param TopOfScreen The link_entry pointer to top menu.
1754 @param HighlightMenu The menu which will be highlight.
1755 @param SkipValue The skip value for the top menu.
1760 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
1761 OUT LIST_ENTRY
**TopOfScreen
,
1762 OUT LIST_ENTRY
**HighlightMenu
,
1763 OUT UINTN
*SkipValue
1768 UI_MENU_OPTION
*MenuOption
;
1771 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
1772 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
;
1776 // Reenter caused by option mismatch or auto exit caused by refresh form(refresh interval/guid),
1777 // base on the record highlight info to find the highlight menu.
1779 ASSERT (gFormData
->HiiHandle
== gHighligthMenuInfo
.HiiHandle
&&
1780 gFormData
->FormId
== gHighligthMenuInfo
.FormId
);
1782 *HighlightMenu
= FindHighLightMenuOption(NULL
);
1783 if (*HighlightMenu
!= NULL
) {
1785 // Update skip info for this highlight menu.
1787 MenuOption
= MENU_OPTION_FROM_LINK (*HighlightMenu
);
1788 UpdateOptionSkipLines (MenuOption
);
1791 // Found the last time highlight menu.
1793 *TopOfScreen
= FindTopOfScreenMenuOption();
1794 if (*TopOfScreen
!= NULL
) {
1796 // Found the last time selectable top of screen menu.
1798 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1799 MenuOption
= MENU_OPTION_FROM_LINK (*TopOfScreen
);
1800 UpdateOptionSkipLines (MenuOption
);
1802 *SkipValue
= gHighligthMenuInfo
.SkipValue
;
1805 // Not found last time top of screen menu, so base on current highlight menu
1806 // to find the new top of screen menu.
1807 // Make the current highlight menu at the bottom of the form to calculate the
1808 // top of screen menu.
1810 if (MenuOption
->Skip
>= BottomRow
- TopRow
) {
1811 *TopOfScreen
= *HighlightMenu
;
1814 *TopOfScreen
= FindTopOfScreenMenu(*HighlightMenu
, BottomRow
- TopRow
- MenuOption
->Skip
, &TmpValue
);
1817 *SkipValue
= TmpValue
;
1821 // Last time highlight menu has disappear, find the first highlightable menu as the defalut one.
1823 *HighlightMenu
= gMenuOption
.ForwardLink
;
1824 if (!IsListEmpty (&gMenuOption
)) {
1825 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
, TRUE
);
1827 *TopOfScreen
= gMenuOption
.ForwardLink
;
1832 } else if (FormData
->HighLightedStatement
!= NULL
) {
1833 if (IsSavedHighlightStatement (FormData
->HighLightedStatement
)) {
1835 // Input highlight menu is same as last time highlight menu.
1836 // Base on last time highlight menu to set the top of screen menu and highlight menu.
1838 *HighlightMenu
= FindHighLightMenuOption(NULL
);
1839 ASSERT (*HighlightMenu
!= NULL
);
1842 // Update skip info for this highlight menu.
1844 MenuOption
= MENU_OPTION_FROM_LINK (*HighlightMenu
);
1845 UpdateOptionSkipLines (MenuOption
);
1847 *TopOfScreen
= FindTopOfScreenMenuOption();
1848 if (*TopOfScreen
== NULL
) {
1850 // Not found last time top of screen menu, so base on current highlight menu
1851 // to find the new top of screen menu.
1852 // Make the current highlight menu at the bottom of the form to calculate the
1853 // top of screen menu.
1855 if (MenuOption
->Skip
>= BottomRow
- TopRow
) {
1856 *TopOfScreen
= *HighlightMenu
;
1859 *TopOfScreen
= FindTopOfScreenMenu(*HighlightMenu
, BottomRow
- TopRow
- MenuOption
->Skip
, &TmpValue
);
1862 *SkipValue
= TmpValue
;
1864 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1865 MenuOption
= MENU_OPTION_FROM_LINK (*TopOfScreen
);
1866 UpdateOptionSkipLines (MenuOption
);
1868 *SkipValue
= gHighligthMenuInfo
.SkipValue
;
1870 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1873 // Input highlight menu is not save as last time highlight menu.
1875 *HighlightMenu
= FindHighLightMenuOption(FormData
->HighLightedStatement
);
1876 MenuOption
= MENU_OPTION_FROM_LINK (*HighlightMenu
);
1877 UpdateOptionSkipLines (MenuOption
);
1880 // Make the current highlight menu at the bottom of the form to calculate the
1881 // top of screen menu.
1883 if (MenuOption
->Skip
>= BottomRow
- TopRow
) {
1884 *TopOfScreen
= *HighlightMenu
;
1887 *TopOfScreen
= FindTopOfScreenMenu(*HighlightMenu
, BottomRow
- TopRow
- MenuOption
->Skip
, &TmpValue
);
1890 *SkipValue
= TmpValue
;
1892 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1895 // If not has input highlight statement, just return the first one in this form.
1897 *TopOfScreen
= gMenuOption
.ForwardLink
;
1898 *HighlightMenu
= gMenuOption
.ForwardLink
;
1899 if (!IsListEmpty (&gMenuOption
)) {
1900 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
, TRUE
);
1907 Record the highlight menu and top of screen menu info.
1909 @param Highlight The menu opton which is highlight.
1910 @param TopOfScreen The menu opton which is at the top of the form.
1911 @param SkipValue The skip line info for the top of screen menu.
1915 UpdateHighlightMenuInfo (
1916 IN LIST_ENTRY
*Highlight
,
1917 IN LIST_ENTRY
*TopOfScreen
,
1921 UI_MENU_OPTION
*MenuOption
;
1922 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1924 gHighligthMenuInfo
.HiiHandle
= gFormData
->HiiHandle
;
1925 gHighligthMenuInfo
.FormId
= gFormData
->FormId
;
1926 gHighligthMenuInfo
.SkipValue
= (UINT16
)SkipValue
;
1928 if (!IsListEmpty (&gMenuOption
)) {
1929 MenuOption
= MENU_OPTION_FROM_LINK (Highlight
);
1930 Statement
= MenuOption
->ThisTag
;
1932 gUserInput
->SelectedStatement
= Statement
;
1934 gHighligthMenuInfo
.HLTSequence
= MenuOption
->Sequence
;
1935 gHighligthMenuInfo
.HLTQuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1936 if (gHighligthMenuInfo
.HLTQuestionId
== 0) {
1938 // if question id == 0, save the opcode buffer..
1940 if (gHighligthMenuInfo
.HLTOpCode
!= NULL
) {
1941 FreePool (gHighligthMenuInfo
.HLTOpCode
);
1943 gHighligthMenuInfo
.HLTOpCode
= AllocateCopyPool (Statement
->OpCode
->Length
, Statement
->OpCode
);
1944 ASSERT (gHighligthMenuInfo
.HLTOpCode
!= NULL
);
1946 gHighligthMenuInfo
.HLTIndex
= GetIndexInfoForOpcode(Statement
->OpCode
);
1949 MenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
1950 Statement
= MenuOption
->ThisTag
;
1952 gHighligthMenuInfo
.TOSQuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1953 if (gHighligthMenuInfo
.TOSQuestionId
== 0) {
1955 // if question id == 0, save the opcode buffer..
1957 if (gHighligthMenuInfo
.TOSOpCode
!= NULL
) {
1958 FreePool (gHighligthMenuInfo
.TOSOpCode
);
1960 gHighligthMenuInfo
.TOSOpCode
= AllocateCopyPool (Statement
->OpCode
->Length
, Statement
->OpCode
);
1961 ASSERT (gHighligthMenuInfo
.TOSOpCode
!= NULL
);
1963 gHighligthMenuInfo
.TOSIndex
= GetIndexInfoForOpcode(Statement
->OpCode
);
1966 gUserInput
->SelectedStatement
= NULL
;
1968 gHighligthMenuInfo
.HLTSequence
= 0;
1969 gHighligthMenuInfo
.HLTQuestionId
= 0;
1970 if (gHighligthMenuInfo
.HLTOpCode
!= NULL
) {
1971 FreePool (gHighligthMenuInfo
.HLTOpCode
);
1973 gHighligthMenuInfo
.HLTOpCode
= NULL
;
1974 gHighligthMenuInfo
.HLTIndex
= 0;
1976 gHighligthMenuInfo
.TOSQuestionId
= 0;
1977 if (gHighligthMenuInfo
.TOSOpCode
!= NULL
) {
1978 FreePool (gHighligthMenuInfo
.TOSOpCode
);
1980 gHighligthMenuInfo
.TOSOpCode
= NULL
;
1981 gHighligthMenuInfo
.TOSIndex
= 0;
1986 Update attribut for this menu.
1988 @param MenuOption The menu opton which this attribut used to.
1989 @param Highlight Whether this menu will be highlight.
1993 SetDisplayAttribute (
1994 IN UI_MENU_OPTION
*MenuOption
,
1995 IN BOOLEAN Highlight
1998 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2000 Statement
= MenuOption
->ThisTag
;
2003 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
2007 if (MenuOption
->GrayOut
) {
2008 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetGrayedTextColor ());
2010 if (Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) {
2011 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetSubTitleTextColor ());
2013 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2019 Print string for this menu option.
2021 @param MenuOption The menu opton which this attribut used to.
2022 @param Col The column that this string will be print at.
2023 @param Row The row that this string will be print at.
2024 @param String The string which need to print.
2025 @param Width The width need to print, if string is less than the
2026 width, the block space will be used.
2027 @param Highlight Whether this menu will be highlight.
2032 IN UI_MENU_OPTION
*MenuOption
,
2037 IN BOOLEAN Highlight
2043 // Print string with normal color.
2046 PrintStringAtWithWidth (Col
, Row
, String
, Width
);
2051 // Print the highlight menu string.
2052 // First print the highlight string.
2054 SetDisplayAttribute(MenuOption
, TRUE
);
2055 Length
= PrintStringAt (Col
, Row
, String
);
2058 // Second, clean the empty after the string.
2060 SetDisplayAttribute(MenuOption
, FALSE
);
2061 PrintStringAtWithWidth (Col
+ Length
, Row
, L
"", Width
- Length
);
2065 Check whether this menu can has option string.
2067 @param MenuOption The menu opton which this attribut used to.
2069 @retval TRUE This menu option can have option string.
2070 @retval FALSE This menu option can't have option string.
2075 IN UI_MENU_OPTION
*MenuOption
2078 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2081 EFI_IFR_TEXT
*TestOp
;
2084 Statement
= MenuOption
->ThisTag
;
2087 // See if the second text parameter is really NULL
2089 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
2090 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
2091 if (TestOp
->TextTwo
!= 0) {
2092 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
2093 Size
= StrLen (String
);
2098 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
2099 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
2100 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
2101 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
2102 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
2104 // Allow a wide display if text op-code and no secondary text op-code
2106 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
2116 Double confirm with user about the action.
2118 @param Action The user input action.
2120 @retval TRUE User confirm with the input or not need user confirm.
2121 @retval FALSE User want ignore this input.
2137 CatLen
= StrLen (gConfirmMsgConnect
);
2140 // Below action need extra popup dialog to confirm.
2142 CheckFlags
= BROWSER_ACTION_DISCARD
|
2143 BROWSER_ACTION_DEFAULT
|
2144 BROWSER_ACTION_SUBMIT
|
2145 BROWSER_ACTION_RESET
|
2146 BROWSER_ACTION_EXIT
;
2149 // Not need to confirm with user, just return TRUE.
2151 if ((Action
& CheckFlags
) == 0) {
2155 if ((Action
& BROWSER_ACTION_DISCARD
) == BROWSER_ACTION_DISCARD
) {
2156 CfmStrLen
+= StrLen (gConfirmDiscardMsg
);
2159 if ((Action
& BROWSER_ACTION_DEFAULT
) == BROWSER_ACTION_DEFAULT
) {
2160 if (CfmStrLen
!= 0) {
2161 CfmStrLen
+= CatLen
;
2164 CfmStrLen
+= StrLen (gConfirmDefaultMsg
);
2167 if ((Action
& BROWSER_ACTION_SUBMIT
) == BROWSER_ACTION_SUBMIT
) {
2168 if (CfmStrLen
!= 0) {
2169 CfmStrLen
+= CatLen
;
2172 CfmStrLen
+= StrLen (gConfirmSubmitMsg
);
2175 if ((Action
& BROWSER_ACTION_RESET
) == BROWSER_ACTION_RESET
) {
2176 if (CfmStrLen
!= 0) {
2177 CfmStrLen
+= CatLen
;
2180 CfmStrLen
+= StrLen (gConfirmResetMsg
);
2183 if ((Action
& BROWSER_ACTION_EXIT
) == BROWSER_ACTION_EXIT
) {
2184 if (CfmStrLen
!= 0) {
2185 CfmStrLen
+= CatLen
;
2188 CfmStrLen
+= StrLen (gConfirmExitMsg
);
2192 // Allocate buffer to save the string.
2193 // String + "?" + "\0"
2195 CfmStr
= AllocateZeroPool ((CfmStrLen
+ 1 + 1) * sizeof (CHAR16
));
2196 ASSERT (CfmStr
!= NULL
);
2198 if ((Action
& BROWSER_ACTION_DISCARD
) == BROWSER_ACTION_DISCARD
) {
2199 StrCpy (CfmStr
, gConfirmDiscardMsg
);
2202 if ((Action
& BROWSER_ACTION_DEFAULT
) == BROWSER_ACTION_DEFAULT
) {
2203 if (CfmStr
[0] != 0) {
2204 StrCat (CfmStr
, gConfirmMsgConnect
);
2205 StrCat (CfmStr
, gConfirmDefaultMsg2nd
);
2207 StrCpy (CfmStr
, gConfirmDefaultMsg
);
2211 if ((Action
& BROWSER_ACTION_SUBMIT
) == BROWSER_ACTION_SUBMIT
) {
2212 if (CfmStr
[0] != 0) {
2213 StrCat (CfmStr
, gConfirmMsgConnect
);
2214 StrCat (CfmStr
, gConfirmSubmitMsg2nd
);
2216 StrCpy (CfmStr
, gConfirmSubmitMsg
);
2220 if ((Action
& BROWSER_ACTION_RESET
) == BROWSER_ACTION_RESET
) {
2221 if (CfmStr
[0] != 0) {
2222 StrCat (CfmStr
, gConfirmMsgConnect
);
2223 StrCat (CfmStr
, gConfirmResetMsg2nd
);
2225 StrCpy (CfmStr
, gConfirmResetMsg
);
2229 if ((Action
& BROWSER_ACTION_EXIT
) == BROWSER_ACTION_EXIT
) {
2230 if (CfmStr
[0] != 0) {
2231 StrCat (CfmStr
, gConfirmMsgConnect
);
2232 StrCat (CfmStr
, gConfirmExitMsg2nd
);
2234 StrCpy (CfmStr
, gConfirmExitMsg
);
2238 StrCat (CfmStr
, gConfirmMsgEnd
);
2241 CreateDialog (&Key
, gEmptyString
, CfmStr
, gConfirmOpt
, gEmptyString
, NULL
);
2242 } while (((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (gConfirmOptYes
[0] | UPPER_LOWER_CASE_OFFSET
)) &&
2243 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (gConfirmOptNo
[0] | UPPER_LOWER_CASE_OFFSET
)));
2245 if ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) == (gConfirmOptYes
[0] | UPPER_LOWER_CASE_OFFSET
)) {
2257 Print string for this menu option.
2259 @param MenuOption The menu opton which this attribut used to.
2260 @param SkipWidth The skip width between the left to the start of the prompt.
2261 @param BeginCol The begin column for one menu.
2262 @param SkipLine The skip line for this menu.
2263 @param BottomRow The bottom row for this form.
2264 @param Highlight Whether this menu will be highlight.
2265 @param UpdateCol Whether need to update the column info for Date/Time.
2267 @retval EFI_SUCESSS Process the user selection success.
2272 IN UI_MENU_OPTION
*MenuOption
,
2277 IN BOOLEAN Highlight
,
2278 IN BOOLEAN UpdateCol
2281 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2286 CHAR16
*OptionString
;
2287 CHAR16
*OutputString
;
2295 UINTN PromptLineNum
;
2296 UINTN OptionLineNum
;
2300 Statement
= MenuOption
->ThisTag
;
2310 // Set default color.
2312 SetDisplayAttribute (MenuOption
, FALSE
);
2315 // 1. Paint the option string.
2317 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
2318 if (EFI_ERROR (Status
)) {
2322 if (OptionString
!= NULL
) {
2323 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
2325 // Adjust option string for date/time opcode.
2327 ProcessStringForDateTime(MenuOption
, OptionString
, UpdateCol
);
2330 Width
= (UINT16
) gOptionBlockWidth
- 1;
2331 Row
= MenuOption
->Row
;
2335 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2336 if (((Temp2
== 0)) && (Row
<= BottomRow
)) {
2337 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
2339 // For date/time question, it has three menu options for this qustion.
2340 // The first/second menu options with the skip value is 0. the last one
2341 // with skip value is 1.
2343 if (MenuOption
->Skip
!= 0) {
2345 // For date/ time, print the last past (year for date and second for time)
2346 // - 7 means skip [##/##/ for date and [##:##: for time.
2348 DisplayMenuString (MenuOption
,MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1 - 7, Highlight
);
2351 // For date/ time, print the first and second past (year for date and second for time)
2352 // The OutputString has a NARROW_CHAR or WIDE_CHAR at the begin of the string,
2353 // so need to - 1 to remove it, otherwise, it will clean 1 extr char follow it.
2354 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, StrLen (OutputString
) - 1, Highlight
);
2357 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
2363 // If there is more string to process print on the next row and increment the Skip value
2365 if (StrLen (&OptionString
[Index
]) != 0) {
2369 // Since the Number of lines for this menu entry may or may not be reflected accurately
2370 // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
2371 // some testing to ensure we are keeping this in-sync.
2373 // If the difference in rows is greater than or equal to the skip value, increase the skip value
2375 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
2381 FreePool (OutputString
);
2389 FreePool (OptionString
);
2393 // 2. Paint the description.
2395 PromptWidth
= GetWidth (MenuOption
, &AdjustValue
);
2396 Row
= MenuOption
->Row
;
2400 if (MenuOption
->Description
== NULL
|| MenuOption
->Description
[0] == '\0') {
2401 PrintStringAtWithWidth (BeginCol
, Row
, L
"", PromptWidth
+ AdjustValue
+ SkipWidth
);
2404 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, PromptWidth
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2405 if ((Temp
== 0) && (Row
<= BottomRow
)) {
2407 // 1.Clean the start LEFT_SKIPPED_COLUMNS
2409 PrintStringAtWithWidth (BeginCol
, Row
, L
"", SkipWidth
);
2411 if (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
&& MenuOption
->Col
>= 2) {
2413 // Print Arrow for Goto button.
2416 MenuOption
->Col
- 2,
2418 GEOMETRICSHAPE_RIGHT_TRIANGLE
2421 DisplayMenuString (MenuOption
, MenuOption
->Col
, Row
, OutputString
, PromptWidth
+ AdjustValue
, Highlight
);
2425 // If there is more string to process print on the next row and increment the Skip value
2427 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
2433 FreePool (OutputString
);
2444 // 3. If this is a text op with secondary text information
2446 if ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
!= 0)) {
2447 StringPtr
= GetToken (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
2449 Width
= (UINT16
) gOptionBlockWidth
- 1;
2450 Row
= MenuOption
->Row
;
2454 for (Index
= 0; GetLineByWidth (StringPtr
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2455 if ((Temp3
== 0) && (Row
<= BottomRow
)) {
2456 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
2460 // If there is more string to process print on the next row and increment the Skip value
2462 if (StrLen (&StringPtr
[Index
]) != 0) {
2466 // If the rows for text two is greater than or equal to the skip value, increase the skip value
2468 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
2474 FreePool (OutputString
);
2480 FreePool (StringPtr
);
2484 // 4.Line number for Option string and prompt string are not equal.
2485 // Clean the column whose line number is less.
2487 if (HasOptionString(MenuOption
) && (OptionLineNum
!= PromptLineNum
)) {
2488 Col
= OptionLineNum
< PromptLineNum
? MenuOption
->OptCol
: BeginCol
;
2489 Row
= (OptionLineNum
< PromptLineNum
? OptionLineNum
: PromptLineNum
) + MenuOption
->Row
;
2490 Width
= (UINT16
) (OptionLineNum
< PromptLineNum
? gOptionBlockWidth
: PromptWidth
+ AdjustValue
+ SkipWidth
);
2491 MaxRow
= (OptionLineNum
< PromptLineNum
? PromptLineNum
: OptionLineNum
) + MenuOption
->Row
- 1;
2493 while (Row
<= MaxRow
) {
2494 DisplayMenuString (MenuOption
, Col
, Row
++, L
"", Width
, FALSE
);
2502 Display menu and wait for user to select one menu option, then return it.
2503 If AutoBoot is enabled, then if user doesn't select any option,
2504 after period of time, it will automatically return the first menu option.
2506 @param FormData The current form data info.
2508 @retval EFI_SUCESSS Process the user selection success.
2509 @retval EFI_NOT_FOUND Process option string for orderedlist/Oneof fail.
2514 IN FORM_DISPLAY_ENGINE_FORM
*FormData
2519 UINTN DistanceValue
;
2528 CHAR16
*OptionString
;
2530 CHAR16
*HelpHeaderString
;
2531 CHAR16
*HelpBottomString
;
2540 LIST_ENTRY
*TopOfScreen
;
2541 LIST_ENTRY
*SavedListEntry
;
2542 UI_MENU_OPTION
*MenuOption
;
2543 UI_MENU_OPTION
*NextMenuOption
;
2544 UI_MENU_OPTION
*SavedMenuOption
;
2545 UI_CONTROL_FLAG ControlFlag
;
2546 UI_SCREEN_OPERATION ScreenOperation
;
2547 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2548 BROWSER_HOT_KEY
*HotKey
;
2549 UINTN HelpPageIndex
;
2550 UINTN HelpPageCount
;
2553 UINTN HelpHeaderLine
;
2554 UINTN HelpBottomLine
;
2555 BOOLEAN MultiHelpPage
;
2556 UINT16 EachLineWidth
;
2557 UINT16 HeaderLineWidth
;
2558 UINT16 BottomLineWidth
;
2559 EFI_STRING_ID HelpInfo
;
2560 UI_EVENT_TYPE EventType
;
2561 BOOLEAN SkipHighLight
;
2563 EventType
= UIEventNone
;
2564 Status
= EFI_SUCCESS
;
2566 HelpHeaderString
= NULL
;
2567 HelpBottomString
= NULL
;
2568 OptionString
= NULL
;
2569 ScreenOperation
= UiNoOperation
;
2577 MultiHelpPage
= FALSE
;
2579 HeaderLineWidth
= 0;
2580 BottomLineWidth
= 0;
2584 SkipHighLight
= FALSE
;
2586 NextMenuOption
= NULL
;
2587 SavedMenuOption
= NULL
;
2591 gModalSkipColumn
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 6;
2593 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
2595 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
2596 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
- 1;
2599 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2600 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gModalSkipColumn
;
2602 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
;
2605 FindTopMenu(FormData
, &TopOfScreen
, &NewPos
, &SkipValue
);
2606 if (!IsListEmpty (&gMenuOption
)) {
2607 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2608 gUserInput
->SelectedStatement
= NextMenuOption
->ThisTag
;
2611 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
2613 ControlFlag
= CfInitialization
;
2615 switch (ControlFlag
) {
2616 case CfInitialization
:
2617 if ((gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
) ||
2618 (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))) {
2620 // Clear Statement range if different formset is painted.
2623 gStatementDimensions
.LeftColumn
,
2624 gStatementDimensions
.RightColumn
,
2625 TopRow
- SCROLL_ARROW_HEIGHT
,
2626 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2627 GetFieldTextColor ()
2631 ControlFlag
= CfRepaint
;
2635 ControlFlag
= CfRefreshHighLight
;
2645 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2648 // 1. Check whether need to print the arrow up.
2650 if (!ValueIsScroll (TRUE
, TopOfScreen
)) {
2654 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2655 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2657 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2660 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2662 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2663 TopRow
- SCROLL_ARROW_HEIGHT
,
2666 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2670 // 2.Paint the menu.
2672 for (Link
= TopOfScreen
; Link
!= &gMenuOption
; Link
= Link
->ForwardLink
) {
2673 MenuOption
= MENU_OPTION_FROM_LINK (Link
);
2674 MenuOption
->Row
= Row
;
2675 MenuOption
->Col
= Col
;
2676 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2677 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
+ gModalSkipColumn
;
2679 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
;
2682 if (MenuOption
->NestInStatement
) {
2683 MenuOption
->Col
+= SUBTITLE_INDENT
;
2687 // Save the highlight menu, will be used in CfRefreshHighLight case.
2689 if (Link
== NewPos
) {
2690 SavedMenuOption
= MenuOption
;
2691 SkipHighLight
= TRUE
;
2694 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2695 Status
= DisplayOneMenu (MenuOption
,
2696 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2697 gStatementDimensions
.LeftColumn
+ gModalSkipColumn
,
2698 Link
== TopOfScreen
? SkipValue
: 0,
2700 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2704 Status
= DisplayOneMenu (MenuOption
,
2705 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2706 gStatementDimensions
.LeftColumn
,
2707 Link
== TopOfScreen
? SkipValue
: 0,
2709 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2714 if (EFI_ERROR (Status
)) {
2722 // 3. Update the row info which will be used by next menu.
2724 if (Link
== TopOfScreen
) {
2725 Row
+= MenuOption
->Skip
- SkipValue
;
2727 Row
+= MenuOption
->Skip
;
2730 if (Row
> BottomRow
) {
2731 if (!ValueIsScroll (FALSE
, Link
)) {
2735 Row
= BottomRow
+ 1;
2741 // 3. Menus in this form may not cover all form, clean the remain field.
2743 while (Row
<= BottomRow
) {
2744 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2745 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2747 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gHelpBlockWidth
- gStatementDimensions
.LeftColumn
);
2752 // 4. Print the down arrow row.
2754 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2755 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * + gModalSkipColumn
);
2757 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2760 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2762 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2763 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2766 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2773 case CfRefreshHighLight
:
2776 // MenuOption: Last menu option that need to remove hilight
2777 // MenuOption is set to NULL in Repaint
2778 // NewPos: Current menu option that need to hilight
2780 ControlFlag
= CfUpdateHelpString
;
2782 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
2784 if (SkipHighLight
) {
2785 SkipHighLight
= FALSE
;
2786 MenuOption
= SavedMenuOption
;
2787 RefreshKeyHelp(gFormData
, SavedMenuOption
->ThisTag
, FALSE
);
2791 if (IsListEmpty (&gMenuOption
)) {
2793 // No menu option, just update the hotkey filed.
2795 RefreshKeyHelp(gFormData
, NULL
, FALSE
);
2799 if (MenuOption
!= NULL
&& TopOfScreen
== &MenuOption
->Link
) {
2804 if (NewPos
== TopOfScreen
) {
2810 if (NewPos
!= NULL
&& (MenuOption
== NULL
|| NewPos
!= &MenuOption
->Link
)) {
2811 if (MenuOption
!= NULL
) {
2813 // Remove the old highlight menu.
2815 Status
= DisplayOneMenu (MenuOption
,
2816 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2817 gStatementDimensions
.LeftColumn
,
2826 // This is the current selected statement
2828 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2829 RefreshKeyHelp(gFormData
, MenuOption
->ThisTag
, FALSE
);
2831 if (!IsSelectable (MenuOption
)) {
2835 Status
= DisplayOneMenu (MenuOption
,
2836 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2837 gStatementDimensions
.LeftColumn
,
2846 case CfUpdateHelpString
:
2847 ControlFlag
= CfPrepareToReadKey
;
2848 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2853 // NewLine means only update highlight menu (remove old highlight and highlith
2854 // the new one), not need to full repain the form.
2856 if (Repaint
|| NewLine
) {
2857 if (IsListEmpty (&gMenuOption
)) {
2859 // Don't print anything if no mwnu option.
2861 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2864 // Don't print anything if it is a NULL help token
2866 ASSERT(MenuOption
!= NULL
);
2867 HelpInfo
= ((EFI_IFR_STATEMENT_HEADER
*) ((CHAR8
*)MenuOption
->ThisTag
->OpCode
+ sizeof (EFI_IFR_OP_HEADER
)))->Help
;
2868 if (HelpInfo
== 0 || !IsSelectable (MenuOption
)) {
2869 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2871 StringPtr
= GetToken (HelpInfo
, gFormData
->HiiHandle
);
2875 RowCount
= BottomRow
- TopRow
+ 1;
2878 // 1.Calculate how many line the help string need to print.
2880 if (HelpString
!= NULL
) {
2881 FreePool (HelpString
);
2884 HelpLine
= ProcessHelpString (StringPtr
, &HelpString
, &EachLineWidth
, RowCount
);
2885 FreePool (StringPtr
);
2887 if (HelpLine
> RowCount
) {
2888 MultiHelpPage
= TRUE
;
2889 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_UP
), gHiiHandle
);
2890 if (HelpHeaderString
!= NULL
) {
2891 FreePool (HelpHeaderString
);
2892 HelpHeaderString
= NULL
;
2894 HelpHeaderLine
= ProcessHelpString (StringPtr
, &HelpHeaderString
, &HeaderLineWidth
, 0);
2895 FreePool (StringPtr
);
2896 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_DOWN
), gHiiHandle
);
2897 if (HelpBottomString
!= NULL
) {
2898 FreePool (HelpBottomString
);
2899 HelpBottomString
= NULL
;
2901 HelpBottomLine
= ProcessHelpString (StringPtr
, &HelpBottomString
, &BottomLineWidth
, 0);
2902 FreePool (StringPtr
);
2904 // Calculate the help page count.
2906 if (HelpLine
> 2 * RowCount
- 2) {
2907 HelpPageCount
= (HelpLine
- RowCount
+ 1) / (RowCount
- 2) + 1;
2908 if ((HelpLine
- RowCount
+ 1) % (RowCount
- 2) > 1) {
2915 MultiHelpPage
= FALSE
;
2920 // Check whether need to show the 'More(U/u)' at the begin.
2921 // Base on current direct info, here shows aligned to the right side of the column.
2922 // If the direction is multi line and aligned to right side may have problem, so
2923 // add ASSERT code here.
2925 if (HelpPageIndex
> 0) {
2926 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2927 for (Index
= 0; Index
< HelpHeaderLine
; Index
++) {
2928 ASSERT (HelpHeaderLine
== 1);
2929 ASSERT (GetStringWidth (HelpHeaderString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2930 PrintStringAtWithWidth (
2931 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2937 gStatementDimensions
.RightColumn
- GetStringWidth (HelpHeaderString
) / 2 - 1,
2939 &HelpHeaderString
[Index
* HeaderLineWidth
]
2944 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHelpTextColor ());
2946 // Print the help string info.
2948 if (!MultiHelpPage
) {
2949 for (Index
= 0; Index
< HelpLine
; Index
++) {
2950 PrintStringAtWithWidth (
2951 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2953 &HelpString
[Index
* EachLineWidth
],
2957 for (; Index
< RowCount
; Index
++) {
2958 PrintStringAtWithWidth (
2959 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2965 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2967 if (HelpPageIndex
== 0) {
2968 for (Index
= 0; Index
< RowCount
- HelpBottomLine
; Index
++) {
2969 PrintStringAtWithWidth (
2970 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2972 &HelpString
[Index
* EachLineWidth
],
2977 for (Index
= 0; (Index
< RowCount
- HelpBottomLine
- HelpHeaderLine
) &&
2978 (Index
+ HelpPageIndex
* (RowCount
- 2) + 1 < HelpLine
); Index
++) {
2979 PrintStringAtWithWidth (
2980 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2981 Index
+ TopRow
+ HelpHeaderLine
,
2982 &HelpString
[(Index
+ HelpPageIndex
* (RowCount
- 2) + 1)* EachLineWidth
],
2986 if (HelpPageIndex
== HelpPageCount
- 1) {
2987 for (; Index
< RowCount
- HelpHeaderLine
; Index
++) {
2988 PrintStringAtWithWidth (
2989 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2990 Index
+ TopRow
+ HelpHeaderLine
,
2995 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
3001 // Check whether need to print the 'More(D/d)' at the bottom.
3002 // Base on current direct info, here shows aligned to the right side of the column.
3003 // If the direction is multi line and aligned to right side may have problem, so
3004 // add ASSERT code here.
3006 if (HelpPageIndex
< HelpPageCount
- 1 && MultiHelpPage
) {
3007 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
3008 for (Index
= 0; Index
< HelpBottomLine
; Index
++) {
3009 ASSERT (HelpBottomLine
== 1);
3010 ASSERT (GetStringWidth (HelpBottomString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
3011 PrintStringAtWithWidth (
3012 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
3013 BottomRow
+ Index
- HelpBottomLine
+ 1,
3018 gStatementDimensions
.RightColumn
- GetStringWidth (HelpBottomString
) / 2 - 1,
3019 BottomRow
+ Index
- HelpBottomLine
+ 1,
3020 &HelpBottomString
[Index
* BottomLineWidth
]
3025 // Reset this flag every time we finish using it.
3031 case CfPrepareToReadKey
:
3032 ControlFlag
= CfReadKey
;
3033 ScreenOperation
= UiNoOperation
;
3037 ControlFlag
= CfScreenOperation
;
3040 // Wait for user's selection
3043 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
3044 if (!EFI_ERROR (Status
)) {
3045 EventType
= UIEventKey
;
3050 // If we encounter error, continue to read another key in.
3052 if (Status
!= EFI_NOT_READY
) {
3056 EventType
= UiWaitForEvent(gST
->ConIn
->WaitForKey
);
3057 if (EventType
== UIEventKey
) {
3058 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
3063 if (EventType
== UIEventDriver
) {
3065 gUserInput
->Action
= BROWSER_ACTION_NONE
;
3066 ControlFlag
= CfExit
;
3070 if (EventType
== UIEventTimeOut
) {
3071 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
3072 ControlFlag
= CfExit
;
3076 switch (Key
.UnicodeChar
) {
3077 case CHAR_CARRIAGE_RETURN
:
3078 if(MenuOption
== NULL
|| MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
3079 ControlFlag
= CfReadKey
;
3083 ScreenOperation
= UiSelect
;
3088 // We will push the adjustment of these numeric values directly to the input handler
3089 // NOTE: we won't handle manual input numeric
3094 // If the screen has no menu items, and the user didn't select UiReset
3095 // ignore the selection and go back to reading keys.
3097 ASSERT(MenuOption
!= NULL
);
3098 if(IsListEmpty (&gMenuOption
) || MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
3099 ControlFlag
= CfReadKey
;
3103 Statement
= MenuOption
->ThisTag
;
3104 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
)
3105 || (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
3106 || ((Statement
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (GetFieldFromNum(Statement
->OpCode
) != 0))
3108 if (Key
.UnicodeChar
== '+') {
3109 gDirection
= SCAN_RIGHT
;
3111 gDirection
= SCAN_LEFT
;
3114 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
3115 if (OptionString
!= NULL
) {
3116 FreePool (OptionString
);
3118 if (EFI_ERROR (Status
)) {
3120 // Repaint to clear possible error prompt pop-up
3125 ControlFlag
= CfExit
;
3131 ScreenOperation
= UiUp
;
3136 ScreenOperation
= UiDown
;
3140 if(IsListEmpty (&gMenuOption
)) {
3141 ControlFlag
= CfReadKey
;
3145 ASSERT(MenuOption
!= NULL
);
3146 if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_CHECKBOX_OP
&& !MenuOption
->GrayOut
&& !MenuOption
->ReadOnly
) {
3147 ScreenOperation
= UiSelect
;
3153 if (!MultiHelpPage
) {
3154 ControlFlag
= CfReadKey
;
3157 ControlFlag
= CfUpdateHelpString
;
3158 HelpPageIndex
= HelpPageIndex
< HelpPageCount
- 1 ? HelpPageIndex
+ 1 : HelpPageCount
- 1;
3163 if (!MultiHelpPage
) {
3164 ControlFlag
= CfReadKey
;
3167 ControlFlag
= CfUpdateHelpString
;
3168 HelpPageIndex
= HelpPageIndex
> 0 ? HelpPageIndex
- 1 : 0;
3172 for (Index
= 0; Index
< mScanCodeNumber
; Index
++) {
3173 if (Key
.ScanCode
== gScanCodeToOperation
[Index
].ScanCode
) {
3174 ScreenOperation
= gScanCodeToOperation
[Index
].ScreenOperation
;
3179 if (((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) && (Key
.ScanCode
== SCAN_ESC
|| Index
== mScanCodeNumber
)) {
3181 // ModalForm has no ESC key and Hot Key.
3183 ControlFlag
= CfReadKey
;
3184 } else if (Index
== mScanCodeNumber
) {
3186 // Check whether Key matches the registered hot key.
3189 HotKey
= GetHotKeyFromRegisterList (&Key
);
3190 if (HotKey
!= NULL
) {
3191 ScreenOperation
= UiHotKey
;
3198 case CfScreenOperation
:
3199 if ((ScreenOperation
!= UiReset
) && (ScreenOperation
!= UiHotKey
)) {
3201 // If the screen has no menu items, and the user didn't select UiReset or UiHotKey
3202 // ignore the selection and go back to reading keys.
3204 if (IsListEmpty (&gMenuOption
)) {
3205 ControlFlag
= CfReadKey
;
3211 Index
< sizeof (gScreenOperationToControlFlag
) / sizeof (gScreenOperationToControlFlag
[0]);
3214 if (ScreenOperation
== gScreenOperationToControlFlag
[Index
].ScreenOperation
) {
3215 ControlFlag
= gScreenOperationToControlFlag
[Index
].ControlFlag
;
3222 ControlFlag
= CfRepaint
;
3224 ASSERT(MenuOption
!= NULL
);
3225 Statement
= MenuOption
->ThisTag
;
3226 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
3230 switch (Statement
->OpCode
->OpCode
) {
3231 case EFI_IFR_REF_OP
:
3232 case EFI_IFR_ACTION_OP
:
3233 case EFI_IFR_RESET_BUTTON_OP
:
3234 ControlFlag
= CfExit
;
3239 // Editable Questions: oneof, ordered list, checkbox, numeric, string, password
3241 RefreshKeyHelp (gFormData
, Statement
, TRUE
);
3242 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
3244 if (OptionString
!= NULL
) {
3245 FreePool (OptionString
);
3248 if (EFI_ERROR (Status
)) {
3251 RefreshKeyHelp (gFormData
, Statement
, FALSE
);
3254 ControlFlag
= CfExit
;
3262 // We come here when someone press ESC
3263 // If the policy is not exit front page when user press ESC, process here.
3265 if (!FormExitPolicy()) {
3268 ControlFlag
= CfRepaint
;
3272 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
3273 ControlFlag
= CfExit
;
3277 ControlFlag
= CfRepaint
;
3279 ASSERT (HotKey
!= NULL
);
3281 if (FxConfirmPopup(HotKey
->Action
)) {
3282 gUserInput
->Action
= HotKey
->Action
;
3283 ControlFlag
= CfExit
;
3287 ControlFlag
= CfRepaint
;
3293 ControlFlag
= CfRepaint
;
3294 ASSERT(MenuOption
!= NULL
);
3295 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
3296 if (MenuOption
->Sequence
!= 0) {
3298 // In the middle or tail of the Date/Time op-code set, go left.
3300 ASSERT(NewPos
!= NULL
);
3301 NewPos
= NewPos
->BackLink
;
3307 ControlFlag
= CfRepaint
;
3308 ASSERT(MenuOption
!= NULL
);
3309 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
3310 if (MenuOption
->Sequence
!= 2) {
3312 // In the middle or tail of the Date/Time op-code set, go left.
3314 ASSERT(NewPos
!= NULL
);
3315 NewPos
= NewPos
->ForwardLink
;
3321 ControlFlag
= CfRepaint
;
3324 SavedListEntry
= NewPos
;
3325 ASSERT(NewPos
!= NULL
);
3327 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3328 ASSERT (MenuOption
!= NULL
);
3331 // Adjust Date/Time position before we advance forward.
3333 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3335 NewPos
= NewPos
->BackLink
;
3337 // Find next selectable menu or the first menu beyond current form.
3339 Difference
= MoveToNextStatement (TRUE
, &NewPos
, MenuOption
->Row
- TopRow
, FALSE
);
3340 if (Difference
< 0) {
3342 // We hit the begining MenuOption that can be focused
3343 // so we simply scroll to the top.
3346 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3347 TopOfScreen
= gMenuOption
.ForwardLink
;
3348 NewPos
= SavedListEntry
;
3352 // Scroll up to the last page when we have arrived at top page.
3354 TopOfScreen
= FindTopOfScreenMenu (gMenuOption
.BackLink
, BottomRow
- TopRow
, &SkipValue
);
3355 NewPos
= gMenuOption
.BackLink
;
3356 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
3359 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3361 if (MenuOption
->Row
< TopRow
+ Difference
+ NextMenuOption
->Skip
) {
3363 // Previous focus MenuOption is above the TopOfScreen, so we need to scroll
3365 TopOfScreen
= NewPos
;
3371 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
3373 // BottomRow - TopRow + 1 means the total rows current forms supported.
3374 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
3375 // and new top menu. New top menu will all shows in next form, but last highlight menu
3376 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
3377 // last highlight menu.
3379 if (!IsSelectable(NextMenuOption
) && IsSelectable(MenuOption
) &&
3380 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
3381 NewPos
= SavedListEntry
;
3385 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3388 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3390 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3391 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3393 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3398 // SkipValue means lines is skipped when show the top menu option.
3400 ControlFlag
= CfRepaint
;
3406 // First minus the menu of the top screen, it's value is SkipValue.
3408 if (SkipValue
>= BottomRow
- TopRow
+ 1) {
3410 // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one
3411 // form of options to be show, so just update the SkipValue to show the next
3412 // parts of options.
3414 SkipValue
-= BottomRow
- TopRow
+ 1;
3415 NewPos
= TopOfScreen
;
3418 Index
= (BottomRow
+ 1) - SkipValue
- TopRow
;
3421 TopOfScreen
= FindTopOfScreenMenu(TopOfScreen
, Index
, &SkipValue
);
3422 NewPos
= TopOfScreen
;
3423 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, FALSE
);
3425 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3428 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3429 // Don't do this when we are already in the first page.
3431 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3432 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3434 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3439 // SkipValue means lines is skipped when show the top menu option.
3441 ControlFlag
= CfRepaint
;
3446 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3447 Index
= TopRow
+ NextMenuOption
->Skip
- SkipValue
;
3449 // Count to the menu option which will show at the top of the next form.
3451 while ((Index
<= BottomRow
+ 1) && (Link
->ForwardLink
!= &gMenuOption
)) {
3452 Link
= Link
->ForwardLink
;
3453 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3454 Index
= Index
+ NextMenuOption
->Skip
;
3457 if ((Link
->ForwardLink
== &gMenuOption
) && (Index
<= BottomRow
+ 1)) {
3459 // Highlight on the last menu which can be highlight.
3462 MoveToNextStatement (TRUE
, &Link
, Index
- TopRow
, TRUE
);
3465 // Calculate the skip line for top of screen menu.
3467 if (Link
== TopOfScreen
) {
3469 // The top of screen menu option occupies the entire form.
3471 SkipValue
+= BottomRow
- TopRow
+ 1;
3473 SkipValue
= NextMenuOption
->Skip
- (Index
- (BottomRow
+ 1));
3478 // Move to the Next selectable menu.
3480 MoveToNextStatement (FALSE
, &Link
, BottomRow
- TopRow
, TRUE
);
3484 // Save the menu as the next highlight menu.
3488 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3491 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3492 // Don't do this when we are already in the last page.
3494 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3495 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3497 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3502 // SkipValue means lines is skipped when show the top menu option.
3503 // NewPos points to the menu which is highlighted now.
3505 ControlFlag
= CfRepaint
;
3508 if (NewPos
== TopOfScreen
) {
3514 SavedListEntry
= NewPos
;
3516 // Since the behavior of hitting the down arrow on a Date/Time op-code is intended
3517 // to be one that progresses to the next set of op-codes, we need to advance to the last
3518 // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate
3519 // checking can be done. The only other logic we need to introduce is that if a Date/Time
3520 // op-code is the last entry in the menu, we need to rewind back to the first op-code of
3521 // the Date/Time op-code.
3523 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3525 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3526 NewPos
= NewPos
->ForwardLink
;
3528 // Find the next selectable menu.
3530 if (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
> BottomRow
+ 1) {
3531 if (gMenuOption
.ForwardLink
== NewPos
|| &gMenuOption
== NewPos
) {
3537 Difference
= MoveToNextStatement (FALSE
, &NewPos
, BottomRow
+ 1 - (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
), FALSE
);
3539 if (Difference
< 0) {
3541 // Scroll to the first page.
3543 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3544 TopOfScreen
= gMenuOption
.ForwardLink
;
3548 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3550 NewPos
= gMenuOption
.ForwardLink
;
3551 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
3555 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3557 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3558 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3560 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3565 // Get next selected menu info.
3567 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3568 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3569 if (NextMenuOption
->Row
== 0) {
3570 UpdateOptionSkipLines (NextMenuOption
);
3574 // Calculate new highlight menu end row.
3576 Temp
= (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
) + Difference
+ NextMenuOption
->Skip
- 1;
3577 if (Temp
> BottomRow
) {
3579 // Get the top screen menu info.
3581 AdjustDateAndTimePosition (FALSE
, &TopOfScreen
);
3582 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3585 // Current Top screen menu occupy (SavedMenuOption->Skip - SkipValue) rows.
3586 // Full shows the new selected menu need to skip (Temp - BottomRow - 1) rows.
3588 if ((Temp
- BottomRow
) >= (SavedMenuOption
->Skip
- SkipValue
)) {
3590 // Skip the top op-code
3592 TopOfScreen
= TopOfScreen
->ForwardLink
;
3593 DistanceValue
= (Temp
- BottomRow
) - (SavedMenuOption
->Skip
- SkipValue
);
3595 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3598 // If we have a remainder, skip that many more op-codes until we drain the remainder
3599 // Special case is the selected highlight menu has more than one form of menus.
3601 while (DistanceValue
>= SavedMenuOption
->Skip
&& TopOfScreen
!= NewPos
) {
3603 // Since the Difference is greater than or equal to this op-code's skip value, skip it
3605 DistanceValue
= DistanceValue
- (INTN
) SavedMenuOption
->Skip
;
3606 TopOfScreen
= TopOfScreen
->ForwardLink
;
3607 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3610 // Since we will act on this op-code in the next routine, and increment the
3611 // SkipValue, set the skips to one less than what is required.
3613 if (TopOfScreen
!= NewPos
) {
3614 SkipValue
= DistanceValue
;
3620 // Since we will act on this op-code in the next routine, and increment the
3621 // SkipValue, set the skips to one less than what is required.
3623 SkipValue
+= Temp
- BottomRow
;
3626 } else if (!IsSelectable (NextMenuOption
)) {
3628 // Continue to go down until scroll to next page or the selectable option is found.
3630 ScreenOperation
= UiDown
;
3631 ControlFlag
= CfScreenOperation
;
3635 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3638 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
3640 // BottomRow - TopRow + 1 means the total rows current forms supported.
3641 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
3642 // and new top menu. New top menu will all shows in next form, but last highlight menu
3643 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
3644 // last highlight menu.
3646 if (!IsSelectable (NextMenuOption
) && IsSelectable (MenuOption
) &&
3647 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
3648 NewPos
= SavedListEntry
;
3651 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3654 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3656 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3657 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3659 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3662 case CfUiNoOperation
:
3663 ControlFlag
= CfRepaint
;
3667 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
3668 if (HelpString
!= NULL
) {
3669 FreePool (HelpString
);
3671 if (HelpHeaderString
!= NULL
) {
3672 FreePool (HelpHeaderString
);
3674 if (HelpBottomString
!= NULL
) {
3675 FreePool (HelpBottomString
);
3687 Base on the browser status info to show an pop up message.
3691 BrowserStatusProcess (
3697 EFI_EVENT WaitList
[2];
3698 EFI_EVENT RefreshIntervalEvent
;
3699 EFI_EVENT TimeOutEvent
;
3703 WARNING_IF_CONTEXT EventContext
;
3704 EFI_IFR_OP_HEADER
*OpCodeBuf
;
3705 EFI_STRING_ID StringToken
;
3706 CHAR16 DiscardChange
;
3707 CHAR16 JumpToFormSet
;
3708 CHAR16
*PrintString
;
3710 if (gFormData
->BrowserStatus
== BROWSER_SUCCESS
) {
3715 TimeOutEvent
= NULL
;
3716 RefreshIntervalEvent
= NULL
;
3718 if (gFormData
->HighLightedStatement
!= NULL
) {
3719 OpCodeBuf
= gFormData
->HighLightedStatement
->OpCode
;
3722 if (gFormData
->BrowserStatus
== (BROWSER_WARNING_IF
)) {
3723 ASSERT (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_WARNING_IF_OP
);
3725 TimeOut
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->TimeOut
;
3726 StringToken
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->Warning
;
3729 if ((gFormData
->BrowserStatus
== (BROWSER_NO_SUBMIT_IF
)) &&
3730 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_NO_SUBMIT_IF_OP
)) {
3731 StringToken
= ((EFI_IFR_NO_SUBMIT_IF
*) OpCodeBuf
)->Error
;
3732 } else if ((gFormData
->BrowserStatus
== (BROWSER_INCONSISTENT_IF
)) &&
3733 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_INCONSISTENT_IF_OP
)) {
3734 StringToken
= ((EFI_IFR_INCONSISTENT_IF
*) OpCodeBuf
)->Error
;
3738 if (StringToken
!= 0) {
3739 ErrorInfo
= GetToken (StringToken
, gFormData
->HiiHandle
);
3740 } else if (gFormData
->ErrorString
!= NULL
) {
3742 // Only used to compatible with old setup browser.
3743 // Not use this field in new browser core.
3745 ErrorInfo
= gFormData
->ErrorString
;
3747 switch (gFormData
->BrowserStatus
) {
3748 case BROWSER_SUBMIT_FAIL
:
3749 ErrorInfo
= gSaveFailed
;
3752 case BROWSER_FORM_NOT_FOUND
:
3753 ErrorInfo
= gFormNotFound
;
3756 case BROWSER_FORM_SUPPRESS
:
3757 ErrorInfo
= gFormSuppress
;
3760 case BROWSER_PROTOCOL_NOT_FOUND
:
3761 ErrorInfo
= gProtocolNotFound
;
3764 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3765 ErrorInfo
= gNoSubmitIfFailed
;
3769 ErrorInfo
= gBrwoserError
;
3774 switch (gFormData
->BrowserStatus
) {
3775 case BROWSER_SUBMIT_FAIL
:
3776 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3777 ASSERT (gUserInput
!= NULL
);
3778 if (gFormData
->BrowserStatus
== (BROWSER_SUBMIT_FAIL
)) {
3779 PrintString
= gSaveProcess
;
3780 JumpToFormSet
= gJumpToFormSet
[0];
3782 PrintString
= gSaveNoSubmitProcess
;
3783 JumpToFormSet
= gCheckError
[0];
3785 DiscardChange
= gDiscardChange
[0];
3788 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, PrintString
, gEmptyString
, NULL
);
3789 } while (((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) &&
3790 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (JumpToFormSet
| UPPER_LOWER_CASE_OFFSET
)));
3792 if ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) == (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) {
3793 gUserInput
->Action
= BROWSER_ACTION_DISCARD
;
3795 gUserInput
->Action
= BROWSER_ACTION_GOTO
;
3802 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, gPressEnter
, gEmptyString
, NULL
);
3803 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
3805 Status
= gBS
->CreateEvent (EVT_NOTIFY_WAIT
, TPL_CALLBACK
, EmptyEventProcess
, NULL
, &TimeOutEvent
);
3806 ASSERT_EFI_ERROR (Status
);
3808 EventContext
.SyncEvent
= TimeOutEvent
;
3809 EventContext
.TimeOut
= &TimeOut
;
3810 EventContext
.ErrorInfo
= ErrorInfo
;
3812 Status
= gBS
->CreateEvent (EVT_TIMER
| EVT_NOTIFY_SIGNAL
, TPL_CALLBACK
, RefreshTimeOutProcess
, &EventContext
, &RefreshIntervalEvent
);
3813 ASSERT_EFI_ERROR (Status
);
3816 // Show the dialog first to avoid long time not reaction.
3818 gBS
->SignalEvent (RefreshIntervalEvent
);
3820 Status
= gBS
->SetTimer (RefreshIntervalEvent
, TimerPeriodic
, ONE_SECOND
);
3821 ASSERT_EFI_ERROR (Status
);
3824 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
3825 if (!EFI_ERROR (Status
) && Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
3829 if (Status
!= EFI_NOT_READY
) {
3833 WaitList
[0] = TimeOutEvent
;
3834 WaitList
[1] = gST
->ConIn
->WaitForKey
;
3836 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
3837 ASSERT_EFI_ERROR (Status
);
3841 // Timeout occur, close the hoot time out event.
3847 gBS
->CloseEvent (TimeOutEvent
);
3848 gBS
->CloseEvent (RefreshIntervalEvent
);
3853 if (StringToken
!= 0) {
3854 FreePool (ErrorInfo
);
3859 Display one form, and return user input.
3861 @param FormData Form Data to be shown.
3862 @param UserInputData User input data.
3864 @retval EFI_SUCCESS 1.Form Data is shown, and user input is got.
3865 2.Error info has show and return.
3866 @retval EFI_INVALID_PARAMETER The input screen dimension is not valid
3867 @retval EFI_NOT_FOUND New form data has some error.
3872 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
3873 OUT USER_INPUT
*UserInputData
3878 ASSERT (FormData
!= NULL
);
3879 if (FormData
== NULL
) {
3880 return EFI_INVALID_PARAMETER
;
3883 gUserInput
= UserInputData
;
3884 gFormData
= FormData
;
3887 // Process the status info first.
3889 BrowserStatusProcess();
3890 if (gFormData
->BrowserStatus
!= BROWSER_SUCCESS
) {
3892 // gFormData->BrowserStatus != BROWSER_SUCCESS, means only need to print the error info, return here.
3897 Status
= DisplayPageFrame (FormData
, &gStatementDimensions
);
3898 if (EFI_ERROR (Status
)) {
3903 // Global Widths should be initialized before any MenuOption creation
3904 // or the GetWidth() used in UiAddMenuOption() will return incorrect value.
3908 // |<-.->|<-.........->|<- .........->|<-...........->|
3909 // Skip Prompt Option Help
3911 gOptionBlockWidth
= (CHAR16
) ((gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 3) + 1;
3912 gHelpBlockWidth
= (CHAR16
) (gOptionBlockWidth
- 1 - LEFT_SKIPPED_COLUMNS
);
3913 gPromptBlockWidth
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gOptionBlockWidth
- 1) - 1);
3915 ConvertStatementToMenu();
3918 // Check whether layout is changed.
3921 || (gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
)
3922 || (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))
3923 || (gOldFormEntry
.FormId
!= FormData
->FormId
)) {
3924 mStatementLayoutIsChanged
= TRUE
;
3926 mStatementLayoutIsChanged
= FALSE
;
3929 Status
= UiDisplayMenu(FormData
);
3932 // Backup last form info.
3934 mIsFirstForm
= FALSE
;
3935 gOldFormEntry
.HiiHandle
= FormData
->HiiHandle
;
3936 CopyGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
);
3937 gOldFormEntry
.FormId
= FormData
->FormId
;
3943 Clear Screen to the initial state.
3947 DriverClearDisplayPage (
3951 ClearDisplayPage ();
3952 mIsFirstForm
= TRUE
;
3956 Set Buffer to Value for Size bytes.
3958 @param Buffer Memory to set.
3959 @param Size Number of bytes to set
3960 @param Value Value of the set operation.
3973 while ((Size
--) != 0) {
3979 Initialize Setup Browser driver.
3981 @param ImageHandle The image handle.
3982 @param SystemTable The system table.
3984 @retval EFI_SUCCESS The Setup Browser module is initialized correctly..
3985 @return Other value if failed to initialize the Setup Browser module.
3990 InitializeDisplayEngine (
3991 IN EFI_HANDLE ImageHandle
,
3992 IN EFI_SYSTEM_TABLE
*SystemTable
3996 EFI_INPUT_KEY HotKey
;
3997 EFI_STRING NewString
;
3998 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL
*FormBrowserEx2
;
4001 // Publish our HII data
4003 gHiiHandle
= HiiAddPackages (
4004 &gDisplayEngineGuid
,
4006 DisplayEngineStrings
,
4009 ASSERT (gHiiHandle
!= NULL
);
4012 // Install Form Display protocol
4014 Status
= gBS
->InstallProtocolInterface (
4015 &mPrivateData
.Handle
,
4016 &gEdkiiFormDisplayEngineProtocolGuid
,
4017 EFI_NATIVE_INTERFACE
,
4018 &mPrivateData
.FromDisplayProt
4020 ASSERT_EFI_ERROR (Status
);
4022 InitializeDisplayStrings();
4024 ZeroMem (&gHighligthMenuInfo
, sizeof (gHighligthMenuInfo
));
4025 ZeroMem (&gOldFormEntry
, sizeof (gOldFormEntry
));
4028 // Use BrowserEx2 protocol to register HotKey.
4030 Status
= gBS
->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid
, NULL
, (VOID
**) &FormBrowserEx2
);
4031 if (!EFI_ERROR (Status
)) {
4033 // Register the default HotKey F9 and F10 again.
4035 HotKey
.UnicodeChar
= CHAR_NULL
;
4036 HotKey
.ScanCode
= SCAN_F10
;
4037 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_TEN_STRING
), NULL
);
4038 ASSERT (NewString
!= NULL
);
4039 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_SUBMIT
, 0, NewString
);
4041 HotKey
.ScanCode
= SCAN_F9
;
4042 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_NINE_STRING
), NULL
);
4043 ASSERT (NewString
!= NULL
);
4044 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_DEFAULT
, EFI_HII_DEFAULT_CLASS_STANDARD
, NewString
);
4051 This is the default unload handle for display core drivers.
4053 @param[in] ImageHandle The drivers' driver image.
4055 @retval EFI_SUCCESS The image is unloaded.
4056 @retval Others Failed to unload the image.
4061 UnloadDisplayEngine (
4062 IN EFI_HANDLE ImageHandle
4065 HiiRemovePackages(gHiiHandle
);
4067 FreeDisplayStrings ();
4069 if (gHighligthMenuInfo
.HLTOpCode
!= NULL
) {
4070 FreePool (gHighligthMenuInfo
.HLTOpCode
);
4073 if (gHighligthMenuInfo
.TOSOpCode
!= NULL
) {
4074 FreePool (gHighligthMenuInfo
.TOSOpCode
);