ReactOS 0.4.16-dev-336-gb667d82
ui.h
Go to the documentation of this file.
1/*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#pragma once
21
22extern ULONG UiScreenWidth; // Screen Width
23extern ULONG UiScreenHeight; // Screen Height
24
25extern UCHAR UiStatusBarFgColor; // Status bar foreground color
26extern UCHAR UiStatusBarBgColor; // Status bar background color
27extern UCHAR UiBackdropFgColor; // Backdrop foreground color
28extern UCHAR UiBackdropBgColor; // Backdrop background color
29extern UCHAR UiBackdropFillStyle; // Backdrop fill style
30extern UCHAR UiTitleBoxFgColor; // Title box foreground color
31extern UCHAR UiTitleBoxBgColor; // Title box background color
32extern UCHAR UiMessageBoxFgColor; // Message box foreground color
33extern UCHAR UiMessageBoxBgColor; // Message box background color
34extern UCHAR UiMenuFgColor; // Menu foreground color
35extern UCHAR UiMenuBgColor; // Menu background color
36extern UCHAR UiTextColor; // Normal text color
37extern UCHAR UiSelectedTextColor; // Selected text color
38extern UCHAR UiSelectedTextBgColor; // Selected text background color
39extern UCHAR UiEditBoxTextColor; // Edit box text color
40extern UCHAR UiEditBoxBgColor; // Edit box text background color
41
42extern BOOLEAN UiShowTime; // Whether to draw the time
43extern BOOLEAN UiMenuBox; // Whether to draw a box around the menu
44extern BOOLEAN UiCenterMenu; // Whether to use a centered or left-aligned menu
45extern BOOLEAN UiUseSpecialEffects; // Whether to use fade effects
46
47extern CHAR UiTitleBoxTitleText[260]; // Title box's title text
48extern CHAR UiTimeText[260];
49
50extern const PCSTR UiMonthNames[12];
51
52/* User Interface Functions **************************************************/
53
54BOOLEAN UiInitialize(BOOLEAN ShowUi); // Initialize User-Interface
55VOID UiUnInitialize(PCSTR BootText); // Un-initialize User-Interface
56VOID UiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
57VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
58VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
59VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr); // Draws a box around the area specified
60
61/* Draws text at coordinates specified */
62VOID
64 _In_ ULONG X,
65 _In_ ULONG Y,
67 _In_ UCHAR Attr);
68
69/* Draws text at coordinates specified */
70VOID
72 _In_ ULONG X,
73 _In_ ULONG Y,
74 _In_opt_ ULONG MaxNumChars,
75 _In_reads_or_z_(MaxNumChars) PCSTR Text,
76 _In_ UCHAR Attr);
77
78/* Draws centered text at the coordinates specified and clips the edges */
79VOID
81 _In_ ULONG Left,
83 _In_ ULONG Right,
85 _In_ PCSTR TextString,
86 _In_ UCHAR Attr);
87
88VOID UiDrawStatusText(PCSTR StatusText); // Draws text at the very bottom line on the screen
89VOID UiUpdateDateTime(VOID); // Updates the date and time
90
91/* Displays an info box on the screen */
92VOID
94 _In_ PCSTR MessageText);
95
96/* Displays a message box on the screen with an ok button */
97VOID
99 _In_ PCSTR Format, ...);
100
101/* Displays a message box on the screen with an ok button using no system resources */
102VOID
104 _In_ PCSTR MessageText);
105
106/* Loading Progress-Bar Functions ********************************************/
107
108/*
109 * Loading progress bar, based on the one from NTOS Inbv.
110 * Supports progress within sub-ranges, used when loading
111 * with an unknown number of steps.
112 */
113typedef struct _UI_PROGRESS_BAR
114{
115 // UI_PROGRESS_STATE
116 struct
117 {
119 // ULONG Ceiling;
122
123 // BT_PROGRESS_INDICATOR
124 struct
125 {
130
135 // ULONG Width; // == Right - Left + 1;
138
140
141VOID
143 _In_ ULONG Left,
144 _In_ ULONG Top,
145 _In_ ULONG Right,
147 _In_ PCSTR ProgressText);
148
149/* Indicate loading progress without any specific number of steps */
150VOID
152
153/* Set a progress loading percentage range */
154VOID
156 _In_ ULONG Floor,
157 _In_ ULONG Ceiling);
158
159/* Update the loading progress percentage within a selected range */
160VOID
162 _In_ ULONG Percentage,
163 _In_opt_ PCSTR ProgressText);
164
165VOID
167 _In_ PCSTR ProgressText);
168
169/* Draws the progress bar showing nPos percent filled */
170VOID
172 _In_ PCSTR ProgressText);
173
174/* Draws the progress bar showing nPos percent filled */
175VOID
177 _In_ ULONG Left,
178 _In_ ULONG Top,
179 _In_ ULONG Right,
181 _In_ PCSTR ProgressText);
182
183
184// Displays all the message boxes in a given section.
185VOID
187 IN ULONG_PTR SectionId);
188
189VOID
191 IN ULONG Argc,
192 IN PCHAR Argv[]);
193
194BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
195
196UCHAR UiTextToColor(PCSTR ColorText); // Converts the text color into it's equivalent color value
197UCHAR UiTextToFillStyle(PCSTR FillStyleText); // Converts the text fill into it's equivalent fill value
198
199VOID UiFadeInBackdrop(VOID); // Draws the backdrop and fades the screen in
200VOID UiFadeOut(VOID); // Fades the screen out
201
202/* Menu Functions ************************************************************/
203
204typedef struct tagUI_MENU_INFO
205{
209
215
221
222typedef
225 IN ULONG KeyPress,
226 IN ULONG SelectedMenuItem,
228
231 IN PCSTR MenuHeader,
232 IN PCSTR MenuFooter OPTIONAL,
233 IN BOOLEAN ShowBootOptions,
234 IN PCSTR MenuItemList[],
235 IN ULONG MenuItemCount,
236 IN ULONG DefaultMenuItem,
237 IN LONG MenuTimeOut,
238 OUT PULONG SelectedMenuItem,
239 IN BOOLEAN CanEscape,
242
244//
245// UI virtual table
246//
248typedef struct tagUIVTBL
249{
252
254 VOID (*FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr);
256 VOID (*DrawBox)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr);
258 VOID (*DrawText2)(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr);
259 VOID (*DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr);
260 VOID (*DrawStatusText)(PCSTR StatusText);
262 VOID (*MessageBox)(PCSTR MessageText);
264
266 _In_ PCSTR ProgressText);
267
269 _In_ ULONG Left,
270 _In_ ULONG Top,
271 _In_ ULONG Right,
273 _In_ PCSTR ProgressText);
274
276 _In_ PCSTR ProgressText);
277
279 _In_ ULONG SubPercentTimes100);
280
281 BOOLEAN (*EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
282 UCHAR (*TextToColor)(PCSTR ColorText);
283 UCHAR (*TextToFillStyle)(PCSTR FillStyleText);
286
288 IN PCSTR MenuHeader,
289 IN PCSTR MenuFooter OPTIONAL,
290 IN BOOLEAN ShowBootOptions,
291 IN PCSTR MenuItemList[],
292 IN ULONG MenuItemCount,
293 IN ULONG DefaultMenuItem,
294 IN LONG MenuTimeOut,
295 OUT PULONG SelectedMenuItem,
296 IN BOOLEAN CanEscape,
299
302
303VOID UiInit(const char *CmdLine);
304
305extern UIVTBL UiVtbl;
306
307/*
308 * Fill styles for DrawBackdrop()
309 */
310#define LIGHT_FILL 0xB0
311#define MEDIUM_FILL 0xB1
312#define DARK_FILL 0xB2
313
314/*
315 * Combines the foreground and background colors into a single attribute byte
316 */
317#define ATTR(cFore, cBack) ((cBack << 4) | cFore)
318
319/*
320 * Screen colors
321 */
322#define COLOR_BLACK 0
323#define COLOR_BLUE 1
324#define COLOR_GREEN 2
325#define COLOR_CYAN 3
326#define COLOR_RED 4
327#define COLOR_MAGENTA 5
328#define COLOR_BROWN 6
329#define COLOR_GRAY 7
330
331#define COLOR_DARKGRAY 8
332#define COLOR_LIGHTBLUE 9
333#define COLOR_LIGHTGREEN 10
334#define COLOR_LIGHTCYAN 11
335#define COLOR_LIGHTRED 12
336#define COLOR_LIGHTMAGENTA 13
337#define COLOR_YELLOW 14
338#define COLOR_WHITE 15
339
340/* Add COLOR_BLINK to a background to cause blinking */
341// #define COLOR_BLINK 8
342
343/*
344 * Defines for IBM box drawing characters
345 */
346#define HORZ 0xC4 // Single horizontal line
347#define D_HORZ 0xCD // Double horizontal line
348#define VERT 0xB3 // Single vertical line
349#define D_VERT 0xBA // Double vertical line
350
351
352/* THEME HEADERS *************************************************************/
353
354// #include <ui/gui.h>
355#include <ui/minitui.h>
356#include <ui/noui.h>
357#include <ui/tui.h>
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53
BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: ui.c:634
struct tagUIVTBL * PUIVTBL
struct _UI_PROGRESS_BAR UI_PROGRESS_BAR
UCHAR UiMessageBoxFgColor
Definition: ui.c:32
UCHAR UiTextToFillStyle(PCSTR FillStyleText)
Definition: ui.c:383
UCHAR UiMessageBoxBgColor
Definition: ui.c:33
UI_PROGRESS_BAR UiProgressBar
Definition: ui.c:62
ULONG UiScreenWidth
Definition: ui.c:54
VOID UiSetProgressBarText(_In_ PCSTR ProgressText)
Definition: ui.c:476
UCHAR UiTextToColor(PCSTR ColorText)
Definition: ui.c:378
UCHAR UiEditBoxTextColor
Definition: ui.c:39
UCHAR UiStatusBarBgColor
Definition: ui.c:26
BOOLEAN UiDisplayMenu(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: ui.c:605
VOID UiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: ui.c:254
BOOLEAN UiUseSpecialEffects
Definition: ui.c:45
BOOLEAN UiCenterMenu
Definition: ui.c:44
VOID UiDrawText2(_In_ ULONG X, _In_ ULONG Y, _In_opt_ ULONG MaxNumChars, _In_reads_or_z_(MaxNumChars) PCSTR Text, _In_ UCHAR Attr)
Definition: ui.c:264
UCHAR UiTitleBoxBgColor
Definition: ui.c:31
VOID UiShowMessageBoxesInArgv(IN ULONG Argc, IN PCHAR Argv[])
Definition: ui.c:568
VOID UiIndicateProgress(VOID)
Definition: ui.c:418
const PCSTR UiMonthNames[12]
Definition: ui.c:50
UCHAR UiTextColor
Definition: ui.c:36
VOID UiShowMessageBoxesInSection(IN ULONG_PTR SectionId)
Definition: ui.c:524
UCHAR UiMenuBgColor
Definition: ui.c:35
struct tagUIVTBL UIVTBL
VOID UiInfoBox(_In_ PCSTR MessageText)
Definition: ui.c:297
struct tagUI_MENU_INFO * PUI_MENU_INFO
CHAR UiTimeText[260]
Definition: ui.c:48
VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
Definition: ui.c:243
BOOLEAN(* UiMenuKeyPressFilterCallback)(IN ULONG KeyPress, IN ULONG SelectedMenuItem, IN PVOID Context OPTIONAL)
Definition: ui.h:224
struct _UI_PROGRESS_BAR * PUI_PROGRESS_BAR
struct tagUI_MENU_INFO UI_MENU_INFO
VOID UiUpdateProgressBar(_In_ ULONG Percentage, _In_opt_ PCSTR ProgressText)
Definition: ui.c:454
CHAR UiTitleBoxTitleText[260]
Definition: ui.c:47
VOID UiFadeOut(VOID)
Definition: ui.c:629
UCHAR UiTitleBoxFgColor
Definition: ui.c:30
UCHAR UiBackdropFgColor
Definition: ui.c:27
BOOLEAN UiShowTime
Definition: ui.c:42
UCHAR UiBackdropFillStyle
Definition: ui.c:29
VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: ui.c:238
VOID UiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: ui.c:372
VOID UiSetProgressBarSubset(_In_ ULONG Floor, _In_ ULONG Ceiling)
Definition: ui.c:439
UCHAR UiBackdropBgColor
Definition: ui.c:28
ULONG UiScreenHeight
Definition: ui.c:55
BOOLEAN UiMenuBox
Definition: ui.c:43
UIVTBL UiVtbl
Definition: ui.c:64
VOID UiUnInitialize(PCSTR BootText)
Definition: ui.c:224
VOID UiDrawBackdrop(VOID)
Definition: ui.c:233
VOID UiDrawProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.c:494
VOID UiDrawProgressBarCenter(_In_ PCSTR ProgressText)
Definition: ui.c:487
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:286
UCHAR UiStatusBarFgColor
Definition: ui.c:25
VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
Definition: ui.c:248
UCHAR UiSelectedTextColor
Definition: ui.c:37
UCHAR UiSelectedTextBgColor
Definition: ui.c:38
UCHAR UiMenuFgColor
Definition: ui.c:34
BOOLEAN UiInitialize(BOOLEAN ShowUi)
Definition: ui.c:92
VOID UiInitProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.c:389
VOID UiDrawCenteredText(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR TextString, _In_ UCHAR Attr)
Definition: ui.c:275
VOID UiInit(const char *CmdLine)
VOID UiUpdateDateTime(VOID)
Definition: ui.c:291
UCHAR UiEditBoxBgColor
Definition: ui.c:40
VOID UiFadeInBackdrop(VOID)
Definition: ui.c:624
VOID UiMessageBox(_In_ PCSTR Format,...)
Definition: ui.c:359
char * Text
Definition: combotst.c:136
#define Y(I)
static const WCHAR CmdLine[]
Definition: install.c:48
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:107
#define X(b, s)
#define _In_reads_or_z_(s)
Definition: no_sal2.h:174
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define BOOLEAN
Definition: pedump.c:73
long LONG
Definition: pedump.c:60
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
menu info structure
Definition: window.h:276
struct _UI_PROGRESS_BAR::@178 State
ULONG Top
Definition: ui.h:132
ULONG Bottom
Definition: ui.h:134
ULONG Count
Definition: ui.h:126
ULONG Bias
Definition: ui.h:120
struct _UI_PROGRESS_BAR::@179 Indicator
ULONG Percentage
Definition: ui.h:128
BOOLEAN Show
Definition: ui.h:136
ULONG Left
Definition: ui.h:131
ULONG Right
Definition: ui.h:133
ULONG Expected
Definition: ui.h:127
ULONG Floor
Definition: ui.h:118
Definition: ui.h:249
VOID(* DrawBackdrop)(VOID)
Definition: ui.h:253
VOID(* FadeInBackdrop)(VOID)
Definition: ui.h:284
VOID(* DrawText)(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr)
Definition: ui.h:257
VOID(* FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: ui.h:254
VOID(* DrawBox)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
Definition: ui.h:256
VOID(* DrawMenu)(PUI_MENU_INFO MenuInfo)
Definition: ui.h:300
VOID(* DrawStatusText)(PCSTR StatusText)
Definition: ui.h:260
UCHAR(* TextToFillStyle)(PCSTR FillStyleText)
Definition: ui.h:283
VOID(* TickProgressBar)(_In_ ULONG SubPercentTimes100)
Definition: ui.h:278
BOOLEAN(* EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: ui.h:281
VOID(* DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr)
Definition: ui.h:259
VOID(* MessageBox)(PCSTR MessageText)
Definition: ui.h:262
BOOLEAN(* Initialize)(VOID)
Definition: ui.h:250
VOID(* DrawProgressBarCenter)(_In_ PCSTR ProgressText)
Definition: ui.h:265
VOID(* UnInitialize)(VOID)
Definition: ui.h:251
VOID(* DrawShadow)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
Definition: ui.h:255
VOID(* DrawProgressBar)(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.h:268
VOID(* MessageBoxCritical)(PCSTR MessageText)
Definition: ui.h:263
VOID(* DrawText2)(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr)
Definition: ui.h:258
VOID(* SetProgressBarText)(_In_ PCSTR ProgressText)
Definition: ui.h:275
VOID(* FadeOut)(VOID)
Definition: ui.h:285
VOID(* UpdateDateTime)(VOID)
Definition: ui.h:261
UCHAR(* TextToColor)(PCSTR ColorText)
Definition: ui.h:282
BOOLEAN(* DisplayMenu)(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: ui.h:287
PCSTR MenuHeader
Definition: ui.h:206
BOOLEAN ShowBootOptions
Definition: ui.h:208
ULONG Right
Definition: ui.h:218
LONG MenuTimeRemaining
Definition: ui.h:212
ULONG Bottom
Definition: ui.h:219
ULONG SelectedMenuItem
Definition: ui.h:213
ULONG Left
Definition: ui.h:216
PCSTR MenuFooter
Definition: ui.h:207
ULONG MenuItemCount
Definition: ui.h:211
PCSTR * MenuItemList
Definition: ui.h:210
PVOID Context
Definition: ui.h:214
ULONG Top
Definition: ui.h:217
#define OPTIONAL
Definition: typedefs.h:41
uint32_t * PULONG
Definition: typedefs.h:59
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175