]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c
Update Browser to provide the customization possibilities.
[mirror_edk2.git] / MdeModulePkg / Library / CustomizedDisplayLib / CustomizedDisplayLib.c
1 /** @file
2
3 This library class defines a set of interfaces to customize Display module
4
5 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15 #include "CustomizedDisplayLibInternal.h"
16
17 EFI_GUID gCustomizedDisplayLibGuid = { 0x99fdc8fd, 0x849b, 0x4eba, { 0xad, 0x13, 0xfb, 0x96, 0x99, 0xc9, 0xa, 0x4d } };
18
19 EFI_HII_HANDLE mCDLStringPackHandle;
20 UINT16 gClassOfVfr; // Formset class information
21 UINT16 gLastClassOfVfr = 0;
22 BANNER_DATA *gBannerData;
23
24 UINTN gFooterHeight;
25
26 /**
27 +------------------------------------------------------------------------------+
28 | Setup Page |
29 +------------------------------------------------------------------------------+
30
31 Statement
32 Statement
33 Statement
34
35
36
37
38
39 +------------------------------------------------------------------------------+
40 | F1=Scroll Help F9=Reset to Defaults F10=Save and Exit |
41 | ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Discard Changes |
42 +------------------------------------------------------------------------------+
43 StatusBar
44 **/
45
46 /**
47 This funtion defines Page Frame and Backgroud.
48
49 Based on the above layout, it will be responsible for HeaderHeight, FooterHeight,
50 StatusBarHeight and Backgroud. And, it will reserve Screen for Statement.
51
52 @param[in] FormData Form Data to be shown in Page.
53 @param[out] ScreenForStatement Screen to be used for Statement. (Prompt, Value and Help)
54
55 @return Status
56 **/
57 EFI_STATUS
58 EFIAPI
59 DisplayPageFrame (
60 IN FORM_DISPLAY_ENGINE_FORM *FormData,
61 OUT EFI_SCREEN_DESCRIPTOR *ScreenForStatement
62 )
63 {
64 EFI_STATUS Status;
65
66 ASSERT (FormData != NULL && ScreenForStatement != NULL);
67 if (FormData == NULL || ScreenForStatement == NULL) {
68 return EFI_INVALID_PARAMETER;
69 }
70
71 Status = ScreenDiemensionInfoValidate (FormData);
72 if (EFI_ERROR (Status)) {
73 return Status;
74 }
75
76 gClassOfVfr = FORMSET_CLASS_PLATFORM_SETUP;
77 if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
78 gClassOfVfr = FORMSET_CLASS_MODEL_PAGE;
79 }
80
81 ProcessExternedOpcode(FormData);
82
83 //
84 // Calculate the ScreenForStatement.
85 //
86 ScreenForStatement->BottomRow = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight;
87 if ((gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) == FORMSET_CLASS_FRONT_PAGE) {
88 ScreenForStatement->TopRow = gScreenDimensions.TopRow + FRONT_PAGE_HEADER_HEIGHT;
89 } else {
90 ScreenForStatement->TopRow = gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT;
91 }
92 ScreenForStatement->LeftColumn = gScreenDimensions.LeftColumn;
93 ScreenForStatement->RightColumn = gScreenDimensions.RightColumn;
94
95 //
96 // If Last Vfr Class is same to current Vfr Class,
97 // they will have the same page frame. So, Page Frame is not required to be repainted.
98 //
99 if (gLastClassOfVfr == gClassOfVfr) {
100 UpdateStatusBar(NV_UPDATE_REQUIRED, FormData->SettingChangedFlag);
101 PrintFormTitle(FormData);
102 return EFI_SUCCESS;
103 }
104
105 //
106 // Record last ClassOfVfr and Streen Information.
107 //
108 gLastClassOfVfr = gClassOfVfr;
109
110 //
111 // Ensure we are in Text mode
112 //
113 gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
114
115 ClearLines (0, gScreenDimensions.RightColumn, 0, gScreenDimensions.BottomRow, KEYHELP_BACKGROUND);
116
117 if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
118 return EFI_SUCCESS;
119 }
120
121 if ((gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) == FORMSET_CLASS_FRONT_PAGE) {
122 PrintBannerInfo (FormData);
123 }
124
125 PrintFramework ();
126
127 UpdateStatusBar(NV_UPDATE_REQUIRED, FormData->SettingChangedFlag);
128
129 PrintFormTitle(FormData);
130
131 return EFI_SUCCESS;
132 }
133
134 /**
135 This function updates customized key panel's help information.
136 The library will prepare those Strings for the basic key, ESC, Enter, Up/Down/Left/Right, +/-.
137 and arrange them in Footer panel.
138
139 @param[in] FormData Form Data to be shown in Page. FormData has the highlighted statement.
140 @param[in] Statement The statement current selected.
141 @param[in] Selected Whether or not a tag be selected. TRUE means Enter has hit this question.
142 **/
143 VOID
144 EFIAPI
145 RefreshKeyHelp (
146 IN FORM_DISPLAY_ENGINE_FORM *FormData,
147 IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
148 IN BOOLEAN Selected
149 )
150 {
151 UINTN SecCol;
152 UINTN ThdCol;
153 UINTN LeftColumnOfHelp;
154 UINTN RightColumnOfHelp;
155 UINTN TopRowOfHelp;
156 UINTN BottomRowOfHelp;
157 UINTN StartColumnOfHelp;
158 EFI_IFR_NUMERIC *NumericOp;
159 EFI_IFR_DATE *DateOp;
160 EFI_IFR_TIME *TimeOp;
161 BOOLEAN HexDisplay;
162
163 ASSERT (FormData != NULL);
164 if (FormData == NULL) {
165 return;
166 }
167
168 gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND);
169
170 if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
171 return;
172 }
173
174 SecCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3;
175 ThdCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3 * 2;
176
177 StartColumnOfHelp = gScreenDimensions.LeftColumn + 2;
178 LeftColumnOfHelp = gScreenDimensions.LeftColumn + 1;
179 RightColumnOfHelp = gScreenDimensions.RightColumn - 2;
180 TopRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1;
181 BottomRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2;
182
183 ClearLines (LeftColumnOfHelp, RightColumnOfHelp, TopRowOfHelp, BottomRowOfHelp, KEYHELP_TEXT | KEYHELP_BACKGROUND);
184 if (Statement == NULL) {
185 //
186 // Print Key for Form without showable statement.
187 //
188 PrintHotKeyHelpString (FormData);
189 PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
190 return;
191 }
192
193 HexDisplay = FALSE;
194 NumericOp = NULL;
195 DateOp = NULL;
196 TimeOp = NULL;
197 if (Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) {
198 NumericOp = (EFI_IFR_NUMERIC *) Statement->OpCode;
199 HexDisplay = (NumericOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
200 } else if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) {
201 DateOp = (EFI_IFR_DATE *) Statement->OpCode;
202 HexDisplay = (DateOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
203 } else if (Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
204 TimeOp = (EFI_IFR_TIME *) Statement->OpCode;
205 HexDisplay = (TimeOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
206 }
207 switch (Statement->OpCode->OpCode) {
208 case EFI_IFR_ORDERED_LIST_OP:
209 case EFI_IFR_ONE_OF_OP:
210 case EFI_IFR_NUMERIC_OP:
211 case EFI_IFR_TIME_OP:
212 case EFI_IFR_DATE_OP:
213 if (!Selected) {
214 PrintHotKeyHelpString (FormData);
215
216 if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) {
217 PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
218 }
219
220 if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
221 (Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) {
222 PrintAt (
223 0,
224 StartColumnOfHelp,
225 BottomRowOfHelp,
226 L"%c%c%c%c%s",
227 ARROW_UP,
228 ARROW_DOWN,
229 ARROW_RIGHT,
230 ARROW_LEFT,
231 gMoveHighlight
232 );
233 PrintStringAt (SecCol, BottomRowOfHelp, gEnterString);
234 PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber);
235 } else {
236 PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
237 if (Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP && NumericOp != NULL && LibGetFieldFromNum(Statement->OpCode) != 0) {
238 PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber);
239 }
240 PrintStringAt (SecCol, BottomRowOfHelp, gEnterString);
241 }
242 } else {
243 PrintStringAt (SecCol, BottomRowOfHelp, gEnterCommitString);
244
245 //
246 // If it is a selected numeric with manual input, display different message
247 //
248 if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) ||
249 (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
250 (Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) {
251 PrintStringAt (
252 SecCol,
253 TopRowOfHelp,
254 HexDisplay ? gHexNumericInput : gDecNumericInput
255 );
256 } else if (Statement->OpCode->OpCode != EFI_IFR_ORDERED_LIST_OP) {
257 PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
258 }
259
260 if (Statement->OpCode->OpCode == EFI_IFR_ORDERED_LIST_OP) {
261 PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gPlusString);
262 PrintStringAt (ThdCol, TopRowOfHelp, gMinusString);
263 }
264
265 PrintStringAt (ThdCol, BottomRowOfHelp, gEnterEscapeString);
266 }
267 break;
268
269 case EFI_IFR_CHECKBOX_OP:
270 PrintHotKeyHelpString (FormData);
271
272 if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) {
273 PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
274 }
275
276 PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
277 PrintStringAt (SecCol, BottomRowOfHelp, gToggleCheckBox);
278 break;
279
280 case EFI_IFR_REF_OP:
281 case EFI_IFR_PASSWORD_OP:
282 case EFI_IFR_STRING_OP:
283 case EFI_IFR_TEXT_OP:
284 case EFI_IFR_ACTION_OP:
285 case EFI_IFR_RESET_BUTTON_OP:
286 case EFI_IFR_SUBTITLE_OP:
287 if (!Selected) {
288 PrintHotKeyHelpString (FormData);
289
290 if ((gClassOfVfr & FORMSET_CLASS_PLATFORM_SETUP) == FORMSET_CLASS_PLATFORM_SETUP) {
291 PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
292 }
293
294 PrintAt (0, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
295 if (Statement->OpCode->OpCode != EFI_IFR_TEXT_OP && Statement->OpCode->OpCode != EFI_IFR_SUBTITLE_OP) {
296 PrintStringAt (SecCol, BottomRowOfHelp, gEnterString);
297 }
298 } else {
299 if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) {
300 PrintStringAt (
301 (gScreenDimensions.RightColumn - LibGetStringWidth (gEnterCommitString) / 2) / 2,
302 BottomRowOfHelp,
303 gEnterCommitString
304 );
305 PrintStringAt (ThdCol, BottomRowOfHelp, gEnterEscapeString);
306 }
307 }
308 break;
309
310 default:
311 break;
312 }
313 }
314
315 /**
316 Update status bar.
317
318 This function updates the status bar on the bottom of menu screen. It just shows StatusBar.
319 Original logic in this function should be splitted out.
320
321 @param[in] MessageType The type of message to be shown. InputError or Configuration Changed.
322 @param[in] State Show or Clear Message.
323 **/
324 VOID
325 EFIAPI
326 UpdateStatusBar (
327 IN UINTN MessageType,
328 IN BOOLEAN State
329 )
330 {
331 UINTN Index;
332 CHAR16 OptionWidth;
333
334 OptionWidth = (CHAR16) ((gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3);
335
336 switch (MessageType) {
337 case INPUT_ERROR:
338 if (State) {
339 gST->ConOut->SetAttribute (gST->ConOut, ERROR_TEXT);
340 PrintStringAt (
341 gScreenDimensions.LeftColumn + OptionWidth,
342 gScreenDimensions.BottomRow - 1,
343 gInputErrorMessage
344 );
345 } else {
346 gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
347 for (Index = 0; Index < (LibGetStringWidth (gInputErrorMessage) - 2) / 2; Index++) {
348 PrintStringAt (gScreenDimensions.LeftColumn + OptionWidth + Index, gScreenDimensions.BottomRow - 1, L" ");
349 }
350 }
351 break;
352
353 case NV_UPDATE_REQUIRED:
354 //
355 // Global setting support. Show configuration change on every form.
356 //
357 if (State) {
358 gST->ConOut->SetAttribute (gST->ConOut, INFO_TEXT);
359 PrintStringAt (
360 gScreenDimensions.LeftColumn + OptionWidth * 2,
361 gScreenDimensions.BottomRow - 1,
362 gNvUpdateMessage
363 );
364 } else {
365 gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
366 for (Index = 0; Index < (LibGetStringWidth (gNvUpdateMessage) - 2) / 2; Index++) {
367 PrintStringAt (
368 (gScreenDimensions.LeftColumn + OptionWidth * 2 + Index),
369 gScreenDimensions.BottomRow - 1,
370 L" "
371 );
372 }
373 }
374 break;
375
376 default:
377 break;
378 }
379 }
380
381 /**
382 Create popup window. It will replace CreateDialog().
383
384 This function draws OEM/Vendor specific pop up windows.
385
386 @param[out] Key User Input Key
387 @param ... String to be shown in Popup. The variable argument list is terminated by a NULL.
388
389 **/
390 VOID
391 EFIAPI
392 CreateDialog (
393 OUT EFI_INPUT_KEY *Key, OPTIONAL
394 ...
395 )
396 {
397 VA_LIST Marker;
398 EFI_INPUT_KEY KeyValue;
399 EFI_STATUS Status;
400 UINTN LargestString;
401 UINTN LineNum;
402 UINTN Index;
403 UINTN Count;
404 CHAR16 Character;
405 UINTN Start;
406 UINTN End;
407 UINTN Top;
408 UINTN Bottom;
409 CHAR16 *String;
410 UINTN DimensionsWidth;
411 UINTN DimensionsHeight;
412 UINTN CurrentAttribute;
413
414 //
415 // If screen dimension info is not ready, get it from console.
416 //
417 if (gScreenDimensions.RightColumn == 0 || gScreenDimensions.BottomRow == 0) {
418 ZeroMem (&gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
419 gST->ConOut->QueryMode (
420 gST->ConOut,
421 gST->ConOut->Mode->Mode,
422 &gScreenDimensions.RightColumn,
423 &gScreenDimensions.BottomRow
424 );
425 }
426
427 DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;
428 DimensionsHeight = gScreenDimensions.BottomRow - gScreenDimensions.TopRow;
429
430 LargestString = 0;
431 LineNum = 0;
432 VA_START (Marker, Key);
433 while ((String = VA_ARG (Marker, CHAR16 *)) != NULL) {
434 LineNum ++;
435
436 if ((LibGetStringWidth (String) / 2) > LargestString) {
437 LargestString = (LibGetStringWidth (String) / 2);
438 }
439 }
440 VA_END (Marker);
441
442 if ((LargestString + 2) > DimensionsWidth) {
443 LargestString = DimensionsWidth - 2;
444 }
445
446 CurrentAttribute = gST->ConOut->Mode->Attribute;
447 gST->ConOut->EnableCursor (gST->ConOut, FALSE);
448 gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());
449
450 //
451 // Subtract the PopUp width from total Columns, allow for one space extra on
452 // each end plus a border.
453 //
454 Start = (DimensionsWidth - LargestString - 2) / 2 + gScreenDimensions.LeftColumn + 1;
455 End = Start + LargestString + 1;
456
457 Top = ((DimensionsHeight - LineNum - 2) / 2) + gScreenDimensions.TopRow - 1;
458 Bottom = Top + LineNum + 2;
459
460 Character = BOXDRAW_DOWN_RIGHT;
461 PrintCharAt (Start, Top, Character);
462 Character = BOXDRAW_HORIZONTAL;
463 for (Index = Start; Index + 2 < End; Index++) {
464 PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
465 }
466
467 Character = BOXDRAW_DOWN_LEFT;
468 PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
469 Character = BOXDRAW_VERTICAL;
470
471 Count = 0;
472 VA_START (Marker, Key);
473 for (Index = Top; Index + 2 < Bottom; Index++, Count++) {
474 String = VA_ARG (Marker, CHAR16*);
475
476 if (String[0] == CHAR_NULL) {
477 //
478 // Passing in a NULL results in a blank space
479 //
480 ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ());
481 } else if (String[0] == L' ') {
482 //
483 // Passing in a space results in the assumption that this is where typing will occur
484 //
485 ClearLines (Start + 1, End - 1, Index + 1, Index + 1, POPUP_INVERSE_TEXT | POPUP_INVERSE_BACKGROUND);
486 PrintStringAt (
487 ((DimensionsWidth - LibGetStringWidth (String) / 2) / 2) + gScreenDimensions.LeftColumn + 1,
488 Index + 1,
489 String + 1
490 );
491 } else {
492 //
493 // This will clear the background of the line - we never know who might have been
494 // here before us. This differs from the next clear in that it used the non-reverse
495 // video for normal printing.
496 //
497 ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ());
498 PrintStringAt (
499 ((DimensionsWidth - LibGetStringWidth (String) / 2) / 2) + gScreenDimensions.LeftColumn + 1,
500 Index + 1,
501 String
502 );
503 }
504
505 gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());
506 PrintCharAt (Start, Index + 1, Character);
507 PrintCharAt (End - 1, Index + 1, Character);
508 }
509 VA_END (Marker);
510
511 Character = BOXDRAW_UP_RIGHT;
512 PrintCharAt (Start, Bottom - 1, Character);
513 Character = BOXDRAW_HORIZONTAL;
514 for (Index = Start; Index + 2 < End; Index++) {
515 PrintCharAt ((UINTN)-1, (UINTN) -1, Character);
516 }
517
518 Character = BOXDRAW_UP_LEFT;
519 PrintCharAt ((UINTN)-1, (UINTN) -1, Character);
520
521 if (Key != NULL) {
522 Status = WaitForKeyStroke (&KeyValue);
523 ASSERT_EFI_ERROR (Status);
524 CopyMem (Key, &KeyValue, sizeof (EFI_INPUT_KEY));
525 }
526
527 gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);
528 gST->ConOut->EnableCursor (gST->ConOut, TRUE);
529 }
530
531 /**
532 Confirm how to handle the changed data.
533
534 @return Action BROWSER_ACTION_SUBMIT, BROWSER_ACTION_DISCARD or other values.
535 **/
536 UINTN
537 EFIAPI
538 ConfirmDataChange (
539 VOID
540 )
541 {
542 CHAR16 YesResponse;
543 CHAR16 NoResponse;
544 EFI_INPUT_KEY Key;
545
546 gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
547
548 YesResponse = gYesResponse[0];
549 NoResponse = gNoResponse[0];
550
551 //
552 // If NV flag is up, prompt user
553 //
554 do {
555 CreateDialog (&Key, gLibEmptyString, gSaveChanges, gAreYouSure, gLibEmptyString, NULL);
556 } while
557 (
558 (Key.ScanCode != SCAN_ESC) &&
559 ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (NoResponse | UPPER_LOWER_CASE_OFFSET)) &&
560 ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (YesResponse | UPPER_LOWER_CASE_OFFSET))
561 );
562
563 if (Key.ScanCode == SCAN_ESC) {
564 return BROWSER_ACTION_NONE;
565 } else if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) {
566 return BROWSER_ACTION_SUBMIT;
567 } else {
568 return BROWSER_ACTION_DISCARD;
569 }
570 }
571
572 /**
573 OEM specifies whether Setup exits Page by ESC key.
574
575 This function customized the behavior that whether Setup exits Page so that
576 system able to boot when configuration is not changed.
577
578 @retval TRUE Exits FrontPage
579 @retval FALSE Don't exit FrontPage.
580 **/
581 BOOLEAN
582 EFIAPI
583 FormExitPolicy (
584 VOID
585 )
586 {
587 return (gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) == FORMSET_CLASS_FRONT_PAGE ? FALSE : TRUE;
588 }
589
590 /**
591 Set Timeout value for a ceratain Form to get user response.
592
593 This function allows to set timeout value on a ceratain form if necessary.
594 If timeout is not zero, the form will exit if user has no response in timeout.
595
596 @param[in] FormData Form Data to be shown in Page
597
598 @return 0 No timeout for this form.
599 @return > 0 Timeout value in 100 ns units.
600 **/
601 UINT64
602 EFIAPI
603 FormExitTimeout (
604 IN FORM_DISPLAY_ENGINE_FORM *FormData
605 )
606 {
607 return 0;
608 }
609 //
610 // Print Functions
611 //
612 /**
613 Prints a unicode string to the default console, at
614 the supplied cursor position, using L"%s" format.
615
616 @param Column The cursor position to print the string at. When it is -1, use current Position.
617 @param Row The cursor position to print the string at. When it is -1, use current Position.
618 @param String String pointer.
619
620 @return Length of string printed to the console
621
622 **/
623 UINTN
624 EFIAPI
625 PrintStringAt (
626 IN UINTN Column,
627 IN UINTN Row,
628 IN CHAR16 *String
629 )
630 {
631 return PrintAt (0, Column, Row, L"%s", String);
632 }
633
634 /**
635 Prints a unicode string to the default console, at
636 the supplied cursor position, using L"%s" format.
637
638 @param Column The cursor position to print the string at. When it is -1, use current Position.
639 @param Row The cursor position to print the string at. When it is -1, use current Position.
640 @param String String pointer.
641 @param Width Width for String.
642
643 @return Length of string printed to the console
644
645 **/
646 UINTN
647 EFIAPI
648 PrintStringAtWithWidth (
649 IN UINTN Column,
650 IN UINTN Row,
651 IN CHAR16 *String,
652 IN UINTN Width
653 )
654 {
655 return PrintAt (Width, Column, Row, L"%s", String);
656 }
657
658 /**
659 Prints a chracter to the default console, at
660 the supplied cursor position, using L"%c" format.
661
662 @param Column The cursor position to print the string at. When it is -1, use current Position.
663 @param Row The cursor position to print the string at. When it is -1, use current Position.
664 @param Character Character to print.
665
666 @return Length of string printed to the console.
667
668 **/
669 UINTN
670 EFIAPI
671 PrintCharAt (
672 IN UINTN Column,
673 IN UINTN Row,
674 CHAR16 Character
675 )
676 {
677 return PrintAt (0, Column, Row, L"%c", Character);
678 }
679
680 /**
681 Clear retangle with specified text attribute.
682
683 @param LeftColumn Left column of retangle.
684 @param RightColumn Right column of retangle.
685 @param TopRow Start row of retangle.
686 @param BottomRow End row of retangle.
687 @param TextAttribute The character foreground and background.
688
689 **/
690 VOID
691 EFIAPI
692 ClearLines (
693 IN UINTN LeftColumn,
694 IN UINTN RightColumn,
695 IN UINTN TopRow,
696 IN UINTN BottomRow,
697 IN UINTN TextAttribute
698 )
699 {
700 CHAR16 *Buffer;
701 UINTN Row;
702
703 //
704 // For now, allocate an arbitrarily long buffer
705 //
706 Buffer = AllocateZeroPool (0x10000);
707 ASSERT (Buffer != NULL);
708
709 //
710 // Set foreground and background as defined
711 //
712 gST->ConOut->SetAttribute (gST->ConOut, TextAttribute);
713
714 //
715 // Much faster to buffer the long string instead of print it a character at a time
716 //
717 LibSetUnicodeMem (Buffer, RightColumn - LeftColumn, L' ');
718
719 //
720 // Clear the desired area with the appropriate foreground/background
721 //
722 for (Row = TopRow; Row <= BottomRow; Row++) {
723 PrintStringAt (LeftColumn, Row, Buffer);
724 }
725
726 gST->ConOut->SetCursorPosition (gST->ConOut, LeftColumn, TopRow);
727
728 FreePool (Buffer);
729 }
730
731 //
732 // Color Setting Functions
733 //
734
735 /**
736 Get OEM/Vendor specific popup attribute colors.
737
738 @retval Byte code color setting for popup color.
739 **/
740 UINT8
741 EFIAPI
742 GetPopupColor (
743 VOID
744 )
745 {
746 return POPUP_TEXT | POPUP_BACKGROUND;
747 }
748
749 /**
750 Get OEM/Vendor specific popup attribute colors.
751
752 @retval Byte code color setting for popup inverse color.
753 **/
754 UINT8
755 EFIAPI
756 GetPopupInverseColor (
757 VOID
758 )
759 {
760 return POPUP_INVERSE_TEXT | POPUP_INVERSE_BACKGROUND;
761 }
762
763 /**
764 Get OEM/Vendor specific PickList color attribute.
765
766 @retval Byte code color setting for pick list color.
767 **/
768 UINT8
769 EFIAPI
770 GetPickListColor (
771 VOID
772 )
773 {
774 return PICKLIST_HIGHLIGHT_TEXT | PICKLIST_HIGHLIGHT_BACKGROUND;
775 }
776
777 /**
778 Get OEM/Vendor specific arrow color attribute.
779
780 @retval Byte code color setting for arrow color.
781 **/
782 UINT8
783 EFIAPI
784 GetArrowColor (
785 VOID
786 )
787 {
788 return ARROW_TEXT | ARROW_BACKGROUND;
789 }
790
791 /**
792 Get OEM/Vendor specific info text color attribute.
793
794 @retval Byte code color setting for info text color.
795 **/
796 UINT8
797 EFIAPI
798 GetInfoTextColor (
799 VOID
800 )
801 {
802 return INFO_TEXT | FIELD_BACKGROUND;
803 }
804
805 /**
806 Get OEM/Vendor specific help text color attribute.
807
808 @retval Byte code color setting for help text color.
809 **/
810 UINT8
811 EFIAPI
812 GetHelpTextColor (
813 VOID
814 )
815 {
816 return HELP_TEXT | FIELD_BACKGROUND;
817 }
818
819 /**
820 Get OEM/Vendor specific grayed out text color attribute.
821
822 @retval Byte code color setting for grayed out text color.
823 **/
824 UINT8
825 EFIAPI
826 GetGrayedTextColor (
827 VOID
828 )
829 {
830 return FIELD_TEXT_GRAYED | FIELD_BACKGROUND;
831 }
832
833 /**
834 Get OEM/Vendor specific highlighted text color attribute.
835
836 @retval Byte code color setting for highlight text color.
837 **/
838 UINT8
839 EFIAPI
840 GetHighlightTextColor (
841 VOID
842 )
843 {
844 return PcdGet8 (PcdBrowserFieldTextHighlightColor) | PcdGet8 (PcdBrowserFieldBackgroundHighlightColor);
845 }
846
847 /**
848 Get OEM/Vendor specific field text color attribute.
849
850 @retval Byte code color setting for field text color.
851 **/
852 UINT8
853 EFIAPI
854 GetFieldTextColor (
855 VOID
856 )
857 {
858 return PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND;
859 }
860
861 /**
862 Get OEM/Vendor specific subtitle text color attribute.
863
864 @retval Byte code color setting for subtitle text color.
865 **/
866 UINT8
867 EFIAPI
868 GetSubTitleTextColor (
869 VOID
870 )
871 {
872 return PcdGet8 (PcdBrowserSubtitleTextColor) | FIELD_BACKGROUND;
873 }
874
875 /**
876 Clear Screen to the initial state.
877 **/
878 VOID
879 EFIAPI
880 ClearDisplayPage (
881 VOID
882 )
883 {
884 gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
885 gST->ConOut->ClearScreen (gST->ConOut);
886 gLastClassOfVfr = 0;
887 }
888
889 /**
890 Constructor of Customized Display Library Instance.
891
892 @param ImageHandle The firmware allocated handle for the EFI image.
893 @param SystemTable A pointer to the EFI System Table.
894
895 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
896
897 **/
898 EFI_STATUS
899 EFIAPI
900 CustomizedDisplayLibConstructor (
901 IN EFI_HANDLE ImageHandle,
902 IN EFI_SYSTEM_TABLE *SystemTable
903 )
904 {
905 mCDLStringPackHandle = HiiAddPackages (&gCustomizedDisplayLibGuid, ImageHandle, CustomizedDisplayLibStrings, NULL);
906 ASSERT (mCDLStringPackHandle != NULL);
907
908 InitializeLibStrings();
909
910 return EFI_SUCCESS;
911 }
912
913 /**
914 Destructor of Customized Display Library Instance.
915
916 @param ImageHandle The firmware allocated handle for the EFI image.
917 @param SystemTable A pointer to the EFI System Table.
918
919 @retval EFI_SUCCESS The destructor completed successfully.
920 @retval Other value The destructor did not complete successfully.
921
922 **/
923 EFI_STATUS
924 EFIAPI
925 CustomizedDisplayLibDestructor (
926 IN EFI_HANDLE ImageHandle,
927 IN EFI_SYSTEM_TABLE *SystemTable
928 )
929 {
930 HiiRemovePackages(mCDLStringPackHandle);
931
932 FreeLibStrings ();
933
934 return EFI_SUCCESS;
935 }
936