13EFI_STRING gMessageString;
33 SelectableOption = SELECTABLE_OPTION_FROM_LINK (Link);
56 PrintStringAt (SelectableOption->OptionCol, SelectableOption->OptionRow, SelectableOption->OptionString);
75 IN EFI_HII_POPUP_TYPE PopupType,
76 IN EFI_HII_POPUP_SELECTION OptionType,
77 IN CHAR16 *OptionString,
85 if (UserSelectableOption ==
NULL) {
86 return EFI_OUT_OF_RESOURCES;
93 UserSelectableOption->Signature = USER_SELECTABLE_OPTION_SIGNATURE;
94 UserSelectableOption->OptionString = OptionString;
95 UserSelectableOption->OptionType = OptionType;
96 UserSelectableOption->OptionCol = OptionCol;
97 UserSelectableOption->OptionRow = OptionRow;
98 UserSelectableOption->MinSequence = 0;
101 case EfiHiiPopupTypeOk:
102 UserSelectableOption->MaxSequence = 0;
103 UserSelectableOption->Sequence = 0;
105 case EfiHiiPopupTypeOkCancel:
106 UserSelectableOption->MaxSequence = 1;
107 if (OptionType == EfiHiiPopupSelectionOk) {
108 UserSelectableOption->Sequence = 0;
110 UserSelectableOption->Sequence = 1;
114 case EfiHiiPopupTypeYesNo:
115 UserSelectableOption->MaxSequence = 1;
116 if (OptionType == EfiHiiPopupSelectionYes) {
117 UserSelectableOption->Sequence = 0;
119 UserSelectableOption->Sequence = 1;
123 case EfiHiiPopupTypeYesNoCancel:
124 UserSelectableOption->MaxSequence = 2;
125 if (OptionType == EfiHiiPopupSelectionYes) {
126 UserSelectableOption->Sequence = 0;
127 }
else if (OptionType == EfiHiiPopupSelectionNo) {
128 UserSelectableOption->Sequence = 1;
130 UserSelectableOption->Sequence = 2;
138 InsertTailList (&gUserSelectableOptions, &UserSelectableOption->Link);
154 IN EFI_HII_POPUP_TYPE PopupType
165 EndCol = gPopupDimensions.RightColumn;
166 StartCol = gPopupDimensions.LeftColumn;
167 OptionRow = gPopupDimensions.BottomRow - POPUP_BORDER;
168 ColDimension = EndCol - StartCol + 1;
173 case EfiHiiPopupTypeOk:
177 OptionCol = StartCol + (ColDimension - USER_SELECTABLE_OPTION_OK_WIDTH) / 2;
180 case EfiHiiPopupTypeOkCancel:
184 OptionCol = StartCol + (ColDimension - USER_SELECTABLE_OPTION_OK_CAL_WIDTH) / 3;
186 OptionCol = EndCol - (ColDimension - USER_SELECTABLE_OPTION_OK_CAL_WIDTH) / 3 - (
GetStringWidth (gCancelOption) -2) / 2 + 1;
187 Status =
AddOneSelectableOption (PopupType, EfiHiiPopupSelectionCancel, gCancelOption, OptionCol, OptionRow);
189 case EfiHiiPopupTypeYesNo:
193 OptionCol = StartCol + (ColDimension - USER_SELECTABLE_OPTION_YES_NO_WIDTH) / 3;
195 OptionCol = EndCol - (ColDimension - USER_SELECTABLE_OPTION_YES_NO_WIDTH) / 3 - (
GetStringWidth (gNoOption)- 2) / 2 + 1;
198 case EfiHiiPopupTypeYesNoCancel:
202 OptionCol = StartCol + (ColDimension - USER_SELECTABLE_OPTION_YES_NO_CAL_WIDTH) / 4;
204 OptionCol = StartCol + (ColDimension - (
GetStringWidth (gNoOption) -2) / 2) / 2;
206 OptionCol = EndCol - (ColDimension - USER_SELECTABLE_OPTION_YES_NO_CAL_WIDTH) / 4 - (
GetStringWidth (gCancelOption) - 2) / 2 + 1;
207 Status =
AddOneSelectableOption (PopupType, EfiHiiPopupSelectionCancel, gCancelOption, OptionCol, OptionRow);
225 IN EFI_HII_POPUP_TYPE PopupType,
226 OUT EFI_HII_POPUP_SELECTION *UserSelection
239 HighlightPos = gUserSelectableOptions.ForwardLink;
241 for (Link = gUserSelectableOptions.ForwardLink; Link != &gUserSelectableOptions; Link = Link->ForwardLink) {
242 SelectableOption = SELECTABLE_OPTION_FROM_LINK (Link);
249 if (UserSelection ==
NULL) {
256 HighlightOption = SELECTABLE_OPTION_FROM_LINK (HighlightPos);
257 switch (KeyValue.UnicodeChar) {
259 switch (KeyValue.ScanCode) {
261 if (HighlightOption->Sequence < HighlightOption->MaxSequence) {
262 HighlightPos = HighlightPos->ForwardLink;
264 HighlightPos = gUserSelectableOptions.ForwardLink;
269 if (HighlightOption->Sequence > HighlightOption->MinSequence) {
270 HighlightPos = HighlightPos->BackLink;
272 HighlightPos = gUserSelectableOptions.BackLink;
282 case CHAR_CARRIAGE_RETURN:
283 *UserSelection = HighlightOption->OptionType;
286 if (((KeyValue.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (*gConfirmOptYes | UPPER_LOWER_CASE_OFFSET)) &&
287 ((PopupType == EfiHiiPopupTypeYesNo) || (PopupType == EfiHiiPopupTypeYesNoCancel)))
289 *UserSelection = EfiHiiPopupSelectionYes;
291 }
else if (((KeyValue.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (*gConfirmOptNo| UPPER_LOWER_CASE_OFFSET)) &&
292 ((PopupType == EfiHiiPopupTypeYesNo) || (PopupType == EfiHiiPopupTypeYesNoCancel)))
294 *UserSelection = EfiHiiPopupSelectionNo;
296 }
else if (((KeyValue.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (*gConfirmOptOk | UPPER_LOWER_CASE_OFFSET)) &&
297 ((PopupType == EfiHiiPopupTypeOk) || (PopupType == EfiHiiPopupTypeOkCancel)))
299 *UserSelection = EfiHiiPopupSelectionOk;
301 }
else if (((KeyValue.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (*gConfirmOptCancel| UPPER_LOWER_CASE_OFFSET)) &&
302 ((PopupType == EfiHiiPopupTypeOkCancel) || (PopupType == EfiHiiPopupTypeYesNoCancel)))
304 *UserSelection = EfiHiiPopupSelectionCancel;
338 for (StrOffset = 0; String[StrOffset] != CHAR_NULL; StrOffset++) {
339 switch (String[StrOffset]) {
347 StringWidth += CharWidth;
348 if (StringWidth >= MaxWidth) {
375 IN CHAR16 *InputString,
376 OUT CHAR16 **OutputString,
383 if ((InputString ==
NULL) || (Index ==
NULL) || (OutputString ==
NULL)) {
393 InputString[*Index + StrOffset] != CHAR_CARRIAGE_RETURN && InputString[*Index + StrOffset] != CHAR_LINEFEED && InputString[*Index + StrOffset] != CHAR_NULL;
402 if ((StrOffset == 0) && (InputString[*Index + StrOffset] == CHAR_NULL)) {
410 if (*OutputString ==
NULL) {
414 CopyMem ((*OutputString), &InputString[*Index], StrOffset *
sizeof (CHAR16));
420 if (InputString[*Index + StrOffset] == CHAR_LINEFEED) {
424 if (InputString[*Index + StrOffset + 1] == CHAR_CARRIAGE_RETURN) {
425 *Index = (*Index + StrOffset + 2);
427 *Index = (*Index + StrOffset + 1);
429 }
else if (InputString[*Index + StrOffset] == CHAR_CARRIAGE_RETURN) {
433 if (InputString[*Index + StrOffset + 1] == CHAR_LINEFEED) {
434 *Index = (*Index + StrOffset + 2);
436 *Index = (*Index + StrOffset + 1);
439 *Index = (*Index + StrOffset);
442 return StrOffset + 1;
454 IN EFI_HII_POPUP_TYPE PopupType,
458 CHAR16 *OutputString;
460 UINTN OutputStrWidth;
461 UINTN OptionRowWidth;
470 for (StringIndex = 0;
ParseMessageString (gMessageString, &OutputString, &OutputStrWidth, &StringIndex) != 0;) {
472 if (gMaxRowWidth < OutputStrWidth) {
473 gMaxRowWidth = OutputStrWidth;
482 if (PopupType == EfiHiiPopupTypeOk) {
483 OptionRowWidth = USER_SELECTABLE_OPTION_SKIP_WIDTH *2 + USER_SELECTABLE_OPTION_OK_WIDTH;
484 }
else if (PopupType == EfiHiiPopupTypeOkCancel) {
485 OptionRowWidth = USER_SELECTABLE_OPTION_SKIP_WIDTH *3 + USER_SELECTABLE_OPTION_OK_CAL_WIDTH;
486 }
else if (PopupType == EfiHiiPopupTypeYesNo) {
487 OptionRowWidth = USER_SELECTABLE_OPTION_SKIP_WIDTH *3 + USER_SELECTABLE_OPTION_YES_NO_WIDTH;
488 }
else if (PopupType == EfiHiiPopupTypeYesNoCancel) {
489 OptionRowWidth = USER_SELECTABLE_OPTION_SKIP_WIDTH *4 + USER_SELECTABLE_OPTION_YES_NO_CAL_WIDTH;
492 if (OptionRowWidth > gMaxRowWidth) {
493 gMaxRowWidth = OptionRowWidth;
505 gMaxRowWidth =
MIN (gMaxRowWidth, Columns - 2 * POPUP_BORDER);
506 gMesStrLineNum =
MIN (gMesStrLineNum, Rows -1 - POPUP_FOOTER_HEIGHT - POPUP_HEADER_HEIGHT);
511 ScreenForPopup->LeftColumn = (Columns -2 * POPUP_BORDER - gMaxRowWidth) / 2;
512 ScreenForPopup->RightColumn = ScreenForPopup->LeftColumn + gMaxRowWidth + 2 * POPUP_BORDER - 1;
513 ScreenForPopup->TopRow = (Rows - 1 - POPUP_FOOTER_HEIGHT - POPUP_HEADER_HEIGHT - gMesStrLineNum) / 2;
514 ScreenForPopup->BottomRow = ScreenForPopup->TopRow + gMesStrLineNum + POPUP_FOOTER_HEIGHT + POPUP_HEADER_HEIGHT - 1;
532 IN EFI_HII_POPUP_STYLE PopupStyle
545 CHAR16 *OutputString;
547 UINTN OutputStrWidth;
548 UINTN DrawMesStrRowNum;
550 EndCol = gPopupDimensions.RightColumn;
551 TopRow = gPopupDimensions.TopRow;
552 StartCol = gPopupDimensions.LeftColumn;
553 BottomRow = gPopupDimensions.BottomRow;
554 ColDimension = EndCol - StartCol + 1;
555 DrawMesStrRowNum = 0;
560 Character = BOXDRAW_DOWN_RIGHT;
562 Character = BOXDRAW_HORIZONTAL;
563 for (Index = StartCol; Index + 1 < EndCol; Index++) {
567 Character = BOXDRAW_DOWN_LEFT;
573 Character = BOXDRAW_VERTICAL;
574 DisplayRow = TopRow + POPUP_BORDER;
578 if (PopupStyle == EfiHiiPopupStyleError) {
580 }
else if (PopupStyle == EfiHiiPopupStyleWarning) {
589 DisplayRow = TopRow + POPUP_BORDER + POPUP_STYLE_STRING_HEIGHT;
591 Character = BOXDRAW_HORIZONTAL;
592 for (Index = StartCol + 1; Index < EndCol; Index++) {
596 Character = BOXDRAW_VERTICAL;
603 DisplayRow = TopRow + POPUP_HEADER_HEIGHT;
604 for (Index = DisplayRow, StringIndex = 0;
ParseMessageString (gMessageString, &OutputString, &OutputStrWidth, &StringIndex) != 0 && DrawMesStrRowNum < gMesStrLineNum;) {
608 if (OutputStrWidth > gMaxRowWidth) {
614 if (TempString ==
NULL) {
616 return EFI_OUT_OF_RESOURCES;
619 StrnCpyS (TempString, Length + 1, OutputString, Length - 3);
620 StrCatS (TempString, Length + 1, L
"...");
621 PrintStringAt ((ColDimension - gMaxRowWidth) / 2 + StartCol, Index, TempString);
624 PrintStringAt ((ColDimension - OutputStrWidth) / 2 + StartCol, Index, OutputString);
641 if ((OutputStrWidth > 0) && (DrawMesStrRowNum >= gMesStrLineNum)) {
648 Character = BOXDRAW_VERTICAL;
649 DisplayRow = BottomRow - POPUP_BORDER;
657 Character = BOXDRAW_UP_RIGHT;
659 Character = BOXDRAW_HORIZONTAL;
660 for (Index = StartCol; Index + 1 < EndCol; Index++) {
664 Character = BOXDRAW_UP_LEFT;
690 IN EFI_HII_POPUP_STYLE PopupStyle,
691 IN EFI_HII_POPUP_TYPE PopupType,
693 IN EFI_STRING_ID Message,
694 OUT EFI_HII_POPUP_SELECTION *UserSelection OPTIONAL
701 if ((PopupType < EfiHiiPopupTypeOk) || (PopupType > EfiHiiPopupTypeYesNoCancel)) {
702 return EFI_INVALID_PARAMETER;
705 if ((HiiHandle ==
NULL) || (Message == 0)) {
706 return EFI_INVALID_PARAMETER;
710 if (gMessageString ==
NULL) {
711 return EFI_INVALID_PARAMETER;
718 CopyMem (&SavedConsoleMode, ConOut->Mode, sizeof (SavedConsoleMode));
719 ConOut->EnableCursor (ConOut,
FALSE);
725 if (EFI_ERROR (Status)) {
733 if (EFI_ERROR (Status)) {
743 ConOut->EnableCursor (ConOut, SavedConsoleMode.
CursorVisible);
745 ConOut->SetAttribute (ConOut, SavedConsoleMode.
Attribute);
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
RETURN_STATUS EFIAPI StrCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI StrnCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
UINT8 EFIAPI GetPopupColor(VOID)
VOID EFIAPI ClearLines(IN UINTN LeftColumn, IN UINTN RightColumn, IN UINTN TopRow, IN UINTN BottomRow, IN UINTN TextAttribute)
UINT8 EFIAPI GetHighlightTextColor(VOID)
EFI_STATUS WaitForKeyStroke(OUT EFI_INPUT_KEY *Key)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
#define ASSERT_EFI_ERROR(StatusParameter)
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut