ReactOS 0.4.16-dev-2613-g9533ad7
minitui.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: FreeLoader
4 * FILE: boot/freeldr/freeldr/ui/minitui.c
5 * PURPOSE: Mini Text UI interface
6 * PROGRAMMERS: Brian Palmer <brianp@sginet.com>
7 * Hervé Poussineau
8 */
9
10#include <freeldr.h>
11
12/* NTLDR or Vista+ BOOTMGR progress-bar style */
13// #define NTLDR_PROGRESSBAR
14// #define BTMGR_PROGRESSBAR /* Default style */
15
16#ifdef NTLDR_PROGRESSBAR
17#define MINITUI_PROGRESS_TEXT_ATTR ATTR(UiTextColor, UiMenuBgColor)
18#define MINITUI_PROGRESS_FILL_CHAR '\xDB'
19#define MINITUI_PROGRESS_FILL_ATTR ATTR(UiTextColor, UiMenuBgColor)
20#define MINITUI_PROGRESS_REMAINING_CHAR ' '
21#define MINITUI_PROGRESS_REMAINING_ATTR ATTR(UiTextColor, UiMenuBgColor)
22#else // BTMGR_PROGRESSBAR
23#define MINITUI_PROGRESS_TEXT_ATTR ATTR(COLOR_GRAY, COLOR_BLACK)
24#define MINITUI_PROGRESS_FILL_CHAR ' '
25#define MINITUI_PROGRESS_FILL_ATTR ATTR(COLOR_WHITE, COLOR_WHITE)
26#define MINITUI_PROGRESS_REMAINING_CHAR ' '
27#define MINITUI_PROGRESS_REMAINING_ATTR ATTR(COLOR_GRAY, COLOR_GRAY)
28#endif
29
31{
32 /* Initialize main TUI */
33 if (!TuiInitialize())
34 return FALSE;
35
36 /* Override default settings with "Mini" TUI Theme */
37
38#ifdef NTLDR_PROGRESSBAR
39 UiTextColor = TuiTextToColor("Default");
40#else // BTMGR_PROGRESSBAR
42#endif
43
48 UiBackdropFillStyle = ' '; // TuiTextToFillStyle("None");
51 // UiMessageBoxFgColor = COLOR_WHITE;
52 // UiMessageBoxBgColor = COLOR_BLUE;
57 // UiEditBoxTextColor = COLOR_WHITE;
58 // UiEditBoxBgColor = COLOR_BLACK;
59
64
65 // TODO: Have a boolean to show/hide title box?
67
69 "Seconds until highlighted choice will be started automatically:");
70
71 return TRUE;
72}
73
75{
76 /* Fill in a black background */
77 TuiFillArea(0, 0, UiScreenWidth - 1, DrawHeight - 1,
80
81 /* Update the screen buffer */
83}
84
86{
87 /* No fade-in effect in MiniTui */
89}
90
92{
93 /* Minimal UI doesn't have a status bar */
94}
95
96/*static*/ VOID
98 _In_ PCSTR ProgressText)
99{
100 ULONG ProgressBarWidth;
101 CHAR ProgressString[256];
102
103 /* Make sure the progress bar is enabled */
105
106 /* Calculate the width of the bar proper */
107 ProgressBarWidth = UiProgressBar.Right - UiProgressBar.Left + 1;
108
109 /* First make sure the progress bar text fits */
110 RtlStringCbCopyA(ProgressString, sizeof(ProgressString), ProgressText);
111 TuiTruncateStringEllipsis(ProgressString, ProgressBarWidth);
112
113 /* Clear the text area */
116#ifdef NTLDR_PROGRESSBAR
118#else // BTMGR_PROGRESSBAR
119 UiProgressBar.Bottom - 2, // One empty line between text and bar.
120#endif
122
123 /* Draw the "Loading..." text */
126#ifdef NTLDR_PROGRESSBAR
128#else // BTMGR_PROGRESSBAR
129 UiProgressBar.Bottom - 2, // One empty line between text and bar.
130#endif
131 ProgressString, MINITUI_PROGRESS_TEXT_ATTR);
132}
133
134/*static*/ VOID
136 _In_ ULONG SubPercentTimes100)
137{
138 ULONG ProgressBarWidth;
139 ULONG FillCount;
140
141 /* Make sure the progress bar is enabled */
143
144 ASSERT(SubPercentTimes100 <= (100 * 100));
145
146 /* Calculate the width of the bar proper */
147 ProgressBarWidth = UiProgressBar.Right - UiProgressBar.Left + 1;
148
149 /* Compute fill count */
150 // FillCount = (ProgressBarWidth * Position) / Range;
151 FillCount = ProgressBarWidth * SubPercentTimes100 / (100 * 100);
152
153 /* Fill the progress bar */
154 /* Draw the percent complete -- Use the fill character */
155 if (FillCount > 0)
156 {
158 UiProgressBar.Left + FillCount - 1, UiProgressBar.Bottom,
160 }
164
167}
168
169VOID
171 _In_ PCSTR ProgressText)
172{
173 ULONG Left, Top, Right, Bottom, Width, Height;
174
175 /* Build the coordinates and sizes */
176#ifdef NTLDR_PROGRESSBAR
177 Height = 2;
179 Left = 0;
180 Top = UiScreenHeight - Height - 2;
181#else // BTMGR_PROGRESSBAR
182 Height = 3;
183 Width = UiScreenWidth - 4;
184 Left = 2;
185 Top = UiScreenHeight - Height - 3;
186#endif
187 Right = Left + Width - 1;
188 Bottom = Top + Height - 1;
189
190 /* Draw the progress bar */
191 MiniTuiDrawProgressBar(Left, Top, Right, Bottom, ProgressText);
192}
193
194VOID
196 _In_ ULONG Left,
197 _In_ ULONG Top,
198 _In_ ULONG Right,
200 _In_ PCSTR ProgressText)
201{
202 UiInitProgressBar(Left, Top, Right, Bottom, ProgressText);
203}
204
205VOID
207 _In_ PUI_MENU_INFO MenuInfo)
208{
209 ULONG i;
210
211 /* Draw the backdrop */
213
214 /* No GUI status bar text, just minimal text. Show the menu header. */
215 if (MenuInfo->MenuHeader)
216 {
218 MenuInfo->Top - 2,
219 MenuInfo->MenuHeader,
221 }
222
223 /* Draw the menu box */
224 TuiDrawMenuBox(MenuInfo);
225
226 /* Draw each line of the menu */
227 for (i = 0; i < MenuInfo->MenuItemCount; ++i)
228 {
229 TuiDrawMenuItem(MenuInfo, i);
230 }
231
232 /* Now tell the user how to choose */
234 MenuInfo->Bottom + 1,
235 "Use \x18 and \x19 to move the highlight to your choice.",
238 MenuInfo->Bottom + 2,
239 "Press ENTER to choose.",
241
242 /* And show the menu footer */
243 if (MenuInfo->MenuFooter)
244 {
246 UiScreenHeight - 4,
247 MenuInfo->MenuFooter,
249 }
250
252}
253
255{
280};
unsigned char BOOLEAN
Definition: actypes.h:127
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53
VOID VideoCopyOffScreenBufferToVRAM(VOID)
Definition: video.c:38
UI_PROGRESS_BAR UiProgressBar
Definition: ui.c:62
ULONG UiScreenWidth
Definition: ui.c:54
UCHAR UiStatusBarBgColor
Definition: ui.c:26
BOOLEAN UiUseSpecialEffects
Definition: ui.c:45
BOOLEAN UiCenterMenu
Definition: ui.c:44
#define COLOR_GRAY
Definition: ui.h:335
UCHAR UiTitleBoxBgColor
Definition: ui.c:31
UCHAR UiTextColor
Definition: ui.c:36
UCHAR UiMenuBgColor
Definition: ui.c:35
VOID UiDrawBackdrop(ULONG DrawHeight)
Definition: ui.c:233
#define ATTR(cFore, cBack)
Definition: ui.h:323
CHAR UiTimeText[260]
Definition: ui.c:48
CHAR UiTitleBoxTitleText[260]
Definition: ui.c:47
#define COLOR_WHITE
Definition: ui.h:344
UCHAR UiTitleBoxFgColor
Definition: ui.c:30
UCHAR UiBackdropFgColor
Definition: ui.c:27
BOOLEAN UiShowTime
Definition: ui.c:42
UCHAR UiBackdropFillStyle
Definition: ui.c:29
UCHAR UiBackdropBgColor
Definition: ui.c:28
ULONG UiGetScreenHeight(VOID)
Definition: ui.c:655
ULONG UiScreenHeight
Definition: ui.c:55
BOOLEAN UiMenuBox
Definition: ui.c:43
UIVTBL UiVtbl
Definition: ui.c:64
#define COLOR_BLACK
Definition: ui.h:328
UCHAR UiStatusBarFgColor
Definition: ui.c:25
UCHAR UiSelectedTextColor
Definition: ui.c:37
UCHAR UiSelectedTextBgColor
Definition: ui.c:38
UCHAR UiMenuFgColor
Definition: ui.c:34
VOID UiInitProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.c:389
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MINITUI_PROGRESS_TEXT_ATTR
Definition: minitui.c:23
#define MINITUI_PROGRESS_REMAINING_ATTR
Definition: minitui.c:27
#define MINITUI_PROGRESS_FILL_ATTR
Definition: minitui.c:25
VOID MiniTuiTickProgressBar(_In_ ULONG SubPercentTimes100)
Definition: minitui.c:135
VOID MiniTuiDrawProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: minitui.c:195
#define MINITUI_PROGRESS_FILL_CHAR
Definition: minitui.c:24
VOID MiniTuiDrawStatusText(PCSTR StatusText)
Definition: minitui.c:91
VOID MiniTuiDrawBackdrop(ULONG DrawHeight)
Definition: minitui.c:74
VOID MiniTuiSetProgressBarText(_In_ PCSTR ProgressText)
Definition: minitui.c:97
VOID MiniTuiDrawProgressBarCenter(_In_ PCSTR ProgressText)
Definition: minitui.c:170
#define MINITUI_PROGRESS_REMAINING_CHAR
Definition: minitui.c:26
const UIVTBL MiniTuiVtbl
Definition: minitui.c:254
VOID MiniTuiFadeInBackdrop(VOID)
Definition: minitui.c:85
BOOLEAN MiniTuiInitialize(VOID)
Definition: minitui.c:30
VOID MiniTuiDrawMenu(_In_ PUI_MENU_INFO MenuInfo)
Definition: minitui.c:206
#define ASSERT(a)
Definition: mode.c:44
#define _In_
Definition: no_sal2.h:158
#define ANSI_NULL
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
char CHAR
Definition: pedump.c:57
ULONG Top
Definition: ui.h:138
ULONG Bottom
Definition: ui.h:140
BOOLEAN Show
Definition: ui.h:142
ULONG Left
Definition: ui.h:137
ULONG Right
Definition: ui.h:139
Definition: ui.h:253
VOID(* DrawText)(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr)
Definition: ui.h:261
VOID TuiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: tui.c:761
VOID TuiDrawCenteredText(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR TextString, _In_ UCHAR Attr)
Definition: tui.c:118
VOID TuiTruncateStringEllipsis(_Inout_z_ PSTR StringText, _In_ ULONG MaxChars)
Definition: tui.c:63
VOID TuiDrawBox(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ BOOLEAN Fill, _In_ BOOLEAN Shadow, _In_ UCHAR Attr)
Definition: tui.c:502
VOID TuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
Definition: tui.c:359
UCHAR TuiTextToColor(PCSTR ColorText)
Definition: tui.c:919
VOID TuiUnInitialize(VOID)
Definition: tui.c:249
VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: tui.c:329
UCHAR TuiTextToFillStyle(PCSTR FillStyleText)
Definition: tui.c:958
VOID TuiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: tui.c:78
VOID TuiDrawText2(_In_ ULONG X, _In_ ULONG Y, _In_opt_ ULONG MaxNumChars, _In_reads_or_z_(MaxNumChars) PCSTR Text, _In_ UCHAR Attr)
Definition: tui.c:95
VOID TuiUpdateDateTime(VOID)
Definition: tui.c:547
BOOLEAN TuiInitialize(VOID)
Definition: tui.c:203
BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: tui.c:1038
BOOLEAN TuiDisplayMenu(IN PCSTR MenuHeader, IN PCSTR MenuFooter OPTIONAL, IN PCSTR MenuItemList[], IN ULONG MenuItemCount, IN ULONG DefaultMenuItem, IN LONG MenuTimeOut, OUT PULONG SelectedMenuItem, IN BOOLEAN CanEscape, IN UiMenuKeyPressFilterCallback KeyPressFilter OPTIONAL, IN PVOID Context OPTIONAL)
Definition: tuimenu.c:30
VOID TuiDrawMenuItem(_In_ PUI_MENU_INFO MenuInfo, _In_ ULONG MenuItemNumber)
Definition: tuimenu.c:367
VOID TuiDrawMenuBox(_In_ PUI_MENU_INFO MenuInfo)
Definition: tuimenu.c:343
VOID TuiFadeOut(VOID)
Definition: tui.c:1008
VOID TuiMessageBox(_In_ PCSTR MessageText)
Definition: tui.c:745
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88