From 84547aa4c612f700211286ced861b56d8527356d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 29 Oct 2007 11:00:31 +0000 Subject: [PATCH] Add a virtual function table for UI, as already done for machine functions. This leads to simplification of initialization phase, remove some corner cases and (now) unneeded variables. This also lead to always have a UI to display messages (even maybe as simple as a printf() ) svn path=/trunk/; revision=29947 --- reactos/boot/freeldr/freeldr/bootmgr.c | 7 - reactos/boot/freeldr/freeldr/freeldr.c | 8 +- .../boot/freeldr/freeldr/freeldr_arch.rbuild | 1 + .../boot/freeldr/freeldr/freeldr_base.rbuild | 2 + .../boot/freeldr/freeldr/include/freeldr.h | 6 +- reactos/boot/freeldr/freeldr/include/ui.h | 87 ++++- reactos/boot/freeldr/freeldr/include/ui/gui.h | 2 +- .../boot/freeldr/freeldr/include/ui/minitui.h | 33 ++ .../boot/freeldr/freeldr/include/ui/noui.h | 51 +++ reactos/boot/freeldr/freeldr/include/ui/tui.h | 56 +-- .../boot/freeldr/freeldr/reactos/setupldr.c | 41 +-- reactos/boot/freeldr/freeldr/ui/gui.c | 24 ++ reactos/boot/freeldr/freeldr/ui/minitui.c | 156 ++++++++ reactos/boot/freeldr/freeldr/ui/noui.c | 120 +++++++ reactos/boot/freeldr/freeldr/ui/tui.c | 114 +++--- reactos/boot/freeldr/freeldr/ui/tuimenu.c | 61 +--- reactos/boot/freeldr/freeldr/ui/ui.c | 337 +++++------------- 17 files changed, 623 insertions(+), 483 deletions(-) create mode 100644 reactos/boot/freeldr/freeldr/include/ui/minitui.h create mode 100644 reactos/boot/freeldr/freeldr/include/ui/noui.h create mode 100644 reactos/boot/freeldr/freeldr/ui/minitui.c create mode 100644 reactos/boot/freeldr/freeldr/ui/noui.c diff --git a/reactos/boot/freeldr/freeldr/bootmgr.c b/reactos/boot/freeldr/freeldr/bootmgr.c index ac0dd3fee5c..4c74a1d8e15 100644 --- a/reactos/boot/freeldr/freeldr/bootmgr.c +++ b/reactos/boot/freeldr/freeldr/bootmgr.c @@ -83,12 +83,6 @@ VOID RunLoader(VOID) for (;;) { - /* If Timeout is 0, don't even bother loading any gui */ - if (!UserInterfaceUp) { - SelectedOperatingSystem = DefaultOperatingSystem; - goto NoGui; - } - // Redraw the backdrop UiDrawBackdrop(); @@ -99,7 +93,6 @@ VOID RunLoader(VOID) goto reboot; } -NoGui: TimeOut = -1; // Try to open the operating system section in the .ini file diff --git a/reactos/boot/freeldr/freeldr/freeldr.c b/reactos/boot/freeldr/freeldr/freeldr.c index 55dec88c275..961f1fd9822 100644 --- a/reactos/boot/freeldr/freeldr/freeldr.c +++ b/reactos/boot/freeldr/freeldr/freeldr.c @@ -30,12 +30,18 @@ VOID BootMain(LPSTR CmdLine) DbgPrint((DPRINT_WARNING, "BootMain() called.\n")); - if (!MmInitializeMemoryManager()) + if (!UiInitialize(FALSE)) { printf("Press any key to reboot.\n"); MachConsGetCh(); return; } + if (!MmInitializeMemoryManager()) + { + UiMessageBoxCritical("Unable to initialize memory manager"); + return; + } + RunLoader(); } diff --git a/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild b/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild index f93355c55d0..55671d57b77 100644 --- a/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild @@ -84,6 +84,7 @@ hardware.c loader.c mach.c + portio.c video.c diff --git a/reactos/boot/freeldr/freeldr/freeldr_base.rbuild b/reactos/boot/freeldr/freeldr/freeldr_base.rbuild index 221fea26323..bb8de485233 100644 --- a/reactos/boot/freeldr/freeldr/freeldr_base.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr_base.rbuild @@ -55,6 +55,8 @@ gui.c + minitui.c + noui.c tui.c tuimenu.c ui.c diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h index f352a6322cf..e5f503a0e8f 100644 --- a/reactos/boot/freeldr/freeldr/include/freeldr.h +++ b/reactos/boot/freeldr/freeldr/include/freeldr.h @@ -57,8 +57,10 @@ #include #include /* ui support */ -#include #include +#include +#include +#include /* arch files */ #ifdef _X86_ #include @@ -95,8 +97,6 @@ #define Ke386EraseFlags(x) __asm__ __volatile__("pushl $0 ; popfl\n") #endif -extern BOOLEAN UserInterfaceUp; /* Tells us if the user interface is displayed */ - VOID BootMain(LPSTR CmdLine); VOID RunLoader(VOID); diff --git a/reactos/boot/freeldr/freeldr/include/ui.h b/reactos/boot/freeldr/freeldr/include/ui.h index f0fbdb27e0b..d7676ae5109 100644 --- a/reactos/boot/freeldr/freeldr/include/ui.h +++ b/reactos/boot/freeldr/freeldr/include/ui.h @@ -43,12 +43,9 @@ extern UCHAR UiEditBoxBgColor; // Edit box text background color extern CHAR UiTitleBoxTitleText[260]; // Title box's title text -extern BOOLEAN UserInterfaceUp; // Tells us if the user interface is displayed - extern BOOLEAN UiUseSpecialEffects; // Tells us if we should use fade effects extern BOOLEAN UiCenterMenu; extern BOOLEAN UiMenuBox; -extern BOOLEAN UiMinimal; extern CHAR UiTimeText[]; extern BOOLEAN UiDrawTime; @@ -92,10 +89,92 @@ VOID UiFadeOut(VOID); // Fades the screen out // Menu Functions // /////////////////////////////////////////////////////////////////////////////////////// -typedef BOOLEAN (*UiMenuKeyPressFilterCallback)(ULONG KeyPress); + +struct tagUI_MENU_INFO; +typedef struct tagUI_MENU_INFO UI_MENU_INFO, *PUI_MENU_INFO; + +typedef BOOLEAN (*UiMenuKeyPressFilterCallback)(ULONG KeyPress); BOOLEAN UiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter); +/////////////////////////////////////////////////////////////////////////////////////// +// +// UI virtual table +// +/////////////////////////////////////////////////////////////////////////////////////// +typedef struct tagUIVTBL +{ + BOOLEAN (*Initialize)(VOID); + VOID (*UnInitialize)(VOID); + VOID (*DrawBackdrop)(VOID); + VOID (*FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr); + VOID (*DrawShadow)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); + VOID (*DrawBox)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr); + VOID (*DrawText)(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr); + VOID (*DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr); + VOID (*DrawStatusText)(PCSTR StatusText); + VOID (*UpdateDateTime)(VOID); + VOID (*MessageBox)(PCSTR MessageText); + VOID (*MessageBoxCritical)(PCSTR MessageText); + VOID (*DrawProgressBarCenter)(ULONG Position, ULONG Range, PCHAR ProgressText); + VOID (*DrawProgressBar)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText); + BOOLEAN (*EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length); + UCHAR (*TextToColor)(PCSTR ColorText); + UCHAR (*TextToFillStyle)(PCSTR FillStyleText); + VOID (*FadeInBackdrop)(VOID); + VOID (*FadeOut)(VOID); + + BOOLEAN (*DisplayMenu)(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter); + VOID (*DrawMenu)(PUI_MENU_INFO MenuInfo); +} UIVTBL, *PUIVTBL; + +VOID UiInit(const char *CmdLine); + +extern UIVTBL UiVtbl; + +/* + * Combines the foreground and background colors into a single attribute byte + */ +#define ATTR(cFore, cBack) ((cBack << 4)|cFore) + +/* + * Fill styles for DrawBackdrop() + */ +#define LIGHT_FILL 0xB0 +#define MEDIUM_FILL 0xB1 +#define DARK_FILL 0xB2 + +/* + * Screen colors + */ +#define COLOR_BLACK 0 +#define COLOR_BLUE 1 +#define COLOR_GREEN 2 +#define COLOR_CYAN 3 +#define COLOR_RED 4 +#define COLOR_MAGENTA 5 +#define COLOR_BROWN 6 +#define COLOR_GRAY 7 + +#define COLOR_DARKGRAY 8 +#define COLOR_LIGHTBLUE 9 +#define COLOR_LIGHTGREEN 10 +#define COLOR_LIGHTCYAN 11 +#define COLOR_LIGHTRED 12 +#define COLOR_LIGHTMAGENTA 13 +#define COLOR_YELLOW 14 +#define COLOR_WHITE 15 + +/* Add COLOR_BLINK to a background to cause blinking */ +//#define COLOR_BLINK 8 + +/* + * Defines for IBM box drawing characters + */ +#define HORZ (0xc4) /* Single horizontal line */ +#define D_HORZ (0xcd) /* Double horizontal line.*/ +#define VERT (0xb3) /* Single vertical line */ +#define D_VERT (0xba) /* Double vertical line. */ #endif // #defined __UI_H diff --git a/reactos/boot/freeldr/freeldr/include/ui/gui.h b/reactos/boot/freeldr/freeldr/include/ui/gui.h index 4afce273ba3..07983c41a65 100644 --- a/reactos/boot/freeldr/freeldr/include/ui/gui.h +++ b/reactos/boot/freeldr/freeldr/include/ui/gui.h @@ -51,6 +51,6 @@ UCHAR GuiTextToFillStyle(PCSTR FillStyleText); // Converts the text fill into /////////////////////////////////////////////////////////////////////////////////////// BOOLEAN GuiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem); - +extern const UIVTBL GuiVtbl; #endif // #defined __GUI_H diff --git a/reactos/boot/freeldr/freeldr/include/ui/minitui.h b/reactos/boot/freeldr/freeldr/include/ui/minitui.h new file mode 100644 index 00000000000..d20230b25d4 --- /dev/null +++ b/reactos/boot/freeldr/freeldr/include/ui/minitui.h @@ -0,0 +1,33 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: FreeLoader + * FILE: freeldr/include/ui/minitui.h + * PURPOSE: Mini Text UI interface header + * PROGRAMMERS: Hervé Poussineau + */ + +#ifndef __MINITUI_H +#define __MINITUI_H + +/////////////////////////////////////////////////////////////////////////////////////// +// +// Textual User Interface Functions +// +/////////////////////////////////////////////////////////////////////////////////////// + +VOID MiniTuiDrawBackdrop(VOID); +VOID MiniTuiDrawStatusText(PCSTR StatusText); +VOID MiniTuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText); +VOID MiniTuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText); + +/////////////////////////////////////////////////////////////////////////////////////// +// +// Menu Functions +// +/////////////////////////////////////////////////////////////////////////////////////// + +VOID MiniTuiDrawMenu(PUI_MENU_INFO MenuInfo); + +extern const UIVTBL MiniTuiVtbl; + +#endif // #defined __TUI_H diff --git a/reactos/boot/freeldr/freeldr/include/ui/noui.h b/reactos/boot/freeldr/freeldr/include/ui/noui.h new file mode 100644 index 00000000000..df53ce1bdfd --- /dev/null +++ b/reactos/boot/freeldr/freeldr/include/ui/noui.h @@ -0,0 +1,51 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: FreeLoader + * FILE: freeldr/include/ui/noui.h + * PURPOSE: No UI interface header + * PROGRAMMERS: Hervé Poussineau + */ + +#ifndef _NOUI_H_ +#define _NOUI_H_ + +/////////////////////////////////////////////////////////////////////////////////////// +// +// No User Interface Functions +// +/////////////////////////////////////////////////////////////////////////////////////// + +BOOLEAN NoUiInitialize(VOID); +VOID NoUiUnInitialize(VOID); + +VOID NoUiDrawBackdrop(VOID); +VOID NoUiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr); +VOID NoUiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); +VOID NoUiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr); +VOID NoUiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr); +VOID NoUiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr); +VOID NoUiDrawStatusText(PCSTR StatusText); +VOID NoUiUpdateDateTime(VOID); +VOID NoUiMessageBox(PCSTR MessageText); +VOID NoUiMessageBoxCritical(PCSTR MessageText); +VOID NoUiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText); +VOID NoUiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText); +BOOLEAN NoUiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length); +UCHAR NoUiTextToColor(PCSTR ColorText); +UCHAR NoUiTextToFillStyle(PCSTR FillStyleText); +VOID NoUiFadeInBackdrop(VOID); +VOID NoUiFadeOut(VOID); + +BOOLEAN NoUiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter); +VOID NoUiDrawMenu(PUI_MENU_INFO MenuInfo); + +/////////////////////////////////////////////////////////////////////////////////////// +// +// Menu Functions +// +/////////////////////////////////////////////////////////////////////////////////////// + +BOOLEAN NoUiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter); +VOID NoUiDrawMenu(PUI_MENU_INFO MenuInfo); + +#endif /* _NOUI_H_ */ diff --git a/reactos/boot/freeldr/freeldr/include/ui/tui.h b/reactos/boot/freeldr/freeldr/include/ui/tui.h index 3e29cf0eaeb..3058cb4540c 100644 --- a/reactos/boot/freeldr/freeldr/include/ui/tui.h +++ b/reactos/boot/freeldr/freeldr/include/ui/tui.h @@ -59,7 +59,7 @@ VOID TuiFadeOut(VOID); // Fades the screen out // /////////////////////////////////////////////////////////////////////////////////////// -typedef struct +struct tagUI_MENU_INFO { PCSTR *MenuItemList; ULONG MenuItemCount; @@ -71,59 +71,20 @@ typedef struct ULONG Right; ULONG Bottom; -} TUI_MENU_INFO, *PTUI_MENU_INFO; +}; -VOID NTAPI TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo); -VOID NTAPI TuiDrawMenu(PTUI_MENU_INFO MenuInfo); -VOID NTAPI TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo); -VOID NTAPI TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, ULONG MenuItemNumber); -ULONG NTAPI TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter); -BOOLEAN NTAPI TuiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter); +VOID NTAPI TuiCalcMenuBoxSize(PUI_MENU_INFO MenuInfo); +VOID TuiDrawMenu(PUI_MENU_INFO MenuInfo); +VOID NTAPI TuiDrawMenuBox(PUI_MENU_INFO MenuInfo); +VOID NTAPI TuiDrawMenuItem(PUI_MENU_INFO MenuInfo, ULONG MenuItemNumber); +ULONG NTAPI TuiProcessMenuKeyboardEvent(PUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter); +BOOLEAN TuiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter); -/* - * Combines the foreground and background colors into a single attribute byte - */ -#define ATTR(cFore, cBack) ((cBack << 4)|cFore) -/* - * Fill styles for DrawBackdrop() - */ -#define LIGHT_FILL 0xB0 -#define MEDIUM_FILL 0xB1 -#define DARK_FILL 0xB2 -/* - * Screen colors - */ -#define COLOR_BLACK 0 -#define COLOR_BLUE 1 -#define COLOR_GREEN 2 -#define COLOR_CYAN 3 -#define COLOR_RED 4 -#define COLOR_MAGENTA 5 -#define COLOR_BROWN 6 -#define COLOR_GRAY 7 -#define COLOR_DARKGRAY 8 -#define COLOR_LIGHTBLUE 9 -#define COLOR_LIGHTGREEN 10 -#define COLOR_LIGHTCYAN 11 -#define COLOR_LIGHTRED 12 -#define COLOR_LIGHTMAGENTA 13 -#define COLOR_YELLOW 14 -#define COLOR_WHITE 15 -/* Add COLOR_BLINK to a background to cause blinking */ -#define COLOR_BLINK 8 - -/* - * Defines for IBM box drawing characters - */ -#define HORZ (0xc4) /* Single horizontal line */ -#define D_HORZ (0xcd) /* Double horizontal line.*/ -#define VERT (0xb3) /* Single vertical line */ -#define D_VERT (0xba) /* Double vertical line. */ /* Definitions for corners, depending on HORIZ and VERT */ #define UL (0xda) @@ -146,5 +107,6 @@ BOOLEAN NTAPI TuiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG De #define VD_LL (0xd3) #define VD_LR (0xbd) +extern const UIVTBL TuiVtbl; #endif // #defined __TUI_H diff --git a/reactos/boot/freeldr/freeldr/reactos/setupldr.c b/reactos/boot/freeldr/freeldr/reactos/setupldr.c index d6d38fee719..9a572609c6f 100644 --- a/reactos/boot/freeldr/freeldr/reactos/setupldr.c +++ b/reactos/boot/freeldr/freeldr/reactos/setupldr.c @@ -103,9 +103,7 @@ static BOOLEAN LoadNlsFile(PCSTR szSourcePath, PCSTR szFileName, PCSTR szModuleName) { CHAR szFullName[256]; -#ifdef USE_UI CHAR szBuffer[80]; -#endif PFILE FilePointer; PCSTR szShortName; @@ -150,12 +148,8 @@ LoadNlsFile(PCSTR szSourcePath, PCSTR szFileName, PCSTR szModuleName) /* * Update the status bar with the current file */ -#ifdef USE_UI sprintf(szBuffer, "Setup is loading files (%s)", szShortName); UiDrawStatusText(szBuffer); -#else - printf("Reading %s\n", szShortName); -#endif /* Load the driver */ FrLdrLoadModule(FilePointer, szModuleName, NULL); @@ -221,8 +215,8 @@ VOID RunLoader(VOID) #ifdef USE_UI SetupUiInitialize(); - UiDrawStatusText(""); #endif + UiDrawStatusText(""); extern BOOLEAN FrLdrBootType; FrLdrBootType = TRUE; @@ -231,15 +225,9 @@ VOID RunLoader(VOID) RegInitializeRegistry(); /* Detect hardware */ -#ifdef USE_UI UiDrawStatusText("Detecting hardware..."); -#else - printf("Detecting hardware...\n\n"); -#endif MachHwDetect(); -#ifdef USE_UI UiDrawStatusText(""); -#endif /* set boot device */ MachDiskGetBootDevice(&LoaderBlock.BootDevice); @@ -247,11 +235,7 @@ VOID RunLoader(VOID) /* Open boot drive */ if (!FsOpenBootVolume()) { -#ifdef USE_UI UiMessageBox("Failed to open boot drive."); -#else - printf("Failed to open boot drive."); -#endif return; } @@ -338,21 +322,12 @@ for(;;); /* Insert boot disk 2 */ if (MachDiskBootingFromFloppy()) { -#ifdef USE_UI UiMessageBox("Please insert \"ReactOS Boot Disk 2\" and press ENTER"); -#else - printf("\n\n Please insert \"ReactOS Boot Disk 2\" and press ENTER\n"); - MachConsGetCh(); -#endif /* Open boot drive */ if (!FsOpenBootVolume()) { -#ifdef USE_UI UiMessageBox("Failed to open boot drive."); -#else - printf("Failed to open boot drive."); -#endif return; } @@ -381,11 +356,7 @@ for(;;); /* Load ANSI codepage file */ if (!LoadNlsFile(SourcePath, LoadOptions, "ansi.nls")) { -#ifdef USE_UI UiMessageBox("Failed to load the ANSI codepage file."); -#else - printf("Failed to load the ANSI codepage file."); -#endif return; } @@ -410,11 +381,7 @@ for(;;); /* Load OEM codepage file */ if (!LoadNlsFile(SourcePath, LoadOptions, "oem.nls")) { -#ifdef USE_UI UiMessageBox("Failed to load the OEM codepage file."); -#else - printf("Failed to load the OEM codepage file."); -#endif return; } @@ -439,11 +406,7 @@ for(;;); /* Load Unicode casemap file */ if (!LoadNlsFile(SourcePath, LoadOptions, "casemap.nls")) { -#ifdef USE_UI UiMessageBox("Failed to load the Unicode casemap file."); -#else - printf("Failed to load the Unicode casemap file."); -#endif return; } @@ -480,9 +443,7 @@ for(;;); } while (InfFindNextLine(&InfContext, &InfContext)); } -#ifdef USE_UI UiUnInitialize("Booting ReactOS..."); -#endif /* Now boot the kernel */ DiskStopFloppyMotor(); diff --git a/reactos/boot/freeldr/freeldr/ui/gui.c b/reactos/boot/freeldr/freeldr/ui/gui.c index 9465512f6e0..556d3e077c5 100644 --- a/reactos/boot/freeldr/freeldr/ui/gui.c +++ b/reactos/boot/freeldr/freeldr/ui/gui.c @@ -76,3 +76,27 @@ UCHAR GuiTextToFillStyle(PCSTR FillStyleText) { return 0; } + +const UIVTBL GuiVtbl = +{ + /*GuiInitialize, + GuiUnInitialize, + GuiDrawBackdrop, + GuiFillArea, + GuiDrawShadow, + GuiDrawBox, + GuiDrawText, + GuiDrawCenteredText, + GuiDrawStatusText, + GuiUpdateDateTime, + GuiMessageBox, + GuiMessageBoxCritical, + GuiDrawProgressBarCenter, + GuiDrawProgressBar, + GuiEditBox, + GuiTextToColor, + GuiTextToFillStyle, + GuiFadeInBackdrop, + GuiFadeOut, + GuiDisplayMenu,*/ +}; diff --git a/reactos/boot/freeldr/freeldr/ui/minitui.c b/reactos/boot/freeldr/freeldr/ui/minitui.c new file mode 100644 index 00000000000..c3f46ea21a1 --- /dev/null +++ b/reactos/boot/freeldr/freeldr/ui/minitui.c @@ -0,0 +1,156 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: FreeLoader + * FILE: freeldr/ui/minitui.c + * PURPOSE: Mini Text UI interface + * PROGRAMMERS: Brian Palmer + * Hervé Poussineau + */ + +#include + +VOID MiniTuiDrawBackdrop(VOID) +{ + // + // Fill in a black background + // + TuiFillArea(0, + 0, + UiScreenWidth - 1, + UiScreenHeight - 1, + 0, + 0); + + // + // Update the screen buffer + // + VideoCopyOffScreenBufferToVRAM(); +} + +VOID MiniTuiDrawStatusText(PCSTR StatusText) +{ + // + // Minimal UI doesn't have a status bar + // +} + +VOID MiniTuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText) +{ + ULONG Left, Top, Right, Bottom; + ULONG Width = 50; // Allow for 50 "bars" + ULONG Height = 2; + + Width = 80; + Left = 0; + Right = Left + Width; + Top = UiScreenHeight - Height - 4; + Bottom = Top + Height + 1; + + MiniTuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText); +} + +VOID MiniTuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText) +{ + ULONG i; + ULONG ProgressBarWidth = (Right - Left) - 3; + + // First make sure the progress bar text fits + UiTruncateStringEllipsis(ProgressText, ProgressBarWidth - 4); + + if (Position > Range) + { + Position = Range; + } + + // + // Draw the "Loading..." text + // + TuiDrawCenteredText(Left + 2, Top + 1, Right - 2, Top + 1, "ReactOS is loading files...", ATTR(7, 0)); + + // Draw the percent complete + for (i=0; i<(Position*ProgressBarWidth)/Range; i++) + { + TuiDrawText(Left+2+i, Top+2, "\xDB", ATTR(UiTextColor, UiMenuBgColor)); + } + + TuiUpdateDateTime(); + VideoCopyOffScreenBufferToVRAM(); +} + +VOID +MiniTuiDrawMenu(PUI_MENU_INFO MenuInfo) +{ + ULONG i; + + // + // Draw the backdrop + // + UiDrawBackdrop(); + + // + // No GUI status bar text, just minimal text. first to tell the user to + // choose. + // + UiVtbl.DrawText(0, + MenuInfo->Top - 2, + "Please select the operating system to start:", + ATTR(UiMenuFgColor, UiMenuBgColor)); + + // + // Now tell him how to choose + // + UiVtbl.DrawText(0, + MenuInfo->Bottom + 1, + "Use the up and down arrow keys to move the highlight to " + "your choice.", + ATTR(UiMenuFgColor, UiMenuBgColor)); + UiVtbl.DrawText(0, + MenuInfo->Bottom + 2, + "Press ENTER to choose.", + ATTR(UiMenuFgColor, UiMenuBgColor)); + + // + // And offer F8 options + // + UiVtbl.DrawText(0, + UiScreenHeight - 4, + "For troubleshooting and advanced startup options for " + "ReactOS, press F8.", + ATTR(UiMenuFgColor, UiMenuBgColor)); + + // + // Draw the menu box + // + TuiDrawMenuBox(MenuInfo); + + // + // Draw each line of the menu + // + for (i = 0; i < MenuInfo->MenuItemCount; i++) TuiDrawMenuItem(MenuInfo, i); + VideoCopyOffScreenBufferToVRAM(); +} + +const UIVTBL MiniTuiVtbl = +{ + TuiInitialize, + TuiUnInitialize, + MiniTuiDrawBackdrop, + TuiFillArea, + TuiDrawShadow, + TuiDrawBox, + TuiDrawText, + TuiDrawCenteredText, + MiniTuiDrawStatusText, + TuiUpdateDateTime, + TuiMessageBox, + TuiMessageBoxCritical, + MiniTuiDrawProgressBarCenter, + MiniTuiDrawProgressBar, + TuiEditBox, + TuiTextToColor, + TuiTextToFillStyle, + TuiFadeInBackdrop, + TuiFadeOut, + TuiDisplayMenu, + MiniTuiDrawMenu, +}; diff --git a/reactos/boot/freeldr/freeldr/ui/noui.c b/reactos/boot/freeldr/freeldr/ui/noui.c new file mode 100644 index 00000000000..cb64878b496 --- /dev/null +++ b/reactos/boot/freeldr/freeldr/ui/noui.c @@ -0,0 +1,120 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: FreeLoader + * FILE: freeldr/ui/noui.c + * PURPOSE: No Text UI interface + * PROGRAMMERS: Hervé Poussineau + */ + +#include + +BOOLEAN NoUiInitialize(VOID) +{ + return TRUE; +} + +VOID NoUiUnInitialize(VOID) +{ +} + +VOID NoUiDrawBackdrop(VOID) +{ +} + +VOID NoUiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr) +{ +} + +VOID NoUiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom) +{ +} + +VOID NoUiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr) +{ +} + +VOID NoUiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr) +{ +} + +VOID NoUiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr) +{ +} + +VOID NoUiDrawStatusText(PCSTR StatusText) +{ + printf(StatusText); +} + +VOID NoUiUpdateDateTime(VOID) +{ +} + +VOID NoUiMessageBox(PCSTR MessageText) +{ + // We have not yet displayed the user interface + // We are probably still reading the .ini file + // and have encountered an error. Just use printf() + // and return. + printf("%s\n", MessageText); + printf("Press any key\n"); + MachConsGetCh(); +} + +VOID NoUiMessageBoxCritical(PCSTR MessageText) +{ + // We have not yet displayed the user interface + // We are probably still reading the .ini file + // and have encountered an error. Just use printf() + // and return. + printf("%s\n", MessageText); + printf("Press any key\n"); + MachConsGetCh(); +} + +VOID NoUiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText) +{ +} + +VOID NoUiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText) +{ +} + +BOOLEAN NoUiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length) +{ + return FALSE; +} + +UCHAR NoUiTextToColor(PCSTR ColorText) +{ + return 0; +} + +UCHAR NoUiTextToFillStyle(PCSTR FillStyleText) +{ + return 0; +} + +VOID NoUiFadeInBackdrop(VOID) +{ +} + +VOID NoUiFadeOut(VOID) +{ +} + +/////////////////////////////////////////////////////////////////////////////////////// +// +// Menu Functions +// +/////////////////////////////////////////////////////////////////////////////////////// + +BOOLEAN NoUiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter) +{ + *SelectedMenuItem = DefaultMenuItem; + return TRUE; +} + +VOID NoUiDrawMenu(PUI_MENU_INFO MenuInfo) +{ +} diff --git a/reactos/boot/freeldr/freeldr/ui/tui.c b/reactos/boot/freeldr/freeldr/ui/tui.c index 17c07dd8947..7ed94e36db2 100644 --- a/reactos/boot/freeldr/freeldr/ui/tui.c +++ b/reactos/boot/freeldr/freeldr/ui/tui.c @@ -20,7 +20,6 @@ #include PVOID TextVideoBuffer = NULL; -extern BOOLEAN UiMinimal; /* * printf() - prints formatted text to stdout @@ -112,25 +111,6 @@ VOID TuiUnInitialize(VOID) VOID TuiDrawBackdrop(VOID) { - if (UiMinimal) - { - // - // Fill in a black background - // - TuiFillArea(0, - 0, - UiScreenWidth - 1, - UiScreenHeight - 1, - 0, - 0); - - // - // Update the screen buffer - // - VideoCopyOffScreenBufferToVRAM(); - return; - } - // // Fill in the background (excluding title box & status bar) // @@ -449,11 +429,6 @@ VOID TuiDrawStatusText(PCSTR StatusText) { ULONG i; - // - // Minimal UI doesn't have a status bar - // - if (UiMinimal) return; - TuiDrawText(0, UiScreenHeight-1, " ", ATTR(UiStatusBarFgColor, UiStatusBarBgColor)); TuiDrawText(1, UiScreenHeight-1, StatusText, ATTR(UiStatusBarFgColor, UiStatusBarBgColor)); @@ -691,28 +666,10 @@ VOID TuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText) ULONG Width = 50; // Allow for 50 "bars" ULONG Height = 2; - // - // Is this the minimal UI? - // - if (UiMinimal) - { - // - // Use alternate settings - // - Width = 80; - Left = 0; - Right = Left + Width; - Top = UiScreenHeight - Height - 4; - Bottom = Top + Height + 1; - } - else - { - Left = (UiScreenWidth - Width - 4) / 2; - Right = Left + Width + 3; - Top = (UiScreenHeight - Height - 2) / 2; - Top += 2; - } - + Left = (UiScreenWidth - Width - 4) / 2; + Right = Left + Width + 3; + Top = (UiScreenHeight - Height - 2) / 2; + Top += 2; Bottom = Top + Height + 1; TuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText); @@ -731,26 +688,13 @@ VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position = Range; } - // - // Minimal UI has no box, and only generic loading text - // - if (!UiMinimal) - { - // Draw the box - TuiDrawBox(Left, Top, Right, Bottom, VERT, HORZ, TRUE, TRUE, ATTR(UiMenuFgColor, UiMenuBgColor)); + // Draw the box + TuiDrawBox(Left, Top, Right, Bottom, VERT, HORZ, TRUE, TRUE, ATTR(UiMenuFgColor, UiMenuBgColor)); - // - // Draw the "Loading..." text - // - TuiDrawCenteredText(Left + 2, Top + 2, Right - 2, Top + 2, ProgressText, ATTR(UiTextColor, UiMenuBgColor)); - } - else - { - // - // Draw the "Loading..." text - // - TuiDrawCenteredText(Left + 2, Top + 1, Right - 2, Top + 1, "ReactOS is loading files...", ATTR(7, 0)); - } + // + // Draw the "Loading..." text + // + TuiDrawCenteredText(Left + 2, Top + 2, Right - 2, Top + 2, ProgressText, ATTR(UiTextColor, UiMenuBgColor)); // Draw the percent complete for (i=0; i<(Position*ProgressBarWidth)/Range; i++) @@ -758,14 +702,11 @@ VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG TuiDrawText(Left+2+i, Top+2, "\xDB", ATTR(UiTextColor, UiMenuBgColor)); } - // Draw the shadow for non-minimal UI - if (!UiMinimal) - { - for (; iTop - 2, - "Please select the operating system to start:", - ATTR(UiMenuFgColor, UiMenuBgColor)); - - // - // Now tell him how to choose - // - TuiDrawText(0, - MenuInfo->Bottom + 1, - "Use the up and down arrow keys to move the highlight to " - "your choice.", - ATTR(UiMenuFgColor, UiMenuBgColor)); - TuiDrawText(0, - MenuInfo->Bottom + 2, - "Press ENTER to choose.", - ATTR(UiMenuFgColor, UiMenuBgColor)); - - // - // And offer F8 options - // - TuiDrawText(0, - UiScreenHeight - 4, - "For troubleshooting and advanced startup options for " - "ReactOS, press F8.", - ATTR(UiMenuFgColor, UiMenuBgColor)); - } - else - { - // - // Update the status bar - // - UiDrawStatusText("Use \x18\x19 to select, then press ENTER."); - } + UiVtbl.DrawStatusText("Use \x18\x19 to select, then press ENTER."); // // Draw the menu box @@ -263,7 +222,7 @@ TuiDrawMenu(PTUI_MENU_INFO MenuInfo) VOID NTAPI -TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo) +TuiDrawMenuBox(PUI_MENU_INFO MenuInfo) { CHAR MenuLineText[80]; CHAR TempString[80]; @@ -361,7 +320,7 @@ TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo) VOID NTAPI -TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, +TuiDrawMenuItem(PUI_MENU_INFO MenuInfo, ULONG MenuItemNumber) { ULONG i; @@ -441,7 +400,7 @@ TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, ULONG NTAPI -TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, +TuiProcessMenuKeyboardEvent(PUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter) { ULONG KeyEvent = 0; @@ -483,7 +442,7 @@ TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, // // It processed the key character, so redraw and exit // - TuiDrawMenu(MenuInfo); + UiVtbl.DrawMenu(MenuInfo); return 0; } diff --git a/reactos/boot/freeldr/freeldr/ui/ui.c b/reactos/boot/freeldr/freeldr/ui/ui.c index 4d2c3f7f5d0..15bb592d257 100644 --- a/reactos/boot/freeldr/freeldr/ui/ui.c +++ b/reactos/boot/freeldr/freeldr/ui/ui.c @@ -21,8 +21,8 @@ #include -ULONG UiScreenWidth = 80; // Screen Width -ULONG UiScreenHeight = 25; // Screen Height +ULONG UiScreenWidth; // Screen Width +ULONG UiScreenHeight; // Screen Height UCHAR UiStatusBarFgColor = COLOR_BLACK; // Status bar foreground color UCHAR UiStatusBarBgColor = COLOR_CYAN; // Status bar background color @@ -43,34 +43,54 @@ UCHAR UiEditBoxBgColor = COLOR_BLACK; // Edit box text background color CHAR UiTitleBoxTitleText[260] = "Boot Menu"; // Title box's title text -BOOLEAN UserInterfaceUp = FALSE; // Tells us if the user interface is displayed - -VIDEODISPLAYMODE UiDisplayMode = VideoTextMode; // Tells us if we are in text or graphics mode - BOOLEAN UiUseSpecialEffects = FALSE; // Tells us if we should use fade effects BOOLEAN UiDrawTime = TRUE; // Tells us if we should draw the time -BOOLEAN UiMinimal = FALSE; // Tells us if we should use a minimal console-like UI BOOLEAN UiCenterMenu = TRUE; // Tells us if we should use a centered or left-aligned menu BOOLEAN UiMenuBox = TRUE; // Tells us if we shuld draw a box around the menu CHAR UiTimeText[260] = "[Time Remaining: ] "; const CHAR UiMonthNames[12][15] = { "January ", "February ", "March ", "April ", "May ", "June ", "July ", "August ", "September ", "October ", "November ", "December " }; +UIVTBL UiVtbl = +{ + NoUiInitialize, + NoUiUnInitialize, + NoUiDrawBackdrop, + NoUiFillArea, + NoUiDrawShadow, + NoUiDrawBox, + NoUiDrawText, + NoUiDrawCenteredText, + NoUiDrawStatusText, + NoUiUpdateDateTime, + NoUiMessageBox, + NoUiMessageBoxCritical, + NoUiDrawProgressBarCenter, + NoUiDrawProgressBar, + NoUiEditBox, + NoUiTextToColor, + NoUiTextToFillStyle, + NoUiFadeInBackdrop, + NoUiFadeOut, + NoUiDisplayMenu, + NoUiDrawMenu, +}; BOOLEAN UiInitialize(BOOLEAN ShowGui) { + VIDEODISPLAYMODE UiDisplayMode; // Tells us if we are in text or graphics mode + BOOLEAN UiMinimal = FALSE; // Tells us if we should use a minimal console-like UI ULONG SectionId; CHAR DisplayModeText[260]; CHAR SettingText[260]; ULONG Depth; if (!ShowGui) { - if (!TuiInitialize()) + if (!UiVtbl.Initialize()) { MachVideoSetDisplayMode(NULL, FALSE); return FALSE; } - UserInterfaceUp = FALSE; return TRUE; } @@ -85,7 +105,35 @@ BOOLEAN UiInitialize(BOOLEAN ShowGui) { DisplayModeText[0] = '\0'; } + if (IniReadSettingByName(SectionId, "MinimalUI", SettingText, sizeof(SettingText))) + { + if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3) + { + UiMinimal = TRUE; + } + else + { + UiMinimal = FALSE; + } + } + } + UiDisplayMode = MachVideoSetDisplayMode(DisplayModeText, TRUE); + MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth); + + if (VideoTextMode == UiDisplayMode) + UiVtbl = UiMinimal ? MiniTuiVtbl : TuiVtbl; + else + UiVtbl = GuiVtbl; + + if (!UiVtbl.Initialize()) + { + MachVideoSetDisplayMode(NULL, FALSE); + return FALSE; + } + + if (IniOpenSection("Display", &SectionId)) + { if (IniReadSettingByName(SectionId, "TitleText", SettingText, sizeof(SettingText))) { strcpy(UiTitleBoxTitleText, SettingText); @@ -180,17 +228,6 @@ BOOLEAN UiInitialize(BOOLEAN ShowGui) UiDrawTime = FALSE; } } - if (IniReadSettingByName(SectionId, "MinimalUI", SettingText, sizeof(SettingText))) - { - if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3) - { - UiMinimal = TRUE; - } - else - { - UiMinimal = FALSE; - } - } if (IniReadSettingByName(SectionId, "MenuBox", SettingText, sizeof(SettingText))) { if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3) @@ -215,40 +252,16 @@ BOOLEAN UiInitialize(BOOLEAN ShowGui) } } - UiDisplayMode = MachVideoSetDisplayMode(DisplayModeText, TRUE); - MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth); - - - if (VideoTextMode == UiDisplayMode) - { - if (!TuiInitialize()) - { - MachVideoSetDisplayMode(NULL, FALSE); - return FALSE; - } - } - else - { - UNIMPLEMENTED(); - //if (!GuiInitialize()) - //{ - // MachSetDisplayMode(NULL, FALSE); - // return FALSE; - //} - } - // Draw the backdrop and fade it in if special effects are enabled UiFadeInBackdrop(); - UserInterfaceUp = TRUE; - DbgPrint((DPRINT_UI, "UiInitialize() returning TRUE.\n")); return TRUE; } BOOLEAN SetupUiInitialize(VOID) { - + VIDEODISPLAYMODE UiDisplayMode; CHAR DisplayModeText[260]; ULONG Depth; @@ -259,10 +272,11 @@ BOOLEAN SetupUiInitialize(VOID) UiDisplayMode = MachVideoSetDisplayMode(DisplayModeText, TRUE); MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth); - TuiInitialize(); + UiVtbl = TuiVtbl; + UiVtbl.Initialize(); // Draw the backdrop and fade it in if special effects are enabled - TuiFillArea(0, + UiVtbl.FillArea(0, 0, UiScreenWidth - 1, UiScreenHeight - 2, @@ -271,10 +285,9 @@ BOOLEAN SetupUiInitialize(VOID) UiDrawTime = FALSE; UiStatusBarBgColor = 7; - UserInterfaceUp = TRUE; - TuiDrawText(4, 1, "ReactOS " KERNEL_VERSION_STR " Setup", ATTR(COLOR_GRAY, UiBackdropBgColor)); - TuiDrawText(3, 2, "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD", ATTR(COLOR_GRAY, UiBackdropBgColor)); + UiVtbl.DrawText(4, 1, "ReactOS " KERNEL_VERSION_STR " Setup", ATTR(COLOR_GRAY, UiBackdropBgColor)); + UiVtbl.DrawText(3, 2, "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD", ATTR(COLOR_GRAY, UiBackdropBgColor)); DbgPrint((DPRINT_UI, "UiInitialize() returning TRUE.\n")); @@ -287,123 +300,47 @@ VOID UiUnInitialize(PCSTR BootText) UiDrawStatusText("Booting..."); UiInfoBox(BootText); - if (VideoTextMode == UiDisplayMode) - { - TuiUnInitialize(); - } - else - { - UNIMPLEMENTED(); - //GuiUnInitialize(); - } + UiVtbl.UnInitialize(); } VOID UiDrawBackdrop(VOID) { - if (!UserInterfaceUp) return; - - if (VideoTextMode == UiDisplayMode) - { - TuiDrawBackdrop(); - } - else - { - UNIMPLEMENTED(); - //GuiDrawBackdrop(); - } + UiVtbl.DrawBackdrop(); } VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr /* Color Attributes */) { - if (VideoTextMode == UiDisplayMode) - { - TuiFillArea(Left, Top, Right, Bottom, FillChar, Attr); - } - else - { - UNIMPLEMENTED(); - //GuiFillArea(Left, Top, Right, Bottom, FillChar, Attr); - } + UiVtbl.FillArea(Left, Top, Right, Bottom, FillChar, Attr); } VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom) { - if (VideoTextMode == UiDisplayMode) - { - TuiDrawShadow(Left, Top, Right, Bottom); - } - else - { - UNIMPLEMENTED(); - //GuiDrawShadow(Left, Top, Right, Bottom); - } + UiVtbl.DrawShadow(Left, Top, Right, Bottom); } VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr) { - if (VideoTextMode == UiDisplayMode) - { - TuiDrawBox(Left, Top, Right, Bottom, VertStyle, HorzStyle, Fill, Shadow, Attr); - } - else - { - UNIMPLEMENTED(); - //GuiDrawBox(Left, Top, Right, Bottom, VertStyle, HorzStyle, Fill, Shadow, Attr); - } + UiVtbl.DrawBox(Left, Top, Right, Bottom, VertStyle, HorzStyle, Fill, Shadow, Attr); } VOID UiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr) { - if (VideoTextMode == UiDisplayMode) - { - TuiDrawText(X, Y, Text, Attr); - } - else - { - UNIMPLEMENTED(); - //GuiDrawText(X, Y, Text, Attr); - } + UiVtbl.DrawText(X, Y, Text, Attr); } VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr) { - if (VideoTextMode == UiDisplayMode) - { - TuiDrawCenteredText(Left, Top, Right, Bottom, TextString, Attr); - } - else - { - UNIMPLEMENTED(); - //GuiDrawCenteredText(Left, Top, Right, Bottom, TextString, Attr); - } + UiVtbl.DrawCenteredText(Left, Top, Right, Bottom, TextString, Attr); } VOID UiDrawStatusText(PCSTR StatusText) { - if (!UserInterfaceUp) return; - - if (VideoTextMode == UiDisplayMode) - { - TuiDrawStatusText(StatusText); - } - else - { - UNIMPLEMENTED(); - //GuiDrawStatusText(StatusText); - } + UiVtbl.DrawStatusText(StatusText); } VOID UiUpdateDateTime(VOID) { - if (VideoTextMode == UiDisplayMode) - { - TuiUpdateDateTime(); - } - else - { - UNIMPLEMENTED(); - //GuiUpdateDateTime(); - } + UiVtbl.UpdateDateTime(); } VOID UiInfoBox(PCSTR MessageText) @@ -469,108 +406,32 @@ VOID UiInfoBox(PCSTR MessageText) VOID UiMessageBox(PCSTR MessageText) { - // We have not yet displayed the user interface - // We are probably still reading the .ini file - // and have encountered an error. Just use printf() - // and return. - if (!UserInterfaceUp) - { - printf("%s\n", MessageText); - printf("Press any key\n"); - MachConsGetCh(); - return; - } - - if (VideoTextMode == UiDisplayMode) - { - TuiMessageBox(MessageText); - } - else - { - UNIMPLEMENTED(); - //GuiMessageBox(MessageText); - } + UiVtbl.MessageBox(MessageText); } VOID UiMessageBoxCritical(PCSTR MessageText) { - // We have not yet displayed the user interface - // We are probably still reading the .ini file - // and have encountered an error. Just use printf() - // and return. - if (!UserInterfaceUp) - { - printf("%s\n", MessageText); - printf("Press any key\n"); - MachConsGetCh(); - return; - } - - if (VideoTextMode == UiDisplayMode) - { - TuiMessageBoxCritical(MessageText); - } - else - { - UNIMPLEMENTED(); - //GuiMessageBoxCritical(MessageText); - } + UiVtbl.MessageBoxCritical(MessageText); } UCHAR UiTextToColor(PCSTR ColorText) { - if (VideoTextMode == UiDisplayMode) - { - return TuiTextToColor(ColorText); - } - else - { - UNIMPLEMENTED(); - return 0; - //return GuiTextToColor(ColorText); - } + return UiVtbl.TextToColor(ColorText); } UCHAR UiTextToFillStyle(PCSTR FillStyleText) { - if (VideoTextMode == UiDisplayMode) - { - return TuiTextToFillStyle(FillStyleText); - } - else - { - UNIMPLEMENTED(); - return 0; - //return GuiTextToFillStyle(FillStyleText); - } + return UiVtbl.TextToFillStyle(FillStyleText); } VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText) { - if (!UserInterfaceUp) return; - - if (VideoTextMode == UiDisplayMode) - { - TuiDrawProgressBarCenter(Position, Range, ProgressText); - } - else - { - UNIMPLEMENTED(); - //GuiDrawProgressBarCenter(Position, Range, ProgressText); - } + UiVtbl.DrawProgressBarCenter(Position, Range, ProgressText); } VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText) { - if (VideoTextMode == UiDisplayMode) - { - TuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText); - } - else - { - UNIMPLEMENTED(); - //GuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText); - } + UiVtbl.DrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText); } VOID UiShowMessageBoxesInSection(PCSTR SectionName) @@ -653,54 +514,20 @@ VOID UiTruncateStringEllipsis(PCHAR StringText, ULONG MaxChars) BOOLEAN UiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter) { - if (VideoTextMode == UiDisplayMode) - { - return TuiDisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem, CanEscape, KeyPressFilter); - } - else - { - UNIMPLEMENTED(); - return FALSE; - //return GuiDisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem, CanEscape, KeyPressFilter); - } + return UiVtbl.DisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem, CanEscape, KeyPressFilter); } VOID UiFadeInBackdrop(VOID) { - if (VideoTextMode == UiDisplayMode) - { - TuiFadeInBackdrop(); - } - else - { - UNIMPLEMENTED(); - //GuiFadeInBackdrop(); - } + UiVtbl.FadeInBackdrop(); } VOID UiFadeOut(VOID) { - if (VideoTextMode == UiDisplayMode) - { - TuiFadeOut(); - } - else - { - UNIMPLEMENTED(); - //GuiFadeInOut(); - } + UiVtbl.FadeOut(); } BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length) { - if (VideoTextMode == UiDisplayMode) - { - return TuiEditBox(MessageText, EditTextBuffer, Length); - } - else - { - UNIMPLEMENTED(); - return FALSE; - //return GuiEditBox(MessageText, EditTextBuffer, Length); - } + return UiVtbl.EditBox(MessageText, EditTextBuffer, Length); }