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
This commit is contained in:
Hervé Poussineau 2007-10-29 11:00:31 +00:00
parent e2cdcc5958
commit 84547aa4c6
17 changed files with 623 additions and 483 deletions

View file

@ -83,12 +83,6 @@ VOID RunLoader(VOID)
for (;;) for (;;)
{ {
/* If Timeout is 0, don't even bother loading any gui */
if (!UserInterfaceUp) {
SelectedOperatingSystem = DefaultOperatingSystem;
goto NoGui;
}
// Redraw the backdrop // Redraw the backdrop
UiDrawBackdrop(); UiDrawBackdrop();
@ -99,7 +93,6 @@ VOID RunLoader(VOID)
goto reboot; goto reboot;
} }
NoGui:
TimeOut = -1; TimeOut = -1;
// Try to open the operating system section in the .ini file // Try to open the operating system section in the .ini file

View file

@ -30,12 +30,18 @@ VOID BootMain(LPSTR CmdLine)
DbgPrint((DPRINT_WARNING, "BootMain() called.\n")); DbgPrint((DPRINT_WARNING, "BootMain() called.\n"));
if (!MmInitializeMemoryManager()) if (!UiInitialize(FALSE))
{ {
printf("Press any key to reboot.\n"); printf("Press any key to reboot.\n");
MachConsGetCh(); MachConsGetCh();
return; return;
} }
if (!MmInitializeMemoryManager())
{
UiMessageBoxCritical("Unable to initialize memory manager");
return;
}
RunLoader(); RunLoader();
} }

View file

@ -84,6 +84,7 @@
<file>hardware.c</file> <file>hardware.c</file>
<file>loader.c</file> <file>loader.c</file>
<file>mach.c</file> <file>mach.c</file>
<file>portio.c</file>
<file>video.c</file> <file>video.c</file>
</module> </module>
</if> </if>

View file

@ -55,6 +55,8 @@
</directory> </directory>
<directory name="ui"> <directory name="ui">
<file>gui.c</file> <file>gui.c</file>
<file>minitui.c</file>
<file>noui.c</file>
<file>tui.c</file> <file>tui.c</file>
<file>tuimenu.c</file> <file>tuimenu.c</file>
<file>ui.c</file> <file>ui.c</file>

View file

@ -57,8 +57,10 @@
#include <fs/ntfs.h> #include <fs/ntfs.h>
#include <fs/iso.h> #include <fs/iso.h>
/* ui support */ /* ui support */
#include <ui/tui.h>
#include <ui/gui.h> #include <ui/gui.h>
#include <ui/minitui.h>
#include <ui/noui.h>
#include <ui/tui.h>
/* arch files */ /* arch files */
#ifdef _X86_ #ifdef _X86_
#include <arch/i386/hardware.h> #include <arch/i386/hardware.h>
@ -95,8 +97,6 @@
#define Ke386EraseFlags(x) __asm__ __volatile__("pushl $0 ; popfl\n") #define Ke386EraseFlags(x) __asm__ __volatile__("pushl $0 ; popfl\n")
#endif #endif
extern BOOLEAN UserInterfaceUp; /* Tells us if the user interface is displayed */
VOID BootMain(LPSTR CmdLine); VOID BootMain(LPSTR CmdLine);
VOID RunLoader(VOID); VOID RunLoader(VOID);

View file

@ -43,12 +43,9 @@ extern UCHAR UiEditBoxBgColor; // Edit box text background color
extern CHAR UiTitleBoxTitleText[260]; // Title box's title text 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 UiUseSpecialEffects; // Tells us if we should use fade effects
extern BOOLEAN UiCenterMenu; extern BOOLEAN UiCenterMenu;
extern BOOLEAN UiMenuBox; extern BOOLEAN UiMenuBox;
extern BOOLEAN UiMinimal;
extern CHAR UiTimeText[]; extern CHAR UiTimeText[];
extern BOOLEAN UiDrawTime; extern BOOLEAN UiDrawTime;
@ -92,10 +89,92 @@ VOID UiFadeOut(VOID); // Fades the screen out
// Menu Functions // 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); 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 #endif // #defined __UI_H

