2 FormDiplay protocol to show Form
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __FORM_DISPLAY_H__
16 #define __FORM_DISPLAY_H__
19 #include <Library/UefiBootServicesTableLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/BaseMemoryLib.h>
22 #include <Library/BaseLib.h>
23 #include <Library/HiiLib.h>
24 #include <Library/MemoryAllocationLib.h>
25 #include <Library/PrintLib.h>
26 #include <Library/CustomizedDisplayLib.h>
28 #include <Protocol/FormBrowserEx2.h>
29 #include <Protocol/SimpleTextIn.h>
30 #include <Protocol/DisplayProtocol.h>
31 #include <Protocol/HiiPopup.h>
33 #include <Guid/MdeModuleHii.h>
36 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
38 extern UINT8 DisplayEngineStrings
[];
39 extern EFI_SCREEN_DESCRIPTOR gStatementDimensions
;
40 extern USER_INPUT
*gUserInput
;
41 extern FORM_DISPLAY_ENGINE_FORM
*gFormData
;
42 extern EFI_HII_HANDLE gHiiHandle
;
43 extern UINT16 gDirection
;
44 extern LIST_ENTRY gMenuOption
;
45 extern CHAR16
*gConfirmOptYes
;
46 extern CHAR16
*gConfirmOptNo
;
47 extern CHAR16
*gConfirmOptOk
;
48 extern CHAR16
*gConfirmOptCancel
;
49 extern CHAR16
*gYesOption
;
50 extern CHAR16
*gNoOption
;
51 extern CHAR16
*gOkOption
;
52 extern CHAR16
*gCancelOption
;
53 extern CHAR16
*gErrorPopup
;
54 extern CHAR16
*gWarningPopup
;
55 extern CHAR16
*gInfoPopup
;
58 // Browser Global Strings
60 extern CHAR16
*gSaveFailed
;
61 extern CHAR16
*gPromptForData
;
62 extern CHAR16
*gPromptForPassword
;
63 extern CHAR16
*gPromptForNewPassword
;
64 extern CHAR16
*gConfirmPassword
;
65 extern CHAR16
*gConfirmError
;
66 extern CHAR16
*gPassowordInvalid
;
67 extern CHAR16
*gPressEnter
;
68 extern CHAR16
*gEmptyString
;
69 extern CHAR16
*gMiniString
;
70 extern CHAR16
*gOptionMismatch
;
71 extern CHAR16
*gFormSuppress
;
72 extern CHAR16
*gProtocolNotFound
;
73 extern CHAR16
*gPasswordUnsupported
;
75 extern CHAR16 gPromptBlockWidth
;
76 extern CHAR16 gOptionBlockWidth
;
77 extern CHAR16 gHelpBlockWidth
;
78 extern CHAR16
*mUnknownString
;
79 extern BOOLEAN gMisMatch
;
85 #define LEFT_SKIPPED_COLUMNS 3
86 #define SCROLL_ARROW_HEIGHT 1
87 #define POPUP_PAD_SPACE_COUNT 5
88 #define POPUP_FRAME_WIDTH 2
90 #define UPPER_LOWER_CASE_OFFSET 0x20
93 // Display definitions
95 #define LEFT_ONEOF_DELIMITER L'<'
96 #define RIGHT_ONEOF_DELIMITER L'>'
98 #define LEFT_NUMERIC_DELIMITER L'['
99 #define RIGHT_NUMERIC_DELIMITER L']'
101 #define LEFT_CHECKBOX_DELIMITER L'['
102 #define RIGHT_CHECKBOX_DELIMITER L']'
104 #define CHECK_ON L'X'
105 #define CHECK_OFF L' '
107 #define TIME_SEPARATOR L':'
108 #define DATE_SEPARATOR L'/'
110 #define SUBTITLE_INDENT 2
113 // This is the Input Error Message
115 #define INPUT_ERROR 1
118 // This is the NV RAM update required Message
120 #define NV_UPDATE_REQUIRED 2
124 #define ONE_SECOND 10000000
127 // It take 23 characters including the NULL to print a 64 bits number with "[" and "]".
128 // pow(2, 64) = [18446744073709551616]
129 // with extra '-' flat, set the width to 24.
131 #define MAX_NUMERIC_INPUT_WIDTH 24
133 #define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
134 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
135 #define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
136 #define EFI_HII_EXPRESSION_SUPPRESS_IF 3
137 #define EFI_HII_EXPRESSION_DISABLE_IF 4
140 // Character definitions
142 #define CHAR_SPACE 0x0020
144 #define FORM_DISPLAY_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'D', 'D', 'V')
153 EDKII_FORM_DISPLAY_ENGINE_PROTOCOL FromDisplayProt
;
154 EFI_HII_POPUP_PROTOCOL HiiPopup
;
155 } FORM_DISPLAY_DRIVER_PRIVATE_DATA
;
171 } UI_SCREEN_OPERATION
;
205 UI_SCREEN_OPERATION ScreenOperation
;
206 } SCAN_CODE_TO_SCREEN_OPERATION
;
209 UI_SCREEN_OPERATION ScreenOperation
;
210 UI_CONTROL_FLAG ControlFlag
;
211 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
214 EFI_HII_HANDLE HiiHandle
;
218 // Info for the highlight question.
219 // HLT means highlight
221 // If one statement has questionid, save questionid info to find the question.
222 // If one statement not has questionid info, save the opcode info to find the
223 // statement. If more than one statement has same opcode in one form(just like
224 // empty subtitle info may has more than one info one form), also use Index
225 // info to find the statement.
227 EFI_QUESTION_ID HLTQuestionId
;
228 EFI_IFR_OP_HEADER
*HLTOpCode
;
233 // Info for the top of screen question.
234 // TOS means Top Of Screen
236 EFI_QUESTION_ID TOSQuestionId
;
237 EFI_IFR_OP_HEADER
*TOSOpCode
;
241 } DISPLAY_HIGHLIGHT_MENU_INFO
;
247 } WARNING_IF_CONTEXT
;
249 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
255 EFI_HII_HANDLE Handle
;
256 FORM_DISPLAY_ENGINE_STATEMENT
*ThisTag
;
263 UINTN Skip
; // Number of lines
266 // Display item sequence for date/time
267 // Date: Month/Day/Year
270 // Time: Hour : Minute : Second
280 // Whether user could change value of this item
283 BOOLEAN NestInStatement
;
286 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
288 #define USER_SELECTABLE_OPTION_OK_WIDTH StrLen (gOkOption)
289 #define USER_SELECTABLE_OPTION_OK_CAL_WIDTH (StrLen (gOkOption) + StrLen (gCancelOption))
290 #define USER_SELECTABLE_OPTION_YES_NO_WIDTH (StrLen (gYesOption) + StrLen (gNoOption))
291 #define USER_SELECTABLE_OPTION_YES_NO_CAL_WIDTH (StrLen (gYesOption) + StrLen (gNoOption) + StrLen (gCancelOption))
293 #define USER_SELECTABLE_OPTION_SKIP_WIDTH 2
296 // +-------------------------------------------+ // POPUP_BORDER }
297 // | ERROR/WARNING/INFO | // POPUP_STYLE_STRING_HEIGHT } POPUP_HEADER_HEIGHT
298 // |-------------------------------------------| // POPUP_EMPTY_LINE_HEIGHT }
299 // | popup messages |
300 // | | // POPUP_EMPTY_LINE_HEIGHT }
301 // | user selectable options | // POPUP_USER_SELECTABLE_OPTION_HEIGHT } POPUP_FOOTER_HEIGHT
302 // +-------------------------------------------+ // POPUP_BORDER }
304 #define POPUP_BORDER 1
305 #define POPUP_EMPTY_LINE_HEIGHT 1
306 #define POPUP_STYLE_STRING_HEIGHT 1
307 #define POPUP_USER_SELECTABLE_OPTION_HEIGHT 1
309 #define POPUP_HEADER_HEIGHT (POPUP_BORDER + POPUP_STYLE_STRING_HEIGHT + POPUP_EMPTY_LINE_HEIGHT)
310 #define POPUP_FOOTER_HEIGHT (POPUP_EMPTY_LINE_HEIGHT + POPUP_USER_SELECTABLE_OPTION_HEIGHT + POPUP_BORDER)
312 #define USER_SELECTABLE_OPTION_SIGNATURE SIGNATURE_32 ('u', 's', 's', 'o')
317 EFI_HII_POPUP_SELECTION OptionType
;
318 CHAR16
*OptionString
;
320 // Display item sequence for user select options
324 // Ok/Cancel: Ok : Cancel
330 // Yes/No/Cancel: Yes : No: Cancel
338 } USER_SELECTABLE_OPTION
;
340 #define SELECTABLE_OPTION_FROM_LINK(a) CR (a, USER_SELECTABLE_OPTION, Link, USER_SELECTABLE_OPTION_SIGNATURE)
343 Print Question Value according to it's storage width and display attributes.
345 @param Question The Question to be printed.
346 @param FormattedNumber Buffer for output string.
347 @param BufferSize The FormattedNumber buffer size in bytes.
349 @retval EFI_SUCCESS Print success.
350 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
354 PrintFormattedNumber (
355 IN FORM_DISPLAY_ENGINE_STATEMENT
*Question
,
356 IN OUT CHAR16
*FormattedNumber
,
361 Set value of a data element in an Array by its Index.
363 @param Array The data array.
364 @param Type Type of the data in this array.
365 @param Index Zero based index for data in this array.
366 @param Value The value to be set.
378 Return data element in an Array by its Index.
380 @param Array The data array.
381 @param Type Type of the data in this array.
382 @param Index Zero based index for data in this array.
384 @retval Value The data to be returned
395 Search an Option of a Question by its value.
397 @param Question The Question
398 @param OptionValue Value for Option to be searched.
400 @retval Pointer Pointer to the found Option.
401 @retval NULL Option not found.
404 DISPLAY_QUESTION_OPTION
*
406 IN FORM_DISPLAY_ENGINE_STATEMENT
*Question
,
407 IN EFI_HII_VALUE
*OptionValue
411 Compare two Hii value.
413 @param Value1 Expression value to compare on left-hand.
414 @param Value2 Expression value to compare on right-hand.
415 @param Result Return value after compare.
416 retval 0 Two operators equal.
417 return Positive value if Value1 is greater than Value2.
418 retval Negative value if Value1 is less than Value2.
419 @param HiiHandle Only required for string compare.
421 @retval other Could not perform compare on two values.
422 @retval EFI_SUCCESS Compare the value success.
427 IN EFI_HII_VALUE
*Value1
,
428 IN EFI_HII_VALUE
*Value2
,
430 IN EFI_HII_HANDLE HiiHandle OPTIONAL
434 Draw a pop up windows based on the dimension, number of lines and
437 @param RequestedWidth The width of the pop-up.
438 @param NumberOfLines The number of lines.
439 @param ... A series of text strings that displayed in the pop-up.
444 CreateMultiStringPopUp (
445 IN UINTN RequestedWidth
,
446 IN UINTN NumberOfLines
,
451 Will copy LineWidth amount of a string in the OutputString buffer and return the
452 number of CHAR16 characters that were copied into the OutputString buffer.
453 The output string format is:
454 Glyph Info + String info + '\0'.
456 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
458 @param InputString String description for this option.
459 @param LineWidth Width of the desired string to extract in CHAR16
461 @param GlyphWidth The glyph width of the begin of the char in the string.
462 @param Index Where in InputString to start the copy process
463 @param OutputString Buffer to copy the string into
465 @return Returns the number of CHAR16 characters that were copied into the OutputString
466 buffer, include extra glyph info and '\0' info.
471 IN CHAR16
*InputString
,
473 IN OUT UINT16
*GlyphWidth
,
475 OUT CHAR16
**OutputString
480 Get the string based on the StringId and HII Package List Handle.
482 @param Token The String's ID.
483 @param HiiHandle The Hii handle for this string package.
485 @return The output string.
490 IN EFI_STRING_ID Token
,
491 IN EFI_HII_HANDLE HiiHandle
495 Count the storage space of a Unicode string.
497 This function handles the Unicode string with NARROW_CHAR
498 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
499 does not count in the resultant output. If a WIDE_CHAR is
500 hit, then 2 Unicode character will consume an output storage
501 space with size of CHAR16 till a NARROW_CHAR is hit.
503 If String is NULL, then ASSERT ().
505 @param String The input string to be counted.
507 @return Storage space for the input string.
516 This routine reads a numeric value from the user input.
518 @param MenuOption Pointer to the current input menu.
520 @retval EFI_SUCCESS If numerical input is read successfully
521 @retval EFI_DEVICE_ERROR If operation fails
526 IN UI_MENU_OPTION
*MenuOption
530 Get string or password input from user.
532 @param MenuOption Pointer to the current input menu.
533 @param Prompt The prompt string shown on popup window.
534 @param StringPtr Old user input and destination for use input string.
536 @retval EFI_SUCCESS If string input is read successfully
537 @retval EFI_DEVICE_ERROR If operation fails
542 IN UI_MENU_OPTION
*MenuOption
,
544 IN OUT CHAR16
*StringPtr
548 Draw a pop up windows based on the dimension, number of lines and
551 @param RequestedWidth The width of the pop-up.
552 @param NumberOfLines The number of lines.
553 @param Marker The variable argument list for the list of string to be printed.
558 IN UINTN RequestedWidth
,
559 IN UINTN NumberOfLines
,
564 Wait for a key to be pressed by user.
566 @param Key The key which is pressed by user.
568 @retval EFI_SUCCESS The function always completed successfully.
573 OUT EFI_INPUT_KEY
*Key
577 Get selection for OneOf and OrderedList (Left/Right will be ignored).
579 @param MenuOption Pointer to the current input menu.
581 @retval EFI_SUCCESS If Option input is processed successfully
582 @retval EFI_DEVICE_ERROR If operation fails
586 GetSelectionInputPopUp (
587 IN UI_MENU_OPTION
*MenuOption
591 Process the help string: Split StringPtr to several lines of strings stored in
592 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
594 @param StringPtr The entire help string.
595 @param FormattedString The oupput formatted string.
596 @param EachLineWidth The max string length of each line in the formatted string.
597 @param RowCount TRUE: if Question is selected.
602 IN CHAR16
*StringPtr
,
603 OUT CHAR16
**FormattedString
,
604 OUT UINT16
*EachLineWidth
,
609 Process a Question's Option (whether selected or un-selected).
611 @param MenuOption The MenuOption for this Question.
612 @param Selected TRUE: if Question is selected.
613 @param OptionString Pointer of the Option String to be displayed.
614 @param SkipErrorValue Whether need to return when value without option for it.
616 @retval EFI_SUCCESS Question Option process success.
617 @retval Other Question Option process fail.
622 IN UI_MENU_OPTION
*MenuOption
,
624 OUT CHAR16
**OptionString
,
625 IN BOOLEAN SkipErrorValue
629 Set Buffer to Value for Size bytes.
631 @param Buffer Memory to set.
632 @param Size Number of bytes to set
633 @param Value Value of the set operation.
644 Display one form, and return user input.
646 @param FormData Form Data to be shown.
647 @param UserInputData User input data.
649 @retval EFI_SUCCESS Form Data is shown, and user input is got.
654 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
655 OUT USER_INPUT
*UserInputData
659 Clear Screen to the initial state.
663 DriverClearDisplayPage (
668 Exit Display and Clear Screen to the original state.
680 @param Event The Event need to be process
681 @param Context The context of the event.
692 Process for the refresh interval statement.
694 @param Event The Event need to be process
695 @param Context The context of the event.
700 RefreshTimeOutProcess (
706 Record the highlight menu and top of screen menu info.
708 @param Highlight The menu opton which is highlight.
709 @param TopOfScreen The menu opton which is at the top of the form.
710 @param SkipValue The skip line info for the top of screen menu.
714 UpdateHighlightMenuInfo (
715 IN LIST_ENTRY
*Highlight
,
716 IN LIST_ENTRY
*TopOfScreen
,
721 Displays a popup window.
723 @param This A pointer to the EFI_HII_POPUP_PROTOCOL instance.
724 @param PopupStyle Popup style to use.
725 @param PopupType Type of the popup to display.
726 @param HiiHandle HII handle of the string pack containing Message
727 @param Message A message to display in the popup box.
728 @param UserSelection User selection.
730 @retval EFI_SUCCESS The popup box was successfully displayed.
731 @retval EFI_INVALID_PARAMETER HiiHandle and Message do not define a valid HII string.
732 @retval EFI_INVALID_PARAMETER PopupType is not one of the values defined by this specification.
733 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to display the popup box.
739 IN EFI_HII_POPUP_PROTOCOL
*This
,
740 IN EFI_HII_POPUP_STYLE PopupStyle
,
741 IN EFI_HII_POPUP_TYPE PopupType
,
742 IN EFI_HII_HANDLE HiiHandle
,
743 IN EFI_STRING_ID Message
,
744 OUT EFI_HII_POPUP_SELECTION
*UserSelection OPTIONAL