Author: hpoussin
Date: Mon Oct 29 14:00:31 2007
New Revision: 29947
URL:
http://svn.reactos.org/svn/reactos?rev=29947&view=rev
Log:
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()
)
Added:
trunk/reactos/boot/freeldr/freeldr/include/ui/minitui.h (with props)
trunk/reactos/boot/freeldr/freeldr/include/ui/noui.h (with props)
trunk/reactos/boot/freeldr/freeldr/ui/minitui.c (with props)
trunk/reactos/boot/freeldr/freeldr/ui/noui.c (with props)
Modified:
trunk/reactos/boot/freeldr/freeldr/bootmgr.c
trunk/reactos/boot/freeldr/freeldr/freeldr.c
trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild
trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild
trunk/reactos/boot/freeldr/freeldr/include/freeldr.h
trunk/reactos/boot/freeldr/freeldr/include/ui.h
trunk/reactos/boot/freeldr/freeldr/include/ui/gui.h
trunk/reactos/boot/freeldr/freeldr/include/ui/tui.h
trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c
trunk/reactos/boot/freeldr/freeldr/ui/gui.c
trunk/reactos/boot/freeldr/freeldr/ui/tui.c
trunk/reactos/boot/freeldr/freeldr/ui/tuimenu.c
trunk/reactos/boot/freeldr/freeldr/ui/ui.c
Modified: trunk/reactos/boot/freeldr/freeldr/bootmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/bootm…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/bootmgr.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/bootmgr.c Mon Oct 29 14:00:31 2007
@@ -83,12 +83,6 @@
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 @@
goto reboot;
}
-NoGui:
TimeOut = -1;
// Try to open the operating system section in the .ini file
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/freeldr.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/freeldr.c Mon Oct 29 14:00:31 2007
@@ -30,12 +30,18 @@
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();
}
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild (original)
+++ trunk/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild Mon Oct 29 14:00:31 2007
@@ -84,6 +84,7 @@
<file>hardware.c</file>
<file>loader.c</file>
<file>mach.c</file>
+ <file>portio.c</file>
<file>video.c</file>
</module>
</if>
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild (original)
+++ trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild Mon Oct 29 14:00:31 2007
@@ -55,6 +55,8 @@
</directory>
<directory name="ui">
<file>gui.c</file>
+ <file>minitui.c</file>
+ <file>noui.c</file>
<file>tui.c</file>
<file>tuimenu.c</file>
<file>ui.c</file>
Modified: trunk/reactos/boot/freeldr/freeldr/include/freeldr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/freeldr.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/freeldr.h Mon Oct 29 14:00:31 2007
@@ -57,8 +57,10 @@
#include <fs/ntfs.h>
#include <fs/iso.h>
/* ui support */
+#include <ui/gui.h>
+#include <ui/minitui.h>
+#include <ui/noui.h>
#include <ui/tui.h>
-#include <ui/gui.h>
/* arch files */
#ifdef _X86_
#include <arch/i386/hardware.h>
@@ -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);
Modified: trunk/reactos/boot/freeldr/freeldr/include/ui.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/ui.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/ui.h Mon Oct 29 14:00:31 2007
@@ -43,12 +43,9 @@
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 @@
// 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
Modified: trunk/reactos/boot/freeldr/freeldr/include/ui/gui.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/ui/gui.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/ui/gui.h Mon Oct 29 14:00:31 2007
@@ -51,6 +51,6 @@
///////////////////////////////////////////////////////////////////////////////////////
BOOLEAN GuiDisplayMenu(PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem,
LONG MenuTimeOut, ULONG* SelectedMenuItem);
-
+extern const UIVTBL GuiVtbl;
#endif // #defined __GUI_H
Added: trunk/reactos/boot/freeldr/freeldr/include/ui/minitui.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/ui/minitui.h (added)
+++ trunk/reactos/boot/freeldr/freeldr/include/ui/minitui.h Mon Oct 29 14:00:31 2007
@@ -1,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
Propchange: trunk/reactos/boot/freeldr/freeldr/include/ui/minitui.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/boot/freeldr/freeldr/include/ui/noui.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/ui/noui.h (added)
+++ trunk/reactos/boot/freeldr/freeldr/include/ui/noui.h Mon Oct 29 14:00:31 2007
@@ -1,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_ */
Propchange: trunk/reactos/boot/freeldr/freeldr/include/ui/noui.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/boot/freeldr/freeldr/include/ui/tui.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/ui/tui.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/ui/tui.h Mon Oct 29 14:00:31 2007
@@ -59,7 +59,7 @@
//
///////////////////////////////////////////////////////////////////////////////////////
-typedef struct
+struct tagUI_MENU_INFO
{
PCSTR *MenuItemList;
ULONG MenuItemCount;
@@ -71,59 +71,20 @@
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 @@
#define VD_LL (0xd3)
#define VD_LR (0xbd)
+extern const UIVTBL TuiVtbl;
#endif // #defined __TUI_H
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/setupldr.c Mon Oct 29 14:00:31 2007
@@ -103,9 +103,7 @@
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 @@
/*
* 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 @@
#ifdef USE_UI
SetupUiInitialize();
+#endif
UiDrawStatusText("");
-#endif
extern BOOLEAN FrLdrBootType;
FrLdrBootType = TRUE;
@@ -231,15 +225,9 @@
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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
} while (InfFindNextLine(&InfContext, &InfContext));
}
-#ifdef USE_UI
UiUnInitialize("Booting ReactOS...");
-#endif
/* Now boot the kernel */
DiskStopFloppyMotor();
Modified: trunk/reactos/boot/freeldr/freeldr/ui/gui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/gu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/ui/gui.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/ui/gui.c Mon Oct 29 14:00:31 2007
@@ -76,3 +76,27 @@
{
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,*/
+};
Added: trunk/reactos/boot/freeldr/freeldr/ui/minitui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/mi…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/ui/minitui.c (added)
+++ trunk/reactos/boot/freeldr/freeldr/ui/minitui.c Mon Oct 29 14:00:31 2007
@@ -1,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(a)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,
+};
Propchange: trunk/reactos/boot/freeldr/freeldr/ui/minitui.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/boot/freeldr/freeldr/ui/noui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/no…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/ui/noui.c (added)
+++ trunk/reactos/boot/freeldr/freeldr/ui/noui.c Mon Oct 29 14:00:31 2007
@@ -1,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)
+{
+}
Propchange: trunk/reactos/boot/freeldr/freeldr/ui/noui.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/boot/freeldr/freeldr/ui/tui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/tu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/ui/tui.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/ui/tui.c Mon Oct 29 14:00:31 2007
@@ -20,7 +20,6 @@
#include <freeldr.h>
PVOID TextVideoBuffer = NULL;
-extern BOOLEAN UiMinimal;
/*
* printf() - prints formatted text to stdout
@@ -112,25 +111,6 @@
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 @@
{
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 @@
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 @@
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 "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 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));
// Draw the percent complete
for (i=0; i<(Position*ProgressBarWidth)/Range; i++)
@@ -758,14 +702,11 @@
TuiDrawText(Left+2+i, Top+2, "\xDB", ATTR(UiTextColor, UiMenuBgColor));
}
- // Draw the shadow for non-minimal UI
- if (!UiMinimal)
- {
- for (; i<ProgressBarWidth; i++)
- {
- TuiDrawText(Left+2+i, Top+2, "\xB2", ATTR(UiTextColor, UiMenuBgColor));
- }
- }
+ // Draw the shadow
+ for (; i<ProgressBarWidth; i++)
+ {
+ TuiDrawText(Left+2+i, Top+2, "\xB2", ATTR(UiTextColor, UiMenuBgColor));
+ }
TuiUpdateDateTime();
VideoCopyOffScreenBufferToVRAM();
@@ -1045,3 +986,28 @@
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,
+};
Modified: trunk/reactos/boot/freeldr/freeldr/ui/tuimenu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/tu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/ui/tuimenu.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/ui/tuimenu.c Mon Oct 29 14:00:31 2007
@@ -14,7 +14,6 @@
/* FUNCTIONS *****************************************************************/
BOOLEAN
-NTAPI
TuiDisplayMenu(PCSTR MenuItemList[],
ULONG MenuItemCount,
ULONG DefaultMenuItem,
@@ -23,7 +22,7 @@
BOOLEAN CanEscape,
UiMenuKeyPressFilterCallback KeyPressFilter)
{
- TUI_MENU_INFO MenuInformation;
+ UI_MENU_INFO MenuInformation;
ULONG LastClockSecond;
ULONG CurrentClockSecond;
ULONG KeyPress;
@@ -55,7 +54,7 @@
//
// Draw the menu
//
- TuiDrawMenu(&MenuInformation);
+ UiVtbl.DrawMenu(&MenuInformation);
//
// Get the current second of time
@@ -136,7 +135,7 @@
VOID
NTAPI
-TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo)
+TuiCalcMenuBoxSize(PUI_MENU_INFO MenuInfo)
{
ULONG i;
ULONG Width = 0;
@@ -195,8 +194,7 @@
}
VOID
-NTAPI
-TuiDrawMenu(PTUI_MENU_INFO MenuInfo)
+TuiDrawMenu(PUI_MENU_INFO MenuInfo)
{
ULONG i;
@@ -206,48 +204,9 @@
UiDrawBackdrop();
//
- // Check if this is the minimal (console) UI
- //
- if (UiMinimal)
- {
- //
- // 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.");
- }
+ // Update the status bar
+ //
+ UiVtbl.DrawStatusText("Use \x18\x19 to select, then press ENTER.");
//
// Draw the menu box
@@ -263,7 +222,7 @@
VOID
NTAPI
-TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
+TuiDrawMenuBox(PUI_MENU_INFO MenuInfo)
{
CHAR MenuLineText[80];
CHAR TempString[80];
@@ -361,7 +320,7 @@
VOID
NTAPI
-TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo,
+TuiDrawMenuItem(PUI_MENU_INFO MenuInfo,
ULONG MenuItemNumber)
{
ULONG i;
@@ -441,7 +400,7 @@
ULONG
NTAPI
-TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo,
+TuiProcessMenuKeyboardEvent(PUI_MENU_INFO MenuInfo,
UiMenuKeyPressFilterCallback KeyPressFilter)
{
ULONG KeyEvent = 0;
@@ -483,7 +442,7 @@
//
// It processed the key character, so redraw and exit
//
- TuiDrawMenu(MenuInfo);
+ UiVtbl.DrawMenu(MenuInfo);
return 0;
}
Modified: trunk/reactos/boot/freeldr/freeldr/ui/ui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/ui…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/ui/ui.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/ui/ui.c Mon Oct 29 14:00:31 2007
@@ -21,8 +21,8 @@
#include <debug.h>
-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 @@
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,132 +105,15 @@
{
DisplayModeText[0] = '\0';
}
-
- if (IniReadSettingByName(SectionId, "TitleText", SettingText,
sizeof(SettingText)))
- {
- strcpy(UiTitleBoxTitleText, SettingText);
- }
- if (IniReadSettingByName(SectionId, "TimeText", SettingText,
sizeof(SettingText)))
- {
- strcpy(UiTimeText, SettingText);
- }
- if (IniReadSettingByName(SectionId, "StatusBarColor", SettingText,
sizeof(SettingText)))
- {
- UiStatusBarBgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "StatusBarTextColor", SettingText,
sizeof(SettingText)))
- {
- UiStatusBarFgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "BackdropTextColor", SettingText,
sizeof(SettingText)))
- {
- UiBackdropFgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "BackdropColor", SettingText,
sizeof(SettingText)))
- {
- UiBackdropBgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "BackdropFillStyle", SettingText,
sizeof(SettingText)))
- {
- UiBackdropFillStyle = UiTextToFillStyle(SettingText);
- }
- if (IniReadSettingByName(SectionId, "TitleBoxTextColor", SettingText,
sizeof(SettingText)))
- {
- UiTitleBoxFgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "TitleBoxColor", SettingText,
sizeof(SettingText)))
- {
- UiTitleBoxBgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "MessageBoxTextColor", SettingText,
sizeof(SettingText)))
- {
- UiMessageBoxFgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "MessageBoxColor", SettingText,
sizeof(SettingText)))
- {
- UiMessageBoxBgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "MenuTextColor", SettingText,
sizeof(SettingText)))
- {
- UiMenuFgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "MenuColor", SettingText,
sizeof(SettingText)))
- {
- UiMenuBgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "TextColor", SettingText,
sizeof(SettingText)))
- {
- UiTextColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "SelectedTextColor", SettingText,
sizeof(SettingText)))
- {
- UiSelectedTextColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "SelectedColor", SettingText,
sizeof(SettingText)))
- {
- UiSelectedTextBgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "EditBoxTextColor", SettingText,
sizeof(SettingText)))
- {
- UiEditBoxTextColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "EditBoxColor", SettingText,
sizeof(SettingText)))
- {
- UiEditBoxBgColor = UiTextToColor(SettingText);
- }
- if (IniReadSettingByName(SectionId, "SpecialEffects", SettingText,
sizeof(SettingText)))
+ if (IniReadSettingByName(SectionId, "MinimalUI", SettingText,
sizeof(SettingText)))
{
if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
{
- UiUseSpecialEffects = TRUE;
+ UiMinimal = TRUE;
}
else
{
- UiUseSpecialEffects = FALSE;
- }
- }
- if (IniReadSettingByName(SectionId, "ShowTime", SettingText,
sizeof(SettingText)))
- {
- if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
- {
- UiDrawTime = TRUE;
- }
- else
- {
- 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)
- {
- UiMenuBox = TRUE;
- }
- else
- {
- UiMenuBox = FALSE;
- }
- }
- if (IniReadSettingByName(SectionId, "CenterMenu", SettingText,
sizeof(SettingText)))
- {
- if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
- {
- UiCenterMenu = TRUE;
- }
- else
- {
- UiCenterMenu = FALSE;
}
}
}
@@ -218,37 +121,147 @@
UiDisplayMode = MachVideoSetDisplayMode(DisplayModeText, TRUE);
MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth);
-
if (VideoTextMode == UiDisplayMode)
- {
- if (!TuiInitialize())
- {
- MachVideoSetDisplayMode(NULL, FALSE);
- return FALSE;
- }
- }
+ UiVtbl = UiMinimal ? MiniTuiVtbl : TuiVtbl;
else
- {
- UNIMPLEMENTED();
- //if (!GuiInitialize())
- //{
- // MachSetDisplayMode(NULL, FALSE);
- // return FALSE;
- //}
+ UiVtbl = GuiVtbl;
+
+ if (!UiVtbl.Initialize())
+ {
+ MachVideoSetDisplayMode(NULL, FALSE);
+ return FALSE;
+ }
+
+ if (IniOpenSection("Display", &SectionId))
+ {
+ if (IniReadSettingByName(SectionId, "TitleText", SettingText,
sizeof(SettingText)))
+ {
+ strcpy(UiTitleBoxTitleText, SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "TimeText", SettingText,
sizeof(SettingText)))
+ {
+ strcpy(UiTimeText, SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "StatusBarColor", SettingText,
sizeof(SettingText)))
+ {
+ UiStatusBarBgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "StatusBarTextColor", SettingText,
sizeof(SettingText)))
+ {
+ UiStatusBarFgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "BackdropTextColor", SettingText,
sizeof(SettingText)))
+ {
+ UiBackdropFgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "BackdropColor", SettingText,
sizeof(SettingText)))
+ {
+ UiBackdropBgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "BackdropFillStyle", SettingText,
sizeof(SettingText)))
+ {
+ UiBackdropFillStyle = UiTextToFillStyle(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "TitleBoxTextColor", SettingText,
sizeof(SettingText)))
+ {
+ UiTitleBoxFgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "TitleBoxColor", SettingText,
sizeof(SettingText)))
+ {
+ UiTitleBoxBgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "MessageBoxTextColor", SettingText,
sizeof(SettingText)))
+ {
+ UiMessageBoxFgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "MessageBoxColor", SettingText,
sizeof(SettingText)))
+ {
+ UiMessageBoxBgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "MenuTextColor", SettingText,
sizeof(SettingText)))
+ {
+ UiMenuFgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "MenuColor", SettingText,
sizeof(SettingText)))
+ {
+ UiMenuBgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "TextColor", SettingText,
sizeof(SettingText)))
+ {
+ UiTextColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "SelectedTextColor", SettingText,
sizeof(SettingText)))
+ {
+ UiSelectedTextColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "SelectedColor", SettingText,
sizeof(SettingText)))
+ {
+ UiSelectedTextBgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "EditBoxTextColor", SettingText,
sizeof(SettingText)))
+ {
+ UiEditBoxTextColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "EditBoxColor", SettingText,
sizeof(SettingText)))
+ {
+ UiEditBoxBgColor = UiTextToColor(SettingText);
+ }
+ if (IniReadSettingByName(SectionId, "SpecialEffects", SettingText,
sizeof(SettingText)))
+ {
+ if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
+ {
+ UiUseSpecialEffects = TRUE;
+ }
+ else
+ {
+ UiUseSpecialEffects = FALSE;
+ }
+ }
+ if (IniReadSettingByName(SectionId, "ShowTime", SettingText,
sizeof(SettingText)))
+ {
+ if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
+ {
+ UiDrawTime = TRUE;
+ }
+ else
+ {
+ UiDrawTime = FALSE;
+ }
+ }
+ if (IniReadSettingByName(SectionId, "MenuBox", SettingText,
sizeof(SettingText)))
+ {
+ if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
+ {
+ UiMenuBox = TRUE;
+ }
+ else
+ {
+ UiMenuBox = FALSE;
+ }
+ }
+ if (IniReadSettingByName(SectionId, "CenterMenu", SettingText,
sizeof(SettingText)))
+ {
+ if (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
+ {
+ UiCenterMenu = TRUE;
+ }
+ else
+ {
+ UiCenterMenu = 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 @@
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 @@
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 @@
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 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 @@
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);
+}