]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h
Update Browser to provide the customization possibilities.
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / FormDisplay.h
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h
new file mode 100644 (file)
index 0000000..ad4684e
--- /dev/null
@@ -0,0 +1,580 @@
+/** @file\r
+  FormDiplay protocol to show Form\r
+\r
+Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under \r
+the terms and conditions of the BSD License that accompanies this distribution.  \r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.                                            \r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __FORM_DISPLAY_H__\r
+#define __FORM_DISPLAY_H__\r
+\r
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/CustomizedDisplayLib.h>\r
+\r
+#include <Protocol/FormBrowserEx2.h>\r
+#include <Protocol/SimpleTextIn.h>\r
+#include <Protocol/DisplayProtocol.h>\r
+\r
+#include <Guid/MdeModuleHii.h>\r
+\r
+//\r
+// This is the generated header file which includes whatever needs to be exported (strings + IFR)\r
+//\r
+extern UINT8  DisplayEngineStrings[];\r
+extern EFI_SCREEN_DESCRIPTOR         gStatementDimensions;\r
+extern USER_INPUT                    *gUserInput;\r
+extern FORM_DISPLAY_ENGINE_FORM      *gFormData;\r
+extern EFI_HII_HANDLE                gHiiHandle;\r
+extern UINT16                        gDirection;\r
+extern LIST_ENTRY                    gMenuOption;\r
+\r
+//\r
+// Browser Global Strings\r
+//\r
+extern CHAR16            *gSaveFailed;\r
+extern CHAR16            *gPromptForData;\r
+extern CHAR16            *gPromptForPassword;\r
+extern CHAR16            *gPromptForNewPassword;\r
+extern CHAR16            *gConfirmPassword;\r
+extern CHAR16            *gConfirmError;\r
+extern CHAR16            *gPassowordInvalid;\r
+extern CHAR16            *gPressEnter;\r
+extern CHAR16            *gEmptyString;\r
+extern CHAR16            *gMiniString;\r
+extern CHAR16            *gOptionMismatch;\r
+extern CHAR16            *gFormSuppress;\r
+extern CHAR16            *gProtocolNotFound;\r
+\r
+extern CHAR16            gPromptBlockWidth;\r
+extern CHAR16            gOptionBlockWidth;\r
+extern CHAR16            gHelpBlockWidth;\r
+extern CHAR16            *mUnknownString;\r
+\r
+//\r
+// Screen definitions\r
+//\r
+\r
+#define LEFT_SKIPPED_COLUMNS          3\r
+#define SCROLL_ARROW_HEIGHT           1\r
+#define POPUP_PAD_SPACE_COUNT         5\r
+#define POPUP_FRAME_WIDTH             2\r
+\r
+//\r
+// Display definitions\r
+//\r
+#define LEFT_ONEOF_DELIMITER      L'<'\r
+#define RIGHT_ONEOF_DELIMITER     L'>'\r
+\r
+#define LEFT_NUMERIC_DELIMITER    L'['\r
+#define RIGHT_NUMERIC_DELIMITER   L']'\r
+\r
+#define LEFT_CHECKBOX_DELIMITER   L'['\r
+#define RIGHT_CHECKBOX_DELIMITER  L']'\r
+\r
+#define CHECK_ON                  L'X'\r
+#define CHECK_OFF                 L' '\r
+\r
+#define TIME_SEPARATOR            L':'\r
+#define DATE_SEPARATOR            L'/'\r
+\r
+#define SUBTITLE_INDENT  2\r
+\r
+//\r
+// This is the Input Error Message\r
+//\r
+#define INPUT_ERROR 1\r
+\r
+//\r
+// This is the NV RAM update required Message\r
+//\r
+#define NV_UPDATE_REQUIRED  2\r
+//\r
+// Time definitions\r
+//\r
+#define ONE_SECOND  10000000\r
+\r
+//\r
+// It take 23 characters including the NULL to print a 64 bits number with "[" and "]".\r
+// pow(2, 64) = [18446744073709551616]\r
+//\r
+#define MAX_NUMERIC_INPUT_WIDTH 23\r
+\r
+#define EFI_HII_EXPRESSION_INCONSISTENT_IF   0\r
+#define EFI_HII_EXPRESSION_NO_SUBMIT_IF      1\r
+#define EFI_HII_EXPRESSION_GRAY_OUT_IF       2\r
+#define EFI_HII_EXPRESSION_SUPPRESS_IF       3\r
+#define EFI_HII_EXPRESSION_DISABLE_IF        4\r
+\r
+//\r
+// Character definitions\r
+//\r
+#define CHAR_SPACE              0x0020\r
+\r
+#define FORM_DISPLAY_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'D', 'D', 'V')\r
+typedef struct {\r
+  UINT32                             Signature;\r
+\r
+  EFI_HANDLE                         Handle;\r
+\r
+  //\r
+  // Produced protocol\r
+  //\r
+  EDKII_FORM_DISPLAY_ENGINE_PROTOCOL FromDisplayProt;\r
+} FORM_DISPLAY_DRIVER_PRIVATE_DATA;\r
+\r
+\r
+typedef enum {\r
+  UiNoOperation,\r
+  UiSelect,\r
+  UiUp,\r
+  UiDown,\r
+  UiLeft,\r
+  UiRight,\r
+  UiReset,\r
+  UiPrevious,\r
+  UiPageUp,\r
+  UiPageDown,\r
+  UiHotKey,\r
+  UiMaxOperation\r
+} UI_SCREEN_OPERATION;\r
+\r
+typedef enum {\r
+  CfInitialization,\r
+  CfCheckSelection,\r
+  CfRepaint,\r
+  CfRefreshHighLight,\r
+  CfUpdateHelpString,\r
+  CfPrepareToReadKey,\r
+  CfReadKey,\r
+  CfScreenOperation,\r
+  CfUiSelect,\r
+  CfUiReset,\r
+  CfUiLeft,\r
+  CfUiRight,\r
+  CfUiUp,\r
+  CfUiPageUp,\r
+  CfUiPageDown,\r
+  CfUiDown,\r
+  CfUiDefault,\r
+  CfUiNoOperation,\r
+  CfExit,\r
+  CfUiHotKey,\r
+  CfMaxControlFlag\r
+} UI_CONTROL_FLAG;\r
+\r
+typedef enum {\r
+  UIEventNone,\r
+  UIEventKey,\r
+  UIEventTimeOut,\r
+  UIEventDriver\r
+} UI_EVENT_TYPE;\r
+\r
+typedef struct {\r
+  UINT16              ScanCode;\r
+  UI_SCREEN_OPERATION ScreenOperation;\r
+} SCAN_CODE_TO_SCREEN_OPERATION;\r
+\r
+typedef struct {\r
+  UI_SCREEN_OPERATION ScreenOperation;\r
+  UI_CONTROL_FLAG     ControlFlag;\r
+} SCREEN_OPERATION_T0_CONTROL_FLAG;\r
+\r
+typedef struct {\r
+  EFI_QUESTION_ID    QuestionId;\r
+  UINT16             DisplayRow;\r
+} DISPLAY_HIGHLIGHT_MENU_INFO;\r
+\r
+#define UI_MENU_OPTION_SIGNATURE  SIGNATURE_32 ('u', 'i', 'm', 'm')\r
+\r
+typedef struct {\r
+  UINTN                   Signature;\r
+  LIST_ENTRY              Link;\r
+\r
+  EFI_HII_HANDLE          Handle;\r
+  FORM_DISPLAY_ENGINE_STATEMENT  *ThisTag;\r
+  UINT16                  EntryNumber;\r
+\r
+  UINTN                   Row;\r
+  UINTN                   Col;\r
+  UINTN                   OptCol;\r
+  CHAR16                  *Description;\r
+  UINTN                   Skip;           // Number of lines\r
+\r
+  //\r
+  // Display item sequence for date/time\r
+  //  Date:      Month/Day/Year\r
+  //  Sequence:  0     1   2\r
+  //\r
+  //  Time:      Hour : Minute : Second\r
+  //  Sequence:  0      1        2\r
+  //\r
+  //\r
+  UINTN                   Sequence;\r
+\r
+  BOOLEAN                 GrayOut;\r
+  BOOLEAN                 ReadOnly;\r
+\r
+  //\r
+  // Whether user could change value of this item\r
+  //\r
+  BOOLEAN                 IsQuestion;\r
+  BOOLEAN                 NestInStatement;\r
+} UI_MENU_OPTION;\r
+\r
+#define MENU_OPTION_FROM_LINK(a)  CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)\r
+\r
+/**\r
+  Print Question Value according to it's storage width and display attributes.\r
+\r
+  @param  Question               The Question to be printed.\r
+  @param  FormattedNumber        Buffer for output string.\r
+  @param  BufferSize             The FormattedNumber buffer size in bytes.\r
+\r
+  @retval EFI_SUCCESS            Print success.\r
+  @retval EFI_BUFFER_TOO_SMALL   Buffer size is not enough for formatted number.\r
+\r
+**/\r
+EFI_STATUS\r
+PrintFormattedNumber (\r
+  IN FORM_DISPLAY_ENGINE_STATEMENT   *Question,\r
+  IN OUT CHAR16               *FormattedNumber,\r
+  IN UINTN                    BufferSize\r
+  );\r
+\r
+/**\r
+  Set value of a data element in an Array by its Index.\r
+\r
+  @param  Array                  The data array.\r
+  @param  Type                   Type of the data in this array.\r
+  @param  Index                  Zero based index for data in this array.\r
+  @param  Value                  The value to be set.\r
+\r
+**/\r
+VOID\r
+SetArrayData (\r
+  IN VOID                     *Array,\r
+  IN UINT8                    Type,\r
+  IN UINTN                    Index,\r
+  IN UINT64                   Value\r
+  );\r
+\r
+/**\r
+  Return data element in an Array by its Index.\r
+\r
+  @param  Array                  The data array.\r
+  @param  Type                   Type of the data in this array.\r
+  @param  Index                  Zero based index for data in this array.\r
+\r
+  @retval Value                  The data to be returned\r
+\r
+**/\r
+UINT64\r
+GetArrayData (\r
+  IN VOID                     *Array,\r
+  IN UINT8                    Type,\r
+  IN UINTN                    Index\r
+  );\r
+  \r
+/**\r
+  Search an Option of a Question by its value.\r
+\r
+  @param  Question               The Question\r
+  @param  OptionValue            Value for Option to be searched.\r
+\r
+  @retval Pointer                Pointer to the found Option.\r
+  @retval NULL                   Option not found.\r
+\r
+**/\r
+DISPLAY_QUESTION_OPTION *\r
+ValueToOption (\r
+  IN FORM_DISPLAY_ENGINE_STATEMENT   *Question,\r
+  IN EFI_HII_VALUE                   *OptionValue\r
+  );\r
+\r
+/**\r
+  Compare two Hii value.\r
+\r
+  @param  Value1                 Expression value to compare on left-hand.\r
+  @param  Value2                 Expression value to compare on right-hand.\r
+  @param  Result                 Return value after compare.\r
+                                 retval 0                      Two operators equal.\r
+                                 return Positive value if Value1 is greater than Value2.\r
+                                 retval Negative value if Value1 is less than Value2.\r
+  @param  HiiHandle              Only required for string compare.\r
+\r
+  @retval other                  Could not perform compare on two values.\r
+  @retval EFI_SUCCESS            Compare the value success.\r
+\r
+**/\r
+EFI_STATUS\r
+CompareHiiValue (\r
+  IN  EFI_HII_VALUE   *Value1,\r
+  IN  EFI_HII_VALUE   *Value2,\r
+  OUT INTN            *Result,\r
+  IN  EFI_HII_HANDLE  HiiHandle OPTIONAL\r
+  );\r
+\r
+/**\r
+  Draw a pop up windows based on the dimension, number of lines and\r
+  strings specified.\r
+\r
+  @param RequestedWidth  The width of the pop-up.\r
+  @param NumberOfLines   The number of lines.\r
+  @param ...             A series of text strings that displayed in the pop-up.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CreateMultiStringPopUp (\r
+  IN  UINTN                       RequestedWidth,\r
+  IN  UINTN                       NumberOfLines,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Will copy LineWidth amount of a string in the OutputString buffer and return the\r
+  number of CHAR16 characters that were copied into the OutputString buffer.\r
+  The output string format is:\r
+    Glyph Info + String info + '\0'.\r
+\r
+  In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.\r
+\r
+  @param  InputString            String description for this option.\r
+  @param  LineWidth              Width of the desired string to extract in CHAR16\r
+                                 characters\r
+  @param  GlyphWidth             The glyph width of the begin of the char in the string.\r
+  @param  Index                  Where in InputString to start the copy process\r
+  @param  OutputString           Buffer to copy the string into\r
+\r
+  @return Returns the number of CHAR16 characters that were copied into the OutputString \r
+  buffer, include extra glyph info and '\0' info.\r
+\r
+**/\r
+UINT16\r
+GetLineByWidth (\r
+  IN      CHAR16                      *InputString,\r
+  IN      UINT16                      LineWidth,\r
+  IN OUT  UINT16                      *GlyphWidth,\r
+  IN OUT  UINTN                       *Index,\r
+  OUT     CHAR16                      **OutputString\r
+  );\r
+\r
+\r
+/**\r
+  Get the string based on the StringId and HII Package List Handle.\r
+\r
+  @param  Token                  The String's ID.\r
+  @param  HiiHandle              The Hii handle for this string package.\r
+\r
+  @return The output string.\r
+\r
+**/\r
+CHAR16 *\r
+GetToken (\r
+  IN  EFI_STRING_ID                Token,\r
+  IN  EFI_HII_HANDLE               HiiHandle\r
+  );\r
+  \r
+/**\r
+  Count the storage space of a Unicode string.\r
+\r
+  This function handles the Unicode string with NARROW_CHAR\r
+  and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR\r
+  does not count in the resultant output. If a WIDE_CHAR is\r
+  hit, then 2 Unicode character will consume an output storage\r
+  space with size of CHAR16 till a NARROW_CHAR is hit.\r
+\r
+  If String is NULL, then ASSERT ().\r
+\r
+  @param String          The input string to be counted.\r
+\r
+  @return Storage space for the input string.\r
+\r
+**/\r
+UINTN\r
+GetStringWidth (\r
+  IN CHAR16               *String\r
+  );\r
+\r
+/**\r
+  This routine reads a numeric value from the user input.\r
+\r
+  @param  MenuOption        Pointer to the current input menu.\r
+\r
+  @retval EFI_SUCCESS       If numerical input is read successfully\r
+  @retval EFI_DEVICE_ERROR  If operation fails\r
+\r
+**/\r
+EFI_STATUS\r
+GetNumericInput (\r
+  IN  UI_MENU_OPTION              *MenuOption\r
+  );\r
+\r
+/**\r
+  Get string or password input from user.\r
+\r
+  @param  MenuOption        Pointer to the current input menu.\r
+  @param  Prompt            The prompt string shown on popup window.\r
+  @param  StringPtr         Old user input and destination for use input string.\r
+\r
+  @retval EFI_SUCCESS       If string input is read successfully\r
+  @retval EFI_DEVICE_ERROR  If operation fails\r
+\r
+**/\r
+EFI_STATUS\r
+ReadString (\r
+  IN     UI_MENU_OPTION              *MenuOption,\r
+  IN     CHAR16                      *Prompt,\r
+  IN OUT CHAR16                      *StringPtr\r
+  );\r
+\r
+/**\r
+  Draw a pop up windows based on the dimension, number of lines and\r
+  strings specified.\r
+\r
+  @param RequestedWidth  The width of the pop-up.\r
+  @param NumberOfLines   The number of lines.\r
+  @param Marker          The variable argument list for the list of string to be printed.\r
+\r
+**/\r
+VOID\r
+CreateSharedPopUp (\r
+  IN  UINTN                       RequestedWidth,\r
+  IN  UINTN                       NumberOfLines,\r
+  IN  VA_LIST                     Marker\r
+  );\r
+  \r
+/**\r
+  Wait for a key to be pressed by user.\r
+\r
+  @param Key         The key which is pressed by user.\r
+\r
+  @retval EFI_SUCCESS The function always completed successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+WaitForKeyStroke (\r
+  OUT  EFI_INPUT_KEY           *Key\r
+  );\r
+\r
+/**\r
+  Get selection for OneOf and OrderedList (Left/Right will be ignored).\r
+\r
+  @param  MenuOption        Pointer to the current input menu.\r
+\r
+  @retval EFI_SUCCESS       If Option input is processed successfully\r
+  @retval EFI_DEVICE_ERROR  If operation fails\r
+\r
+**/\r
+EFI_STATUS\r
+GetSelectionInputPopUp (\r
+  IN  UI_MENU_OPTION              *MenuOption\r
+  );\r
+\r
+/**\r
+  Process the help string: Split StringPtr to several lines of strings stored in\r
+  FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.\r
+\r
+  @param  StringPtr              The entire help string.\r
+  @param  FormattedString        The oupput formatted string.\r
+  @param  EachLineWidth          The max string length of each line in the formatted string.\r
+  @param  RowCount               TRUE: if Question is selected.\r
+\r
+**/\r
+UINTN\r
+ProcessHelpString (\r
+  IN  CHAR16  *StringPtr,\r
+  OUT CHAR16  **FormattedString,\r
+  OUT UINT16  *EachLineWidth,\r
+  IN  UINTN   RowCount\r
+  );\r
+\r
+/**\r
+  Process a Question's Option (whether selected or un-selected).\r
+\r
+  @param  MenuOption             The MenuOption for this Question.\r
+  @param  Selected               TRUE: if Question is selected.\r
+  @param  OptionString           Pointer of the Option String to be displayed.\r
+  @param  SkipErrorValue         Whether need to return when value without option for it.\r
+\r
+  @retval EFI_SUCCESS            Question Option process success.\r
+  @retval Other                  Question Option process fail.\r
+\r
+**/\r
+EFI_STATUS\r
+ProcessOptions (\r
+  IN  UI_MENU_OPTION              *MenuOption,\r
+  IN  BOOLEAN                     Selected,\r
+  OUT CHAR16                      **OptionString,\r
+  IN  BOOLEAN                     SkipErrorValue\r
+  );\r
+\r
+/**\r
+  Set Buffer to Value for Size bytes.\r
+\r
+  @param  Buffer                 Memory to set.\r
+  @param  Size                   Number of bytes to set\r
+  @param  Value                  Value of the set operation.\r
+\r
+**/\r
+VOID\r
+SetUnicodeMem (\r
+  IN VOID   *Buffer,\r
+  IN UINTN  Size,\r
+  IN CHAR16 Value\r
+  );\r
+\r
+/**\r
+  Display one form, and return user input.\r
+  \r
+  @param FormData                Form Data to be shown.\r
+  @param UserInputData           User input data.\r
+  \r
+  @retval EFI_SUCCESS            Form Data is shown, and user input is got.\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+FormDisplay (\r
+  IN  FORM_DISPLAY_ENGINE_FORM  *FormData,\r
+  OUT USER_INPUT                *UserInputData\r
+  );\r
+\r
+/**\r
+  Exit Display and Clear Screen to the original state.\r
+\r
+**/\r
+VOID\r
+EFIAPI \r
+ExitDisplay (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Process validate for one question.\r
+\r
+  @param  Question               The question which need to validate.\r
+\r
+  @retval EFI_SUCCESS            Question Option process success.\r
+  @retval Other                  Question Option process fail.\r
+\r
+**/\r
+EFI_STATUS \r
+ValidateQuestion (\r
+  IN FORM_DISPLAY_ENGINE_STATEMENT   *Question\r
+  );\r
+\r
+#endif\r