View file

@ -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); BOOLEAN GuiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem);
extern const UIVTBL GuiVtbl;
#endif // #defined __GUI_H #endif // #defined __GUI_H

View file

@ -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

View file

@ -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_ */

View file

@ -59,7 +59,7 @@ VOID TuiFadeOut(VOID); // Fades the screen out
// //
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
typedef struct struct tagUI_MENU_INFO
{ {
PCSTR *MenuItemList; PCSTR *MenuItemList;
ULONG MenuItemCount; ULONG MenuItemCount;
@ -71,59 +71,20 @@ typedef struct
ULONG Right; ULONG Right;
ULONG Bottom; ULONG Bottom;
} TUI_MENU_INFO, *PTUI_MENU_INFO; };
VOID NTAPI TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo); VOID NTAPI TuiCalcMenuBoxSize(PUI_MENU_INFO MenuInfo);
VOID NTAPI TuiDrawMenu(PTUI_MENU_INFO MenuInfo); VOID TuiDrawMenu(PUI_MENU_INFO MenuInfo);
VOID NTAPI TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo); VOID NTAPI TuiDrawMenuBox(PUI_MENU_INFO MenuInfo);
VOID NTAPI TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, ULONG MenuItemNumber); VOID NTAPI TuiDrawMenuItem(PUI_MENU_INFO MenuInfo, ULONG MenuItemNumber);
ULONG NTAPI TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter); ULONG NTAPI TuiProcessMenuKeyboardEvent(PUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter);
BOOLEAN NTAPI TuiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, 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 */ /* Definitions for corners, depending on HORIZ and VERT */
#define UL (0xda) #define UL (0xda)
@ -146,5 +107,6 @@ BOOLEAN NTAPI TuiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG De
#define VD_LL (0xd3) #define VD_LL (0xd3)
#define VD_LR (0xbd) #define VD_LR (0xbd)
extern const UIVTBL TuiVtbl;
#endif // #defined __TUI_H #endif // #defined __TUI_H

View file

