ReactOS 0.4.16-dev-334-g4d9f67c
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
17{
18 /* Initialize main TUI */
19 if (!TuiInitialize())
20 return FALSE;
21
22 /* Override default settings with "Mini" TUI Theme */
23
24 UiTextColor = TuiTextToColor("Default");
25
30 UiBackdropFillStyle = ' '; // TuiTextToFillStyle("None");
33 // UiMessageBoxFgColor = COLOR_WHITE;
34 // UiMessageBoxBgColor = COLOR_BLUE;
39 // UiEditBoxTextColor = COLOR_WHITE;
40 // UiEditBoxBgColor = COLOR_BLACK;
41
46
47 // TODO: Have a boolean to show/hide title box?
49
51 "Seconds until highlighted choice will be started automatically:");
52
53 return TRUE;
54}
55
57{
58 /* Fill in a black background */
62
63 /* Update the screen buffer */
65}
66
68{
69 /* Minimal UI doesn't have a status bar */
70}
71
72/*static*/ VOID
74 _In_ PCSTR ProgressText)
75{
76 ULONG ProgressBarWidth;
77 CHAR ProgressString[256];
78
79 /* Make sure the progress bar is enabled */
81
82 /* Calculate the width of the bar proper */
83 ProgressBarWidth = UiProgressBar.Right - UiProgressBar.Left + 1;
84
85 /* First make sure the progress bar text fits */
86 RtlStringCbCopyA(ProgressString, sizeof(ProgressString), ProgressText);
87 TuiTruncateStringEllipsis(ProgressString, ProgressBarWidth);
88
89 /* Clear the text area */
92#ifdef NTLDR_PROGRESSBAR
94#else // BTMGR_PROGRESSBAR
95 UiProgressBar.Bottom - 2, // One empty line between text and bar.
96#endif
98
99 /* Draw the "Loading..." text */
102#ifdef NTLDR_PROGRESSBAR
104#else // BTMGR_PROGRESSBAR
105 UiProgressBar.Bottom - 2, // One empty line between text and bar.
106#endif
107 ProgressString, ATTR(UiTextColor, UiMenuBgColor));
108}
109
110/*static*/ VOID
112 _In_ ULONG SubPercentTimes100)
113{
114 ULONG ProgressBarWidth;
115 ULONG FillCount;
116
117 /* Make sure the progress bar is enabled */
119
120 ASSERT(SubPercentTimes100 <= (100 * 100));
121
122 /* Calculate the width of the bar proper */
123 ProgressBarWidth = UiProgressBar.Right - UiProgressBar.Left + 1;
124
125 /* Compute fill count */
126 // FillCount = (ProgressBarWidth * Position) / Range;
127 FillCount = ProgressBarWidth * SubPercentTimes100 / (100 * 100);
128
129 /* Fill the progress bar */
130 /* Draw the percent complete -- Use the fill character */
131 if (FillCount > 0)
132 {
134 UiProgressBar.Left + FillCount - 1, UiProgressBar.Bottom,
135 '\xDB', ATTR(UiTextColor, UiMenuBgColor));
136 }
137 /* Fill the remaining with blanks */
141
144}
145
146VOID
148 _In_ PCSTR ProgressText)
149{
150 ULONG Left, Top, Right, Bottom, Width, Height;
151
152 /* Build the coordinates and sizes */
153#ifdef NTLDR_PROGRESSBAR
154 Height = 2;
156 Left = 0;
157 Top = UiScreenHeight - Height - 2;
158#else // BTMGR_PROGRESSBAR
159 Height = 3;
160 Width = UiScreenWidth - 4;
161 Left = 2;
162 Top = UiScreenHeight - Height - 3;
163#endif
164 Right = Left + Width - 1;
165 Bottom = Top + Height - 1;
166
167 /* Draw the progress bar */
168 MiniTuiDrawProgressBar(Left, Top, Right, Bottom, ProgressText);
169}
170
171VOID
173 _In_ ULONG Left,
174 _In_ ULONG Top,
175 _In_ ULONG Right,
177 _In_ PCSTR ProgressText)
178{
179 UiInitProgressBar(Left, Top, Right, Bottom, ProgressText);
180}
181
182VOID
185{
186 ULONG i;
187
188 /* Draw the backdrop */
190
191 /* No GUI status bar text, just minimal text. Show the menu header. */
192 if (MenuInfo->MenuHeader)
193 {
195 MenuInfo->Top - 2,
196 MenuInfo->MenuHeader,
198 }
199
200 /* Draw the menu box */
202
203 /* Draw each line of the menu */
204 for (i = 0; i < MenuInfo->MenuItemCount; ++i)
205 {
207 }
208
209 /* Now tell the user how to choose */
211 MenuInfo->Bottom + 1,
212 "Use \x18 and \x19 to move the highlight to your choice.",
215 MenuInfo->Bottom + 2,
216 "Press ENTER to choose.",
218
219 /* And show the menu footer */
220 if (MenuInfo->MenuFooter)
221 {
223 UiScreenHeight - 4,
224 MenuInfo->MenuFooter,
226 }
227
228 /* Display the boot options if needed */
229 if (MenuInfo->ShowBootOptions)
230 {
232 }
233
235}
236
238{
259 MiniTuiDrawBackdrop, /* no FadeIn */
263};
264
unsigned char BOOLEAN
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53
VOID DisplayBootTimeOptions(VOID)
Definition: options.c:181
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
UCHAR UiTitleBoxBgColor
Definition: ui.c:31
UCHAR UiTextColor
Definition: ui.c:36
UCHAR UiMenuBgColor
Definition: ui.c:35
#define ATTR(cFore, cBack)
Definition: ui.h:317
CHAR UiTimeText[260]
Definition: ui.c:48
CHAR UiTitleBoxTitleText[260]
Definition: ui.c:47
#define COLOR_WHITE
Definition: ui.h:338
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 UiScreenHeight
Definition: ui.c:55
BOOLEAN UiMenuBox
Definition: ui.c:43
UIVTBL UiVtbl
Definition: ui.c:64
#define COLOR_BLACK
Definition: ui.h:322
VOID UiDrawBackdrop(VOID)
Definition: ui.c:233
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
VOID MiniTuiTickProgressBar(_In_ ULONG SubPercentTimes100)
Definition: minitui.c:111
VOID MiniTuiDrawProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: minitui.c:172
VOID MiniTuiDrawStatusText(PCSTR StatusText)
Definition: minitui.c:67
VOID MiniTuiSetProgressBarText(_In_ PCSTR ProgressText)
Definition: minitui.c:73
VOID MiniTuiDrawProgressBarCenter(_In_ PCSTR ProgressText)
Definition: minitui.c:147
const UIVTBL MiniTuiVtbl
Definition: minitui.c:237
BOOLEAN MiniTuiInitialize(VOID)
Definition: minitui.c:16
VOID MiniTuiDrawBackdrop(VOID)
Definition: minitui.c:56
VOID MiniTuiDrawMenu(_In_ PUI_MENU_INFO MenuInfo)
Definition: minitui.c:183
#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
menu info structure
Definition: window.h:276
ULONG Top
Definition: ui.h:132
ULONG Bottom
Definition: ui.h:134
BOOLEAN Show
Definition: ui.h:136
ULONG Left
Definition: ui.h:131
ULONG Right
Definition: ui.h:133
Definition: ui.h:249
VOID(* DrawText)(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr)
Definition: ui.h:257
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
BOOLEAN TuiDisplayMenu(IN PCSTR MenuHeader, IN PCSTR MenuFooter OPTIONAL, IN BOOLEAN ShowBootOptions, 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 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
VOID TuiDrawMenuItem(_In_ PUI_MENU_INFO MenuInfo, _In_ ULONG MenuItemNumber)
Definition: tuimenu.c:375
VOID TuiDrawMenuBox(_In_ PUI_MENU_INFO MenuInfo)
Definition: tuimenu.c:351
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
char CHAR
Definition: xmlstorage.h:175