2 FormDiplay protocol to show Form
4 Copyright (c) 2013 - 2014, 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>
32 #include <Guid/MdeModuleHii.h>
35 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
37 extern UINT8 DisplayEngineStrings
[];
38 extern EFI_SCREEN_DESCRIPTOR gStatementDimensions
;
39 extern USER_INPUT
*gUserInput
;
40 extern FORM_DISPLAY_ENGINE_FORM
*gFormData
;
41 extern EFI_HII_HANDLE gHiiHandle
;
42 extern UINT16 gDirection
;
43 extern LIST_ENTRY gMenuOption
;
46 // Browser Global Strings
48 extern CHAR16
*gSaveFailed
;
49 extern CHAR16
*gPromptForData
;
50 extern CHAR16
*gPromptForPassword
;
51 extern CHAR16
*gPromptForNewPassword
;
52 extern CHAR16
*gConfirmPassword
;
53 extern CHAR16
*gConfirmError
;
54 extern CHAR16
*gPassowordInvalid
;
55 extern CHAR16
*gPressEnter
;
56 extern CHAR16
*gEmptyString
;
57 extern CHAR16
*gMiniString
;
58 extern CHAR16
*gOptionMismatch
;
59 extern CHAR16
*gFormSuppress
;
60 extern CHAR16
*gProtocolNotFound
;
62 extern CHAR16 gPromptBlockWidth
;
63 extern CHAR16 gOptionBlockWidth
;
64 extern CHAR16 gHelpBlockWidth
;
65 extern CHAR16
*mUnknownString
;
71 #define LEFT_SKIPPED_COLUMNS 3
72 #define SCROLL_ARROW_HEIGHT 1
73 #define POPUP_PAD_SPACE_COUNT 5
74 #define POPUP_FRAME_WIDTH 2
76 #define UPPER_LOWER_CASE_OFFSET 0x20
79 // Display definitions
81 #define LEFT_ONEOF_DELIMITER L'<'
82 #define RIGHT_ONEOF_DELIMITER L'>'
84 #define LEFT_NUMERIC_DELIMITER L'['
85 #define RIGHT_NUMERIC_DELIMITER L']'
87 #define LEFT_CHECKBOX_DELIMITER L'['
88 #define RIGHT_CHECKBOX_DELIMITER L']'
91 #define CHECK_OFF L' '
93 #define TIME_SEPARATOR L':'
94 #define DATE_SEPARATOR L'/'
96 #define SUBTITLE_INDENT 2
99 // This is the Input Error Message
101 #define INPUT_ERROR 1
104 // This is the NV RAM update required Message
106 #define NV_UPDATE_REQUIRED 2
110 #define ONE_SECOND 10000000
113 // It take 23 characters including the NULL to print a 64 bits number with "[" and "]".
114 // pow(2, 64) = [18446744073709551616]
116 #define MAX_NUMERIC_INPUT_WIDTH 23
118 #define EFI_HII_EXPRESSION_INCONSISTENT_IF 0
119 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1
120 #define EFI_HII_EXPRESSION_GRAY_OUT_IF 2
121 #define EFI_HII_EXPRESSION_SUPPRESS_IF 3
122 #define EFI_HII_EXPRESSION_DISABLE_IF 4
125 // Character definitions
127 #define CHAR_SPACE 0x0020
129 #define FORM_DISPLAY_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'D', 'D', 'V')
138 EDKII_FORM_DISPLAY_ENGINE_PROTOCOL FromDisplayProt
;
139 } FORM_DISPLAY_DRIVER_PRIVATE_DATA
;
155 } UI_SCREEN_OPERATION
;
190 UI_SCREEN_OPERATION ScreenOperation
;
191 } SCAN_CODE_TO_SCREEN_OPERATION
;
194 UI_SCREEN_OPERATION ScreenOperation
;
195 UI_CONTROL_FLAG ControlFlag
;
196 } SCREEN_OPERATION_T0_CONTROL_FLAG
;
199 EFI_HII_HANDLE HiiHandle
;
200 EFI_QUESTION_ID QuestionId
;
201 EFI_IFR_OP_HEADER
*OpCode
;
204 } DISPLAY_HIGHLIGHT_MENU_INFO
;
210 } WARNING_IF_CONTEXT
;
212 #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
218 EFI_HII_HANDLE Handle
;
219 FORM_DISPLAY_ENGINE_STATEMENT
*ThisTag
;
226 UINTN Skip
; // Number of lines
229 // Display item sequence for date/time
230 // Date: Month/Day/Year
233 // Time: Hour : Minute : Second
243 // Whether user could change value of this item
246 BOOLEAN NestInStatement
;
249 #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
252 Print Question Value according to it's storage width and display attributes.
254 @param Question The Question to be printed.
255 @param FormattedNumber Buffer for output string.
256 @param BufferSize The FormattedNumber buffer size in bytes.
258 @retval EFI_SUCCESS Print success.
259 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
263 PrintFormattedNumber (
264 IN FORM_DISPLAY_ENGINE_STATEMENT
*Question
,
265 IN OUT CHAR16
*FormattedNumber
,
270 Set value of a data element in an Array by its Index.
272 @param Array The data array.
273 @param Type Type of the data in this array.
274 @param Index Zero based index for data in this array.
275 @param Value The value to be set.
287 Return data element in an Array by its Index.
289 @param Array The data array.
290 @param Type Type of the data in this array.
291 @param Index Zero based index for data in this array.
293 @retval Value The data to be returned
304 Search an Option of a Question by its value.
306 @param Question The Question
307 @param OptionValue Value for Option to be searched.
309 @retval Pointer Pointer to the found Option.
310 @retval NULL Option not found.
313 DISPLAY_QUESTION_OPTION
*
315 IN FORM_DISPLAY_ENGINE_STATEMENT
*Question
,
316 IN EFI_HII_VALUE
*OptionValue
320 Compare two Hii value.
322 @param Value1 Expression value to compare on left-hand.
323 @param Value2 Expression value to compare on right-hand.
324 @param Result Return value after compare.
325 retval 0 Two operators equal.
326 return Positive value if Value1 is greater than Value2.
327 retval Negative value if Value1 is less than Value2.
328 @param HiiHandle Only required for string compare.
330 @retval other Could not perform compare on two values.
331 @retval EFI_SUCCESS Compare the value success.
336 IN EFI_HII_VALUE
*Value1
,
337 IN EFI_HII_VALUE
*Value2
,
339 IN EFI_HII_HANDLE HiiHandle OPTIONAL
343 Draw a pop up windows based on the dimension, number of lines and
346 @param RequestedWidth The width of the pop-up.
347 @param NumberOfLines The number of lines.
348 @param ... A series of text strings that displayed in the pop-up.
353 CreateMultiStringPopUp (
354 IN UINTN RequestedWidth
,
355 IN UINTN NumberOfLines
,
360 Will copy LineWidth amount of a string in the OutputString buffer and return the
361 number of CHAR16 characters that were copied into the OutputString buffer.
362 The output string format is:
363 Glyph Info + String info + '\0'.
365 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
367 @param InputString String description for this option.
368 @param LineWidth Width of the desired string to extract in CHAR16
370 @param GlyphWidth The glyph width of the begin of the char in the string.
371 @param Index Where in InputString to start the copy process
372 @param OutputString Buffer to copy the string into
374 @return Returns the number of CHAR16 characters that were copied into the OutputString
375 buffer, include extra glyph info and '\0' info.
380 IN CHAR16
*InputString
,
382 IN OUT UINT16
*GlyphWidth
,
384 OUT CHAR16
**OutputString
389 Get the string based on the StringId and HII Package List Handle.
391 @param Token The String's ID.
392 @param HiiHandle The Hii handle for this string package.
394 @return The output string.
399 IN EFI_STRING_ID Token
,
400 IN EFI_HII_HANDLE HiiHandle
404 Count the storage space of a Unicode string.
406 This function handles the Unicode string with NARROW_CHAR
407 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
408 does not count in the resultant output. If a WIDE_CHAR is
409 hit, then 2 Unicode character will consume an output storage
410 space with size of CHAR16 till a NARROW_CHAR is hit.
412 If String is NULL, then ASSERT ().
414 @param String The input string to be counted.
416 @return Storage space for the input string.
425 This routine reads a numeric value from the user input.
427 @param MenuOption Pointer to the current input menu.
429 @retval EFI_SUCCESS If numerical input is read successfully
430 @retval EFI_DEVICE_ERROR If operation fails
435 IN UI_MENU_OPTION
*MenuOption
439 Get string or password input from user.
441 @param MenuOption Pointer to the current input menu.
442 @param Prompt The prompt string shown on popup window.
443 @param StringPtr Old user input and destination for use input string.
445 @retval EFI_SUCCESS If string input is read successfully
446 @retval EFI_DEVICE_ERROR If operation fails
451 IN UI_MENU_OPTION
*MenuOption
,
453 IN OUT CHAR16
*StringPtr
457 Draw a pop up windows based on the dimension, number of lines and
460 @param RequestedWidth The width of the pop-up.
461 @param NumberOfLines The number of lines.
462 @param Marker The variable argument list for the list of string to be printed.
467 IN UINTN RequestedWidth
,
468 IN UINTN NumberOfLines
,
473 Wait for a key to be pressed by user.
475 @param Key The key which is pressed by user.
477 @retval EFI_SUCCESS The function always completed successfully.
482 OUT EFI_INPUT_KEY
*Key
486 Get selection for OneOf and OrderedList (Left/Right will be ignored).
488 @param MenuOption Pointer to the current input menu.
490 @retval EFI_SUCCESS If Option input is processed successfully
491 @retval EFI_DEVICE_ERROR If operation fails
495 GetSelectionInputPopUp (
496 IN UI_MENU_OPTION
*MenuOption
500 Process the help string: Split StringPtr to several lines of strings stored in
501 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
503 @param StringPtr The entire help string.
504 @param FormattedString The oupput formatted string.
505 @param EachLineWidth The max string length of each line in the formatted string.
506 @param RowCount TRUE: if Question is selected.
511 IN CHAR16
*StringPtr
,
512 OUT CHAR16
**FormattedString
,
513 OUT UINT16
*EachLineWidth
,
518 Process a Question's Option (whether selected or un-selected).
520 @param MenuOption The MenuOption for this Question.
521 @param Selected TRUE: if Question is selected.
522 @param OptionString Pointer of the Option String to be displayed.
523 @param SkipErrorValue Whether need to return when value without option for it.
525 @retval EFI_SUCCESS Question Option process success.
526 @retval Other Question Option process fail.
531 IN UI_MENU_OPTION
*MenuOption
,
533 OUT CHAR16
**OptionString
,
534 IN BOOLEAN SkipErrorValue
538 Set Buffer to Value for Size bytes.
540 @param Buffer Memory to set.
541 @param Size Number of bytes to set
542 @param Value Value of the set operation.
553 Display one form, and return user input.
555 @param FormData Form Data to be shown.
556 @param UserInputData User input data.
558 @retval EFI_SUCCESS Form Data is shown, and user input is got.
563 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
564 OUT USER_INPUT
*UserInputData
568 Clear Screen to the initial state.
572 DriverClearDisplayPage (
577 Exit Display and Clear Screen to the original state.
589 @param Event The Event need to be process
590 @param Context The context of the event.
601 Process for the refresh interval statement.
603 @param Event The Event need to be process
604 @param Context The context of the event.
609 RefreshTimeOutProcess (