@ -103,9 +103,7 @@ static BOOLEAN
LoadNlsFile(PCSTR szSourcePath, PCSTR szFileName, PCSTR szModuleName) LoadNlsFile(PCSTR szSourcePath, PCSTR szFileName, PCSTR szModuleName)
{ {
CHAR szFullName[256]; CHAR szFullName[256];
#ifdef USE_UI
CHAR szBuffer[80]; CHAR szBuffer[80];
#endif
PFILE FilePointer; PFILE FilePointer;
PCSTR szShortName; PCSTR szShortName;
@ -150,12 +148,8 @@ LoadNlsFile(PCSTR szSourcePath, PCSTR szFileName, PCSTR szModuleName)
/* /*
* Update the status bar with the current file * Update the status bar with the current file
*/ */
#ifdef USE_UI
sprintf(szBuffer, "Setup is loading files (%s)", szShortName); sprintf(szBuffer, "Setup is loading files (%s)", szShortName);
UiDrawStatusText(szBuffer); UiDrawStatusText(szBuffer);
#else
printf("Reading %s\n", szShortName);
#endif
/* Load the driver */ /* Load the driver */
FrLdrLoadModule(FilePointer, szModuleName, NULL); FrLdrLoadModule(FilePointer, szModuleName, NULL);
@ -221,8 +215,8 @@ VOID RunLoader(VOID)
#ifdef USE_UI #ifdef USE_UI
SetupUiInitialize(); SetupUiInitialize();
UiDrawStatusText("");
#endif #endif
UiDrawStatusText("");
extern BOOLEAN FrLdrBootType; extern BOOLEAN FrLdrBootType;
FrLdrBootType = TRUE; FrLdrBootType = TRUE;
@ -231,15 +225,9 @@ VOID RunLoader(VOID)
RegInitializeRegistry(); RegInitializeRegistry();
/* Detect hardware */ /* Detect hardware */
#ifdef USE_UI
UiDrawStatusText("Detecting hardware..."); UiDrawStatusText("Detecting hardware...");
#else
printf("Detecting hardware...\n\n");
#endif
MachHwDetect(); MachHwDetect();
#ifdef USE_UI
UiDrawStatusText(""); UiDrawStatusText("");
#endif
/* set boot device */ /* set boot device */
MachDiskGetBootDevice(&LoaderBlock.BootDevice); MachDiskGetBootDevice(&LoaderBlock.BootDevice);
@ -247,11 +235,7 @@ VOID RunLoader(VOID)
/* Open boot drive */ /* Open boot drive */
if (!FsOpenBootVolume()) if (!FsOpenBootVolume())
{ {
#ifdef USE_UI
UiMessageBox("Failed to open boot drive."); UiMessageBox("Failed to open boot drive.");
#else
printf("Failed to open boot drive.");
#endif
return; return;
} }
@ -338,21 +322,12 @@ for(;;);
/* Insert boot disk 2 */ /* Insert boot disk 2 */
if (MachDiskBootingFromFloppy()) if (MachDiskBootingFromFloppy())
{ {
#ifdef USE_UI
UiMessageBox("Please insert \"ReactOS Boot Disk 2\" and press ENTER"); 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 */ /* Open boot drive */
if (!FsOpenBootVolume()) if (!FsOpenBootVolume())
{ {
#ifdef USE_UI
UiMessageBox("Failed to open boot drive."); UiMessageBox("Failed to open boot drive.");
#else
printf("Failed to open boot drive.");
#endif
return; return;
} }
@ -381,11 +356,7 @@ for(;;);
/* Load ANSI codepage file */ /* Load ANSI codepage file */
if (!LoadNlsFile(SourcePath, LoadOptions, "ansi.nls")) if (!LoadNlsFile(SourcePath, LoadOptions, "ansi.nls"))
{ {
#ifdef USE_UI
UiMessageBox("Failed to load the ANSI codepage file."); UiMessageBox("Failed to load the ANSI codepage file.");
#else
printf("Failed to load the ANSI codepage file.");
#endif
return; return;
} }
@ -410,11 +381,7 @@ for(;;);
/* Load OEM codepage file */ /* Load OEM codepage file */
if (!LoadNlsFile(SourcePath, LoadOptions, "oem.nls")) if (!LoadNlsFile(SourcePath, LoadOptions, "oem.nls"))
{ {
#ifdef USE_UI
UiMessageBox("Failed to load the OEM codepage file."); UiMessageBox("Failed to load the OEM codepage file.");
#else
printf("Failed to load the OEM codepage file.");
#endif
return; return;
} }
@ -439,11 +406,7 @@ for(;;);
/* Load Unicode casemap file */ /* Load Unicode casemap file */
if (!LoadNlsFile(SourcePath, LoadOptions, "casemap.nls")) if (!LoadNlsFile(SourcePath, LoadOptions, "casemap.nls"))
{ {
#ifdef USE_UI
UiMessageBox("Failed to load the Unicode casemap file."); UiMessageBox("Failed to load the Unicode casemap file.");
#else
printf("Failed to load the Unicode casemap file.");
#endif
return; return;
} }
@ -480,9 +443,7 @@ for(;;);
} while (InfFindNextLine(&InfContext, &InfContext)); } while (InfFindNextLine(&InfContext, &InfContext));
} }
#ifdef USE_UI
UiUnInitialize("Booting ReactOS..."); UiUnInitialize("Booting ReactOS...");
#endif
/* Now boot the kernel */ /* Now boot the kernel */
DiskStopFloppyMotor(); DiskStopFloppyMotor();

View file

