ReactOS  0.4.15-dev-4857-g47842d7
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 
22 extern ULONG UiScreenWidth; // Screen Width
23 extern ULONG UiScreenHeight; // Screen Height
24 
25 extern UCHAR UiStatusBarFgColor; // Status bar foreground color
26 extern UCHAR UiStatusBarBgColor; // Status bar background color
27 extern UCHAR UiBackdropFgColor; // Backdrop foreground color
28 extern UCHAR UiBackdropBgColor; // Backdrop background color
29 extern UCHAR UiBackdropFillStyle; // Backdrop fill style
30 extern UCHAR UiTitleBoxFgColor; // Title box foreground color
31 extern UCHAR UiTitleBoxBgColor; // Title box background color
32 extern UCHAR UiMessageBoxFgColor; // Message box foreground color
33 extern UCHAR UiMessageBoxBgColor; // Message box background color
34 extern UCHAR UiMenuFgColor; // Menu foreground color
35 extern UCHAR UiMenuBgColor; // Menu background color
36 extern UCHAR UiTextColor; // Normal text color
37 extern UCHAR UiSelectedTextColor; // Selected text color
38 extern UCHAR UiSelectedTextBgColor; // Selected text background color
39 extern UCHAR UiEditBoxTextColor; // Edit box text color
40 extern UCHAR UiEditBoxBgColor; // Edit box text background color
41 
42 extern BOOLEAN UiShowTime; // Whether to draw the time
43 extern BOOLEAN UiMenuBox; // Whether to draw a box around the menu
44 extern BOOLEAN UiCenterMenu; // Whether to use a centered or left-aligned menu
45 extern BOOLEAN UiUseSpecialEffects; // Whether to use fade effects
46 
47 extern CHAR UiTitleBoxTitleText[260]; // Title box's title text
48 extern CHAR UiTimeText[260];
49 
50 extern const PCSTR UiMonthNames[12];
51 
53 //
54 // User Interface Functions
55 //
57 
58 BOOLEAN UiInitialize(BOOLEAN ShowUi); // Initialize User-Interface
59 VOID UiUnInitialize(PCSTR BootText); // Un-initialize User-Interface
60 VOID UiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
61 VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
62 VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
63 VOID 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
64 
65 /* Draws text at coordinates specified */
66 VOID
68  _In_ ULONG X,
69  _In_ ULONG Y,
70  _In_ PCSTR Text,
71  _In_ UCHAR Attr);
72 
73 /* Draws text at coordinates specified */
74 VOID
76  _In_ ULONG X,
77  _In_ ULONG Y,
78  _In_opt_ ULONG MaxNumChars,
79  _In_reads_or_z_(MaxNumChars) PCSTR Text,
80  _In_ UCHAR Attr);
81 
82 /* Draws centered text at the coordinates specified and clips the edges */
83 VOID
85  _In_ ULONG Left,
86  _In_ ULONG Top,
87  _In_ ULONG Right,
89  _In_ PCSTR TextString,
90  _In_ UCHAR Attr);
91 
92 VOID UiDrawStatusText(PCSTR StatusText); // Draws text at the very bottom line on the screen
93 VOID UiUpdateDateTime(VOID); // Updates the date and time
94 VOID UiInfoBox(PCSTR MessageText); // Displays a info box on the screen
95 VOID UiMessageBox(PCSTR Format, ...); // Displays a message box on the screen with an ok button
96 VOID UiMessageBoxCritical(PCSTR MessageText); // Displays a message box on the screen with an ok button using no system resources
97 
98 
99 /* Loading Progress-Bar Functions ********************************************/
100 
101 /*
102  * Loading progress bar, based on the one from NTOS Inbv.
103  * Supports progress within sub-ranges, used when loading
104  * with an unknown number of steps.
105  */
106 typedef struct _UI_PROGRESS_BAR
107 {
108  // UI_PROGRESS_STATE
109  struct
110  {
112  // ULONG Ceiling;
114  } State;
115 
116  // BT_PROGRESS_INDICATOR
117  struct
118  {
122  } Indicator;
123 
128  // ULONG Width; // == Right - Left + 1;
131 
133 
134 VOID
136  _In_ ULONG Left,
137  _In_ ULONG Top,
138  _In_ ULONG Right,
139  _In_ ULONG Bottom,
140  _In_ PCSTR ProgressText);
141 
142 /* Indicate loading progress without any specific number of steps */
143 VOID
145 
146 /* Set a progress loading percentage range */
147 VOID
149  _In_ ULONG Floor,
150  _In_ ULONG Ceiling);
151 
152 /* Update the loading progress percentage within a selected range */
153 VOID
155  _In_ ULONG Percentage,
156  _In_opt_ PCSTR ProgressText);
157 
158 VOID
160  _In_ PCSTR ProgressText);
161 
162 /* Draws the progress bar showing nPos percent filled */
163 VOID
165  _In_ PCSTR ProgressText);
166 
167 /* Draws the progress bar showing nPos percent filled */
168 VOID
170  _In_ ULONG Left,
171  _In_ ULONG Top,
172  _In_ ULONG Right,
173  _In_ ULONG Bottom,
174  _In_ PCSTR ProgressText);
175 
176 
177 // Displays all the message boxes in a given section.
178 VOID
180  IN ULONG_PTR SectionId);
181 
182 VOID
184  IN ULONG Argc,
185  IN PCHAR Argv[]);
186 
187 BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
188 
189 UCHAR UiTextToColor(PCSTR ColorText); // Converts the text color into it's equivalent color value
190 UCHAR UiTextToFillStyle(PCSTR FillStyleText); // Converts the text fill into it's equivalent fill value
191 
192 VOID UiFadeInBackdrop(VOID); // Draws the backdrop and fades the screen in
193 VOID UiFadeOut(VOID); // Fades the screen out
194 
196 //
197 // Menu Functions
198 //
200 
201 typedef struct tagUI_MENU_INFO
202 {
206 
212 
218 
219 typedef
220 BOOLEAN
222  IN ULONG KeyPress,
223  IN ULONG SelectedMenuItem,
225 
226 BOOLEAN
228  IN PCSTR MenuHeader,
229  IN PCSTR MenuFooter OPTIONAL,
230  IN BOOLEAN ShowBootOptions,
231  IN PCSTR MenuItemList[],
232  IN ULONG MenuItemCount,
233  IN ULONG DefaultMenuItem,
234  IN LONG MenuTimeOut,
235  OUT PULONG SelectedMenuItem,
236  IN BOOLEAN CanEscape,
239 
241 //
242 // UI virtual table
243 //
245 typedef struct tagUIVTBL
246 {
249 
251  VOID (*FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr);
253  VOID (*DrawBox)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr);
255  VOID (*DrawText2)(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr);
256  VOID (*DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr);
257  VOID (*DrawStatusText)(PCSTR StatusText);
259  VOID (*MessageBox)(PCSTR MessageText);
260  VOID (*MessageBoxCritical)(PCSTR MessageText);
261 
263  _In_ PCSTR ProgressText);
264 
266  _In_ ULONG Left,
267  _In_ ULONG Top,
268  _In_ ULONG Right,
269  _In_ ULONG Bottom,
270  _In_ PCSTR ProgressText);
271 
273  _In_ PCSTR ProgressText);
274 
276  _In_ ULONG SubPercentTimes100);
277 
278  BOOLEAN (*EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
279  UCHAR (*TextToColor)(PCSTR ColorText);
280  UCHAR (*TextToFillStyle)(PCSTR FillStyleText);
283 
285  IN PCSTR MenuHeader,
286  IN PCSTR MenuFooter OPTIONAL,
287  IN BOOLEAN ShowBootOptions,
288  IN PCSTR MenuItemList[],
289  IN ULONG MenuItemCount,
290  IN ULONG DefaultMenuItem,
291  IN LONG MenuTimeOut,
292  OUT PULONG SelectedMenuItem,
293  IN BOOLEAN CanEscape,
296 
298 } UIVTBL, *PUIVTBL;
299 
300 VOID UiInit(const char *CmdLine);
301 
302 extern UIVTBL UiVtbl;
303 
304 /*
305  * Fill styles for DrawBackdrop()
306  */
307 #define LIGHT_FILL 0xB0
308 #define MEDIUM_FILL 0xB1
309 #define DARK_FILL 0xB2
310 
311 /*
312  * Combines the foreground and background colors into a single attribute byte
313  */
314 #define ATTR(cFore, cBack) ((cBack << 4) | cFore)
315 
316 /*
317  * Screen colors
318  */
319 #define COLOR_BLACK 0
320 #define COLOR_BLUE 1
321 #define COLOR_GREEN 2
322 #define COLOR_CYAN 3
323 #define COLOR_RED 4
324 #define COLOR_MAGENTA 5
325 #define COLOR_BROWN 6
326 #define COLOR_GRAY 7
327 
328 #define COLOR_DARKGRAY 8
329 #define COLOR_LIGHTBLUE 9
330 #define COLOR_LIGHTGREEN 10
331 #define COLOR_LIGHTCYAN 11
332 #define COLOR_LIGHTRED 12
333 #define COLOR_LIGHTMAGENTA 13
334 #define COLOR_YELLOW 14
335 #define COLOR_WHITE 15
336 
337 /* Add COLOR_BLINK to a background to cause blinking */
338 // #define COLOR_BLINK 8
339 
340 /*
341  * Defines for IBM box drawing characters
342  */
343 #define HORZ 0xC4 // Single horizontal line
344 #define D_HORZ 0xCD // Double horizontal line
345 #define VERT 0xB3 // Single vertical line
346 #define D_VERT 0xBA // Double vertical line
347 
348 
349 /* THEME HEADERS *************************************************************/
350 
351 // #include <ui/gui.h>
352 #include <ui/minitui.h>
353 #include <ui/noui.h>
354 #include <ui/tui.h>
PCSTR MenuHeader
Definition: ui.h:203
VOID UiUpdateProgressBar(_In_ ULONG Percentage, _In_opt_ PCSTR ProgressText)
Definition: ui.c:462
signed char * PCHAR
Definition: retypes.h:7
ULONG MenuItemCount
Definition: ui.h:208
#define IN
Definition: typedefs.h:39
struct _UI_PROGRESS_BAR::@174 Indicator
LONG MenuTimeRemaining
Definition: ui.h:209
UCHAR UiTextColor
Definition: ui.c:38
VOID(* DrawProgressBar)(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.h:265
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:109
#define _In_opt_
Definition: ms_sal.h:309
#define Y(I)
CHAR UiTitleBoxTitleText[260]
Definition: ui.c:49
VOID UiSetProgressBarSubset(_In_ ULONG Floor, _In_ ULONG Ceiling)
Definition: ui.c:447
VOID(* DrawText)(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr)
Definition: ui.h:254
UCHAR UiMessageBoxFgColor
Definition: ui.c:34
char CHAR
Definition: xmlstorage.h:175
VOID UiInfoBox(PCSTR MessageText)
Definition: ui.c:302
const PCSTR UiMonthNames[12]
Definition: ui.c:52
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:270
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:631
ULONG UiScreenHeight
Definition: ui.c:57
VOID UiInitProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.c:392
UCHAR UiTitleBoxBgColor
Definition: ui.c:33
VOID(* FadeInBackdrop)(VOID)
Definition: ui.h:281
BOOLEAN UiCenterMenu
Definition: ui.c:46
uint32_t ULONG_PTR
Definition: typedefs.h:65
UCHAR(* TextToColor)(PCSTR ColorText)
Definition: ui.h:279
PVOID Context
Definition: ui.h:211
static const WCHAR CmdLine[]
Definition: install.c:48
ULONG Right
Definition: ui.h:126
UIVTBL UiVtbl
Definition: ui.c:70
ULONG Bottom
Definition: ui.h:216
VOID(* SetProgressBarText)(_In_ PCSTR ProgressText)
Definition: ui.h:272
struct tagUI_MENU_INFO UI_MENU_INFO
UCHAR UiEditBoxTextColor
Definition: ui.c:41
long LONG
Definition: pedump.c:60
BOOLEAN ShowBootOptions
Definition: ui.h:205
struct _UI_PROGRESS_BAR UI_PROGRESS_BAR
VOID(* TickProgressBar)(_In_ ULONG SubPercentTimes100)
Definition: ui.h:275
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:363
VOID UiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: ui.c:260
VOID UiInit(const char *CmdLine)
unsigned char BOOLEAN
VOID UiDrawProgressBarCenter(_In_ PCSTR ProgressText)
Definition: ui.c:503
ULONG Top
Definition: ui.h:214
ULONG Count
Definition: ui.h:119
#define _In_
Definition: ms_sal.h:308
VOID(* DrawText2)(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr)
Definition: ui.h:255
VOID(* MessageBox)(PCSTR MessageText)
Definition: ui.h:259
ULONG Top
Definition: ui.h:125
VOID UiIndicateProgress(VOID)
Definition: ui.c:426
ULONG Expected
Definition: ui.h:120
VOID(* FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: ui.h:251
ULONG Right
Definition: ui.h:215
BOOLEAN(* Initialize)(VOID)
Definition: ui.h:247
VOID(* UpdateDateTime)(VOID)
Definition: ui.h:258
BOOLEAN UiMenuBox
Definition: ui.c:45
VOID UiDrawCenteredText(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR TextString, _In_ UCHAR Attr)
Definition: ui.c:281
ULONG SelectedMenuItem
Definition: ui.h:210
UCHAR UiTextToFillStyle(PCSTR FillStyleText)
Definition: ui.c:384
VOID UiShowMessageBoxesInArgv(IN ULONG Argc, IN PCHAR Argv[])
Definition: ui.c:594
VOID(* DrawShadow)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
Definition: ui.h:252
struct tagUI_MENU_INFO * PUI_MENU_INFO
VOID(* DrawBox)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
Definition: ui.h:253
BOOLEAN Show
Definition: ui.h:129
UCHAR UiBackdropFillStyle
Definition: ui.c:31
UCHAR UiEditBoxBgColor
Definition: ui.c:42
VOID UiShowMessageBoxesInSection(IN ULONG_PTR SectionId)
Definition: ui.c:550
VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
Definition: ui.c:254
BOOLEAN(* EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: ui.h:278
UCHAR UiStatusBarBgColor
Definition: ui.c:28
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:292
BOOLEAN(* UiMenuKeyPressFilterCallback)(IN ULONG KeyPress, IN ULONG SelectedMenuItem, IN PVOID Context OPTIONAL)
Definition: ui.h:221
UCHAR UiMenuBgColor
Definition: ui.c:37
UCHAR UiTitleBoxFgColor
Definition: ui.c:32
VOID UiSetProgressBarText(_In_ PCSTR ProgressText)
Definition: ui.c:488
#define VOID
Definition: acefi.h:82
BOOLEAN UiUseSpecialEffects
Definition: ui.c:47
VOID UiUnInitialize(PCSTR BootText)
Definition: ui.c:230
VOID UiUpdateDateTime(VOID)
Definition: ui.c:297
ULONG Bias
Definition: ui.h:113
ULONG Bottom
Definition: ui.h:127
VOID UiDrawProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.c:514
Definition: ui.h:245
VOID UiDrawBackdrop(VOID)
Definition: ui.c:239
menu info structure
Definition: window.h:275
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:284
UCHAR UiBackdropBgColor
Definition: ui.c:30
struct _UI_PROGRESS_BAR::@173 State
ULONG Left
Definition: ui.h:213
VOID(* MessageBoxCritical)(PCSTR MessageText)
Definition: ui.h:260
VOID(* DrawMenu)(PUI_MENU_INFO MenuInfo)
Definition: ui.h:297
BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: ui.c:660
struct tagUIVTBL * PUIVTBL
VOID(* DrawProgressBarCenter)(_In_ PCSTR ProgressText)
Definition: ui.h:262
static LPHIST_ENTRY Bottom
Definition: history.c:54
VOID(* DrawStatusText)(PCSTR StatusText)
Definition: ui.h:257
UCHAR UiSelectedTextBgColor
Definition: ui.c:40
ULONG Percentage
Definition: ui.h:121
VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
Definition: ui.c:249
struct _UI_PROGRESS_BAR * PUI_PROGRESS_BAR
struct tagUIVTBL UIVTBL
VOID(* DrawBackdrop)(VOID)
Definition: ui.h:250
UCHAR UiMessageBoxBgColor
Definition: ui.c:35
#define OPTIONAL
Definition: typedefs.h:41
unsigned int * PULONG
Definition: retypes.h:1
VOID(* FadeOut)(VOID)
Definition: ui.h:282
#define _In_reads_or_z_(size)
Definition: ms_sal.h:325
BOOLEAN UiInitialize(BOOLEAN ShowUi)
Definition: ui.c:98
ULONG Left
Definition: ui.h:124
#define BOOLEAN
Definition: pedump.c:73
#define OUT
Definition: typedefs.h:40
VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: ui.c:244
unsigned int ULONG
Definition: retypes.h:1
ULONG Floor
Definition: ui.h:111
UCHAR UiBackdropFgColor
Definition: ui.c:29
UCHAR UiMenuFgColor
Definition: ui.c:36
const char * PCSTR
Definition: typedefs.h:52
CHAR UiTimeText[260]
Definition: ui.c:50
PCSTR MenuFooter
Definition: ui.h:204
ULONG UiScreenWidth
Definition: ui.c:56
VOID(* DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr)
Definition: ui.h:256
UCHAR UiTextToColor(PCSTR ColorText)
Definition: ui.c:379
UCHAR(* TextToFillStyle)(PCSTR FillStyleText)
Definition: ui.h:280
VOID UiFadeOut(VOID)
Definition: ui.c:655
static LPHIST_ENTRY Top
Definition: history.c:53
VOID(* UnInitialize)(VOID)
Definition: ui.h:248
UI_PROGRESS_BAR UiProgressBar
Definition: ui.c:66
VOID UiFadeInBackdrop(VOID)
Definition: ui.c:650
UCHAR UiStatusBarFgColor
Definition: ui.c:27
PCSTR * MenuItemList
Definition: ui.h:207
#define X(b, s)
char * Text
Definition: combotst.c:136
VOID UiMessageBoxCritical(PCSTR MessageText)
Definition: ui.c:374
UCHAR UiSelectedTextColor
Definition: ui.c:39
BOOLEAN UiShowTime
Definition: ui.c:44
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68