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