@ -76,3 +76,27 @@ UCHAR GuiTextToFillStyle(PCSTR FillStyleText)
{ {
return 0; 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,*/
};

View file

@ -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 <brianp@sginet.com>
* Hervé Poussineau
*/
#include <freeldr.h>
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,
};

View file

@ -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 <freeldr.h>
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)
{
}

View file

@ -20,7 +20,6 @@
#include <freeldr.h> #include <freeldr.h>
PVOID TextVideoBuffer = NULL; PVOID TextVideoBuffer = NULL;
extern BOOLEAN UiMinimal;
/* /*
* printf() - prints formatted text to stdout * printf() - prints formatted text to stdout
@ -112,25 +111,6 @@ VOID TuiUnInitialize(VOID)
VOID TuiDrawBackdrop(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) // Fill in the background (excluding title box & status bar)
// //
@ -449,11 +429,6 @@ VOID TuiDrawStatusText(PCSTR StatusText)
{ {
ULONG i; ULONG i;
//
// Minimal UI doesn't have a status bar
//
if (UiMinimal) return;
TuiDrawText(0, UiScreenHeight-1, " ", ATTR(UiStatusBarFgColor, UiStatusBarBgColor)); TuiDrawText(0, UiScreenHeight-1, " ", ATTR(UiStatusBarFgColor, UiStatusBarBgColor));
TuiDrawText(1, UiScreenHeight-1, StatusText, 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 Width = 50; // Allow for 50 "bars"
ULONG Height = 2; ULONG Height = 2;
// Left = (UiScreenWidth - Width - 4) / 2;
// Is this the minimal UI? Right = Left + Width + 3;
// Top = (UiScreenHeight - Height - 2) / 2;
if (UiMinimal) Top += 2;
{
//
// 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;
}
Bottom = Top + Height + 1; Bottom = Top + Height + 1;
TuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText); 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; Position = Range;
} }
// // Draw the box
// Minimal UI has no box, and only generic loading text TuiDrawBox(Left, Top, Right, Bottom, VERT, HORZ, TRUE, TRUE, ATTR(UiMenuFgColor, UiMenuBgColor));
//
if (!UiMinimal)
{
// Draw the box
TuiDrawBox(Left, Top, Right, Bottom, VERT, HORZ, TRUE, TRUE, ATTR(UiMenuFgColor, UiMenuBgColor));
// //
// Draw the "Loading..." text // Draw the "Loading..." text
// //
TuiDrawCenteredText(Left + 2, Top + 2, Right - 2, Top + 2, ProgressText, ATTR(UiTextColor, UiMenuBgColor)); 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 percent complete // Draw the percent complete
for (i=0; i<(Position*ProgressBarWidth)/Range; i++) 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)); TuiDrawText(Left+2+i, Top+2, "\xDB", ATTR(UiTextColor, UiMenuBgColor));
} }
// Draw the shadow for non-minimal UI // Draw the shadow
if (!UiMinimal) for (; i<ProgressBarWidth; i++)
{ {
for (; i<ProgressBarWidth; i++) TuiDrawText(Left+2+i, Top+2, "\xB2", ATTR(UiTextColor, UiMenuBgColor));
{ }
TuiDrawText(Left+2+i, Top+2, "\xB2", ATTR(UiTextColor, UiMenuBgColor));
}
}
TuiUpdateDateTime(); TuiUpdateDateTime();
VideoCopyOffScreenBufferToVRAM(); VideoCopyOffScreenBufferToVRAM();
@ -1045,3 +986,28 @@ BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
return ReturnCode; return ReturnCode;
} }
const UIVTBL TuiVtbl =
{
TuiInitialize,
TuiUnInitialize,
TuiDrawBackdrop,
TuiFillArea,
TuiDrawShadow,
TuiDrawBox,
TuiDrawText,
TuiDrawCenteredText,
TuiDrawStatusText,
TuiUpdateDateTime,
TuiMessageBox,
TuiMessageBoxCritical,
TuiDrawProgressBarCenter,
TuiDrawProgressBar,
TuiEditBox,
TuiTextToColor,
TuiTextToFillStyle,
TuiFadeInBackdrop,
TuiFadeOut,
TuiDisplayMenu,
TuiDrawMenu,
};

View file

@ -14,7 +14,6 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
BOOLEAN BOOLEAN
NTAPI
TuiDisplayMenu(PCSTR MenuItemList[], TuiDisplayMenu(PCSTR MenuItemList[],
ULONG MenuItemCount, ULONG MenuItemCount,
ULONG DefaultMenuItem, ULONG DefaultMenuItem,
@ -23,7 +22,7 @@ TuiDisplayMenu(PCSTR MenuItemList[],
BOOLEAN CanEscape, BOOLEAN CanEscape,
UiMenuKeyPressFilterCallback KeyPressFilter) UiMenuKeyPressFilterCallback KeyPressFilter)
{ {
TUI_MENU_INFO MenuInformation; UI_MENU_INFO MenuInformation;
ULONG LastClockSecond; ULONG LastClockSecond;
ULONG CurrentClockSecond; ULONG CurrentClockSecond;
ULONG KeyPress; ULONG KeyPress;
@ -55,7 +54,7 @@ TuiDisplayMenu(PCSTR MenuItemList[],
// //
// Draw the menu // Draw the menu
// //
TuiDrawMenu(&MenuInformation); UiVtbl.DrawMenu(&MenuInformation);
// //
// Get the current second of time // Get the current second of time
@ -136,7 +135,7 @@ TuiDisplayMenu(PCSTR MenuItemList[],
VOID VOID
NTAPI NTAPI
TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo) TuiCalcMenuBoxSize(PUI_MENU_INFO MenuInfo)
{ {
ULONG i; ULONG i;
ULONG Width = 0; ULONG Width = 0;
@ -195,8 +194,7 @@ TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo)
} }
VOID VOID
NTAPI TuiDrawMenu(PUI_MENU_INFO MenuInfo)
TuiDrawMenu(PTUI_MENU_INFO MenuInfo)
{ {
ULONG i; ULONG i;
@ -206,48 +204,9 @@ TuiDrawMenu(PTUI_MENU_INFO MenuInfo)
UiDrawBackdrop(); UiDrawBackdrop();
// //
// Check if this is the minimal (console) UI // Update the status bar
// //
if (UiMinimal) UiVtbl.DrawStatusText("Use \x18\x19 to select, then press ENTER.");
{
//
// No GUI status bar text, just minimal text. first to tell the user to
// choose.
//
TuiDrawText(0,
MenuInfo->Top - 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.");
}
// //
// Draw the menu box // Draw the menu box
@ -263,7 +222,7 @@ TuiDrawMenu(PTUI_MENU_INFO MenuInfo)
VOID VOID
NTAPI NTAPI
TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo) TuiDrawMenuBox(PUI_MENU_INFO MenuInfo)
{ {
CHAR MenuLineText[80]; CHAR MenuLineText[80];
CHAR TempString[80]; CHAR TempString[80];
@ -361,7 +320,7 @@ TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
VOID VOID
NTAPI NTAPI
TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, TuiDrawMenuItem(PUI_MENU_INFO MenuInfo,
ULONG MenuItemNumber) ULONG MenuItemNumber)
{ {
ULONG i; ULONG i;
@ -441,7 +400,7 @@ TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo,
ULONG ULONG
NTAPI NTAPI
TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, TuiProcessMenuKeyboardEvent(PUI_MENU_INFO MenuInfo,
UiMenuKeyPressFilterCallback KeyPressFilter) UiMenuKeyPressFilterCallback KeyPressFilter)
{ {
ULONG KeyEvent = 0; ULONG KeyEvent = 0;
@ -483,7 +442,7 @@ TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo,
// //
// It processed the key character, so redraw and exit // It processed the key character, so redraw and exit
// //
TuiDrawMenu(MenuInfo); UiVtbl.DrawMenu(MenuInfo);
return 0; return 0;
} }

View file

@ -21,8 +21,8 @@
#include <debug.h> #include <debug.h>
ULONG UiScreenWidth = 80; // Screen Width ULONG UiScreenWidth; // Screen Width
ULONG UiScreenHeight = 25; // Screen Height ULONG UiScreenHeight; // Screen Height
UCHAR UiStatusBarFgColor = COLOR_BLACK; // Status bar foreground color UCHAR UiStatusBarFgColor = COLOR_BLACK; // Status bar foreground color
UCHAR UiStatusBarBgColor = COLOR_CYAN; // Status bar background 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 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 UiUseSpecialEffects = FALSE; // Tells us if we should use fade effects
BOOLEAN UiDrawTime = TRUE; // Tells us if we should draw the time 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 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 BOOLEAN UiMenuBox = TRUE; // Tells us if we shuld draw a box around the menu
CHAR UiTimeText[260] = "[Time Remaining: ] "; CHAR UiTimeText[260] = "[Time Remaining: ] ";
const CHAR UiMonthNames[12][15] = { "January ", "February ", "March ", "April ", "May ", "June ", "July ", "August ", "September ", "October ", "November ", "December " }; 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) 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; ULONG SectionId;
CHAR DisplayModeText[260]; CHAR DisplayModeText[260];
CHAR SettingText[260]; CHAR SettingText[260];
ULONG Depth; ULONG Depth;
if (!ShowGui) { if (!ShowGui) {
if (!TuiInitialize()) if (!UiVtbl.Initialize())
{ {
MachVideoSetDisplayMode(NULL, FALSE); MachVideoSetDisplayMode(NULL, FALSE);
return FALSE; return FALSE;
} }
UserInterfaceUp = FALSE;
return TRUE; return TRUE;
} }
@ -85,7 +105,35 @@ BOOLEAN UiInitialize(BOOLEAN ShowGui)
{ {
DisplayModeText[0] = '\0'; 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))) if (IniReadSettingByName(SectionId, "TitleText", SettingText, sizeof(SettingText)))
{ {
strcpy(UiTitleBoxTitleText, SettingText); strcpy(UiTitleBoxTitleText, SettingText);
@ -180,17 +228,6 @@ BOOLEAN UiInitialize(BOOLEAN ShowGui)
UiDrawTime = FALSE; 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 (IniReadSettingByName(SectionId, "MenuBox", SettingText, sizeof(SettingText)))
{ {
if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3) 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 // Draw the backdrop and fade it in if special effects are enabled
UiFadeInBackdrop(); UiFadeInBackdrop();
UserInterfaceUp = TRUE;
DbgPrint((DPRINT_UI, "UiInitialize() returning TRUE.\n")); DbgPrint((DPRINT_UI, "UiInitialize() returning TRUE.\n"));
return TRUE; return TRUE;
} }
BOOLEAN SetupUiInitialize(VOID) BOOLEAN SetupUiInitialize(VOID)
{ {
VIDEODISPLAYMODE UiDisplayMode;
CHAR DisplayModeText[260]; CHAR DisplayModeText[260];
ULONG Depth; ULONG Depth;
@ -259,10 +272,11 @@ BOOLEAN SetupUiInitialize(VOID)
UiDisplayMode = MachVideoSetDisplayMode(DisplayModeText, TRUE); UiDisplayMode = MachVideoSetDisplayMode(DisplayModeText, TRUE);
MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth); MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth);
TuiInitialize(); UiVtbl = TuiVtbl;
UiVtbl.Initialize();
// Draw the backdrop and fade it in if special effects are enabled // Draw the backdrop and fade it in if special effects are enabled
TuiFillArea(0, UiVtbl.FillArea(0,
0, 0,
UiScreenWidth - 1, UiScreenWidth - 1,
UiScreenHeight - 2, UiScreenHeight - 2,
@ -271,10 +285,9 @@ BOOLEAN SetupUiInitialize(VOID)
UiDrawTime = FALSE; UiDrawTime = FALSE;
UiStatusBarBgColor = 7; UiStatusBarBgColor = 7;
UserInterfaceUp = TRUE;
TuiDrawText(4, 1, "ReactOS " KERNEL_VERSION_STR " Setup", ATTR(COLOR_GRAY, UiBackdropBgColor)); UiVtbl.DrawText(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(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")); DbgPrint((DPRINT_UI, "UiInitialize() returning TRUE.\n"));
@ -287,123 +300,47 @@ VOID UiUnInitialize(PCSTR BootText)
UiDrawStatusText("Booting..."); UiDrawStatusText("Booting...");
UiInfoBox(BootText); UiInfoBox(BootText);
if (VideoTextMode == UiDisplayMode) UiVtbl.UnInitialize();
{
TuiUnInitialize();
}
else
{
UNIMPLEMENTED();
//GuiUnInitialize();
}
} }
VOID UiDrawBackdrop(VOID) VOID UiDrawBackdrop(VOID)
{ {
if (!UserInterfaceUp) return; UiVtbl.DrawBackdrop();
if (VideoTextMode == UiDisplayMode)
{
TuiDrawBackdrop();
}
else
{
UNIMPLEMENTED();
//GuiDrawBackdrop();
}
} }
VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr /* Color Attributes */) VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr /* Color Attributes */)
{ {
if (VideoTextMode == UiDisplayMode) UiVtbl.FillArea(Left, Top, Right, Bottom, FillChar, Attr);
{
TuiFillArea(Left, Top, Right, Bottom, FillChar, Attr);
}
else
{
UNIMPLEMENTED();
//GuiFillArea(Left, Top, Right, Bottom, FillChar, Attr);
}
} }
VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom) VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
{ {
if (VideoTextMode == UiDisplayMode) UiVtbl.DrawShadow(Left, Top, Right, Bottom);
{
TuiDrawShadow(Left, Top, Right, Bottom);
}
else
{
UNIMPLEMENTED();
//GuiDrawShadow(Left, Top, Right, Bottom);
}
} }
VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr) VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
{ {
if (VideoTextMode == UiDisplayMode) UiVtbl.DrawBox(Left, Top, Right, Bottom, VertStyle, HorzStyle, Fill, Shadow, Attr);
{
TuiDrawBox(Left, Top, Right, Bottom, VertStyle, HorzStyle, Fill, Shadow, Attr);
}
else
{
UNIMPLEMENTED();
//GuiDrawBox(Left, Top, Right, Bottom, VertStyle, HorzStyle, Fill, Shadow, Attr);
}
} }
VOID UiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr) VOID UiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr)
{ {
if (VideoTextMode == UiDisplayMode) UiVtbl.DrawText(X, Y, Text, Attr);
{
TuiDrawText(X, Y, Text, Attr);
}
else
{
UNIMPLEMENTED();
//GuiDrawText(X, Y, Text, Attr);
}
} }
VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr) VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr)
{ {
if (VideoTextMode == UiDisplayMode) UiVtbl.DrawCenteredText(Left, Top, Right, Bottom, TextString, Attr);
{
TuiDrawCenteredText(Left, Top, Right, Bottom, TextString, Attr);
}
else
{
UNIMPLEMENTED();
//GuiDrawCenteredText(Left, Top, Right, Bottom, TextString, Attr);
}
} }
VOID UiDrawStatusText(PCSTR StatusText) VOID UiDrawStatusText(PCSTR StatusText)
{ {
if (!UserInterfaceUp) return; UiVtbl.DrawStatusText(StatusText);
if (VideoTextMode == UiDisplayMode)
{
TuiDrawStatusText(StatusText);
}
else
{
UNIMPLEMENTED();
//GuiDrawStatusText(StatusText);
}
} }
VOID UiUpdateDateTime(VOID) VOID UiUpdateDateTime(VOID)
{ {
if (VideoTextMode == UiDisplayMode) UiVtbl.UpdateDateTime();
{
TuiUpdateDateTime();
}
else
{
UNIMPLEMENTED();
//GuiUpdateDateTime();
}
} }
VOID UiInfoBox(PCSTR MessageText) VOID UiInfoBox(PCSTR MessageText)
@ -469,108 +406,32 @@ VOID UiInfoBox(PCSTR MessageText)
VOID UiMessageBox(PCSTR MessageText) VOID UiMessageBox(PCSTR MessageText)
{ {
// We have not yet displayed the user interface UiVtbl.MessageBox(MessageText);
// 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);
}
} }
VOID UiMessageBoxCritical(PCSTR MessageText) VOID UiMessageBoxCritical(PCSTR MessageText)
{ {
// We have not yet displayed the user interface UiVtbl.MessageBoxCritical(MessageText);
// 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);
}
} }
UCHAR UiTextToColor(PCSTR ColorText) UCHAR UiTextToColor(PCSTR ColorText)
{ {
if (VideoTextMode == UiDisplayMode) return UiVtbl.TextToColor(ColorText);
{
return TuiTextToColor(ColorText);
}
else
{
UNIMPLEMENTED();
return 0;
//return GuiTextToColor(ColorText);
}
} }
UCHAR UiTextToFillStyle(PCSTR FillStyleText) UCHAR UiTextToFillStyle(PCSTR FillStyleText)
{ {
if (VideoTextMode == UiDisplayMode) return UiVtbl.TextToFillStyle(FillStyleText);
{
return TuiTextToFillStyle(FillStyleText);
}
else
{
UNIMPLEMENTED();
return 0;
//return GuiTextToFillStyle(FillStyleText);
}
} }
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText) VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
{ {
if (!UserInterfaceUp) return; UiVtbl.DrawProgressBarCenter(Position, Range, ProgressText);
if (VideoTextMode == UiDisplayMode)
{
TuiDrawProgressBarCenter(Position, Range, ProgressText);
}
else
{
UNIMPLEMENTED();
//GuiDrawProgressBarCenter(Position, Range, ProgressText);
}
} }
VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText) VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText)
{ {
if (VideoTextMode == UiDisplayMode) UiVtbl.DrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
{
TuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
}
else
{
UNIMPLEMENTED();
//GuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
}
} }
VOID UiShowMessageBoxesInSection(PCSTR SectionName) 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) BOOLEAN UiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
{ {
if (VideoTextMode == UiDisplayMode) return UiVtbl.DisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem, CanEscape, KeyPressFilter);
{
return TuiDisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem, CanEscape, KeyPressFilter);
}
else
{
UNIMPLEMENTED();
return FALSE;
//return GuiDisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem, CanEscape, KeyPressFilter);
}
} }
VOID UiFadeInBackdrop(VOID) VOID UiFadeInBackdrop(VOID)
{ {
if (VideoTextMode == UiDisplayMode) UiVtbl.FadeInBackdrop();
{
TuiFadeInBackdrop();
}
else
{
UNIMPLEMENTED();
//GuiFadeInBackdrop();
}
} }
VOID UiFadeOut(VOID) VOID UiFadeOut(VOID)
{ {
if (VideoTextMode == UiDisplayMode) UiVtbl.FadeOut();
{
TuiFadeOut();
}
else
{
UNIMPLEMENTED();
//GuiFadeInOut();
}
} }
BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length) BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
{ {
if (VideoTextMode == UiDisplayMode) return UiVtbl.EditBox(MessageText, EditTextBuffer, Length);
{
return TuiEditBox(MessageText, EditTextBuffer, Length);
}
else
{
UNIMPLEMENTED();
return FALSE;
//return GuiEditBox(MessageText, EditTextBuffer, Length);
}
} }