]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h
Fixed user input arrow down/ page down caused form display highlight menu error.
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / FormDisplay.h
CommitLineData
7c6c064c
ED
1/** @file\r
2 FormDiplay protocol to show Form\r
3\r
336c8e11 4Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
7c6c064c
ED
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
42645c3d 66extern BOOLEAN gMisMatch;\r
7c6c064c
ED
67\r
68//\r
69// Screen definitions\r
70//\r
71\r
72#define LEFT_SKIPPED_COLUMNS 3\r
73#define SCROLL_ARROW_HEIGHT 1\r
74#define POPUP_PAD_SPACE_COUNT 5\r
75#define POPUP_FRAME_WIDTH 2\r
76\r
4d4deaac
ED
77#define UPPER_LOWER_CASE_OFFSET 0x20\r
78\r
7c6c064c
ED
79//\r
80// Display definitions\r
81//\r
82#define LEFT_ONEOF_DELIMITER L'<'\r
83#define RIGHT_ONEOF_DELIMITER L'>'\r
84\r
85#define LEFT_NUMERIC_DELIMITER L'['\r
86#define RIGHT_NUMERIC_DELIMITER L']'\r
87\r
88#define LEFT_CHECKBOX_DELIMITER L'['\r
89#define RIGHT_CHECKBOX_DELIMITER L']'\r
90\r
91#define CHECK_ON L'X'\r
92#define CHECK_OFF L' '\r
93\r
94#define TIME_SEPARATOR L':'\r
95#define DATE_SEPARATOR L'/'\r
96\r
97#define SUBTITLE_INDENT 2\r
98\r
99//\r
100// This is the Input Error Message\r
101//\r
102#define INPUT_ERROR 1\r
103\r
104//\r
105// This is the NV RAM update required Message\r
106//\r
107#define NV_UPDATE_REQUIRED 2\r
108//\r
109// Time definitions\r
110//\r
111#define ONE_SECOND 10000000\r
112\r
113//\r
114// It take 23 characters including the NULL to print a 64 bits number with "[" and "]".\r
115// pow(2, 64) = [18446744073709551616]\r
116//\r
117#define MAX_NUMERIC_INPUT_WIDTH 23\r
118\r
119#define EFI_HII_EXPRESSION_INCONSISTENT_IF 0\r
120#define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1\r
121#define EFI_HII_EXPRESSION_GRAY_OUT_IF 2\r
122#define EFI_HII_EXPRESSION_SUPPRESS_IF 3\r
123#define EFI_HII_EXPRESSION_DISABLE_IF 4\r
124\r
125//\r
126// Character definitions\r
127//\r
128#define CHAR_SPACE 0x0020\r
129\r
130#define FORM_DISPLAY_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'D', 'D', 'V')\r
131typedef struct {\r
132 UINT32 Signature;\r
133\r
134 EFI_HANDLE Handle;\r
135\r
136 //\r
137 // Produced protocol\r
138 //\r
139 EDKII_FORM_DISPLAY_ENGINE_PROTOCOL FromDisplayProt;\r
140} FORM_DISPLAY_DRIVER_PRIVATE_DATA;\r
141\r
142\r
143typedef enum {\r
144 UiNoOperation,\r
145 UiSelect,\r
146 UiUp,\r
147 UiDown,\r
148 UiLeft,\r
149 UiRight,\r
150 UiReset,\r
151 UiPrevious,\r
152 UiPageUp,\r
153 UiPageDown,\r
154 UiHotKey,\r
155 UiMaxOperation\r
156} UI_SCREEN_OPERATION;\r
157\r
158typedef enum {\r
159 CfInitialization,\r
160 CfCheckSelection,\r
161 CfRepaint,\r
162 CfRefreshHighLight,\r
163 CfUpdateHelpString,\r
164 CfPrepareToReadKey,\r
165 CfReadKey,\r
166 CfScreenOperation,\r
167 CfUiSelect,\r
168 CfUiReset,\r
169 CfUiLeft,\r
170 CfUiRight,\r
171 CfUiUp,\r
172 CfUiPageUp,\r
173 CfUiPageDown,\r
174 CfUiDown,\r
7c6c064c
ED
175 CfUiNoOperation,\r
176 CfExit,\r
177 CfUiHotKey,\r
178 CfMaxControlFlag\r
179} UI_CONTROL_FLAG;\r
180\r
181typedef enum {\r
182 UIEventNone,\r
183 UIEventKey,\r
184 UIEventTimeOut,\r
185 UIEventDriver\r
186} UI_EVENT_TYPE;\r
187\r
188typedef struct {\r
189 UINT16 ScanCode;\r
190 UI_SCREEN_OPERATION ScreenOperation;\r
191} SCAN_CODE_TO_SCREEN_OPERATION;\r
192\r
193typedef struct {\r
194 UI_SCREEN_OPERATION ScreenOperation;\r
195 UI_CONTROL_FLAG ControlFlag;\r
196} SCREEN_OPERATION_T0_CONTROL_FLAG;\r
197\r
198typedef struct {\r
336c8e11 199 EFI_HII_HANDLE HiiHandle;\r
42645c3d
ED
200 UINT16 FormId;\r
201 \r
202 //\r
203 // Info for the highlight question.\r
204 // HLT means highlight\r
205 //\r
206 // If one statement has questionid, save questionid info to find the question.\r
207 // If one statement not has questionid info, save the opcode info to find the \r
208 // statement. If more than one statement has same opcode in one form(just like\r
209 // empty subtitle info may has more than one info one form), also use Index \r
210 // info to find the statement.\r
211 //\r
212 EFI_QUESTION_ID HLTQuestionId;\r
213 EFI_IFR_OP_HEADER *HLTOpCode;\r
214 UINTN HLTIndex;\r
215 UINTN HLTSequence;\r
216 \r
217 //\r
218 // Info for the top of screen question.\r
219 // TOS means Top Of Screen\r
220 //\r
221 EFI_QUESTION_ID TOSQuestionId;\r
222 EFI_IFR_OP_HEADER *TOSOpCode;\r
223 UINTN TOSIndex;\r
224\r
336c8e11 225 UINT16 SkipValue;\r
7c6c064c
ED
226} DISPLAY_HIGHLIGHT_MENU_INFO;\r
227\r
bfae1330
ED
228typedef struct {\r
229 EFI_EVENT SyncEvent;\r
230 UINT8 *TimeOut;\r
231 CHAR16 *ErrorInfo;\r
232} WARNING_IF_CONTEXT;\r
233\r
7c6c064c
ED
234#define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')\r
235\r
236typedef struct {\r
237 UINTN Signature;\r
238 LIST_ENTRY Link;\r
239\r
240 EFI_HII_HANDLE Handle;\r
241 FORM_DISPLAY_ENGINE_STATEMENT *ThisTag;\r
242 UINT16 EntryNumber;\r
243\r
244 UINTN Row;\r
245 UINTN Col;\r
246 UINTN OptCol;\r
247 CHAR16 *Description;\r
248 UINTN Skip; // Number of lines\r
249\r
250 //\r
251 // Display item sequence for date/time\r
252 // Date: Month/Day/Year\r
253 // Sequence: 0 1 2\r
254 //\r
255 // Time: Hour : Minute : Second\r
256 // Sequence: 0 1 2\r
257 //\r
258 //\r
259 UINTN Sequence;\r
260\r
261 BOOLEAN GrayOut;\r
262 BOOLEAN ReadOnly;\r
263\r
264 //\r
265 // Whether user could change value of this item\r
266 //\r
267 BOOLEAN IsQuestion;\r
268 BOOLEAN NestInStatement;\r
269} UI_MENU_OPTION;\r
270\r
271#define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)\r
272\r
273/**\r
274 Print Question Value according to it's storage width and display attributes.\r
275\r
276 @param Question The Question to be printed.\r
277 @param FormattedNumber Buffer for output string.\r
278 @param BufferSize The FormattedNumber buffer size in bytes.\r
279\r
280 @retval EFI_SUCCESS Print success.\r
281 @retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.\r
282\r
283**/\r
284EFI_STATUS\r
285PrintFormattedNumber (\r
286 IN FORM_DISPLAY_ENGINE_STATEMENT *Question,\r
287 IN OUT CHAR16 *FormattedNumber,\r
288 IN UINTN BufferSize\r
289 );\r
290\r
291/**\r
292 Set value of a data element in an Array by its Index.\r
293\r
294 @param Array The data array.\r
295 @param Type Type of the data in this array.\r
296 @param Index Zero based index for data in this array.\r
297 @param Value The value to be set.\r
298\r
299**/\r
300VOID\r
301SetArrayData (\r
302 IN VOID *Array,\r
303 IN UINT8 Type,\r
304 IN UINTN Index,\r
305 IN UINT64 Value\r
306 );\r
307\r
308/**\r
309 Return data element in an Array by its Index.\r
310\r
311 @param Array The data array.\r
312 @param Type Type of the data in this array.\r
313 @param Index Zero based index for data in this array.\r
314\r
315 @retval Value The data to be returned\r
316\r
317**/\r
318UINT64\r
319GetArrayData (\r
320 IN VOID *Array,\r
321 IN UINT8 Type,\r
322 IN UINTN Index\r
323 );\r
324 \r
325/**\r
326 Search an Option of a Question by its value.\r
327\r
328 @param Question The Question\r
329 @param OptionValue Value for Option to be searched.\r
330\r
331 @retval Pointer Pointer to the found Option.\r
332 @retval NULL Option not found.\r
333\r
334**/\r
335DISPLAY_QUESTION_OPTION *\r
336ValueToOption (\r
337 IN FORM_DISPLAY_ENGINE_STATEMENT *Question,\r
338 IN EFI_HII_VALUE *OptionValue\r
339 );\r
340\r
341/**\r
342 Compare two Hii value.\r
343\r
344 @param Value1 Expression value to compare on left-hand.\r
345 @param Value2 Expression value to compare on right-hand.\r
346 @param Result Return value after compare.\r
347 retval 0 Two operators equal.\r
348 return Positive value if Value1 is greater than Value2.\r
349 retval Negative value if Value1 is less than Value2.\r
350 @param HiiHandle Only required for string compare.\r
351\r
352 @retval other Could not perform compare on two values.\r
353 @retval EFI_SUCCESS Compare the value success.\r
354\r
355**/\r
356EFI_STATUS\r
357CompareHiiValue (\r
358 IN EFI_HII_VALUE *Value1,\r
359 IN EFI_HII_VALUE *Value2,\r
360 OUT INTN *Result,\r
361 IN EFI_HII_HANDLE HiiHandle OPTIONAL\r
362 );\r
363\r
364/**\r
365 Draw a pop up windows based on the dimension, number of lines and\r
366 strings specified.\r
367\r
368 @param RequestedWidth The width of the pop-up.\r
369 @param NumberOfLines The number of lines.\r
370 @param ... A series of text strings that displayed in the pop-up.\r
371\r
372**/\r
373VOID\r
374EFIAPI\r
375CreateMultiStringPopUp (\r
376 IN UINTN RequestedWidth,\r
377 IN UINTN NumberOfLines,\r
378 ...\r
379 );\r
380\r
381/**\r
382 Will copy LineWidth amount of a string in the OutputString buffer and return the\r
383 number of CHAR16 characters that were copied into the OutputString buffer.\r
384 The output string format is:\r
385 Glyph Info + String info + '\0'.\r
386\r
387 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.\r
388\r
389 @param InputString String description for this option.\r
390 @param LineWidth Width of the desired string to extract in CHAR16\r
391 characters\r
392 @param GlyphWidth The glyph width of the begin of the char in the string.\r
393 @param Index Where in InputString to start the copy process\r
394 @param OutputString Buffer to copy the string into\r
395\r
396 @return Returns the number of CHAR16 characters that were copied into the OutputString \r
397 buffer, include extra glyph info and '\0' info.\r
398\r
399**/\r
400UINT16\r
401GetLineByWidth (\r
402 IN CHAR16 *InputString,\r
403 IN UINT16 LineWidth,\r
404 IN OUT UINT16 *GlyphWidth,\r
405 IN OUT UINTN *Index,\r
406 OUT CHAR16 **OutputString\r
407 );\r
408\r
409\r
410/**\r
411 Get the string based on the StringId and HII Package List Handle.\r
412\r
413 @param Token The String's ID.\r
414 @param HiiHandle The Hii handle for this string package.\r
415\r
416 @return The output string.\r
417\r
418**/\r
419CHAR16 *\r
420GetToken (\r
421 IN EFI_STRING_ID Token,\r
422 IN EFI_HII_HANDLE HiiHandle\r
423 );\r
424 \r
425/**\r
426 Count the storage space of a Unicode string.\r
427\r
428 This function handles the Unicode string with NARROW_CHAR\r
429 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR\r
430 does not count in the resultant output. If a WIDE_CHAR is\r
431 hit, then 2 Unicode character will consume an output storage\r
432 space with size of CHAR16 till a NARROW_CHAR is hit.\r
433\r
434 If String is NULL, then ASSERT ().\r
435\r
436 @param String The input string to be counted.\r
437\r
438 @return Storage space for the input string.\r
439\r
440**/\r
441UINTN\r
442GetStringWidth (\r
443 IN CHAR16 *String\r
444 );\r
445\r
446/**\r
447 This routine reads a numeric value from the user input.\r
448\r
449 @param MenuOption Pointer to the current input menu.\r
450\r
451 @retval EFI_SUCCESS If numerical input is read successfully\r
452 @retval EFI_DEVICE_ERROR If operation fails\r
453\r
454**/\r
455EFI_STATUS\r
456GetNumericInput (\r
457 IN UI_MENU_OPTION *MenuOption\r
458 );\r
459\r
460/**\r
461 Get string or password input from user.\r
462\r
463 @param MenuOption Pointer to the current input menu.\r
464 @param Prompt The prompt string shown on popup window.\r
465 @param StringPtr Old user input and destination for use input string.\r
466\r
467 @retval EFI_SUCCESS If string input is read successfully\r
468 @retval EFI_DEVICE_ERROR If operation fails\r
469\r
470**/\r
471EFI_STATUS\r
472ReadString (\r
473 IN UI_MENU_OPTION *MenuOption,\r
474 IN CHAR16 *Prompt,\r
475 IN OUT CHAR16 *StringPtr\r
476 );\r
477\r
478/**\r
479 Draw a pop up windows based on the dimension, number of lines and\r
480 strings specified.\r
481\r
482 @param RequestedWidth The width of the pop-up.\r
483 @param NumberOfLines The number of lines.\r
484 @param Marker The variable argument list for the list of string to be printed.\r
485\r
486**/\r
487VOID\r
488CreateSharedPopUp (\r
489 IN UINTN RequestedWidth,\r
490 IN UINTN NumberOfLines,\r
491 IN VA_LIST Marker\r
492 );\r
493 \r
494/**\r
495 Wait for a key to be pressed by user.\r
496\r
497 @param Key The key which is pressed by user.\r
498\r
499 @retval EFI_SUCCESS The function always completed successfully.\r
500\r
501**/\r
502EFI_STATUS\r
503WaitForKeyStroke (\r
504 OUT EFI_INPUT_KEY *Key\r
505 );\r
506\r
507/**\r
508 Get selection for OneOf and OrderedList (Left/Right will be ignored).\r
509\r
510 @param MenuOption Pointer to the current input menu.\r
511\r
512 @retval EFI_SUCCESS If Option input is processed successfully\r
513 @retval EFI_DEVICE_ERROR If operation fails\r
514\r
515**/\r
516EFI_STATUS\r
517GetSelectionInputPopUp (\r
518 IN UI_MENU_OPTION *MenuOption\r
519 );\r
520\r
521/**\r
522 Process the help string: Split StringPtr to several lines of strings stored in\r
523 FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.\r
524\r
525 @param StringPtr The entire help string.\r
526 @param FormattedString The oupput formatted string.\r
527 @param EachLineWidth The max string length of each line in the formatted string.\r
528 @param RowCount TRUE: if Question is selected.\r
529\r
530**/\r
531UINTN\r
532ProcessHelpString (\r
533 IN CHAR16 *StringPtr,\r
534 OUT CHAR16 **FormattedString,\r
535 OUT UINT16 *EachLineWidth,\r
536 IN UINTN RowCount\r
537 );\r
538\r
539/**\r
540 Process a Question's Option (whether selected or un-selected).\r
541\r
542 @param MenuOption The MenuOption for this Question.\r
543 @param Selected TRUE: if Question is selected.\r
544 @param OptionString Pointer of the Option String to be displayed.\r
545 @param SkipErrorValue Whether need to return when value without option for it.\r
546\r
547 @retval EFI_SUCCESS Question Option process success.\r
548 @retval Other Question Option process fail.\r
549\r
550**/\r
551EFI_STATUS\r
552ProcessOptions (\r
553 IN UI_MENU_OPTION *MenuOption,\r
554 IN BOOLEAN Selected,\r
555 OUT CHAR16 **OptionString,\r
556 IN BOOLEAN SkipErrorValue\r
557 );\r
558\r
559/**\r
560 Set Buffer to Value for Size bytes.\r
561\r
562 @param Buffer Memory to set.\r
563 @param Size Number of bytes to set\r
564 @param Value Value of the set operation.\r
565\r
566**/\r
567VOID\r
568SetUnicodeMem (\r
569 IN VOID *Buffer,\r
570 IN UINTN Size,\r
571 IN CHAR16 Value\r
572 );\r
573\r
574/**\r
575 Display one form, and return user input.\r
576 \r
577 @param FormData Form Data to be shown.\r
578 @param UserInputData User input data.\r
579 \r
580 @retval EFI_SUCCESS Form Data is shown, and user input is got.\r
581**/\r
582EFI_STATUS\r
583EFIAPI \r
584FormDisplay (\r
585 IN FORM_DISPLAY_ENGINE_FORM *FormData,\r
586 OUT USER_INPUT *UserInputData\r
587 );\r
588\r
5a9f73bf
ED
589/**\r
590 Clear Screen to the initial state.\r
591**/\r
592VOID\r
593EFIAPI \r
594DriverClearDisplayPage (\r
595 VOID\r
596 );\r
597\r
7c6c064c
ED
598/**\r
599 Exit Display and Clear Screen to the original state.\r
600\r
601**/\r
602VOID\r
603EFIAPI \r
604ExitDisplay (\r
605 VOID\r
606 );\r
607\r
608/**\r
bfae1330 609 Process nothing.\r
7c6c064c 610\r
bfae1330
ED
611 @param Event The Event need to be process\r
612 @param Context The context of the event.\r
7c6c064c 613\r
bfae1330
ED
614**/\r
615VOID\r
616EFIAPI\r
617EmptyEventProcess (\r
618 IN EFI_EVENT Event,\r
619 IN VOID *Context\r
620 );\r
621\r
622/**\r
623 Process for the refresh interval statement.\r
624\r
625 @param Event The Event need to be process\r
626 @param Context The context of the event.\r
7c6c064c
ED
627\r
628**/\r
bfae1330
ED
629VOID\r
630EFIAPI\r
631RefreshTimeOutProcess (\r
632 IN EFI_EVENT Event,\r
633 IN VOID *Context\r
7c6c064c
ED
634 );\r
635\r
636#endif\r