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
*gReconnectConfirmChanges
;
117 CHAR16
*gReconnectFail
;
118 CHAR16
*gReconnectRequired
;
120 CHAR16
*gFormNotFound
;
122 CHAR16
*gBrowserError
;
124 CHAR16
*gNoSubmitIfFailed
;
125 CHAR16
*gSaveProcess
;
126 CHAR16
*gSaveNoSubmitProcess
;
127 CHAR16
*gDiscardChange
;
128 CHAR16
*gJumpToFormSet
;
130 CHAR16
*gPromptForData
;
131 CHAR16
*gPromptForPassword
;
132 CHAR16
*gPromptForNewPassword
;
133 CHAR16
*gConfirmPassword
;
134 CHAR16
*gConfirmError
;
135 CHAR16
*gPassowordInvalid
;
137 CHAR16
*gEmptyString
;
139 CHAR16
*gOptionMismatch
;
140 CHAR16
*gFormSuppress
;
141 CHAR16
*gProtocolNotFound
;
142 CHAR16
*gConfirmDefaultMsg
;
143 CHAR16
*gConfirmSubmitMsg
;
144 CHAR16
*gConfirmDiscardMsg
;
145 CHAR16
*gConfirmResetMsg
;
146 CHAR16
*gConfirmExitMsg
;
147 CHAR16
*gConfirmSubmitMsg2nd
;
148 CHAR16
*gConfirmDefaultMsg2nd
;
149 CHAR16
*gConfirmResetMsg2nd
;
150 CHAR16
*gConfirmExitMsg2nd
;
152 CHAR16
*gConfirmOptYes
;
153 CHAR16
*gConfirmOptNo
;
154 CHAR16
*gConfirmMsgConnect
;
155 CHAR16
*gConfirmMsgEnd
;
156 CHAR16 gModalSkipColumn
;
157 CHAR16 gPromptBlockWidth
;
158 CHAR16 gOptionBlockWidth
;
159 CHAR16 gHelpBlockWidth
;
160 CHAR16
*mUnknownString
;
162 FORM_DISPLAY_DRIVER_PRIVATE_DATA mPrivateData
= {
163 FORM_DISPLAY_DRIVER_SIGNATURE
,
167 DriverClearDisplayPage
,
174 Get the string based on the StringId and HII Package List Handle.
176 @param Token The String's ID.
177 @param HiiHandle The package list in the HII database to search for
178 the specified string.
180 @return The output string.
185 IN EFI_STRING_ID Token
,
186 IN EFI_HII_HANDLE HiiHandle
191 String
= HiiGetString (HiiHandle
, Token
, NULL
);
192 if (String
== NULL
) {
193 String
= AllocateCopyPool (StrSize (mUnknownString
), mUnknownString
);
194 ASSERT (String
!= NULL
);
197 return (CHAR16
*) String
;
202 Initialize the HII String Token to the correct values.
206 InitializeDisplayStrings (
210 gReconnectConfirmChanges
= GetToken (STRING_TOKEN (RECONNECT_CONFIRM_CHANGES
), gHiiHandle
);
211 mUnknownString
= GetToken (STRING_TOKEN (UNKNOWN_STRING
), gHiiHandle
);
212 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
213 gNoSubmitIfFailed
= GetToken (STRING_TOKEN (NO_SUBMIT_IF_CHECK_FAILED
), gHiiHandle
);
214 gReconnectFail
= GetToken (STRING_TOKEN (RECONNECT_FAILED
), gHiiHandle
);
215 gReconnectRequired
= GetToken (STRING_TOKEN (RECONNECT_REQUIRED
), gHiiHandle
);
216 gChangesOpt
= GetToken (STRING_TOKEN (RECONNECT_CHANGES_OPTIONS
), gHiiHandle
);
217 gSaveProcess
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP
), gHiiHandle
);
218 gSaveNoSubmitProcess
= GetToken (STRING_TOKEN (DISCARD_OR_CHECK
), gHiiHandle
);
219 gDiscardChange
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP_DISCARD
), gHiiHandle
);
220 gJumpToFormSet
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP_JUMP
), gHiiHandle
);
221 gCheckError
= GetToken (STRING_TOKEN (DISCARD_OR_CHECK_CHECK
), gHiiHandle
);
222 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
223 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
224 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
225 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
226 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
227 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
228 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
229 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
230 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
231 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
232 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
233 gProtocolNotFound
= GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND
), gHiiHandle
);
234 gFormNotFound
= GetToken (STRING_TOKEN (STATUS_BROWSER_FORM_NOT_FOUND
), gHiiHandle
);
235 gNoSubmitIf
= GetToken (STRING_TOKEN (STATUS_BROWSER_NO_SUBMIT_IF
), gHiiHandle
);
236 gBrowserError
= GetToken (STRING_TOKEN (STATUS_BROWSER_ERROR
), gHiiHandle
);
237 gConfirmDefaultMsg
= GetToken (STRING_TOKEN (CONFIRM_DEFAULT_MESSAGE
), gHiiHandle
);
238 gConfirmDiscardMsg
= GetToken (STRING_TOKEN (CONFIRM_DISCARD_MESSAGE
), gHiiHandle
);
239 gConfirmSubmitMsg
= GetToken (STRING_TOKEN (CONFIRM_SUBMIT_MESSAGE
), gHiiHandle
);
240 gConfirmResetMsg
= GetToken (STRING_TOKEN (CONFIRM_RESET_MESSAGE
), gHiiHandle
);
241 gConfirmExitMsg
= GetToken (STRING_TOKEN (CONFIRM_EXIT_MESSAGE
), gHiiHandle
);
242 gConfirmDefaultMsg2nd
= GetToken (STRING_TOKEN (CONFIRM_DEFAULT_MESSAGE_2ND
), gHiiHandle
);
243 gConfirmSubmitMsg2nd
= GetToken (STRING_TOKEN (CONFIRM_SUBMIT_MESSAGE_2ND
), gHiiHandle
);
244 gConfirmResetMsg2nd
= GetToken (STRING_TOKEN (CONFIRM_RESET_MESSAGE_2ND
), gHiiHandle
);
245 gConfirmExitMsg2nd
= GetToken (STRING_TOKEN (CONFIRM_EXIT_MESSAGE_2ND
), gHiiHandle
);
246 gConfirmOpt
= GetToken (STRING_TOKEN (CONFIRM_OPTION
), gHiiHandle
);
247 gConfirmOptYes
= GetToken (STRING_TOKEN (CONFIRM_OPTION_YES
), gHiiHandle
);
248 gConfirmOptNo
= GetToken (STRING_TOKEN (CONFIRM_OPTION_NO
), gHiiHandle
);
249 gConfirmMsgConnect
= GetToken (STRING_TOKEN (CONFIRM_OPTION_CONNECT
), gHiiHandle
);
250 gConfirmMsgEnd
= GetToken (STRING_TOKEN (CONFIRM_OPTION_END
), gHiiHandle
);
254 Free up the resource allocated for all strings required
263 FreePool (mUnknownString
);
264 FreePool (gEmptyString
);
265 FreePool (gSaveFailed
);
266 FreePool (gNoSubmitIfFailed
);
267 FreePool (gReconnectFail
);
268 FreePool (gReconnectRequired
);
269 FreePool (gChangesOpt
);
270 FreePool (gReconnectConfirmChanges
);
271 FreePool (gSaveProcess
);
272 FreePool (gSaveNoSubmitProcess
);
273 FreePool (gDiscardChange
);
274 FreePool (gJumpToFormSet
);
275 FreePool (gCheckError
);
276 FreePool (gPromptForData
);
277 FreePool (gPromptForPassword
);
278 FreePool (gPromptForNewPassword
);
279 FreePool (gConfirmPassword
);
280 FreePool (gConfirmError
);
281 FreePool (gPassowordInvalid
);
282 FreePool (gPressEnter
);
283 FreePool (gMiniString
);
284 FreePool (gOptionMismatch
);
285 FreePool (gFormSuppress
);
286 FreePool (gProtocolNotFound
);
287 FreePool (gBrowserError
);
288 FreePool (gNoSubmitIf
);
289 FreePool (gFormNotFound
);
290 FreePool (gConfirmDefaultMsg
);
291 FreePool (gConfirmSubmitMsg
);
292 FreePool (gConfirmDiscardMsg
);
293 FreePool (gConfirmResetMsg
);
294 FreePool (gConfirmExitMsg
);
295 FreePool (gConfirmDefaultMsg2nd
);
296 FreePool (gConfirmSubmitMsg2nd
);
297 FreePool (gConfirmResetMsg2nd
);
298 FreePool (gConfirmExitMsg2nd
);
299 FreePool (gConfirmOpt
);
300 FreePool (gConfirmOptYes
);
301 FreePool (gConfirmOptNo
);
302 FreePool (gConfirmMsgConnect
);
303 FreePool (gConfirmMsgEnd
);
307 Get prompt string id from the opcode data buffer.
309 @param OpCode The input opcode buffer.
311 @return The prompt string id.
316 IN EFI_IFR_OP_HEADER
*OpCode
319 EFI_IFR_STATEMENT_HEADER
*Header
;
321 if (OpCode
->Length
<= sizeof (EFI_IFR_OP_HEADER
)) {
325 Header
= (EFI_IFR_STATEMENT_HEADER
*) (OpCode
+ 1);
327 return Header
->Prompt
;
331 Get the supported width for a particular op-code
333 @param MenuOption The menu option.
334 @param AdjustWidth The width which is saved for the space.
336 @return Returns the number of CHAR16 characters that is support.
341 IN UI_MENU_OPTION
*MenuOption
,
342 OUT UINT16
*AdjustWidth
347 EFI_IFR_TEXT
*TestOp
;
349 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
351 Statement
= MenuOption
->ThisTag
;
354 // For modal form, clean the entire row.
356 if ((gFormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
357 if (AdjustWidth
!= NULL
) {
358 *AdjustWidth
= LEFT_SKIPPED_COLUMNS
;
360 return (UINT16
)(gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gModalSkipColumn
+ LEFT_SKIPPED_COLUMNS
));
366 // See if the second text parameter is really NULL
368 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
369 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
370 if (TestOp
->TextTwo
!= 0) {
371 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
372 Size
= StrLen (String
);
377 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
378 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
379 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
380 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
381 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
383 // Allow a wide display if text op-code and no secondary text op-code
385 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
389 // Return the space width.
391 if (AdjustWidth
!= NULL
) {
395 // Keep consistent with current behavior.
397 ReturnWidth
= (UINT16
) (gPromptBlockWidth
+ gOptionBlockWidth
- 2);
399 if (AdjustWidth
!= NULL
) {
403 ReturnWidth
= (UINT16
) (gPromptBlockWidth
- 1);
407 // For nest in statement, should the subtitle indent.
409 if (MenuOption
->NestInStatement
) {
410 ReturnWidth
-= SUBTITLE_INDENT
;
417 Will copy LineWidth amount of a string in the OutputString buffer and return the
418 number of CHAR16 characters that were copied into the OutputString buffer.
419 The output string format is:
420 Glyph Info + String info + '\0'.
422 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
424 @param InputString String description for this option.
425 @param LineWidth Width of the desired string to extract in CHAR16
427 @param GlyphWidth The glyph width of the begin of the char in the string.
428 @param Index Where in InputString to start the copy process
429 @param OutputString Buffer to copy the string into
431 @return Returns the number of CHAR16 characters that were copied into the OutputString
432 buffer, include extra glyph info and '\0' info.
437 IN CHAR16
*InputString
,
439 IN OUT UINT16
*GlyphWidth
,
441 OUT CHAR16
**OutputString
446 UINT16 OriginalGlyphWidth
;
448 UINT16 LastSpaceOffset
;
449 UINT16 LastGlyphWidth
;
451 if (InputString
== NULL
|| Index
== NULL
|| OutputString
== NULL
) {
455 if (LineWidth
== 0 || *GlyphWidth
== 0) {
460 // Save original glyph width.
462 OriginalGlyphWidth
= *GlyphWidth
;
463 LastGlyphWidth
= OriginalGlyphWidth
;
468 // 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.
469 // To avoid displaying this empty line in screen, just skip the two CHARs here.
471 if ((InputString
[*Index
] == NARROW_CHAR
) && (InputString
[*Index
+ 1] == CHAR_CARRIAGE_RETURN
)) {
476 // Fast-forward the string and see if there is a carriage-return in the string
478 for (StrOffset
= 0, GlyphOffset
= 0; GlyphOffset
<= LineWidth
; StrOffset
++) {
479 switch (InputString
[*Index
+ StrOffset
]) {
488 case CHAR_CARRIAGE_RETURN
:
495 GlyphOffset
= GlyphOffset
+ *GlyphWidth
;
498 // Record the last space info in this line. Will be used in rewind.
500 if ((InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) && (GlyphOffset
<= LineWidth
)) {
501 LastSpaceOffset
= StrOffset
;
502 LastGlyphWidth
= *GlyphWidth
;
513 // Rewind the string from the maximum size until we see a space to break the line
515 if (GlyphOffset
> LineWidth
) {
517 // Rewind the string to last space char in this line.
519 if (LastSpaceOffset
!= 0) {
520 StrOffset
= LastSpaceOffset
;
521 *GlyphWidth
= LastGlyphWidth
;
524 // Roll back to last char in the line width.
531 // The CHAR_NULL has process last time, this time just return 0 to stand for the end.
533 if (StrOffset
== 0 && (InputString
[*Index
+ StrOffset
] == CHAR_NULL
)) {
538 // Need extra glyph info and '\0' info, so +2.
540 *OutputString
= AllocateZeroPool (((UINTN
) (StrOffset
+ 2) * sizeof(CHAR16
)));
541 if (*OutputString
== NULL
) {
546 // Save the glyph info at the begin of the string, will used by Print function.
548 if (OriginalGlyphWidth
== 1) {
549 *(*OutputString
) = NARROW_CHAR
;
551 *(*OutputString
) = WIDE_CHAR
;
554 CopyMem ((*OutputString
) + 1, &InputString
[*Index
], StrOffset
* sizeof(CHAR16
));
556 if (InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) {
558 // Skip the space info at the begin of next line.
560 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
561 } else if (InputString
[*Index
+ StrOffset
] == CHAR_LINEFEED
) {
563 // Skip the /n or /n/r info.
565 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_CARRIAGE_RETURN
) {
566 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
568 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
570 } else if (InputString
[*Index
+ StrOffset
] == CHAR_CARRIAGE_RETURN
) {
572 // Skip the /r or /r/n info.
574 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_LINEFEED
) {
575 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
577 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
580 *Index
= (UINT16
) (*Index
+ StrOffset
);
584 // Include extra glyph info and '\0' info, so +2.
586 return StrOffset
+ 2;
590 Add one menu option by specified description and context.
592 @param Statement Statement of this Menu Option.
593 @param MenuItemCount The index for this Option in the Menu.
594 @param NestIn Whether this statement is nest in another statement.
599 IN FORM_DISPLAY_ENGINE_STATEMENT
*Statement
,
600 IN UINT16
*MenuItemCount
,
604 UI_MENU_OPTION
*MenuOption
;
608 UINT16 NumberOfLines
;
612 CHAR16
*OutputString
;
613 EFI_STRING_ID PromptId
;
621 PromptId
= GetPrompt (Statement
->OpCode
);
622 ASSERT (PromptId
!= 0);
624 String
= GetToken (PromptId
, gFormData
->HiiHandle
);
625 ASSERT (String
!= NULL
);
627 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
631 for (Index
= 0; Index
< Count
; Index
++) {
632 MenuOption
= AllocateZeroPool (sizeof (UI_MENU_OPTION
));
635 MenuOption
->Signature
= UI_MENU_OPTION_SIGNATURE
;
636 MenuOption
->Description
= String
;
637 MenuOption
->Handle
= gFormData
->HiiHandle
;
638 MenuOption
->ThisTag
= Statement
;
639 MenuOption
->NestInStatement
= NestIn
;
640 MenuOption
->EntryNumber
= *MenuItemCount
;
642 MenuOption
->Sequence
= Index
;
644 if ((Statement
->Attribute
& HII_DISPLAY_GRAYOUT
) != 0) {
645 MenuOption
->GrayOut
= TRUE
;
647 MenuOption
->GrayOut
= FALSE
;
650 if ((Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
651 MenuOption
->GrayOut
= TRUE
;
655 // If the form or the question has the lock attribute, deal same as grayout.
657 if ((gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
658 MenuOption
->GrayOut
= TRUE
;
661 switch (Statement
->OpCode
->OpCode
) {
662 case EFI_IFR_ORDERED_LIST_OP
:
663 case EFI_IFR_ONE_OF_OP
:
664 case EFI_IFR_NUMERIC_OP
:
665 case EFI_IFR_TIME_OP
:
666 case EFI_IFR_DATE_OP
:
667 case EFI_IFR_CHECKBOX_OP
:
668 case EFI_IFR_PASSWORD_OP
:
669 case EFI_IFR_STRING_OP
:
671 // User could change the value of these items
673 MenuOption
->IsQuestion
= TRUE
;
675 case EFI_IFR_TEXT_OP
:
676 if (FeaturePcdGet (PcdBrowserGrayOutTextStatement
)) {
678 // Initializing GrayOut option as TRUE for Text setup options
679 // so that those options will be Gray in colour and un selectable.
681 MenuOption
->GrayOut
= TRUE
;
685 MenuOption
->IsQuestion
= FALSE
;
689 if ((Statement
->Attribute
& HII_DISPLAY_READONLY
) != 0) {
690 MenuOption
->ReadOnly
= TRUE
;
691 if (FeaturePcdGet (PcdBrowerGrayOutReadOnlyMenu
)) {
692 MenuOption
->GrayOut
= TRUE
;
697 (Statement
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
698 (Statement
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
699 Width
= GetWidth (MenuOption
, NULL
);
700 for (; GetLineByWidth (String
, Width
, &GlyphWidth
,&ArrayEntry
, &OutputString
) != 0x0000;) {
702 // If there is more string to process print on the next row and increment the Skip value
704 if (StrLen (&String
[ArrayEntry
]) != 0) {
707 FreePool (OutputString
);
711 // Add three MenuOptions for Date/Time
712 // Data format : [01/02/2004] [11:22:33]
713 // Line number : 0 0 1 0 0 1
720 // Override LineNumber for the MenuOption in Date/Time sequence
722 MenuOption
->Skip
= 1;
724 MenuOption
->Skip
= NumberOfLines
;
727 InsertTailList (&gMenuOption
, &MenuOption
->Link
);
734 Create the menu list base on the form data info.
738 ConvertStatementToMenu (
742 UINT16 MenuItemCount
;
744 LIST_ENTRY
*NestLink
;
745 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
746 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
749 InitializeListHead (&gMenuOption
);
751 Link
= GetFirstNode (&gFormData
->StatementListHead
);
752 while (!IsNull (&gFormData
->StatementListHead
, Link
)) {
753 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
754 Link
= GetNextNode (&gFormData
->StatementListHead
, Link
);
757 // Skip the opcode not recognized by Display core.
759 if (Statement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
763 UiAddMenuOption (Statement
, &MenuItemCount
, FALSE
);
766 // Check the statement nest in this host statement.
768 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
769 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
770 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
771 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
774 // Skip the opcode not recognized by Display core.
776 if (NestStatement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
780 UiAddMenuOption (NestStatement
, &MenuItemCount
, TRUE
);
786 Count the storage space of a Unicode string.
788 This function handles the Unicode string with NARROW_CHAR
789 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
790 does not count in the resultant output. If a WIDE_CHAR is
791 hit, then 2 Unicode character will consume an output storage
792 space with size of CHAR16 till a NARROW_CHAR is hit.
794 If String is NULL, then ASSERT ().
796 @param String The input string to be counted.
798 @return Storage space for the input string.
808 UINTN IncrementValue
;
810 ASSERT (String
!= NULL
);
811 if (String
== NULL
) {
821 // Advance to the null-terminator or to the first width directive
824 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
825 Index
++, Count
= Count
+ IncrementValue
830 // We hit the null-terminator, we now have a count
832 if (String
[Index
] == 0) {
836 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
837 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
839 if (String
[Index
] == NARROW_CHAR
) {
841 // Skip to the next character
847 // Skip to the next character
852 } while (String
[Index
] != 0);
855 // Increment by one to include the null-terminator in the size
859 return Count
* sizeof (CHAR16
);
863 Base on the input option string to update the skip value for a menu option.
865 @param MenuOption The MenuOption to be checked.
866 @param OptionString The input option string.
870 UpdateSkipInfoForMenu (
871 IN UI_MENU_OPTION
*MenuOption
,
872 IN CHAR16
*OptionString
878 CHAR16
*OutputString
;
881 Width
= (UINT16
) gOptionBlockWidth
;
885 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
886 if (StrLen (&OptionString
[Index
]) != 0) {
890 FreePool (OutputString
);
893 if ((Row
> MenuOption
->Skip
) &&
894 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
895 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
896 MenuOption
->Skip
= Row
;
901 Update display lines for a Menu Option.
903 @param MenuOption The MenuOption to be checked.
907 UpdateOptionSkipLines (
908 IN UI_MENU_OPTION
*MenuOption
911 CHAR16
*OptionString
;
915 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
916 if (OptionString
!= NULL
) {
917 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
919 FreePool (OptionString
);
922 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
923 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
925 if (OptionString
!= NULL
) {
926 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
928 FreePool (OptionString
);
934 Check whether this Menu Option could be print.
936 Check Prompt string, option string or text two string not NULL.
938 This is an internal function.
940 @param MenuOption The MenuOption to be checked.
942 @retval TRUE This Menu Option is printable.
943 @retval FALSE This Menu Option could not be printable.
948 UI_MENU_OPTION
*MenuOption
952 EFI_STRING OptionString
;
956 if (MenuOption
->Description
[0] != '\0') {
960 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
961 if (EFI_ERROR (Status
)) {
964 if (OptionString
!= NULL
&& OptionString
[0] != '\0') {
965 FreePool (OptionString
);
969 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
970 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
971 ASSERT (OptionString
!= NULL
);
972 if (OptionString
[0] != '\0'){
973 FreePool (OptionString
);
982 Check whether this Menu Option could be highlighted.
984 This is an internal function.
986 @param MenuOption The MenuOption to be checked.
988 @retval TRUE This Menu Option is selectable.
989 @retval FALSE This Menu Option could not be selected.
994 UI_MENU_OPTION
*MenuOption
997 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
998 MenuOption
->GrayOut
|| MenuOption
->ReadOnly
|| !PrintableMenu (MenuOption
)) {
1006 Move to next selectable statement.
1008 This is an internal function.
1010 @param GoUp The navigation direction. TRUE: up, FALSE: down.
1011 @param CurrentPosition Current position.
1012 @param GapToTop Gap position to top or bottom.
1013 @param FindInForm Whether find menu in current form or beyond.
1015 @return The row distance from current MenuOption to next selectable MenuOption.
1017 @retval -1 Reach the begin of the menu, still can't find the selectable menu.
1018 @retval Value Find the selectable menu, maybe the truly selectable, maybe the
1019 first menu showing beyond current form or last menu showing in
1021 The value is the line number between the new selected menu and the
1022 current select menu, not include the new selected menu.
1026 MoveToNextStatement (
1028 IN OUT LIST_ENTRY
**CurrentPosition
,
1030 IN BOOLEAN FindInForm
1035 UI_MENU_OPTION
*NextMenuOption
;
1036 UI_MENU_OPTION
*PreMenuOption
;
1039 Pos
= *CurrentPosition
;
1041 if (Pos
== &gMenuOption
) {
1045 PreMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
1048 NextMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
1050 // NextMenuOption->Row == 0 means this menu has not calculate
1051 // the NextMenuOption->Skip value yet, just calculate here.
1053 if (NextMenuOption
->Row
== 0) {
1054 UpdateOptionSkipLines (NextMenuOption
);
1057 if (IsSelectable (NextMenuOption
)) {
1062 // In this case, still can't find the selectable menu,
1063 // return the first one beyond the showing form.
1065 if ((UINTN
) Distance
+ NextMenuOption
->Skip
> GapToTop
) {
1067 NextMenuOption
= PreMenuOption
;
1072 Distance
+= NextMenuOption
->Skip
;
1075 // Arrive at begin of the menu list.
1077 if ((GoUp
? Pos
->BackLink
: Pos
->ForwardLink
) == &gMenuOption
) {
1082 Pos
= (GoUp
? Pos
->BackLink
: Pos
->ForwardLink
);
1083 PreMenuOption
= NextMenuOption
;
1086 *CurrentPosition
= &NextMenuOption
->Link
;
1092 Process option string for date/time opcode.
1094 @param MenuOption Menu option point to date/time.
1095 @param OptionString Option string input for process.
1096 @param AddOptCol Whether need to update MenuOption->OptCol.
1100 ProcessStringForDateTime (
1101 UI_MENU_OPTION
*MenuOption
,
1102 CHAR16
*OptionString
,
1108 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1112 ASSERT (MenuOption
!= NULL
&& OptionString
!= NULL
);
1114 Statement
= MenuOption
->ThisTag
;
1117 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1118 Date
= (EFI_IFR_DATE
*) Statement
->OpCode
;
1119 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1120 Time
= (EFI_IFR_TIME
*) Statement
->OpCode
;
1124 // If leading spaces on OptionString - remove the spaces
1126 for (Index
= 0; OptionString
[Index
] == L
' '; Index
++) {
1128 // Base on the blockspace to get the option column info.
1131 MenuOption
->OptCol
++;
1135 for (Count
= 0; OptionString
[Index
] != CHAR_NULL
; Index
++) {
1136 OptionString
[Count
] = OptionString
[Index
];
1139 OptionString
[Count
] = CHAR_NULL
;
1142 // Enable to suppress field in the opcode base on the flag.
1144 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1146 // OptionString format is: <**: **: ****>
1150 if ((Date
->Flags
& EFI_QF_DATE_MONTH_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1152 // At this point, only "<**:" in the optionstring.
1153 // Clean the day's ** field, after clean, the format is "< :"
1155 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1156 } else if ((Date
->Flags
& EFI_QF_DATE_DAY_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1158 // At this point, only "**:" in the optionstring.
1159 // Clean the month's "**" field, after clean, the format is " :"
1161 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1162 } else if ((Date
->Flags
& EFI_QF_DATE_YEAR_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1164 // At this point, only "****>" in the optionstring.
1165 // Clean the year's "****" field, after clean, the format is " >"
1167 SetUnicodeMem (&OptionString
[0], 4, L
' ');
1169 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1171 // OptionString format is: <**: **: **>
1172 // |hour|minute|second|
1175 if ((Time
->Flags
& QF_TIME_HOUR_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1177 // At this point, only "<**:" in the optionstring.
1178 // Clean the hour's ** field, after clean, the format is "< :"
1180 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1181 } else if ((Time
->Flags
& QF_TIME_MINUTE_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1183 // At this point, only "**:" in the optionstring.
1184 // Clean the minute's "**" field, after clean, the format is " :"
1186 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1187 } else if ((Time
->Flags
& QF_TIME_SECOND_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1189 // At this point, only "**>" in the optionstring.
1190 // Clean the second's "**" field, after clean, the format is " >"
1192 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1199 Adjust Data and Time position accordingly.
1200 Data format : [01/02/2004] [11:22:33]
1201 Line number : 0 0 1 0 0 1
1203 This is an internal function.
1205 @param DirectionUp the up or down direction. False is down. True is
1207 @param CurrentPosition Current position. On return: Point to the last
1208 Option (Year or Second) if up; Point to the first
1209 Option (Month or Hour) if down.
1211 @return Return line number to pad. It is possible that we stand on a zero-advance
1212 @return data or time opcode, so pad one line when we judge if we are going to scroll outside.
1216 AdjustDateAndTimePosition (
1217 IN BOOLEAN DirectionUp
,
1218 IN OUT LIST_ENTRY
**CurrentPosition
1222 LIST_ENTRY
*NewPosition
;
1223 UI_MENU_OPTION
*MenuOption
;
1224 UINTN PadLineNumber
;
1227 NewPosition
= *CurrentPosition
;
1228 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1230 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) ||
1231 (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
1233 // Calculate the distance from current position to the last Date/Time MenuOption
1236 while (MenuOption
->Skip
== 0) {
1238 NewPosition
= NewPosition
->ForwardLink
;
1239 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1243 NewPosition
= *CurrentPosition
;
1246 // Since the behavior of hitting the up arrow on a Date/Time MenuOption is intended
1247 // to be one that back to the previous set of MenuOptions, we need to advance to the first
1248 // Date/Time MenuOption and leave the remaining logic in CfUiUp intact so the appropriate
1249 // checking can be done.
1251 while (Count
++ < 2) {
1252 NewPosition
= NewPosition
->BackLink
;
1256 // Since the behavior of hitting the down arrow on a Date/Time MenuOption is intended
1257 // to be one that progresses to the next set of MenuOptions, we need to advance to the last
1258 // Date/Time MenuOption and leave the remaining logic in CfUiDown intact so the appropriate
1259 // checking can be done.
1261 while (Count
-- > 0) {
1262 NewPosition
= NewPosition
->ForwardLink
;
1266 *CurrentPosition
= NewPosition
;
1269 return PadLineNumber
;
1273 Get step info from numeric opcode.
1275 @param[in] OpCode The input numeric op code.
1277 @return step info for this opcode.
1281 IN EFI_IFR_OP_HEADER
*OpCode
1284 EFI_IFR_NUMERIC
*NumericOp
;
1287 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
1289 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1290 case EFI_IFR_NUMERIC_SIZE_1
:
1291 Step
= NumericOp
->data
.u8
.Step
;
1294 case EFI_IFR_NUMERIC_SIZE_2
:
1295 Step
= NumericOp
->data
.u16
.Step
;
1298 case EFI_IFR_NUMERIC_SIZE_4
:
1299 Step
= NumericOp
->data
.u32
.Step
;
1302 case EFI_IFR_NUMERIC_SIZE_8
:
1303 Step
= NumericOp
->data
.u64
.Step
;
1315 Find the registered HotKey based on KeyData.
1317 @param[in] KeyData A pointer to a buffer that describes the keystroke
1318 information for the hot key.
1320 @return The registered HotKey context. If no found, NULL will return.
1323 GetHotKeyFromRegisterList (
1324 IN EFI_INPUT_KEY
*KeyData
1328 BROWSER_HOT_KEY
*HotKey
;
1330 Link
= GetFirstNode (&gFormData
->HotKeyListHead
);
1331 while (!IsNull (&gFormData
->HotKeyListHead
, Link
)) {
1332 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
1334 if (HotKey
->KeyData
->ScanCode
== KeyData
->ScanCode
) {
1338 Link
= GetNextNode (&gFormData
->HotKeyListHead
, Link
);
1346 Determine if the menu is the last menu that can be selected.
1348 This is an internal function.
1350 @param Direction The scroll direction. False is down. True is up.
1351 @param CurrentPos The current focus.
1353 @return FALSE -- the menu isn't the last menu that can be selected.
1354 @return TRUE -- the menu is the last menu that can be selected.
1359 IN BOOLEAN Direction
,
1360 IN LIST_ENTRY
*CurrentPos
1365 Temp
= Direction
? CurrentPos
->BackLink
: CurrentPos
->ForwardLink
;
1367 if (Temp
== &gMenuOption
) {
1375 Wait for a given event to fire, or for an optional timeout to expire.
1377 @param Event The event to wait for
1379 @retval UI_EVENT_TYPE The type of the event which is trigged.
1391 EFI_EVENT TimerEvent
;
1392 EFI_EVENT WaitList
[3];
1393 UI_EVENT_TYPE EventType
;
1396 Timeout
= FormExitTimeout(gFormData
);
1399 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
1402 // Set the timer event
1411 WaitList
[0] = Event
;
1413 if (gFormData
->FormRefreshEvent
!= NULL
) {
1414 WaitList
[EventNum
] = gFormData
->FormRefreshEvent
;
1419 WaitList
[EventNum
] = TimerEvent
;
1423 Status
= gBS
->WaitForEvent (EventNum
, WaitList
, &Index
);
1424 ASSERT_EFI_ERROR (Status
);
1428 EventType
= UIEventKey
;
1432 if (gFormData
->FormRefreshEvent
!= NULL
) {
1433 EventType
= UIEventDriver
;
1435 ASSERT (Timeout
!= 0 && EventNum
== 2);
1436 EventType
= UIEventTimeOut
;
1441 ASSERT (Index
== 2 && EventNum
== 3);
1442 EventType
= UIEventTimeOut
;
1447 gBS
->CloseEvent (TimerEvent
);
1454 Get question id info from the input opcode header.
1456 @param OpCode The input opcode header pointer.
1458 @retval The question id for this opcode.
1463 IN EFI_IFR_OP_HEADER
*OpCode
1466 EFI_IFR_QUESTION_HEADER
*QuestionHeader
;
1468 if (OpCode
->Length
< sizeof (EFI_IFR_OP_HEADER
) + sizeof (EFI_IFR_QUESTION_HEADER
)) {
1472 QuestionHeader
= (EFI_IFR_QUESTION_HEADER
*)((UINT8
*) OpCode
+ sizeof(EFI_IFR_OP_HEADER
));
1474 return QuestionHeader
->QuestionId
;
1479 Find the top of screen menu base on the current menu.
1481 @param CurPos Current input menu.
1482 @param Rows Totol screen rows.
1483 @param SkipValue SkipValue for this new form.
1485 @retval TopOfScreen Top of screen menu for the new form.
1489 FindTopOfScreenMenu (
1490 IN LIST_ENTRY
*CurPos
,
1492 OUT UINTN
*SkipValue
1496 LIST_ENTRY
*TopOfScreen
;
1497 UI_MENU_OPTION
*PreviousMenuOption
;
1500 PreviousMenuOption
= NULL
;
1502 while (Link
->BackLink
!= &gMenuOption
) {
1503 Link
= Link
->BackLink
;
1504 PreviousMenuOption
= MENU_OPTION_FROM_LINK (Link
);
1505 if (PreviousMenuOption
->Row
== 0) {
1506 UpdateOptionSkipLines (PreviousMenuOption
);
1508 if (Rows
<= PreviousMenuOption
->Skip
) {
1511 Rows
= Rows
- PreviousMenuOption
->Skip
;
1514 if (Link
->BackLink
== &gMenuOption
) {
1515 TopOfScreen
= gMenuOption
.ForwardLink
;
1516 if (PreviousMenuOption
!= NULL
&& Rows
< PreviousMenuOption
->Skip
) {
1517 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1523 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1530 Get the index info for this opcode.
1532 @param OpCode The input opcode for the statement.
1534 @retval The index of this statement.
1538 GetIndexInfoForOpcode (
1539 IN EFI_IFR_OP_HEADER
*OpCode
1543 UI_MENU_OPTION
*MenuOption
;
1546 NewPos
= gMenuOption
.ForwardLink
;
1549 for (NewPos
= gMenuOption
.ForwardLink
; NewPos
!= &gMenuOption
; NewPos
= NewPos
->ForwardLink
){
1550 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1552 if (CompareMem (MenuOption
->ThisTag
->OpCode
, OpCode
, OpCode
->Length
) == 0) {
1553 if (MenuOption
->ThisTag
->OpCode
== OpCode
) {
1565 Is this the saved highlight statement.
1567 @param HighLightedStatement The input highlight statement.
1569 @retval TRUE This is the highlight statement.
1570 @retval FALSE This is not the highlight statement.
1574 IsSavedHighlightStatement (
1575 IN FORM_DISPLAY_ENGINE_STATEMENT
*HighLightedStatement
1578 if ((gFormData
->HiiHandle
== gHighligthMenuInfo
.HiiHandle
) &&
1579 (gFormData
->FormId
== gHighligthMenuInfo
.FormId
)) {
1580 if (gHighligthMenuInfo
.HLTQuestionId
!= 0) {
1581 return (BOOLEAN
) (gHighligthMenuInfo
.HLTQuestionId
== GetQuestionIdInfo (HighLightedStatement
->OpCode
));
1583 if (CompareMem (gHighligthMenuInfo
.HLTOpCode
, HighLightedStatement
->OpCode
, gHighligthMenuInfo
.HLTOpCode
->Length
) == 0) {
1584 if (gHighligthMenuInfo
.HLTIndex
== 0 || gHighligthMenuInfo
.HLTIndex
== GetIndexInfoForOpcode(HighLightedStatement
->OpCode
)) {
1597 Is this the highlight menu.
1599 @param MenuOption The input Menu option.
1601 @retval TRUE This is the highlight menu option.
1602 @retval FALSE This is not the highlight menu option.
1606 IsHighLightMenuOption (
1607 IN UI_MENU_OPTION
*MenuOption
1610 if (gHighligthMenuInfo
.HLTQuestionId
!= 0) {
1611 if (GetQuestionIdInfo(MenuOption
->ThisTag
->OpCode
) == gHighligthMenuInfo
.HLTQuestionId
) {
1612 return (BOOLEAN
) (MenuOption
->Sequence
== gHighligthMenuInfo
.HLTSequence
);
1615 if(CompareMem (gHighligthMenuInfo
.HLTOpCode
, MenuOption
->ThisTag
->OpCode
, gHighligthMenuInfo
.HLTOpCode
->Length
) == 0) {
1616 if (gHighligthMenuInfo
.HLTIndex
== 0 || gHighligthMenuInfo
.HLTIndex
== GetIndexInfoForOpcode(MenuOption
->ThisTag
->OpCode
)) {
1617 return (BOOLEAN
) (MenuOption
->Sequence
== gHighligthMenuInfo
.HLTSequence
);
1628 Find the highlight menu.
1630 If the input is NULL, base on the record highlight info in
1631 gHighligthMenuInfo to find the last highlight menu.
1633 @param HighLightedStatement The input highlight statement.
1635 @retval The highlight menu index.
1639 FindHighLightMenuOption (
1640 IN FORM_DISPLAY_ENGINE_STATEMENT
*HighLightedStatement
1644 UI_MENU_OPTION
*MenuOption
;
1646 NewPos
= gMenuOption
.ForwardLink
;
1647 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1649 if (HighLightedStatement
!= NULL
) {
1650 while (MenuOption
->ThisTag
!= HighLightedStatement
) {
1651 NewPos
= NewPos
->ForwardLink
;
1652 if (NewPos
== &gMenuOption
) {
1654 // Not Found it, break
1658 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1662 // Must find the highlight statement.
1664 ASSERT (NewPos
!= &gMenuOption
);
1667 while (!IsHighLightMenuOption (MenuOption
)) {
1668 NewPos
= NewPos
->ForwardLink
;
1669 if (NewPos
== &gMenuOption
) {
1671 // Not Found it, break
1675 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1679 // Highlight statement has disappear (suppressed/disableed)
1681 if (NewPos
== &gMenuOption
) {
1690 Is this the Top of screen menu.
1692 @param MenuOption The input Menu option.
1694 @retval TRUE This is the Top of screen menu option.
1695 @retval FALSE This is not the Top of screen menu option.
1699 IsTopOfScreeMenuOption (
1700 IN UI_MENU_OPTION
*MenuOption
1703 if (gHighligthMenuInfo
.TOSQuestionId
!= 0) {
1704 return (BOOLEAN
) (GetQuestionIdInfo(MenuOption
->ThisTag
->OpCode
) == gHighligthMenuInfo
.TOSQuestionId
);
1707 if(CompareMem (gHighligthMenuInfo
.TOSOpCode
, MenuOption
->ThisTag
->OpCode
, gHighligthMenuInfo
.TOSOpCode
->Length
) == 0) {
1708 if (gHighligthMenuInfo
.TOSIndex
== 0 || gHighligthMenuInfo
.TOSIndex
== GetIndexInfoForOpcode(MenuOption
->ThisTag
->OpCode
)) {
1719 Find the Top of screen menu.
1721 If the input is NULL, base on the record highlight info in
1722 gHighligthMenuInfo to find the last highlight menu.
1724 @param HighLightedStatement The input highlight statement.
1726 @retval The highlight menu index.
1730 FindTopOfScreenMenuOption (
1735 UI_MENU_OPTION
*MenuOption
;
1737 NewPos
= gMenuOption
.ForwardLink
;
1738 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1740 while (!IsTopOfScreeMenuOption(MenuOption
)) {
1741 NewPos
= NewPos
->ForwardLink
;
1742 if (NewPos
== &gMenuOption
) {
1744 // Not Found it, break
1748 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1752 // Last time top of screen menu has disappeared.
1754 if (NewPos
== &gMenuOption
) {
1762 Find the first menu which will be show at the top.
1764 @param FormData The data info for this form.
1765 @param TopOfScreen The link_entry pointer to top menu.
1766 @param HighlightMenu The menu which will be highlight.
1767 @param SkipValue The skip value for the top menu.
1772 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
1773 OUT LIST_ENTRY
**TopOfScreen
,
1774 OUT LIST_ENTRY
**HighlightMenu
,
1775 OUT UINTN
*SkipValue
1780 UI_MENU_OPTION
*MenuOption
;
1783 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
1784 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
;
1786 // When option mismatch happens,there exist two cases,one is reenter the form, just like the if case below,
1787 // and the other is exit current form and enter last form, it can be covered by the else case.
1789 if (gMisMatch
&& gFormData
->HiiHandle
== gHighligthMenuInfo
.HiiHandle
&& gFormData
->FormId
== gHighligthMenuInfo
.FormId
) {
1791 // Reenter caused by option mismatch or auto exit caused by refresh form(refresh interval/guid),
1792 // base on the record highlight info to find the highlight menu.
1795 *HighlightMenu
= FindHighLightMenuOption(NULL
);
1796 if (*HighlightMenu
!= NULL
) {
1798 // Update skip info for this highlight menu.
1800 MenuOption
= MENU_OPTION_FROM_LINK (*HighlightMenu
);
1801 UpdateOptionSkipLines (MenuOption
);
1804 // Found the last time highlight menu.
1806 *TopOfScreen
= FindTopOfScreenMenuOption();
1807 if (*TopOfScreen
!= NULL
) {
1809 // Found the last time selectable top of screen menu.
1811 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1812 MenuOption
= MENU_OPTION_FROM_LINK (*TopOfScreen
);
1813 UpdateOptionSkipLines (MenuOption
);
1815 *SkipValue
= gHighligthMenuInfo
.SkipValue
;
1818 // Not found last time top of screen menu, so base on current highlight menu
1819 // to find the new top of screen menu.
1820 // Make the current highlight menu at the bottom of the form to calculate the
1821 // top of screen menu.
1823 if (MenuOption
->Skip
>= BottomRow
- TopRow
) {
1824 *TopOfScreen
= *HighlightMenu
;
1827 *TopOfScreen
= FindTopOfScreenMenu(*HighlightMenu
, BottomRow
- TopRow
- MenuOption
->Skip
, &TmpValue
);
1830 *SkipValue
= TmpValue
;
1834 // Last time highlight menu has disappear, find the first highlightable menu as the defalut one.
1836 *HighlightMenu
= gMenuOption
.ForwardLink
;
1837 if (!IsListEmpty (&gMenuOption
)) {
1838 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
, TRUE
);
1840 *TopOfScreen
= gMenuOption
.ForwardLink
;
1844 } else if (FormData
->HighLightedStatement
!= NULL
) {
1845 if (IsSavedHighlightStatement (FormData
->HighLightedStatement
)) {
1847 // Input highlight menu is same as last time highlight menu.
1848 // Base on last time highlight menu to set the top of screen menu and highlight menu.
1850 *HighlightMenu
= FindHighLightMenuOption(NULL
);
1851 ASSERT (*HighlightMenu
!= NULL
);
1854 // Update skip info for this highlight menu.
1856 MenuOption
= MENU_OPTION_FROM_LINK (*HighlightMenu
);
1857 UpdateOptionSkipLines (MenuOption
);
1859 *TopOfScreen
= FindTopOfScreenMenuOption();
1860 if (*TopOfScreen
== NULL
) {
1862 // Not found last time top of screen menu, so base on current highlight menu
1863 // to find the new top of screen menu.
1864 // Make the current highlight menu at the bottom of the form to calculate the
1865 // top of screen menu.
1867 if (MenuOption
->Skip
>= BottomRow
- TopRow
) {
1868 *TopOfScreen
= *HighlightMenu
;
1871 *TopOfScreen
= FindTopOfScreenMenu(*HighlightMenu
, BottomRow
- TopRow
- MenuOption
->Skip
, &TmpValue
);
1874 *SkipValue
= TmpValue
;
1876 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1877 MenuOption
= MENU_OPTION_FROM_LINK (*TopOfScreen
);
1878 UpdateOptionSkipLines (MenuOption
);
1880 *SkipValue
= gHighligthMenuInfo
.SkipValue
;
1882 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1885 // Input highlight menu is not save as last time highlight menu.
1887 *HighlightMenu
= FindHighLightMenuOption(FormData
->HighLightedStatement
);
1888 MenuOption
= MENU_OPTION_FROM_LINK (*HighlightMenu
);
1889 UpdateOptionSkipLines (MenuOption
);
1892 // Make the current highlight menu at the bottom of the form to calculate the
1893 // top of screen menu.
1895 if (MenuOption
->Skip
>= BottomRow
- TopRow
) {
1896 *TopOfScreen
= *HighlightMenu
;
1899 *TopOfScreen
= FindTopOfScreenMenu(*HighlightMenu
, BottomRow
- TopRow
- MenuOption
->Skip
, &TmpValue
);
1902 *SkipValue
= TmpValue
;
1904 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1907 // If not has input highlight statement, just return the first one in this form.
1909 *TopOfScreen
= gMenuOption
.ForwardLink
;
1910 *HighlightMenu
= gMenuOption
.ForwardLink
;
1911 if (!IsListEmpty (&gMenuOption
)) {
1912 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
, TRUE
);
1920 // First enter to show the menu, update highlight info.
1922 UpdateHighlightMenuInfo (*HighlightMenu
, *TopOfScreen
, *SkipValue
);
1926 Record the highlight menu and top of screen menu info.
1928 @param Highlight The menu opton which is highlight.
1929 @param TopOfScreen The menu opton which is at the top of the form.
1930 @param SkipValue The skip line info for the top of screen menu.
1934 UpdateHighlightMenuInfo (
1935 IN LIST_ENTRY
*Highlight
,
1936 IN LIST_ENTRY
*TopOfScreen
,
1940 UI_MENU_OPTION
*MenuOption
;
1941 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1943 gHighligthMenuInfo
.HiiHandle
= gFormData
->HiiHandle
;
1944 gHighligthMenuInfo
.FormId
= gFormData
->FormId
;
1945 gHighligthMenuInfo
.SkipValue
= (UINT16
)SkipValue
;
1947 if (!IsListEmpty (&gMenuOption
)) {
1948 MenuOption
= MENU_OPTION_FROM_LINK (Highlight
);
1949 Statement
= MenuOption
->ThisTag
;
1951 gUserInput
->SelectedStatement
= Statement
;
1953 gHighligthMenuInfo
.HLTSequence
= MenuOption
->Sequence
;
1954 gHighligthMenuInfo
.HLTQuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1955 if (gHighligthMenuInfo
.HLTQuestionId
== 0) {
1957 // if question id == 0, save the opcode buffer..
1959 if (gHighligthMenuInfo
.HLTOpCode
!= NULL
) {
1960 FreePool (gHighligthMenuInfo
.HLTOpCode
);
1962 gHighligthMenuInfo
.HLTOpCode
= AllocateCopyPool (Statement
->OpCode
->Length
, Statement
->OpCode
);
1963 ASSERT (gHighligthMenuInfo
.HLTOpCode
!= NULL
);
1965 gHighligthMenuInfo
.HLTIndex
= GetIndexInfoForOpcode(Statement
->OpCode
);
1968 MenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
1969 Statement
= MenuOption
->ThisTag
;
1971 gHighligthMenuInfo
.TOSQuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1972 if (gHighligthMenuInfo
.TOSQuestionId
== 0) {
1974 // if question id == 0, save the opcode buffer..
1976 if (gHighligthMenuInfo
.TOSOpCode
!= NULL
) {
1977 FreePool (gHighligthMenuInfo
.TOSOpCode
);
1979 gHighligthMenuInfo
.TOSOpCode
= AllocateCopyPool (Statement
->OpCode
->Length
, Statement
->OpCode
);
1980 ASSERT (gHighligthMenuInfo
.TOSOpCode
!= NULL
);
1982 gHighligthMenuInfo
.TOSIndex
= GetIndexInfoForOpcode(Statement
->OpCode
);
1985 gUserInput
->SelectedStatement
= NULL
;
1987 gHighligthMenuInfo
.HLTSequence
= 0;
1988 gHighligthMenuInfo
.HLTQuestionId
= 0;
1989 if (gHighligthMenuInfo
.HLTOpCode
!= NULL
) {
1990 FreePool (gHighligthMenuInfo
.HLTOpCode
);
1992 gHighligthMenuInfo
.HLTOpCode
= NULL
;
1993 gHighligthMenuInfo
.HLTIndex
= 0;
1995 gHighligthMenuInfo
.TOSQuestionId
= 0;
1996 if (gHighligthMenuInfo
.TOSOpCode
!= NULL
) {
1997 FreePool (gHighligthMenuInfo
.TOSOpCode
);
1999 gHighligthMenuInfo
.TOSOpCode
= NULL
;
2000 gHighligthMenuInfo
.TOSIndex
= 0;
2005 Update attribut for this menu.
2007 @param MenuOption The menu opton which this attribut used to.
2008 @param Highlight Whether this menu will be highlight.
2012 SetDisplayAttribute (
2013 IN UI_MENU_OPTION
*MenuOption
,
2014 IN BOOLEAN Highlight
2017 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2019 Statement
= MenuOption
->ThisTag
;
2022 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
2026 if (MenuOption
->GrayOut
) {
2027 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetGrayedTextColor ());
2029 if (Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) {
2030 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetSubTitleTextColor ());
2032 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2038 Print string for this menu option.
2040 @param MenuOption The menu opton which this attribut used to.
2041 @param Col The column that this string will be print at.
2042 @param Row The row that this string will be print at.
2043 @param String The string which need to print.
2044 @param Width The width need to print, if string is less than the
2045 width, the block space will be used.
2046 @param Highlight Whether this menu will be highlight.
2051 IN UI_MENU_OPTION
*MenuOption
,
2056 IN BOOLEAN Highlight
2062 // Print string with normal color.
2065 PrintStringAtWithWidth (Col
, Row
, String
, Width
);
2070 // Print the highlight menu string.
2071 // First print the highlight string.
2073 SetDisplayAttribute(MenuOption
, TRUE
);
2074 Length
= PrintStringAt (Col
, Row
, String
);
2077 // Second, clean the empty after the string.
2079 SetDisplayAttribute(MenuOption
, FALSE
);
2080 PrintStringAtWithWidth (Col
+ Length
, Row
, L
"", Width
- Length
);
2084 Check whether this menu can has option string.
2086 @param MenuOption The menu opton which this attribut used to.
2088 @retval TRUE This menu option can have option string.
2089 @retval FALSE This menu option can't have option string.
2094 IN UI_MENU_OPTION
*MenuOption
2097 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2100 EFI_IFR_TEXT
*TestOp
;
2103 Statement
= MenuOption
->ThisTag
;
2106 // See if the second text parameter is really NULL
2108 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
2109 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
2110 if (TestOp
->TextTwo
!= 0) {
2111 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
2112 Size
= StrLen (String
);
2117 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
2118 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
2119 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
2120 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
2121 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
2123 // Allow a wide display if text op-code and no secondary text op-code
2125 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
2135 Double confirm with user about the action.
2137 @param Action The user input action.
2139 @retval TRUE User confirm with the input or not need user confirm.
2140 @retval FALSE User want ignore this input.
2157 CatLen
= StrLen (gConfirmMsgConnect
);
2160 // Below action need extra popup dialog to confirm.
2162 CheckFlags
= BROWSER_ACTION_DISCARD
|
2163 BROWSER_ACTION_DEFAULT
|
2164 BROWSER_ACTION_SUBMIT
|
2165 BROWSER_ACTION_RESET
|
2166 BROWSER_ACTION_EXIT
;
2169 // Not need to confirm with user, just return TRUE.
2171 if ((Action
& CheckFlags
) == 0) {
2175 if ((Action
& BROWSER_ACTION_DISCARD
) == BROWSER_ACTION_DISCARD
) {
2176 CfmStrLen
+= StrLen (gConfirmDiscardMsg
);
2179 if ((Action
& BROWSER_ACTION_DEFAULT
) == BROWSER_ACTION_DEFAULT
) {
2180 if (CfmStrLen
!= 0) {
2181 CfmStrLen
+= CatLen
;
2184 CfmStrLen
+= StrLen (gConfirmDefaultMsg
);
2187 if ((Action
& BROWSER_ACTION_SUBMIT
) == BROWSER_ACTION_SUBMIT
) {
2188 if (CfmStrLen
!= 0) {
2189 CfmStrLen
+= CatLen
;
2192 CfmStrLen
+= StrLen (gConfirmSubmitMsg
);
2195 if ((Action
& BROWSER_ACTION_RESET
) == BROWSER_ACTION_RESET
) {
2196 if (CfmStrLen
!= 0) {
2197 CfmStrLen
+= CatLen
;
2200 CfmStrLen
+= StrLen (gConfirmResetMsg
);
2203 if ((Action
& BROWSER_ACTION_EXIT
) == BROWSER_ACTION_EXIT
) {
2204 if (CfmStrLen
!= 0) {
2205 CfmStrLen
+= CatLen
;
2208 CfmStrLen
+= StrLen (gConfirmExitMsg
);
2212 // Allocate buffer to save the string.
2213 // String + "?" + "\0"
2215 MaxLen
= CfmStrLen
+ 1 + 1;
2216 CfmStr
= AllocateZeroPool (MaxLen
* sizeof (CHAR16
));
2217 ASSERT (CfmStr
!= NULL
);
2219 if ((Action
& BROWSER_ACTION_DISCARD
) == BROWSER_ACTION_DISCARD
) {
2220 StrCpyS (CfmStr
, MaxLen
, gConfirmDiscardMsg
);
2223 if ((Action
& BROWSER_ACTION_DEFAULT
) == BROWSER_ACTION_DEFAULT
) {
2224 if (CfmStr
[0] != 0) {
2225 StrCatS (CfmStr
, MaxLen
, gConfirmMsgConnect
);
2226 StrCatS (CfmStr
, MaxLen
, gConfirmDefaultMsg2nd
);
2228 StrCpyS (CfmStr
, MaxLen
, gConfirmDefaultMsg
);
2232 if ((Action
& BROWSER_ACTION_SUBMIT
) == BROWSER_ACTION_SUBMIT
) {
2233 if (CfmStr
[0] != 0) {
2234 StrCatS (CfmStr
, MaxLen
, gConfirmMsgConnect
);
2235 StrCatS (CfmStr
, MaxLen
, gConfirmSubmitMsg2nd
);
2237 StrCpyS (CfmStr
, MaxLen
, gConfirmSubmitMsg
);
2241 if ((Action
& BROWSER_ACTION_RESET
) == BROWSER_ACTION_RESET
) {
2242 if (CfmStr
[0] != 0) {
2243 StrCatS (CfmStr
, MaxLen
, gConfirmMsgConnect
);
2244 StrCatS (CfmStr
, MaxLen
, gConfirmResetMsg2nd
);
2246 StrCpyS (CfmStr
, MaxLen
, gConfirmResetMsg
);
2250 if ((Action
& BROWSER_ACTION_EXIT
) == BROWSER_ACTION_EXIT
) {
2251 if (CfmStr
[0] != 0) {
2252 StrCatS (CfmStr
, MaxLen
, gConfirmMsgConnect
);
2253 StrCatS (CfmStr
, MaxLen
, gConfirmExitMsg2nd
);
2255 StrCpyS (CfmStr
, MaxLen
, gConfirmExitMsg
);
2259 StrCatS (CfmStr
, MaxLen
, gConfirmMsgEnd
);
2262 CreateDialog (&Key
, gEmptyString
, CfmStr
, gConfirmOpt
, gEmptyString
, NULL
);
2263 } while (((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (gConfirmOptYes
[0] | UPPER_LOWER_CASE_OFFSET
)) &&
2264 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (gConfirmOptNo
[0] | UPPER_LOWER_CASE_OFFSET
)) &&
2265 (Key
.ScanCode
!= SCAN_ESC
));
2267 if ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) == (gConfirmOptYes
[0] | UPPER_LOWER_CASE_OFFSET
)) {
2279 Print string for this menu option.
2281 @param MenuOption The menu opton which this attribut used to.
2282 @param SkipWidth The skip width between the left to the start of the prompt.
2283 @param BeginCol The begin column for one menu.
2284 @param SkipLine The skip line for this menu.
2285 @param BottomRow The bottom row for this form.
2286 @param Highlight Whether this menu will be highlight.
2287 @param UpdateCol Whether need to update the column info for Date/Time.
2289 @retval EFI_SUCESSS Process the user selection success.
2294 IN UI_MENU_OPTION
*MenuOption
,
2299 IN BOOLEAN Highlight
,
2300 IN BOOLEAN UpdateCol
2303 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2308 CHAR16
*OptionString
;
2309 CHAR16
*OutputString
;
2316 BOOLEAN IsProcessingFirstRow
;
2318 UINTN PromptLineNum
;
2319 UINTN OptionLineNum
;
2323 Statement
= MenuOption
->ThisTag
;
2331 IsProcessingFirstRow
= TRUE
;
2334 // Set default color.
2336 SetDisplayAttribute (MenuOption
, FALSE
);
2339 // 1. Paint the option string.
2341 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
2342 if (EFI_ERROR (Status
)) {
2346 if (OptionString
!= NULL
) {
2347 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
2349 // Adjust option string for date/time opcode.
2351 ProcessStringForDateTime(MenuOption
, OptionString
, UpdateCol
);
2354 Width
= (UINT16
) gOptionBlockWidth
- 1;
2355 Row
= MenuOption
->Row
;
2359 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2360 if (((Temp2
== 0)) && (Row
<= BottomRow
)) {
2361 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
2363 // For date/time question, it has three menu options for this qustion.
2364 // The first/second menu options with the skip value is 0. the last one
2365 // with skip value is 1.
2367 if (MenuOption
->Skip
!= 0) {
2369 // For date/ time, print the last past (year for date and second for time)
2370 // - 7 means skip [##/##/ for date and [##:##: for time.
2372 DisplayMenuString (MenuOption
,MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1 - 7, Highlight
);
2375 // For date/ time, print the first and second past (year for date and second for time)
2376 // The OutputString has a NARROW_CHAR or WIDE_CHAR at the begin of the string,
2377 // so need to - 1 to remove it, otherwise, it will clean 1 extr char follow it.
2378 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, StrLen (OutputString
) - 1, Highlight
);
2381 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
2387 // If there is more string to process print on the next row and increment the Skip value
2389 if (StrLen (&OptionString
[Index
]) != 0) {
2393 // Since the Number of lines for this menu entry may or may not be reflected accurately
2394 // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
2395 // some testing to ensure we are keeping this in-sync.
2397 // If the difference in rows is greater than or equal to the skip value, increase the skip value
2399 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
2405 FreePool (OutputString
);
2413 FreePool (OptionString
);
2417 // 2. Paint the description.
2419 PromptWidth
= GetWidth (MenuOption
, &AdjustValue
);
2420 Row
= MenuOption
->Row
;
2424 if (MenuOption
->Description
== NULL
|| MenuOption
->Description
[0] == '\0') {
2425 PrintStringAtWithWidth (BeginCol
, Row
, L
"", PromptWidth
+ AdjustValue
+ SkipWidth
);
2428 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, PromptWidth
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2429 if ((Temp
== 0) && (Row
<= BottomRow
)) {
2431 // 1.Clean the start LEFT_SKIPPED_COLUMNS
2433 PrintStringAtWithWidth (BeginCol
, Row
, L
"", SkipWidth
);
2435 if (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
&& MenuOption
->Col
>= 2 && IsProcessingFirstRow
) {
2437 // Print Arrow for Goto button.
2440 MenuOption
->Col
- 2,
2442 GEOMETRICSHAPE_RIGHT_TRIANGLE
2444 IsProcessingFirstRow
= FALSE
;
2446 DisplayMenuString (MenuOption
, MenuOption
->Col
, Row
, OutputString
, PromptWidth
+ AdjustValue
, Highlight
);
2450 // If there is more string to process print on the next row and increment the Skip value
2452 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
2458 FreePool (OutputString
);
2469 // 3. If this is a text op with secondary text information
2471 if ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
!= 0)) {
2472 StringPtr
= GetToken (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
2474 Width
= (UINT16
) gOptionBlockWidth
- 1;
2475 Row
= MenuOption
->Row
;
2479 for (Index
= 0; GetLineByWidth (StringPtr
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
2480 if ((Temp3
== 0) && (Row
<= BottomRow
)) {
2481 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
2485 // If there is more string to process print on the next row and increment the Skip value
2487 if (StrLen (&StringPtr
[Index
]) != 0) {
2491 // If the rows for text two is greater than or equal to the skip value, increase the skip value
2493 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
2499 FreePool (OutputString
);
2505 FreePool (StringPtr
);
2509 // 4.Line number for Option string and prompt string are not equal.
2510 // Clean the column whose line number is less.
2512 if (HasOptionString(MenuOption
) && (OptionLineNum
!= PromptLineNum
)) {
2513 Col
= OptionLineNum
< PromptLineNum
? MenuOption
->OptCol
: BeginCol
;
2514 Row
= (OptionLineNum
< PromptLineNum
? OptionLineNum
: PromptLineNum
) + MenuOption
->Row
;
2515 Width
= (UINT16
) (OptionLineNum
< PromptLineNum
? gOptionBlockWidth
: PromptWidth
+ AdjustValue
+ SkipWidth
);
2516 MaxRow
= (OptionLineNum
< PromptLineNum
? PromptLineNum
: OptionLineNum
) + MenuOption
->Row
- 1;
2518 while (Row
<= MaxRow
) {
2519 DisplayMenuString (MenuOption
, Col
, Row
++, L
"", Width
, FALSE
);
2527 Display menu and wait for user to select one menu option, then return it.
2528 If AutoBoot is enabled, then if user doesn't select any option,
2529 after period of time, it will automatically return the first menu option.
2531 @param FormData The current form data info.
2533 @retval EFI_SUCESSS Process the user selection success.
2534 @retval EFI_NOT_FOUND Process option string for orderedlist/Oneof fail.
2539 IN FORM_DISPLAY_ENGINE_FORM
*FormData
2544 UINTN DistanceValue
;
2553 CHAR16
*StringRightPtr
;
2554 CHAR16
*StringErrorPtr
;
2555 CHAR16
*OptionString
;
2557 CHAR16
*HelpHeaderString
;
2558 CHAR16
*HelpBottomString
;
2567 LIST_ENTRY
*TopOfScreen
;
2568 LIST_ENTRY
*SavedListEntry
;
2569 UI_MENU_OPTION
*MenuOption
;
2570 UI_MENU_OPTION
*NextMenuOption
;
2571 UI_MENU_OPTION
*SavedMenuOption
;
2572 UI_CONTROL_FLAG ControlFlag
;
2573 UI_SCREEN_OPERATION ScreenOperation
;
2574 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2575 BROWSER_HOT_KEY
*HotKey
;
2576 UINTN HelpPageIndex
;
2577 UINTN HelpPageCount
;
2580 UINTN HelpHeaderLine
;
2581 UINTN HelpBottomLine
;
2582 BOOLEAN MultiHelpPage
;
2583 UINT16 EachLineWidth
;
2584 UINT16 HeaderLineWidth
;
2585 UINT16 BottomLineWidth
;
2586 EFI_STRING_ID HelpInfo
;
2587 UI_EVENT_TYPE EventType
;
2588 BOOLEAN SkipHighLight
;
2589 EFI_HII_VALUE
*StatementValue
;
2591 EventType
= UIEventNone
;
2592 Status
= EFI_SUCCESS
;
2594 HelpHeaderString
= NULL
;
2595 HelpBottomString
= NULL
;
2596 OptionString
= NULL
;
2597 ScreenOperation
= UiNoOperation
;
2605 MultiHelpPage
= FALSE
;
2607 HeaderLineWidth
= 0;
2608 BottomLineWidth
= 0;
2612 SkipHighLight
= FALSE
;
2614 NextMenuOption
= NULL
;
2615 SavedMenuOption
= NULL
;
2619 gModalSkipColumn
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 6;
2621 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
2623 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
2624 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
- 1;
2627 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2628 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gModalSkipColumn
;
2630 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
;
2633 FindTopMenu(FormData
, &TopOfScreen
, &NewPos
, &SkipValue
);
2634 if (!IsListEmpty (&gMenuOption
)) {
2635 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2636 gUserInput
->SelectedStatement
= NextMenuOption
->ThisTag
;
2639 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
2641 ControlFlag
= CfInitialization
;
2643 switch (ControlFlag
) {
2644 case CfInitialization
:
2645 if ((gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
) ||
2646 (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))) {
2648 // Clear Statement range if different formset is painted.
2651 gStatementDimensions
.LeftColumn
,
2652 gStatementDimensions
.RightColumn
,
2653 TopRow
- SCROLL_ARROW_HEIGHT
,
2654 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2655 GetFieldTextColor ()
2659 ControlFlag
= CfRepaint
;
2663 ControlFlag
= CfRefreshHighLight
;
2673 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2676 // 1. Check whether need to print the arrow up.
2678 if (!ValueIsScroll (TRUE
, TopOfScreen
)) {
2682 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2683 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2685 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2688 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2690 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2691 TopRow
- SCROLL_ARROW_HEIGHT
,
2694 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2698 // 2.Paint the menu.
2700 for (Link
= TopOfScreen
; Link
!= &gMenuOption
; Link
= Link
->ForwardLink
) {
2701 MenuOption
= MENU_OPTION_FROM_LINK (Link
);
2702 MenuOption
->Row
= Row
;
2703 MenuOption
->Col
= Col
;
2704 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2705 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
+ gModalSkipColumn
;
2707 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
;
2710 if (MenuOption
->NestInStatement
) {
2711 MenuOption
->Col
+= SUBTITLE_INDENT
;
2715 // Save the highlight menu, will be used in CfRefreshHighLight case.
2717 if (Link
== NewPos
) {
2718 SavedMenuOption
= MenuOption
;
2719 SkipHighLight
= TRUE
;
2722 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2723 Status
= DisplayOneMenu (MenuOption
,
2724 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2725 gStatementDimensions
.LeftColumn
+ gModalSkipColumn
,
2726 Link
== TopOfScreen
? SkipValue
: 0,
2728 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2732 Status
= DisplayOneMenu (MenuOption
,
2733 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2734 gStatementDimensions
.LeftColumn
,
2735 Link
== TopOfScreen
? SkipValue
: 0,
2737 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2742 if (EFI_ERROR (Status
)) {
2750 // 3. Update the row info which will be used by next menu.
2752 if (Link
== TopOfScreen
) {
2753 Row
+= MenuOption
->Skip
- SkipValue
;
2755 Row
+= MenuOption
->Skip
;
2758 if (Row
> BottomRow
) {
2759 if (!ValueIsScroll (FALSE
, Link
)) {
2763 Row
= BottomRow
+ 1;
2769 // 3. Menus in this form may not cover all form, clean the remain field.
2771 while (Row
<= BottomRow
) {
2772 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2773 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2775 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gHelpBlockWidth
- gStatementDimensions
.LeftColumn
);
2780 // 4. Print the down arrow row.
2782 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2783 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * + gModalSkipColumn
);
2785 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2788 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2790 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2791 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2794 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2801 case CfRefreshHighLight
:
2804 // MenuOption: Last menu option that need to remove hilight
2805 // MenuOption is set to NULL in Repaint
2806 // NewPos: Current menu option that need to hilight
2808 ControlFlag
= CfUpdateHelpString
;
2810 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
2812 if (SkipHighLight
) {
2813 SkipHighLight
= FALSE
;
2814 MenuOption
= SavedMenuOption
;
2815 RefreshKeyHelp(gFormData
, SavedMenuOption
->ThisTag
, FALSE
);
2819 if (IsListEmpty (&gMenuOption
)) {
2821 // No menu option, just update the hotkey filed.
2823 RefreshKeyHelp(gFormData
, NULL
, FALSE
);
2827 if (MenuOption
!= NULL
&& TopOfScreen
== &MenuOption
->Link
) {
2832 if (NewPos
== TopOfScreen
) {
2838 if (NewPos
!= NULL
&& (MenuOption
== NULL
|| NewPos
!= &MenuOption
->Link
)) {
2839 if (MenuOption
!= NULL
) {
2841 // Remove the old highlight menu.
2843 Status
= DisplayOneMenu (MenuOption
,
2844 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2845 gStatementDimensions
.LeftColumn
,
2854 // This is the current selected statement
2856 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2857 RefreshKeyHelp(gFormData
, MenuOption
->ThisTag
, FALSE
);
2859 if (!IsSelectable (MenuOption
)) {
2863 Status
= DisplayOneMenu (MenuOption
,
2864 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2865 gStatementDimensions
.LeftColumn
,
2874 case CfUpdateHelpString
:
2875 ControlFlag
= CfPrepareToReadKey
;
2876 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2881 // NewLine means only update highlight menu (remove old highlight and highlith
2882 // the new one), not need to full repain the form.
2884 if (Repaint
|| NewLine
) {
2885 if (IsListEmpty (&gMenuOption
)) {
2887 // Don't print anything if no mwnu option.
2889 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2892 // Don't print anything if it is a NULL help token
2894 ASSERT(MenuOption
!= NULL
);
2895 HelpInfo
= ((EFI_IFR_STATEMENT_HEADER
*) ((CHAR8
*)MenuOption
->ThisTag
->OpCode
+ sizeof (EFI_IFR_OP_HEADER
)))->Help
;
2896 Statement
= MenuOption
->ThisTag
;
2897 StatementValue
= &Statement
->CurrentValue
;
2898 if (HelpInfo
== 0 || !IsSelectable (MenuOption
)) {
2899 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
&& StatementValue
->Value
.date
.Month
== 0xff)||(Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
&& StatementValue
->Value
.time
.Hour
== 0xff)){
2900 StringPtr
= GetToken (STRING_TOKEN (GET_TIME_FAIL
), gHiiHandle
);
2902 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2905 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
&& StatementValue
->Value
.date
.Month
== 0xff)||(Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
&& StatementValue
->Value
.time
.Hour
== 0xff)){
2906 StringRightPtr
= GetToken (HelpInfo
, gFormData
->HiiHandle
);
2907 StringErrorPtr
= GetToken (STRING_TOKEN (GET_TIME_FAIL
), gHiiHandle
);
2908 StringPtr
= AllocateZeroPool ((StrLen (StringRightPtr
) + StrLen (StringErrorPtr
)+ 1 ) * sizeof (CHAR16
));
2909 StrCpyS (StringPtr
, StrLen (StringRightPtr
) + StrLen (StringErrorPtr
) + 1, StringRightPtr
);
2910 StrCatS (StringPtr
, StrLen (StringRightPtr
) + StrLen (StringErrorPtr
) + 1, StringErrorPtr
);
2911 FreePool (StringRightPtr
);
2912 FreePool (StringErrorPtr
);
2914 StringPtr
= GetToken (HelpInfo
, gFormData
->HiiHandle
);
2919 RowCount
= BottomRow
- TopRow
+ 1;
2922 // 1.Calculate how many line the help string need to print.
2924 if (HelpString
!= NULL
) {
2925 FreePool (HelpString
);
2928 HelpLine
= ProcessHelpString (StringPtr
, &HelpString
, &EachLineWidth
, RowCount
);
2929 FreePool (StringPtr
);
2931 if (HelpLine
> RowCount
) {
2932 MultiHelpPage
= TRUE
;
2933 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_UP
), gHiiHandle
);
2934 if (HelpHeaderString
!= NULL
) {
2935 FreePool (HelpHeaderString
);
2936 HelpHeaderString
= NULL
;
2938 HelpHeaderLine
= ProcessHelpString (StringPtr
, &HelpHeaderString
, &HeaderLineWidth
, 0);
2939 FreePool (StringPtr
);
2940 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_DOWN
), gHiiHandle
);
2941 if (HelpBottomString
!= NULL
) {
2942 FreePool (HelpBottomString
);
2943 HelpBottomString
= NULL
;
2945 HelpBottomLine
= ProcessHelpString (StringPtr
, &HelpBottomString
, &BottomLineWidth
, 0);
2946 FreePool (StringPtr
);
2948 // Calculate the help page count.
2950 if (HelpLine
> 2 * RowCount
- 2) {
2951 HelpPageCount
= (HelpLine
- RowCount
+ 1) / (RowCount
- 2) + 1;
2952 if ((HelpLine
- RowCount
+ 1) % (RowCount
- 2) > 1) {
2959 MultiHelpPage
= FALSE
;
2964 // Check whether need to show the 'More(U/u)' at the begin.
2965 // Base on current direct info, here shows aligned to the right side of the column.
2966 // If the direction is multi line and aligned to right side may have problem, so
2967 // add ASSERT code here.
2969 if (HelpPageIndex
> 0) {
2970 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2971 for (Index
= 0; Index
< HelpHeaderLine
; Index
++) {
2972 ASSERT (HelpHeaderLine
== 1);
2973 ASSERT (GetStringWidth (HelpHeaderString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2974 PrintStringAtWithWidth (
2975 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2981 gStatementDimensions
.RightColumn
- GetStringWidth (HelpHeaderString
) / 2 - 1,
2983 &HelpHeaderString
[Index
* HeaderLineWidth
]
2988 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHelpTextColor ());
2990 // Print the help string info.
2992 if (!MultiHelpPage
) {
2993 for (Index
= 0; Index
< HelpLine
; Index
++) {
2994 PrintStringAtWithWidth (
2995 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2997 &HelpString
[Index
* EachLineWidth
],
3001 for (; Index
< RowCount
; Index
++) {
3002 PrintStringAtWithWidth (
3003 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
3009 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
3011 if (HelpPageIndex
== 0) {
3012 for (Index
= 0; Index
< RowCount
- HelpBottomLine
; Index
++) {
3013 PrintStringAtWithWidth (
3014 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
3016 &HelpString
[Index
* EachLineWidth
],
3021 for (Index
= 0; (Index
< RowCount
- HelpBottomLine
- HelpHeaderLine
) &&
3022 (Index
+ HelpPageIndex
* (RowCount
- 2) + 1 < HelpLine
); Index
++) {
3023 PrintStringAtWithWidth (
3024 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
3025 Index
+ TopRow
+ HelpHeaderLine
,
3026 &HelpString
[(Index
+ HelpPageIndex
* (RowCount
- 2) + 1)* EachLineWidth
],
3030 if (HelpPageIndex
== HelpPageCount
- 1) {
3031 for (; Index
< RowCount
- HelpHeaderLine
; Index
++) {
3032 PrintStringAtWithWidth (
3033 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
3034 Index
+ TopRow
+ HelpHeaderLine
,
3039 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
3045 // Check whether need to print the 'More(D/d)' at the bottom.
3046 // Base on current direct info, here shows aligned to the right side of the column.
3047 // If the direction is multi line and aligned to right side may have problem, so
3048 // add ASSERT code here.
3050 if (HelpPageIndex
< HelpPageCount
- 1 && MultiHelpPage
) {
3051 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
3052 for (Index
= 0; Index
< HelpBottomLine
; Index
++) {
3053 ASSERT (HelpBottomLine
== 1);
3054 ASSERT (GetStringWidth (HelpBottomString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
3055 PrintStringAtWithWidth (
3056 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
3057 BottomRow
+ Index
- HelpBottomLine
+ 1,
3062 gStatementDimensions
.RightColumn
- GetStringWidth (HelpBottomString
) / 2 - 1,
3063 BottomRow
+ Index
- HelpBottomLine
+ 1,
3064 &HelpBottomString
[Index
* BottomLineWidth
]
3069 // Reset this flag every time we finish using it.
3075 case CfPrepareToReadKey
:
3076 ControlFlag
= CfReadKey
;
3077 ScreenOperation
= UiNoOperation
;
3081 ControlFlag
= CfScreenOperation
;
3084 // Wait for user's selection
3087 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
3088 if (!EFI_ERROR (Status
)) {
3089 EventType
= UIEventKey
;
3094 // If we encounter error, continue to read another key in.
3096 if (Status
!= EFI_NOT_READY
) {
3100 EventType
= UiWaitForEvent(gST
->ConIn
->WaitForKey
);
3101 if (EventType
== UIEventKey
) {
3102 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
3107 if (EventType
== UIEventDriver
) {
3109 gUserInput
->Action
= BROWSER_ACTION_NONE
;
3110 ControlFlag
= CfExit
;
3114 if (EventType
== UIEventTimeOut
) {
3115 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
3116 ControlFlag
= CfExit
;
3120 switch (Key
.UnicodeChar
) {
3121 case CHAR_CARRIAGE_RETURN
:
3122 if(MenuOption
== NULL
|| MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
3123 ControlFlag
= CfReadKey
;
3127 ScreenOperation
= UiSelect
;
3132 // We will push the adjustment of these numeric values directly to the input handler
3133 // NOTE: we won't handle manual input numeric
3138 // If the screen has no menu items, and the user didn't select UiReset
3139 // ignore the selection and go back to reading keys.
3141 ASSERT(MenuOption
!= NULL
);
3142 if(IsListEmpty (&gMenuOption
) || MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
3143 ControlFlag
= CfReadKey
;
3147 Statement
= MenuOption
->ThisTag
;
3148 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
)
3149 || (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
3150 || ((Statement
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (GetFieldFromNum(Statement
->OpCode
) != 0))
3152 if (Key
.UnicodeChar
== '+') {
3153 gDirection
= SCAN_RIGHT
;
3155 gDirection
= SCAN_LEFT
;
3158 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
3159 if (OptionString
!= NULL
) {
3160 FreePool (OptionString
);
3162 if (EFI_ERROR (Status
)) {
3164 // Repaint to clear possible error prompt pop-up
3169 ControlFlag
= CfExit
;
3175 ScreenOperation
= UiUp
;
3180 ScreenOperation
= UiDown
;
3184 if(IsListEmpty (&gMenuOption
)) {
3185 ControlFlag
= CfReadKey
;
3189 ASSERT(MenuOption
!= NULL
);
3190 if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_CHECKBOX_OP
&& !MenuOption
->GrayOut
&& !MenuOption
->ReadOnly
) {
3191 ScreenOperation
= UiSelect
;
3197 if (!MultiHelpPage
) {
3198 ControlFlag
= CfReadKey
;
3201 ControlFlag
= CfUpdateHelpString
;
3202 HelpPageIndex
= HelpPageIndex
< HelpPageCount
- 1 ? HelpPageIndex
+ 1 : HelpPageCount
- 1;
3207 if (!MultiHelpPage
) {
3208 ControlFlag
= CfReadKey
;
3211 ControlFlag
= CfUpdateHelpString
;
3212 HelpPageIndex
= HelpPageIndex
> 0 ? HelpPageIndex
- 1 : 0;
3216 for (Index
= 0; Index
< mScanCodeNumber
; Index
++) {
3217 if (Key
.ScanCode
== gScanCodeToOperation
[Index
].ScanCode
) {
3218 ScreenOperation
= gScanCodeToOperation
[Index
].ScreenOperation
;
3223 if (((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) && (Key
.ScanCode
== SCAN_ESC
|| Index
== mScanCodeNumber
)) {
3225 // ModalForm has no ESC key and Hot Key.
3227 ControlFlag
= CfReadKey
;
3228 } else if (Index
== mScanCodeNumber
) {
3230 // Check whether Key matches the registered hot key.
3233 HotKey
= GetHotKeyFromRegisterList (&Key
);
3234 if (HotKey
!= NULL
) {
3235 ScreenOperation
= UiHotKey
;
3242 case CfScreenOperation
:
3243 if ((ScreenOperation
!= UiReset
) && (ScreenOperation
!= UiHotKey
)) {
3245 // If the screen has no menu items, and the user didn't select UiReset or UiHotKey
3246 // ignore the selection and go back to reading keys.
3248 if (IsListEmpty (&gMenuOption
)) {
3249 ControlFlag
= CfReadKey
;
3255 Index
< sizeof (gScreenOperationToControlFlag
) / sizeof (gScreenOperationToControlFlag
[0]);
3258 if (ScreenOperation
== gScreenOperationToControlFlag
[Index
].ScreenOperation
) {
3259 ControlFlag
= gScreenOperationToControlFlag
[Index
].ControlFlag
;
3266 ControlFlag
= CfRepaint
;
3268 ASSERT(MenuOption
!= NULL
);
3269 Statement
= MenuOption
->ThisTag
;
3270 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
3274 switch (Statement
->OpCode
->OpCode
) {
3275 case EFI_IFR_REF_OP
:
3276 case EFI_IFR_ACTION_OP
:
3277 case EFI_IFR_RESET_BUTTON_OP
:
3278 ControlFlag
= CfExit
;
3283 // Editable Questions: oneof, ordered list, checkbox, numeric, string, password
3285 RefreshKeyHelp (gFormData
, Statement
, TRUE
);
3286 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
3288 if (OptionString
!= NULL
) {
3289 FreePool (OptionString
);
3292 if (EFI_ERROR (Status
)) {
3295 RefreshKeyHelp (gFormData
, Statement
, FALSE
);
3298 ControlFlag
= CfExit
;
3306 // We come here when someone press ESC
3307 // If the policy is not exit front page when user press ESC, process here.
3309 if (!FormExitPolicy()) {
3312 ControlFlag
= CfRepaint
;
3316 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
3317 ControlFlag
= CfExit
;
3321 ControlFlag
= CfRepaint
;
3323 ASSERT (HotKey
!= NULL
);
3325 if (FxConfirmPopup(HotKey
->Action
)) {
3326 gUserInput
->Action
= HotKey
->Action
;
3327 if ((HotKey
->Action
& BROWSER_ACTION_DEFAULT
) == BROWSER_ACTION_DEFAULT
) {
3328 gUserInput
->DefaultId
= HotKey
->DefaultId
;
3330 ControlFlag
= CfExit
;
3334 ControlFlag
= CfRepaint
;
3340 ControlFlag
= CfRepaint
;
3341 ASSERT(MenuOption
!= NULL
);
3342 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
3343 if (MenuOption
->Sequence
!= 0) {
3345 // In the middle or tail of the Date/Time op-code set, go left.
3347 ASSERT(NewPos
!= NULL
);
3348 NewPos
= NewPos
->BackLink
;
3354 ControlFlag
= CfRepaint
;
3355 ASSERT(MenuOption
!= NULL
);
3356 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
3357 if (MenuOption
->Sequence
!= 2) {
3359 // In the middle or tail of the Date/Time op-code set, go left.
3361 ASSERT(NewPos
!= NULL
);
3362 NewPos
= NewPos
->ForwardLink
;
3368 ControlFlag
= CfRepaint
;
3371 SavedListEntry
= NewPos
;
3372 ASSERT(NewPos
!= NULL
);
3374 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3375 ASSERT (MenuOption
!= NULL
);
3378 // Adjust Date/Time position before we advance forward.
3380 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3382 NewPos
= NewPos
->BackLink
;
3384 // Find next selectable menu or the first menu beyond current form.
3386 Difference
= MoveToNextStatement (TRUE
, &NewPos
, MenuOption
->Row
- TopRow
, FALSE
);
3387 if (Difference
< 0) {
3389 // We hit the begining MenuOption that can be focused
3390 // so we simply scroll to the top.
3393 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3394 TopOfScreen
= gMenuOption
.ForwardLink
;
3395 NewPos
= SavedListEntry
;
3399 // Scroll up to the last page when we have arrived at top page.
3401 TopOfScreen
= FindTopOfScreenMenu (gMenuOption
.BackLink
, BottomRow
- TopRow
, &SkipValue
);
3402 NewPos
= gMenuOption
.BackLink
;
3403 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
3406 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3408 if (MenuOption
->Row
< TopRow
+ Difference
+ NextMenuOption
->Skip
) {
3410 // Previous focus MenuOption is above the TopOfScreen, so we need to scroll
3412 TopOfScreen
= NewPos
;
3418 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
3420 // BottomRow - TopRow + 1 means the total rows current forms supported.
3421 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
3422 // and new top menu. New top menu will all shows in next form, but last highlight menu
3423 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
3424 // last highlight menu.
3426 if (!IsSelectable(NextMenuOption
) && IsSelectable(MenuOption
) &&
3427 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
3428 NewPos
= SavedListEntry
;
3432 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3435 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3437 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3438 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3440 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3445 // SkipValue means lines is skipped when show the top menu option.
3447 ControlFlag
= CfRepaint
;
3453 // First minus the menu of the top screen, it's value is SkipValue.
3455 if (SkipValue
>= BottomRow
- TopRow
+ 1) {
3457 // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one
3458 // form of options to be show, so just update the SkipValue to show the next
3459 // parts of options.
3461 SkipValue
-= BottomRow
- TopRow
+ 1;
3462 NewPos
= TopOfScreen
;
3465 Index
= (BottomRow
+ 1) - SkipValue
- TopRow
;
3468 TopOfScreen
= FindTopOfScreenMenu(TopOfScreen
, Index
, &SkipValue
);
3469 NewPos
= TopOfScreen
;
3470 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, FALSE
);
3472 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3475 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3476 // Don't do this when we are already in the first page.
3478 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3479 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3481 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3486 // SkipValue means lines is skipped when show the top menu option.
3488 ControlFlag
= CfRepaint
;
3493 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3494 Index
= TopRow
+ NextMenuOption
->Skip
- SkipValue
;
3496 // Count to the menu option which will show at the top of the next form.
3498 while ((Index
<= BottomRow
+ 1) && (Link
->ForwardLink
!= &gMenuOption
)) {
3499 Link
= Link
->ForwardLink
;
3500 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
3501 Index
= Index
+ NextMenuOption
->Skip
;
3504 if ((Link
->ForwardLink
== &gMenuOption
) && (Index
<= BottomRow
+ 1)) {
3506 // Highlight on the last menu which can be highlight.
3509 MoveToNextStatement (TRUE
, &Link
, Index
- TopRow
, TRUE
);
3512 // Calculate the skip line for top of screen menu.
3514 if (Link
== TopOfScreen
) {
3516 // The top of screen menu option occupies the entire form.
3518 SkipValue
+= BottomRow
- TopRow
+ 1;
3520 SkipValue
= NextMenuOption
->Skip
- (Index
- (BottomRow
+ 1));
3525 // Move to the Next selectable menu.
3527 MoveToNextStatement (FALSE
, &Link
, BottomRow
- TopRow
, TRUE
);
3531 // Save the menu as the next highlight menu.
3535 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3538 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3539 // Don't do this when we are already in the last page.
3541 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3542 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3544 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3549 // SkipValue means lines is skipped when show the top menu option.
3550 // NewPos points to the menu which is highlighted now.
3552 ControlFlag
= CfRepaint
;
3555 if (NewPos
== TopOfScreen
) {
3561 SavedListEntry
= NewPos
;
3563 // Since the behavior of hitting the down arrow on a Date/Time op-code is intended
3564 // to be one that progresses to the next set of op-codes, we need to advance to the last
3565 // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate
3566 // checking can be done. The only other logic we need to introduce is that if a Date/Time
3567 // op-code is the last entry in the menu, we need to rewind back to the first op-code of
3568 // the Date/Time op-code.
3570 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3572 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3573 NewPos
= NewPos
->ForwardLink
;
3575 // Find the next selectable menu.
3577 if (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
> BottomRow
+ 1) {
3578 if (gMenuOption
.ForwardLink
== NewPos
|| &gMenuOption
== NewPos
) {
3584 Difference
= MoveToNextStatement (FALSE
, &NewPos
, BottomRow
+ 1 - (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
), FALSE
);
3586 if (Difference
< 0) {
3588 // Scroll to the first page.
3590 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3591 TopOfScreen
= gMenuOption
.ForwardLink
;
3595 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3597 NewPos
= gMenuOption
.ForwardLink
;
3598 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
3602 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3604 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3605 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3607 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3612 // Get next selected menu info.
3614 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3615 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3616 if (NextMenuOption
->Row
== 0) {
3617 UpdateOptionSkipLines (NextMenuOption
);
3621 // Calculate new highlight menu end row.
3623 Temp
= (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
) + Difference
+ NextMenuOption
->Skip
- 1;
3624 if (Temp
> BottomRow
) {
3626 // Get the top screen menu info.
3628 AdjustDateAndTimePosition (FALSE
, &TopOfScreen
);
3629 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3632 // Current Top screen menu occupy (SavedMenuOption->Skip - SkipValue) rows.
3633 // Full shows the new selected menu need to skip (Temp - BottomRow - 1) rows.
3635 if ((Temp
- BottomRow
) >= (SavedMenuOption
->Skip
- SkipValue
)) {
3637 // Skip the top op-code
3639 TopOfScreen
= TopOfScreen
->ForwardLink
;
3640 DistanceValue
= (Temp
- BottomRow
) - (SavedMenuOption
->Skip
- SkipValue
);
3642 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3645 // If we have a remainder, skip that many more op-codes until we drain the remainder
3646 // Special case is the selected highlight menu has more than one form of menus.
3648 while (DistanceValue
>= SavedMenuOption
->Skip
&& TopOfScreen
!= NewPos
) {
3650 // Since the Difference is greater than or equal to this op-code's skip value, skip it
3652 DistanceValue
= DistanceValue
- (INTN
) SavedMenuOption
->Skip
;
3653 TopOfScreen
= TopOfScreen
->ForwardLink
;
3654 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3657 // Since we will act on this op-code in the next routine, and increment the
3658 // SkipValue, set the skips to one less than what is required.
3660 if (TopOfScreen
!= NewPos
) {
3661 SkipValue
= DistanceValue
;
3667 // Since we will act on this op-code in the next routine, and increment the
3668 // SkipValue, set the skips to one less than what is required.
3670 SkipValue
+= Temp
- BottomRow
;
3673 } else if (!IsSelectable (NextMenuOption
)) {
3675 // Continue to go down until scroll to next page or the selectable option is found.
3677 ScreenOperation
= UiDown
;
3678 ControlFlag
= CfScreenOperation
;
3682 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3685 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
3687 // BottomRow - TopRow + 1 means the total rows current forms supported.
3688 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
3689 // and new top menu. New top menu will all shows in next form, but last highlight menu
3690 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
3691 // last highlight menu.
3693 if (!IsSelectable (NextMenuOption
) && IsSelectable (MenuOption
) &&
3694 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
3695 NewPos
= SavedListEntry
;
3698 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3701 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3703 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3704 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3706 UpdateHighlightMenuInfo(NewPos
, TopOfScreen
, SkipValue
);
3709 case CfUiNoOperation
:
3710 ControlFlag
= CfRepaint
;
3714 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
3715 if (HelpString
!= NULL
) {
3716 FreePool (HelpString
);
3718 if (HelpHeaderString
!= NULL
) {
3719 FreePool (HelpHeaderString
);
3721 if (HelpBottomString
!= NULL
) {
3722 FreePool (HelpBottomString
);
3734 Base on the browser status info to show an pop up message.
3738 BrowserStatusProcess (
3744 EFI_EVENT WaitList
[2];
3745 EFI_EVENT RefreshIntervalEvent
;
3746 EFI_EVENT TimeOutEvent
;
3750 WARNING_IF_CONTEXT EventContext
;
3751 EFI_IFR_OP_HEADER
*OpCodeBuf
;
3752 EFI_STRING_ID StringToken
;
3753 CHAR16 DiscardChange
;
3754 CHAR16 JumpToFormSet
;
3755 CHAR16
*PrintString
;
3757 if (gFormData
->BrowserStatus
== BROWSER_SUCCESS
) {
3762 TimeOutEvent
= NULL
;
3763 RefreshIntervalEvent
= NULL
;
3765 if (gFormData
->HighLightedStatement
!= NULL
) {
3766 OpCodeBuf
= gFormData
->HighLightedStatement
->OpCode
;
3769 if (gFormData
->BrowserStatus
== (BROWSER_WARNING_IF
)) {
3770 ASSERT (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_WARNING_IF_OP
);
3772 TimeOut
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->TimeOut
;
3773 StringToken
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->Warning
;
3776 if ((gFormData
->BrowserStatus
== (BROWSER_NO_SUBMIT_IF
)) &&
3777 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_NO_SUBMIT_IF_OP
)) {
3778 StringToken
= ((EFI_IFR_NO_SUBMIT_IF
*) OpCodeBuf
)->Error
;
3779 } else if ((gFormData
->BrowserStatus
== (BROWSER_INCONSISTENT_IF
)) &&
3780 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_INCONSISTENT_IF_OP
)) {
3781 StringToken
= ((EFI_IFR_INCONSISTENT_IF
*) OpCodeBuf
)->Error
;
3785 if (StringToken
!= 0) {
3786 ErrorInfo
= GetToken (StringToken
, gFormData
->HiiHandle
);
3787 } else if (gFormData
->ErrorString
!= NULL
) {
3789 // Only used to compatible with old setup browser.
3790 // Not use this field in new browser core.
3792 ErrorInfo
= gFormData
->ErrorString
;
3794 switch (gFormData
->BrowserStatus
) {
3795 case BROWSER_SUBMIT_FAIL
:
3796 ErrorInfo
= gSaveFailed
;
3799 case BROWSER_FORM_NOT_FOUND
:
3800 ErrorInfo
= gFormNotFound
;
3803 case BROWSER_FORM_SUPPRESS
:
3804 ErrorInfo
= gFormSuppress
;
3807 case BROWSER_PROTOCOL_NOT_FOUND
:
3808 ErrorInfo
= gProtocolNotFound
;
3811 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3812 ErrorInfo
= gNoSubmitIfFailed
;
3815 case BROWSER_RECONNECT_FAIL
:
3816 ErrorInfo
= gReconnectFail
;
3819 case BROWSER_RECONNECT_SAVE_CHANGES
:
3820 ErrorInfo
= gReconnectConfirmChanges
;
3823 case BROWSER_RECONNECT_REQUIRED
:
3824 ErrorInfo
= gReconnectRequired
;
3828 ErrorInfo
= gBrowserError
;
3833 switch (gFormData
->BrowserStatus
) {
3834 case BROWSER_SUBMIT_FAIL
:
3835 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3836 case BROWSER_RECONNECT_SAVE_CHANGES
:
3837 ASSERT (gUserInput
!= NULL
);
3838 if (gFormData
->BrowserStatus
== (BROWSER_SUBMIT_FAIL
)) {
3839 PrintString
= gSaveProcess
;
3840 JumpToFormSet
= gJumpToFormSet
[0];
3841 DiscardChange
= gDiscardChange
[0];
3842 } else if (gFormData
->BrowserStatus
== (BROWSER_RECONNECT_SAVE_CHANGES
)){
3843 PrintString
= gChangesOpt
;
3844 JumpToFormSet
= gConfirmOptYes
[0];
3845 DiscardChange
= gConfirmOptNo
[0];
3847 PrintString
= gSaveNoSubmitProcess
;
3848 JumpToFormSet
= gCheckError
[0];
3849 DiscardChange
= gDiscardChange
[0];
3853 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, PrintString
, gEmptyString
, NULL
);
3854 } while (((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) &&
3855 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (JumpToFormSet
| UPPER_LOWER_CASE_OFFSET
)));
3857 if ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) == (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) {
3858 gUserInput
->Action
= BROWSER_ACTION_DISCARD
;
3860 gUserInput
->Action
= BROWSER_ACTION_GOTO
;
3867 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, gPressEnter
, gEmptyString
, NULL
);
3868 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
3870 Status
= gBS
->CreateEvent (EVT_NOTIFY_WAIT
, TPL_CALLBACK
, EmptyEventProcess
, NULL
, &TimeOutEvent
);
3871 ASSERT_EFI_ERROR (Status
);
3873 EventContext
.SyncEvent
= TimeOutEvent
;
3874 EventContext
.TimeOut
= &TimeOut
;
3875 EventContext
.ErrorInfo
= ErrorInfo
;
3877 Status
= gBS
->CreateEvent (EVT_TIMER
| EVT_NOTIFY_SIGNAL
, TPL_CALLBACK
, RefreshTimeOutProcess
, &EventContext
, &RefreshIntervalEvent
);
3878 ASSERT_EFI_ERROR (Status
);
3881 // Show the dialog first to avoid long time not reaction.
3883 gBS
->SignalEvent (RefreshIntervalEvent
);
3885 Status
= gBS
->SetTimer (RefreshIntervalEvent
, TimerPeriodic
, ONE_SECOND
);
3886 ASSERT_EFI_ERROR (Status
);
3889 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
3890 if (!EFI_ERROR (Status
) && Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
3894 if (Status
!= EFI_NOT_READY
) {
3898 WaitList
[0] = TimeOutEvent
;
3899 WaitList
[1] = gST
->ConIn
->WaitForKey
;
3901 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
3902 ASSERT_EFI_ERROR (Status
);
3906 // Timeout occur, close the hoot time out event.
3912 gBS
->CloseEvent (TimeOutEvent
);
3913 gBS
->CloseEvent (RefreshIntervalEvent
);
3918 if (StringToken
!= 0) {
3919 FreePool (ErrorInfo
);
3924 Display one form, and return user input.
3926 @param FormData Form Data to be shown.
3927 @param UserInputData User input data.
3929 @retval EFI_SUCCESS 1.Form Data is shown, and user input is got.
3930 2.Error info has show and return.
3931 @retval EFI_INVALID_PARAMETER The input screen dimension is not valid
3932 @retval EFI_NOT_FOUND New form data has some error.
3937 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
3938 OUT USER_INPUT
*UserInputData
3943 ASSERT (FormData
!= NULL
);
3944 if (FormData
== NULL
) {
3945 return EFI_INVALID_PARAMETER
;
3948 gUserInput
= UserInputData
;
3949 gFormData
= FormData
;
3952 // Process the status info first.
3954 BrowserStatusProcess();
3955 if (gFormData
->BrowserStatus
!= BROWSER_SUCCESS
) {
3957 // gFormData->BrowserStatus != BROWSER_SUCCESS, means only need to print the error info, return here.
3962 Status
= DisplayPageFrame (FormData
, &gStatementDimensions
);
3963 if (EFI_ERROR (Status
)) {
3968 // Global Widths should be initialized before any MenuOption creation
3969 // or the GetWidth() used in UiAddMenuOption() will return incorrect value.
3973 // |<-.->|<-.........->|<- .........->|<-...........->|
3974 // Skip Prompt Option Help
3976 gOptionBlockWidth
= (CHAR16
) ((gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 3) + 1;
3977 gHelpBlockWidth
= (CHAR16
) (gOptionBlockWidth
- 1 - LEFT_SKIPPED_COLUMNS
);
3978 gPromptBlockWidth
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gOptionBlockWidth
- 1) - 1);
3980 ConvertStatementToMenu();
3983 // Check whether layout is changed.
3986 || (gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
)
3987 || (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))
3988 || (gOldFormEntry
.FormId
!= FormData
->FormId
)) {
3989 mStatementLayoutIsChanged
= TRUE
;
3991 mStatementLayoutIsChanged
= FALSE
;
3994 Status
= UiDisplayMenu(FormData
);
3997 // Backup last form info.
3999 mIsFirstForm
= FALSE
;
4000 gOldFormEntry
.HiiHandle
= FormData
->HiiHandle
;
4001 CopyGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
);
4002 gOldFormEntry
.FormId
= FormData
->FormId
;
4008 Clear Screen to the initial state.
4012 DriverClearDisplayPage (
4016 ClearDisplayPage ();
4017 mIsFirstForm
= TRUE
;
4021 Set Buffer to Value for Size bytes.
4023 @param Buffer Memory to set.
4024 @param Size Number of bytes to set
4025 @param Value Value of the set operation.
4038 while ((Size
--) != 0) {
4044 Initialize Setup Browser driver.
4046 @param ImageHandle The image handle.
4047 @param SystemTable The system table.
4049 @retval EFI_SUCCESS The Setup Browser module is initialized correctly..
4050 @return Other value if failed to initialize the Setup Browser module.
4055 InitializeDisplayEngine (
4056 IN EFI_HANDLE ImageHandle
,
4057 IN EFI_SYSTEM_TABLE
*SystemTable
4061 EFI_INPUT_KEY HotKey
;
4062 EFI_STRING NewString
;
4063 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL
*FormBrowserEx2
;
4066 // Publish our HII data
4068 gHiiHandle
= HiiAddPackages (
4069 &gDisplayEngineGuid
,
4071 DisplayEngineStrings
,
4074 ASSERT (gHiiHandle
!= NULL
);
4077 // Install Form Display protocol
4079 Status
= gBS
->InstallProtocolInterface (
4080 &mPrivateData
.Handle
,
4081 &gEdkiiFormDisplayEngineProtocolGuid
,
4082 EFI_NATIVE_INTERFACE
,
4083 &mPrivateData
.FromDisplayProt
4085 ASSERT_EFI_ERROR (Status
);
4087 InitializeDisplayStrings();
4089 ZeroMem (&gHighligthMenuInfo
, sizeof (gHighligthMenuInfo
));
4090 ZeroMem (&gOldFormEntry
, sizeof (gOldFormEntry
));
4093 // Use BrowserEx2 protocol to register HotKey.
4095 Status
= gBS
->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid
, NULL
, (VOID
**) &FormBrowserEx2
);
4096 if (!EFI_ERROR (Status
)) {
4098 // Register the default HotKey F9 and F10 again.
4100 HotKey
.UnicodeChar
= CHAR_NULL
;
4101 HotKey
.ScanCode
= SCAN_F10
;
4102 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_TEN_STRING
), NULL
);
4103 ASSERT (NewString
!= NULL
);
4104 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_SUBMIT
, 0, NewString
);
4106 HotKey
.ScanCode
= SCAN_F9
;
4107 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_NINE_STRING
), NULL
);
4108 ASSERT (NewString
!= NULL
);
4109 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_DEFAULT
, EFI_HII_DEFAULT_CLASS_STANDARD
, NewString
);
4116 This is the default unload handle for display core drivers.
4118 @param[in] ImageHandle The drivers' driver image.
4120 @retval EFI_SUCCESS The image is unloaded.
4121 @retval Others Failed to unload the image.
4126 UnloadDisplayEngine (
4127 IN EFI_HANDLE ImageHandle
4130 HiiRemovePackages(gHiiHandle
);
4132 FreeDisplayStrings ();
4134 if (gHighligthMenuInfo
.HLTOpCode
!= NULL
) {
4135 FreePool (gHighligthMenuInfo
.HLTOpCode
);
4138 if (gHighligthMenuInfo
.TOSOpCode
!= NULL
) {
4139 FreePool (gHighligthMenuInfo
.TOSOpCode
);