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