presentation.c
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C语言 代码 · 共 1,477 行 · 第 1/4 页
C
1,477 行
/*++
Copyright (c) 2004 - 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Presentation.c
Abstract:
Some presentation routines.
--*/
#include "Setup.h"
#include "Ui.h"
VOID
ClearLines (
UINTN LeftColumn,
UINTN RightColumn,
UINTN TopRow,
UINTN BottomRow,
UINTN TextAttribute
)
{
CHAR16 *Buffer;
UINTN Row;
//
// For now, allocate an arbitrarily long buffer
//
Buffer = EfiLibAllocateZeroPool (0x10000);
ASSERT (Buffer != NULL);
//
// Set foreground and background as defined
//
gST->ConOut->SetAttribute (gST->ConOut, TextAttribute);
//
// Much faster to buffer the long string instead of print it a character at a time
//
SetUnicodeMem (Buffer, RightColumn - LeftColumn, L' ');
//
// Clear the desired area with the appropriate foreground/background
//
for (Row = TopRow; Row <= BottomRow; Row++) {
PrintStringAt (LeftColumn, Row, Buffer);
}
gST->ConOut->SetCursorPosition (gST->ConOut, LeftColumn, TopRow);
gBS->FreePool (Buffer);
return ;
}
VOID
NewStrCat (
CHAR16 *Destination,
CHAR16 *Source
)
{
UINTN Length;
for (Length = 0; Destination[Length] != 0; Length++)
;
//
// We now have the length of the original string
// We can safely assume for now that we are concatenating a narrow value to this string.
// For instance, the string is "XYZ" and cat'ing ">"
// If this assumption changes, we need to make this routine a bit more complex
//
Destination[Length] = NARROW_CHAR;
Length++;
EfiStrCpy (Destination + Length, Source);
}
UINTN
GetStringWidth (
CHAR16 *String
)
{
UINTN Index;
UINTN Count;
UINTN IncrementValue;
Index = 0;
Count = 0;
IncrementValue = 1;
do {
//
// Advance to the null-terminator or to the first width directive
//
for (;
(String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0);
Index++, Count = Count + IncrementValue
)
;
//
// We hit the null-terminator, we now have a count
//
if (String[Index] == 0) {
break;
}
//
// We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
// and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
//
if (String[Index] == NARROW_CHAR) {
//
// Skip to the next character
//
Index++;
IncrementValue = 1;
} else {
//
// Skip to the next character
//
Index++;
IncrementValue = 2;
}
} while (String[Index] != 0);
//
// Increment by one to include the null-terminator in the size
//
Count++;
return Count * sizeof (CHAR16);
}
VOID
DisplayPageFrame (
VOID
)
{
UINTN Index;
UINT8 Line;
UINT8 Alignment;
CHAR16 Character;
CHAR16 *Buffer;
CHAR16 *StrFrontPageBanner;
SCREEN_DESCRIPTOR LocalScreen;
UINTN Row;
EfiZeroMem (&LocalScreen, sizeof (SCREEN_DESCRIPTOR));
gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &LocalScreen.RightColumn, &LocalScreen.BottomRow);
ClearLines (0, LocalScreen.RightColumn, 0, LocalScreen.BottomRow, KEYHELP_BACKGROUND);
EfiCopyMem (&LocalScreen, &gScreenDimensions, sizeof (SCREEN_DESCRIPTOR));
//
// For now, allocate an arbitrarily long buffer
//
Buffer = EfiLibAllocateZeroPool (0x10000);
ASSERT (Buffer != NULL);
Character = BOXDRAW_HORIZONTAL;
for (Index = 0; Index + 2 < (LocalScreen.RightColumn - LocalScreen.LeftColumn); Index++) {
Buffer[Index] = Character;
}
if (gClassOfVfr == EFI_FRONT_PAGE_SUBCLASS) {
//
// ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
//
ClearLines (
LocalScreen.LeftColumn,
LocalScreen.RightColumn,
LocalScreen.TopRow,
FRONT_PAGE_HEADER_HEIGHT - 1 + LocalScreen.TopRow,
BANNER_TEXT | BANNER_BACKGROUND
);
//
// for (Line = 0; Line < BANNER_HEIGHT; Line++) {
//
for (Line = (UINT8) LocalScreen.TopRow; Line < BANNER_HEIGHT + (UINT8) LocalScreen.TopRow; Line++) {
//
// for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
//
for (Alignment = (UINT8) LocalScreen.LeftColumn;
Alignment < BANNER_COLUMNS + (UINT8) LocalScreen.LeftColumn;
Alignment++
) {
if (BannerData->Banner[Line - (UINT8) LocalScreen.TopRow][Alignment - (UINT8) LocalScreen.LeftColumn] != 0x0000) {
StrFrontPageBanner = GetToken (
BannerData->Banner[Line - (UINT8) LocalScreen.TopRow][Alignment - (UINT8) LocalScreen.LeftColumn],
FrontPageHandle
);
} else {
continue;
}
switch (Alignment - LocalScreen.LeftColumn) {
case 0:
//
// Handle left column
//
PrintStringAt (LocalScreen.LeftColumn, Line, StrFrontPageBanner);
break;
case 1:
//
// Handle center column
//
PrintStringAt (
LocalScreen.LeftColumn + (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3,
Line,
StrFrontPageBanner
);
break;
case 2:
//
// Handle right column
//
PrintStringAt (
LocalScreen.LeftColumn + (LocalScreen.RightColumn - LocalScreen.LeftColumn) * 2 / 3,
Line,
StrFrontPageBanner
);
break;
}
gBS->FreePool (StrFrontPageBanner);
}
}
}
ClearLines (
LocalScreen.LeftColumn,
LocalScreen.RightColumn,
LocalScreen.BottomRow - STATUS_BAR_HEIGHT - FOOTER_HEIGHT,
LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 1,
KEYHELP_TEXT | KEYHELP_BACKGROUND
);
if (gClassOfVfr != EFI_FRONT_PAGE_SUBCLASS) {
ClearLines (
LocalScreen.LeftColumn,
LocalScreen.RightColumn,
LocalScreen.TopRow,
LocalScreen.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 1,
TITLE_TEXT | TITLE_BACKGROUND
);
//
// Print Top border line
// +------------------------------------------------------------------------------+
// ? ?
// +------------------------------------------------------------------------------+
//
Character = BOXDRAW_DOWN_RIGHT;
PrintChar (Character);
PrintString (Buffer);
Character = BOXDRAW_DOWN_LEFT;
PrintChar (Character);
Character = BOXDRAW_VERTICAL;
for (Row = LocalScreen.TopRow + 1; Row <= LocalScreen.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 2; Row++) {
PrintCharAt (LocalScreen.LeftColumn, Row, Character);
PrintCharAt (LocalScreen.RightColumn - 1, Row, Character);
}
Character = BOXDRAW_UP_RIGHT;
PrintCharAt (LocalScreen.LeftColumn, LocalScreen.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 1, Character);
PrintString (Buffer);
Character = BOXDRAW_UP_LEFT;
PrintChar (Character);
if (gClassOfVfr == EFI_SETUP_APPLICATION_SUBCLASS) {
//
// Print Bottom border line
// +------------------------------------------------------------------------------+
// ? ?
// +------------------------------------------------------------------------------+
//
Character = BOXDRAW_DOWN_RIGHT;
PrintCharAt (LocalScreen.LeftColumn, LocalScreen.BottomRow - STATUS_BAR_HEIGHT - FOOTER_HEIGHT, Character);
PrintString (Buffer);
Character = BOXDRAW_DOWN_LEFT;
PrintChar (Character);
Character = BOXDRAW_VERTICAL;
for (Row = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - FOOTER_HEIGHT + 1;
Row <= LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 2;
Row++
) {
PrintCharAt (LocalScreen.LeftColumn, Row, Character);
PrintCharAt (LocalScreen.RightColumn - 1, Row, Character);
}
Character = BOXDRAW_UP_RIGHT;
PrintCharAt (LocalScreen.LeftColumn, LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 1, Character);
PrintString (Buffer);
Character = BOXDRAW_UP_LEFT;
PrintChar (Character);
}
}
gBS->FreePool (Buffer);
}
/*
+------------------------------------------------------------------------------+
?F2=Previous Page Setup Page ?
+------------------------------------------------------------------------------+
+------------------------------------------------------------------------------+
?F1=Scroll Help F9=Reset to Defaults F10=Save and Exit ?
| ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Discard Changes |
+------------------------------------------------------------------------------+
*/
UI_MENU_OPTION *
DisplayForm (
OUT UI_MENU_OPTION *Selection,
IN UINT16 FormHandle,
IN UINT16 TitleToken,
IN EFI_FORM_TAGS FormTags,
IN EFI_FILE_FORM_TAGS *FileFormTagsHead,
IN UINT8 *CallbackData
)
{
CHAR16 *StringPtr;
UINTN Index;
UINTN Count;
UINT16 MenuItemCount;
EFI_HII_HANDLE Handle;
UINT16 FormId;
STRING_REF String;
EFI_FILE_FORM_TAGS *FileFormTags;
BOOLEAN SuppressIf;
BOOLEAN Suppress;
BOOLEAN GrayOut;
BOOLEAN Conditional;
SCREEN_DESCRIPTOR LocalScreen;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?