EFI_STATUS ClearArea ( IN UINTN Col0, IN UINTN Row0, IN UINTN Col1, IN UINTN Row1, IN UINTN TextAttribute ) { EFI_STATUS Status; CHAR16 Buffer[EFI_MAX_LINE_LENGTH+1]; UINTN Index; UINTN Y0; UINTN X0; UINTN Y1; UINTN X1; X0 = Col0; Y0 = Row0; X1 = Col1; Y1 = Row1; Status = ST->ConOut->SetAttribute (ST->ConOut,TextAttribute); for (Index = 0; Index < X1 - X0 + 1; Index++) { Buffer[Index] = L' '; } Buffer[Index] = L'\0'; for (Index = 0; Index < Y1 - Y0 + 1; Index++) { ST->ConOut->SetCursorPosition(ST->ConOut, X0, Y0 + Index); Status = TestPrintAt (X0, Y0 + Index, Buffer); if (EFI_ERROR (Status)) { break; } } return Status; }
EFI_STATUS DialogRefresh ( IN EFI_DIALOG *Dialog, IN EFI_DIALOG_CONTEXT *Context, IN BOOLEAN RefreshAll ) /*++ Routine Description: refresh the Dialog. Arguments: FileDialog - The EFI_FILE_DIALOG instance pointer. Returns: EFI_SUCCESS - the FileDialog was rendered successfully. EFI_INVALID_PARAMETER - the Parameter is Invalid --*/ { UINTN Index; UINTN SubIndex; CHAR16 Buffer[EFI_MAX_LINE_LENGTH +1 ]; UINTN X0; UINTN Y0; UINTN X1; UINTN Y1; EFI_STATUS Status; if (Dialog == NULL) { return EFI_INVALID_PARAMETER; } if (Context == NULL) { return EFI_INVALID_PARAMETER; } X0 = Dialog->BodyRect.TopLeft.Col; Y0 = Dialog->BodyRect.TopLeft.Row; X1 = Dialog->BodyRect.BottomRight.Col; Y1 = Dialog->BodyRect.BottomRight.Row; if ((X1 < X0 + 15) || (Y1 < Y0 + 5)) { return EFI_INVALID_PARAMETER; } Status = EFI_SUCCESS; ST->ConOut->EnableCursor ( ST->ConOut, FALSE ); ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(Dialog->ForeColor, Dialog->BackColor) ); if (RefreshAll) { for (Index = 0; Index < X1 - X0 + 1; Index++) { Buffer[Index] = L' '; } Buffer[Index] = L'\0'; // //clear the Dialog Rect Area. // for (SubIndex = Y0; SubIndex <= Y1; SubIndex++) { Status = TestPrintAt (X0, SubIndex, Buffer); if (EFI_ERROR(Status)) { return Status; } } // //display the title // if (Dialog->Title != NULL) { Status = DisplayMessage(X0 + 4, Y0 + 1, X1 - 3, Y1 - 4, Dialog->Title); } if (EFI_ERROR (Status)) { return Status; } // // than we draw the four corner. // Buffer[1] = L'\0'; Buffer[0] = BOXDRAW_DOWN_RIGHT; Status = TestPrintAt (X0, Y0, Buffer); if (EFI_ERROR (Status)) { return Status; } Buffer[0] = BOXDRAW_UP_RIGHT; Status = TestPrintAt (X0, Y1, Buffer); if (EFI_ERROR (Status)) { return Status; } Buffer[0] = BOXDRAW_DOWN_LEFT; Status = TestPrintAt (X1, Y0, Buffer); if (EFI_ERROR (Status)) { return Status; } Buffer[0] = BOXDRAW_UP_LEFT; Status = TestPrintAt (X1, Y1, Buffer); if (EFI_ERROR (Status) ) { return Status; } // //draw left-right line. // for (Index = 0; Index < X1 - X0 - 1; Index++) { Buffer[Index] = BOXDRAW_HORIZONTAL; } Buffer[Index] = L'\0'; Status = TestPrintAt (X0 + 1, Y0, Buffer); if (EFI_ERROR (Status)) { return Status; } Status = TestPrintAt (X0 + 1 , Y1, Buffer); if (EFI_ERROR (Status)) { return Status; } // //draw up-down line. // Buffer[0] = BOXDRAW_VERTICAL; Buffer[1] = L'\0'; for (Index= Y0 + 1; Index < Y1; Index++) { Status = TestPrintAt (X0, Index, Buffer); if (EFI_ERROR (Status) ) { return Status; } Status = TestPrintAt (X1, Index, Buffer); if (EFI_ERROR (Status) ) { return Status; } } if (Context->Type == EFI_DIALOG_TYPE_MESSAGE) { StrCpy (Buffer, L"[ OK ]"); Status = TestPrintAt (X0 + (X1 - X0) / 2 - 2 , Y1 - 2, Buffer); } if (Context->Type == EFI_DIALOG_TYPE_YES_OR_NO) { if (Context -> ChooseNumber == 1) { StrCpy (Buffer, L"[ No ]"); Status = TestPrintAt (X0 + (X1 - X0) / 4 * 3 - 4, Y1 - 2, Buffer); if (EFI_ERROR (Status)) { return Status; } ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(EFI_YELLOW, Dialog->BackColor) ); StrCpy (Buffer, L"[ Yes ]"); Status = TestPrintAt (X0+ (X1 - X0) / 4 - 2, Y1 - 2, Buffer); if (EFI_ERROR (Status)) { return Status; } ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(Dialog->ForeColor, Dialog->BackColor) ); } else { StrCpy (Buffer, L"[ Yes ]"); Status = TestPrintAt (X0 + (X1 - X0) / 4 - 2, Y1 - 2, Buffer); if (EFI_ERROR (Status)) { return Status; } ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(EFI_YELLOW, Dialog->BackColor) ); StrCpy (Buffer, L"[ No ]"); Status = TestPrintAt (X0 + (X1 - X0) / 4 * 3 - 4, Y1 - 2, Buffer); if (EFI_ERROR (Status)) { return Status; } ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(Dialog->ForeColor, Dialog->BackColor) ); } } } else { ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(Dialog->ForeColor, Dialog->BackColor) ); if (Context -> ChooseNumber == 1) { StrCpy (Buffer, L"[ No ]"); Status = TestPrintAt (X0 + (X1 - X0) / 4 * 3 - 4, Y1 - 2, Buffer); if (EFI_ERROR (Status)) { return Status; } ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(EFI_YELLOW, Dialog->BackColor) ); StrCpy (Buffer, L"[ Yes ]"); Status = TestPrintAt (X0 + (X1 - X0) / 4 - 2 , Y1 - 2, Buffer); if (EFI_ERROR (Status)) { return Status; } ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(Dialog->ForeColor, Dialog->BackColor) ); } else { StrCpy (Buffer, L"[ Yes ]"); Status = TestPrintAt (X0 + (X1 - X0) / 4 - 2, Y1 - 2, Buffer); if (EFI_ERROR (Status)) { return Status; } ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(EFI_YELLOW, Dialog->BackColor) ); StrCpy (Buffer, L"[ No ]"); Status = TestPrintAt (X0 + (X1 - X0) / 4 * 3 - 4, Y1 - 2, Buffer); if (EFI_ERROR (Status)) { return Status; } ST->ConOut->SetAttribute ( ST->ConOut, EFI_TEXT_ATTR(Dialog->ForeColor, Dialog->BackColor) ); } } return Status; }