VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c@ 77599

Last change on this file since 77599 was 58466, checked in by vboxsync, 10 years ago

EFI/Firmware: Merged in the svn:eol-style, svn:mime-type and trailing whitespace cleanup that was done after the initial UDK2014.SP1 import: svn merge /vendor/edk2/UDK2014.SP1 /vendor/edk2/current .

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette