]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h
Check in the missing code.
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / FormDisplay.h
CommitLineData
b9feb4bd
ED
1/** @file\r
2 FormDiplay protocol to show Form\r
3\r
4Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials are licensed and made available under \r
6the terms and conditions of the BSD License that accompanies this distribution. \r
7The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php. \r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __FORM_DISPLAY_H__\r
16#define __FORM_DISPLAY_H__\r
17\r
18\r
19#include <Library/UefiBootServicesTableLib.h>\r
20#include <Library/DebugLib.h>\r
21#include <Library/BaseMemoryLib.h>\r
22#include <Library/BaseLib.h>\r
23#include <Library/HiiLib.h>\r
24#include <Library/MemoryAllocationLib.h>\r
25#include <Library/PrintLib.h>\r
26#include <Library/CustomizedDisplayLib.h>\r
27\r
28#include <Protocol/FormBrowserEx2.h>\r
29#include <Protocol/SimpleTextIn.h>\r
30#include <Protocol/DisplayProtocol.h>\r
31\r
32#include <Guid/MdeModuleHii.h>\r
33\r
34//\r
35// This is the generated header file which includes whatever needs to be exported (strings + IFR)\r
36//\r
37extern UINT8 DisplayEngineStrings[];\r
38extern EFI_SCREEN_DESCRIPTOR gStatementDimensions;\r
39extern USER_INPUT *gUserInput;\r
40extern FORM_DISPLAY_ENGINE_FORM *gFormData;\r
41extern EFI_HII_HANDLE gHiiHandle;\r
42extern UINT16 gDirection;\r
43extern LIST_ENTRY gMenuOption;\r
44\r
45//\r
46// Browser Global Strings\r
47//\r
48extern CHAR16 *gSaveFailed;\r
49extern CHAR16 *gPromptForData;\r
50extern CHAR16 *gPromptForPassword;\r
51extern CHAR16 *gPromptForNewPassword;\r
52extern CHAR16 *gConfirmPassword;\r
53extern CHAR16 *gConfirmError;\r
54extern CHAR16 *gPassowordInvalid;\r
55extern CHAR16 *gPressEnter;\r
56extern CHAR16 *gEmptyString;\r
57extern CHAR16 *gMiniString;\r
58extern CHAR16 *gOptionMismatch;\r
59extern CHAR16 *gFormSuppress;\r
60extern CHAR16 *gProtocolNotFound;\r
61\r
62extern CHAR16 gPromptBlockWidth;\r
63extern CHAR16 gOptionBlockWidth;\r
64extern CHAR16 gHelpBlockWidth;\r
65extern CHAR16 *mUnknownString;\r
66\r
67//\r
68// Screen definitions\r
69//\r
70\r
71#define LEFT_SKIPPED_COLUMNS 3\r
72#define SCROLL_ARROW_HEIGHT 1\r
73#define POPUP_PAD_SPACE_COUNT 5\r
74#define POPUP_FRAME_WIDTH 2\r
75\r
76//\r
77// Display definitions\r
78//\r
79#define LEFT_ONEOF_DELIMITER L'<'\r
80#define RIGHT_ONEOF_DELIMITER L'>'\r
81\r
82#define LEFT_NUMERIC_DELIMITER L'['\r
83#define RIGHT_NUMERIC_DELIMITER L']'\r
84\r
85#define LEFT_CHECKBOX_DELIMITER L'['\r
86#define RIGHT_CHECKBOX_DELIMITER L']'\r
87\r
88#define CHECK_ON L'X'\r
89#define CHECK_OFF L' '\r
90\r
91#define TIME_SEPARATOR L':'\r
92#define DATE_SEPARATOR L'/'\r
93\r
94#define SUBTITLE_INDENT 2\r
95\r
96//\r
97// This is the Input Error Message\r
98//\r
99#define INPUT_ERROR 1\r
100\r
101//\r
102// This is the NV RAM update required Message\r
103//\r
104#define NV_UPDATE_REQUIRED 2\r
105//\r
106// Time definitions\r
107//\r
108#define ONE_SECOND 10000000\r
109\r
110//\r
111// It take 23 characters including the NULL to print a 64 bits number with "[" and "]".\r
112// pow(2, 64) = [18446744073709551616]\r
113//\r
114#define MAX_NUMERIC_INPUT_WIDTH 23\r
115\r
116#define EFI_HII_EXPRESSION_INCONSISTENT_IF 0\r
117#define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1\r
118#define EFI_HII_EXPRESSION_GRAY_OUT_IF 2\r
119#define EFI_HII_EXPRESSION_SUPPRESS_IF 3\r
120#define EFI_HII_EXPRESSION_DISABLE_IF 4\r
121\r
122//\r
123// Character definitions\r
124//\r
125#define CHAR_SPACE 0x0020\r
126\r
127#define FORM_DISPLAY_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'D', 'D', 'V')\r
128typedef struct {\r
129 UINT32 Signature;\r
130\r
131 EFI_HANDLE Handle;\r
132\r
133 //\r
134 // Produced protocol\r
135 //\r
136 EDKII_FORM_DISPLAY_ENGINE_PROTOCOL FromDisplayProt;\r
137} FORM_DISPLAY_DRIVER_PRIVATE_DATA;\r
138\r
139\r
140typedef enum {\r
141 UiNoOperation,\r
142 UiSelect,\r
143 UiUp,\r
144 UiDown,\r
145 UiLeft,\r
146 UiRight,\r
147 UiReset,\r
148 UiPrevious,\r
149 UiPageUp,\r
150 UiPageDown,\r
151 UiHotKey,\r
152 UiMaxOperation\r
153} UI_SCREEN_OPERATION;\r
154\r
155typedef enum {\r
156 CfInitialization,\r
157 CfCheckSelection,\r
158 CfRepaint,\r
159 CfRefreshHighLight,\r
160 CfUpdateHelpString,\r
161 CfPrepareToReadKey,\r
162 CfReadKey,\r
163 CfScreenOperation,\r
164 CfUiSelect,\r
165 CfUiReset,\r
166 CfUiLeft,\r
167 CfUiRight,\r
168 CfUiUp,\r
169 CfUiPageUp,\r
170 CfUiPageDown,\r
171 CfUiDown,\r
172 CfUiDefault,\r
173 CfUiNoOperation,\r
174 CfExit,\r
175 CfUiHotKey,\r
176 CfMaxControlFlag\r
177} UI_CONTROL_FLAG;\r
178\r
179typedef enum {\r
180 UIEventNone,\r
181 UIEventKey,\r
182 UIEventTimeOut,\r
183 UIEventDriver\r
184} UI_EVENT_TYPE;\r
185\r
186typedef struct {\r
187 UINT16 ScanCode;\r
188 UI_SCREEN_OPERATION ScreenOperation;\r
189} SCAN_CODE_TO_SCREEN_OPERATION;\r
190\r
191typedef struct {\r
192 UI_SCREEN_OPERATION ScreenOperation;\r
193 UI_CONTROL_FLAG ControlFlag;\r
194} SCREEN_OPERATION_T0_CONTROL_FLAG;\r
195\r
196typedef struct {\r
197 EFI_QUESTION_ID QuestionId;\r
198 UINT16 DisplayRow;\r
199} DISPLAY_HIGHLIGHT_MENU_INFO;\r
200\r
201#define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')\r
202\r
203typedef struct {\r
204 UINTN Signature;\r
205 LIST_ENTRY Link;\r
206\r
207 EFI_HII_HANDLE Handle;\r
208 FORM_DISPLAY_ENGINE_STATEMENT *ThisTag;\r
209 UINT16 EntryNumber;\r
210\r
211 UINTN Row;\r
212 UINTN Col;\r
213 UINTN OptCol;\r
214 CHAR16 *Description;\r
215 UINTN Skip; // Number of lines\r
216\r
217 //\r
218 // Display item sequence for date/time\r
219 // Date: Month/Day/Year\r
220 // Sequence: 0 1 2\r
221 //\r
222 // Time: Hour : Minute : Second\r
223 // Sequence: 0 1 2\r
224 //\r
225 //\r
226 UINTN Sequence;\r
227\r
228 BOOLEAN GrayOut;\r
229 BOOLEAN ReadOnly;\r
230\r
231 //\r
232 // Whether user could change value of this item\r
233 //\r
234 BOOLEAN IsQuestion;\r
235 BOOLEAN NestInStatement;\r
236} UI_MENU_OPTION;\r
237\r
238#define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)\r
239\r
240/**\r
241 Print Question Value according to it's storage width and display attributes.\r
242\r
243 @param Question The Question to be printed.\r
244 @param FormattedNumber Buffer for output string.\r
245 @param BufferSize The FormattedNumber buffer size in bytes.\r
246\r
247 @retval EFI_SUCCESS Print success.\r
248 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.\r
249\r
250**/\r
251EFI_STATUS\r
252PrintFormattedNumber (\r
253 IN FORM_DISPLAY_ENGINE_STATEMENT *Question,\r
254 IN OUT CHAR16 *FormattedNumber,\r
255 IN UINTN BufferSize\r
256 );\r
257\r
258/**\r
259 Set value of a data element in an Array by its Index.\r
260\r
261 @param Array The data array.\r
262 @param Type Type of the data in this array.\r
263 @param Index Zero based index for data in this array.\r
264 @param Value The value to be set.\r
265\r
266**/\r
267VOID\r
268SetArrayData (\r
269 IN VOID *Array,\r
270 IN UINT8 Type,\r
271 IN UINTN Index,\r
272 IN UINT64 Value\r
273 );\r
274\r
275/**\r
276 Return data element in an Array by its Index.\r
277\r
278 @param Array The data array.\r
279 @param Type Type of the data in this array.\r
280 @param Index Zero based index for data in this array.\r
281\r
282 @retval Value The data to be returned\r
283\r
284**/\r
285UINT64\r
286GetArrayData (\r
287 IN VOID *Array,\r
288 IN UINT8 Type,\r
289 IN UINTN Index\r
290 );\r
291 \r
292/**\r
293 Search an Option of a Question by its value.\r
294\r
295 @param Question The Question\r
296 @param OptionValue Value for Option to be searched.\r
297\r
298 @retval Pointer Pointer to the found Option.\r
299 @retval NULL Option not found.\r
300\r
301**/\r
302DISPLAY_QUESTION_OPTION *\r
303ValueToOption (\r
304 IN FORM_DISPLAY_ENGINE_STATEMENT *Question,\r
305 IN EFI_HII_VALUE *OptionValue\r
306 );\r
307\r
308/**\r
309 Compare two Hii value.\r
310\r
311 @param Value1 Expression value to compare on left-hand.\r
312 @param Value2 Expression value to compare on right-hand.\r
313 @param Result Return value after compare.\r
314 retval 0 Two operators equal.\r
315 return Positive value if Value1 is greater than Value2.\r
316 retval Negative value if Value1 is less than Value2.\r
317 @param HiiHandle Only required for string compare.\r
318\r
319 @retval other Could not perform compare on two values.\r
320 @retval EFI_SUCCESS Compare the value success.\r
321\r
322**/\r
323EFI_STATUS\r
324CompareHiiValue (\r
325 IN EFI_HII_VALUE *Value1,\r
326 IN EFI_HII_VALUE *Value2,\r
327 OUT INTN *Result,\r
328 IN EFI_HII_HANDLE HiiHandle OPTIONAL\r
329 );\r
330\r
331/**\r
332 Draw a pop up windows based on the dimension, number of lines and\r
333 strings specified.\r
334\r
335 @param RequestedWidth The width of the pop-up.\r
336 @param NumberOfLines The number of lines.\r
337 @param ... A series of text strings that displayed in the pop-up.\r
338\r
339**/\r
340VOID\r
341EFIAPI\r
342CreateMultiStringPopUp (\r
343 IN UINTN RequestedWidth,\r
344 IN UINTN NumberOfLines,\r
345 ...\r
346 );\r
347\r
348/**\r
349 Will copy LineWidth amount of a string in the OutputString buffer and return the\r
350 number of CHAR16 characters that were copied into the OutputString buffer.\r
351 The output string format is:\r
352 Glyph Info + String info + '\0'.\r
353\r
354 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.\r
355\r
356 @param InputString String description for this option.\r
357 @param LineWidth Width of the desired string to extract in CHAR16\r
358 characters\r
359 @param GlyphWidth The glyph width of the begin of the char in the string.\r
360 @param Index Where in InputString to start the copy process\r
361 @param OutputString Buffer to copy the string into\r
362\r
363 @return Returns the number of CHAR16 characters that were copied into the OutputString \r
364 buffer, include extra glyph info and '\0' info.\r
365\r
366**/\r
367UINT16\r
368GetLineByWidth (\r
369 IN CHAR16 *InputString,\r
370 IN UINT16 LineWidth,\r
371 IN OUT UINT16 *GlyphWidth,\r
372 IN OUT UINTN *Index,\r
373 OUT CHAR16 **OutputString\r
374 );\r
375\r
376\r
377/**\r
378 Get the string based on the StringId and HII Package List Handle.\r
379\r
380 @param Token The String's ID.\r
381 @param HiiHandle The Hii handle for this string package.\r
382\r
383 @return The output string.\r
384\r
385**/\r
386CHAR16 *\r
387GetToken (\r
388 IN EFI_STRING_ID Token,\r
389 IN EFI_HII_HANDLE HiiHandle\r
390 );\r
391 \r
392/**\r
393 Count the storage space of a Unicode string.\r
394\r
395 This function handles the Unicode string with NARROW_CHAR\r
396 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR\r
397 does not count in the resultant output. If a WIDE_CHAR is\r
398 hit, then 2 Unicode character will consume an output storage\r
399 space with size of CHAR16 till a NARROW_CHAR is hit.\r
400\r
401 If String is NULL, then ASSERT ().\r
402\r
403 @param String The input string to be counted.\r
404\r
405 @return Storage space for the input string.\r
406\r
407**/\r
408UINTN\r
409GetStringWidth (\r
410 IN CHAR16 *String\r
411 );\r
412\r
413/**\r
414 This routine reads a numeric value from the user input.\r
415\r
416 @param MenuOption Pointer to the current input menu.\r
417\r
418 @retval EFI_SUCCESS If numerical input is read successfully\r
419 @retval EFI_DEVICE_ERROR If operation fails\r
420\r
421**/\r
422EFI_STATUS\r
423GetNumericInput (\r
424 IN UI_MENU_OPTION *MenuOption\r
425 );\r
426\r
427/**\r
428 Get string or password input from user.\r
429\r
430 @param MenuOption Pointer to the current input menu.\r
431 @param Prompt The prompt string shown on popup window.\r
432 @param StringPtr Old user input and destination for use input string.\r
433\r
434 @retval EFI_SUCCESS If string input is read successfully\r
435 @retval EFI_DEVICE_ERROR If operation fails\r
436\r
437**/\r
438EFI_STATUS\r
439ReadString (\r
440 IN UI_MENU_OPTION *MenuOption,\r
441 IN CHAR16 *Prompt,\r
442 IN OUT CHAR16 *StringPtr\r
443 );\r
444\r
445/**\r
446 Draw a pop up windows based on the dimension, number of lines and\r
447 strings specified.\r
448\r
449 @param RequestedWidth The width of the pop-up.\r
450 @param NumberOfLines The number of lines.\r
451 @param Marker The variable argument list for the list of string to be printed.\r
452\r
453**/\r
454VOID\r
455CreateSharedPopUp (\r
456 IN UINTN RequestedWidth,\r
457 IN UINTN NumberOfLines,\r
458 IN VA_LIST Marker\r
459 );\r
460 \r
461/**\r
462 Wait for a key to be pressed by user.\r
463\r
464 @param Key The key which is pressed by user.\r
465\r
466 @retval EFI_SUCCESS The function always completed successfully.\r
467\r
468**/\r
469EFI_STATUS\r
470WaitForKeyStroke (\r
471 OUT EFI_INPUT_KEY *Key\r
472 );\r
473\r
474/**\r
475 Get selection for OneOf and OrderedList (Left/Right will be ignored).\r
476\r
477 @param MenuOption Pointer to the current input menu.\r
478\r
479 @retval EFI_SUCCESS If Option input is processed successfully\r
480 @retval EFI_DEVICE_ERROR If operation fails\r
481\r
482**/\r
483EFI_STATUS\r
484GetSelectionInputPopUp (\r
485 IN UI_MENU_OPTION *MenuOption\r
486 );\r
487\r
488/**\r
489 Process the help string: Split StringPtr to several lines of strings stored in\r
490 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.\r
491\r
492 @param StringPtr The entire help string.\r
493 @param FormattedString The oupput formatted string.\r
494 @param EachLineWidth The max string length of each line in the formatted string.\r
495 @param RowCount TRUE: if Question is selected.\r
496\r
497**/\r
498UINTN\r
499ProcessHelpString (\r
500 IN CHAR16 *StringPtr,\r
501 OUT CHAR16 **FormattedString,\r
502 OUT UINT16 *EachLineWidth,\r
503 IN UINTN RowCount\r
504 );\r
505\r
506/**\r
507 Process a Question's Option (whether selected or un-selected).\r
508\r
509 @param MenuOption The MenuOption for this Question.\r
510 @param Selected TRUE: if Question is selected.\r
511 @param OptionString Pointer of the Option String to be displayed.\r
512 @param SkipErrorValue Whether need to return when value without option for it.\r
513\r
514 @retval EFI_SUCCESS Question Option process success.\r
515 @retval Other Question Option process fail.\r
516\r
517**/\r
518EFI_STATUS\r
519ProcessOptions (\r
520 IN UI_MENU_OPTION *MenuOption,\r
521 IN BOOLEAN Selected,\r
522 OUT CHAR16 **OptionString,\r
523 IN BOOLEAN SkipErrorValue\r
524 );\r
525\r
526/**\r
527 Set Buffer to Value for Size bytes.\r
528\r
529 @param Buffer Memory to set.\r
530 @param Size Number of bytes to set\r
531 @param Value Value of the set operation.\r
532\r
533**/\r
534VOID\r
535SetUnicodeMem (\r
536 IN VOID *Buffer,\r
537 IN UINTN Size,\r
538 IN CHAR16 Value\r
539 );\r
540\r
541/**\r
542 Display one form, and return user input.\r
543 \r
544 @param FormData Form Data to be shown.\r
545 @param UserInputData User input data.\r
546 \r
547 @retval EFI_SUCCESS Form Data is shown, and user input is got.\r
548**/\r
549EFI_STATUS\r
550EFIAPI \r
551FormDisplay (\r
552 IN FORM_DISPLAY_ENGINE_FORM *FormData,\r
553 OUT USER_INPUT *UserInputData\r
554 );\r
555\r
556/**\r
557 Clear Screen to the initial state.\r
558**/\r
559VOID\r
560EFIAPI \r
561DriverClearDisplayPage (\r
562 VOID\r
563 );\r
564\r
565/**\r
566 Exit Display and Clear Screen to the original state.\r
567\r
568**/\r
569VOID\r
570EFIAPI \r
571ExitDisplay (\r
572 VOID\r
573 );\r
574\r
575/**\r
576 Process validate for one question.\r
577\r
578 @param Question The question which need to validate.\r
579\r
580 @retval EFI_SUCCESS Question Option process success.\r
581 @retval Other Question Option process fail.\r
582\r
583**/\r
584EFI_STATUS \r
585ValidateQuestion (\r
586 IN FORM_DISPLAY_ENGINE_STATEMENT *Question\r
587 );\r
588\r
589#endif\r