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