ReactOS 0.4.16-dev-1056-gbe87e00
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(ULONG DrawHeight); // 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
106ULONG
108
109UCHAR
111
112/* Loading Progress-Bar Functions ********************************************/
113
114/*
115 * Loading progress bar, based on the one from NTOS Inbv.
116 * Supports progress within sub-ranges, used when loading
117 * with an unknown number of steps.
118 */
119typedef struct _UI_PROGRESS_BAR
120{
121 // UI_PROGRESS_STATE
122 struct
123 {
125 // ULONG Ceiling;
128
129 // BT_PROGRESS_INDICATOR
130 struct
131 {
136
141 // ULONG Width; // == Right - Left + 1;
144
146
147VOID
149 _In_ ULONG Left,
150 _In_ ULONG Top,
151 _In_ ULONG Right,
153 _In_ PCSTR ProgressText);
154
155/* Indicate loading progress without any specific number of steps */
156VOID
158
159/* Set a progress loading percentage range */
160VOID
162 _In_ ULONG Floor,
163 _In_ ULONG Ceiling);
164
165/* Update the loading progress percentage within a selected range */
166VOID
168 _In_ ULONG Percentage,
169 _In_opt_ PCSTR ProgressText);
170
171VOID
173 _In_ PCSTR ProgressText);
174
175/* Draws the progress bar showing nPos percent filled */
176VOID
178 _In_ PCSTR ProgressText);
179
180/* Draws the progress bar showing nPos percent filled */
181VOID
183 _In_ ULONG Left,
184 _In_ ULONG Top,
185 _In_ ULONG Right,
187 _In_ PCSTR ProgressText);
188
189
190// Displays all the message boxes in a given section.
191VOID
193 IN ULONG_PTR SectionId);
194
195VOID
197 IN ULONG Argc,
198 IN PCHAR Argv[]);
199
200BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
201
202UCHAR UiTextToColor(PCSTR ColorText); // Converts the text color into it's equivalent color value
203UCHAR UiTextToFillStyle(PCSTR FillStyleText); // Converts the text fill into it's equivalent fill value
204
205VOID UiFadeInBackdrop(VOID); // Draws the backdrop and fades the screen in
206VOID UiFadeOut(VOID); // Fades the screen out
207
208/* Menu Functions ************************************************************/
209
210typedef struct tagUI_MENU_INFO
211{
214
220
226
227typedef
230 IN ULONG KeyPress,
231 IN ULONG SelectedMenuItem,
233
236 IN PCSTR MenuHeader,
237 IN PCSTR MenuFooter OPTIONAL,
238 IN PCSTR MenuItemList[],
239 IN ULONG MenuItemCount,
240 IN ULONG DefaultMenuItem,
241 IN LONG MenuTimeOut,
242 OUT PULONG SelectedMenuItem,
243 IN BOOLEAN CanEscape,
246
248//
249// UI virtual table
250//
252typedef struct tagUIVTBL
253{
256
257 VOID (*DrawBackdrop)(ULONG DrawHeight);
258 VOID (*FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr);
260 VOID (*DrawBox)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr);
262 VOID (*DrawText2)(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr);
263 VOID (*DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr);
264 VOID (*DrawStatusText)(PCSTR StatusText);
266 VOID (*MessageBox)(PCSTR MessageText);
268
270 _In_ PCSTR ProgressText);
271
273 _In_ ULONG Left,
274 _In_ ULONG Top,
275 _In_ ULONG Right,
277 _In_ PCSTR ProgressText);
278
280 _In_ PCSTR ProgressText);
281
283 _In_ ULONG SubPercentTimes100);
284
285 BOOLEAN (*EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
286 UCHAR (*TextToColor)(PCSTR ColorText);
287 UCHAR (*TextToFillStyle)(PCSTR FillStyleText);
290
292 IN PCSTR MenuHeader,
293 IN PCSTR MenuFooter OPTIONAL,
294 IN PCSTR MenuItemList[],
295 IN ULONG MenuItemCount,
296 IN ULONG DefaultMenuItem,
297 IN LONG MenuTimeOut,
298 OUT PULONG SelectedMenuItem,
299 IN BOOLEAN CanEscape,
302
305
306VOID UiInit(const char *CmdLine);
307
308VOID
310
311extern UIVTBL UiVtbl;
312
313/*
314 * Fill styles for DrawBackdrop()
315 */
316#define LIGHT_FILL 0xB0
317#define MEDIUM_FILL 0xB1
318#define DARK_FILL 0xB2
319
320/*
321 * Combines the foreground and background colors into a single attribute byte
322 */
323#define ATTR(cFore, cBack) ((cBack << 4) | cFore)
324
325/*
326 * Screen colors
327 */
328#define COLOR_BLACK 0
329#define COLOR_BLUE 1
330#define COLOR_GREEN 2
331#define COLOR_CYAN 3
332#define COLOR_RED 4
333#define COLOR_MAGENTA 5
334#define COLOR_BROWN 6
335#define COLOR_GRAY 7
336
337#define COLOR_DARKGRAY 8
338#define COLOR_LIGHTBLUE 9
339#define COLOR_LIGHTGREEN 10
340#define COLOR_LIGHTCYAN 11
341#define COLOR_LIGHTRED 12
342#define COLOR_LIGHTMAGENTA 13
343#define COLOR_YELLOW 14
344#define COLOR_WHITE 15
345
346/* Add COLOR_BLINK to a background to cause blinking */
347// #define COLOR_BLINK 8
348
349/*
350 * Defines for IBM box drawing characters
351 */
352#define HORZ 0xC4 // Single horizontal line
353#define D_HORZ 0xCD // Double horizontal line
354#define VERT 0xB3 // Single vertical line
355#define D_VERT 0xBA // Double vertical line
356
357
358/* THEME HEADERS *************************************************************/
359
360// #include <ui/gui.h>
361#include <ui/minitui.h>
362#include <ui/noui.h>
363#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:633
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
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 UiDrawBackdrop(ULONG DrawHeight)
Definition: ui.c:233
UCHAR UiGetMenuBgColor(VOID)
Definition: ui.c:661
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:229
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:628
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 UiGetScreenHeight(VOID)
Definition: ui.c:655
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 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
BOOLEAN UiDisplayMenu(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: ui.c:605
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 UiResetForSOS(VOID)
Definition: ui.c:639
VOID UiUpdateDateTime(VOID)
Definition: ui.c:291
UCHAR UiEditBoxBgColor
Definition: ui.c:40
VOID UiFadeInBackdrop(VOID)
Definition: ui.c:623
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
ULONG Top
Definition: ui.h:138
struct _UI_PROGRESS_BAR::@208 Indicator
ULONG Bottom
Definition: ui.h:140
ULONG Count
Definition: ui.h:132
struct _UI_PROGRESS_BAR::@207 State
ULONG Bias
Definition: ui.h:126
ULONG Percentage
Definition: ui.h:134
BOOLEAN Show
Definition: ui.h:142
ULONG Left
Definition: ui.h:137
ULONG Right
Definition: ui.h:139
ULONG Expected
Definition: ui.h:133
ULONG Floor
Definition: ui.h:124
Definition: ui.h:253
VOID(* FadeInBackdrop)(VOID)
Definition: ui.h:288
VOID(* DrawText)(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr)
Definition: ui.h:261
VOID(* FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: ui.h:258
VOID(* DrawBox)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
Definition: ui.h:260
VOID(* DrawMenu)(PUI_MENU_INFO MenuInfo)
Definition: ui.h:303
VOID(* DrawStatusText)(PCSTR StatusText)
Definition: ui.h:264
BOOLEAN(* DisplayMenu)(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: ui.h:291
UCHAR(* TextToFillStyle)(PCSTR FillStyleText)
Definition: ui.h:287
VOID(* TickProgressBar)(_In_ ULONG SubPercentTimes100)
Definition: ui.h:282
BOOLEAN(* EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: ui.h:285
VOID(* DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr)
Definition: ui.h:263
VOID(* MessageBox)(PCSTR MessageText)
Definition: ui.h:266
BOOLEAN(* Initialize)(VOID)
Definition: ui.h:254
VOID(* DrawProgressBarCenter)(_In_ PCSTR ProgressText)
Definition: ui.h:269
VOID(* UnInitialize)(VOID)
Definition: ui.h:255
VOID(* DrawShadow)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
Definition: ui.h:259
VOID(* DrawProgressBar)(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.h:272
VOID(* MessageBoxCritical)(PCSTR MessageText)
Definition: ui.h:267
VOID(* DrawText2)(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr)
Definition: ui.h:262
VOID(* DrawBackdrop)(ULONG DrawHeight)
Definition: ui.h:257
VOID(* SetProgressBarText)(_In_ PCSTR ProgressText)
Definition: ui.h:279
VOID(* FadeOut)(VOID)
Definition: ui.h:289
VOID(* UpdateDateTime)(VOID)
Definition: ui.h:265
UCHAR(* TextToColor)(PCSTR ColorText)
Definition: ui.h:286
PCSTR MenuHeader
Definition: ui.h:212
ULONG Right
Definition: ui.h:223
LONG MenuTimeRemaining
Definition: ui.h:217
ULONG Bottom
Definition: ui.h:224
ULONG SelectedMenuItem
Definition: ui.h:218
ULONG Left
Definition: ui.h:221
PCSTR MenuFooter
Definition: ui.h:213
ULONG MenuItemCount
Definition: ui.h:216
PCSTR * MenuItemList
Definition: ui.h:215
PVOID Context
Definition: ui.h:219
ULONG Top
Definition: ui.h:222
#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