ReactOS  0.4.15-dev-1152-g6c94e4f
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 CHAR UiTitleBoxTitleText[260]; // Title box's title text
43 
44 extern BOOLEAN UiUseSpecialEffects; // Tells us if we should use fade effects
45 extern BOOLEAN UiCenterMenu;
46 extern BOOLEAN UiMenuBox;
47 extern CHAR UiTimeText[];
48 extern BOOLEAN UiDrawTime;
49 
50 extern const CHAR UiMonthNames[12][15];
51 
53 //
54 // User Interface Functions
55 //
57 BOOLEAN UiInitialize(BOOLEAN ShowGui); // Initialize User-Interface
58 VOID UiUnInitialize(PCSTR BootText); // Un-initialize User-Interface
59 VOID UiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
60 VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
61 VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
62 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
63 VOID UiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr); // Draws text at coordinates specified
64 VOID UiDrawText2(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr); // Draws text at coordinates specified
65 VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges
66 VOID UiDrawStatusText(PCSTR StatusText); // Draws text at the very bottom line on the screen
67 VOID UiUpdateDateTime(VOID); // Updates the date and time
68 VOID UiInfoBox(PCSTR MessageText); // Displays a info box on the screen
69 VOID UiMessageBox(PCSTR Format, ...); // Displays a message box on the screen with an ok button
70 VOID UiMessageBoxCritical(PCSTR MessageText); // Displays a message box on the screen with an ok button using no system resources
71 VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled
72 VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled
73 
74 // Displays all the message boxes in a given section.
75 VOID
77  IN ULONG_PTR SectionId);
78 
79 VOID
81  IN ULONG Argc,
82  IN PCHAR Argv[]);
83 
84 VOID UiEscapeString(PCHAR String); // Processes a string and changes all occurrences of "\n" to '\n'
85 BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
86 
87 UCHAR UiTextToColor(PCSTR ColorText); // Converts the text color into it's equivalent color value
88 UCHAR UiTextToFillStyle(PCSTR FillStyleText); // Converts the text fill into it's equivalent fill value
89 
90 VOID UiTruncateStringEllipsis(PCHAR StringText, ULONG MaxChars); // Truncates a string to MaxChars by adding an ellipsis on the end '...'
91 
92 VOID UiFadeInBackdrop(VOID); // Draws the backdrop and fades the screen in
93 VOID UiFadeOut(VOID); // Fades the screen out
94 
96 //
97 // Menu Functions
98 //
100 
101 typedef struct tagUI_MENU_INFO
102 {
106 
112 
118 
119 typedef
120 BOOLEAN
122  IN ULONG KeyPress,
123  IN ULONG SelectedMenuItem,
125 
126 BOOLEAN
128  IN PCSTR MenuHeader,
129  IN PCSTR MenuFooter OPTIONAL,
130  IN BOOLEAN ShowBootOptions,
131  IN PCSTR MenuItemList[],
132  IN ULONG MenuItemCount,
133  IN ULONG DefaultMenuItem,
134  IN LONG MenuTimeOut,
135  OUT PULONG SelectedMenuItem,
136  IN BOOLEAN CanEscape,
139 
141 //
142 // UI virtual table
143 //
145 typedef struct tagUIVTBL
146 {
149 
151  VOID (*FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr);
153  VOID (*DrawBox)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr);
155  VOID (*DrawText2)(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr);
156  VOID (*DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr);
157  VOID (*DrawStatusText)(PCSTR StatusText);
159  VOID (*MessageBox)(PCSTR MessageText);
160  VOID (*MessageBoxCritical)(PCSTR MessageText);
163  BOOLEAN (*EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
164  UCHAR (*TextToColor)(PCSTR ColorText);
165  UCHAR (*TextToFillStyle)(PCSTR FillStyleText);
168 
170  IN PCSTR MenuHeader,
171  IN PCSTR MenuFooter OPTIONAL,
172  IN BOOLEAN ShowBootOptions,
173  IN PCSTR MenuItemList[],
174  IN ULONG MenuItemCount,
175  IN ULONG DefaultMenuItem,
176  IN LONG MenuTimeOut,
177  OUT PULONG SelectedMenuItem,
178  IN BOOLEAN CanEscape,
181 
183 } UIVTBL, *PUIVTBL;
184 
185 VOID UiInit(const char *CmdLine);
186 
187 extern UIVTBL UiVtbl;
188 
189 /*
190  * Combines the foreground and background colors into a single attribute byte
191  */
192 #define ATTR(cFore, cBack) ((cBack << 4)|cFore)
193 
194 /*
195  * Fill styles for DrawBackdrop()
196  */
197 #define LIGHT_FILL 0xB0
198 #define MEDIUM_FILL 0xB1
199 #define DARK_FILL 0xB2
200 
201 /*
202  * Screen colors
203  */
204 #define COLOR_BLACK 0
205 #define COLOR_BLUE 1
206 #define COLOR_GREEN 2
207 #define COLOR_CYAN 3
208 #define COLOR_RED 4
209 #define COLOR_MAGENTA 5
210 #define COLOR_BROWN 6
211 #define COLOR_GRAY 7
212 
213 #define COLOR_DARKGRAY 8
214 #define COLOR_LIGHTBLUE 9
215 #define COLOR_LIGHTGREEN 10
216 #define COLOR_LIGHTCYAN 11
217 #define COLOR_LIGHTRED 12
218 #define COLOR_LIGHTMAGENTA 13
219 #define COLOR_YELLOW 14
220 #define COLOR_WHITE 15
221 
222 /* Add COLOR_BLINK to a background to cause blinking */
223 //#define COLOR_BLINK 8
224 
225 /*
226  * Defines for IBM box drawing characters
227  */
228 #define HORZ (0xc4) /* Single horizontal line */
229 #define D_HORZ (0xcd) /* Double horizontal line.*/
230 #define VERT (0xb3) /* Single vertical line */
231 #define D_VERT (0xba) /* Double vertical line. */
PCSTR MenuHeader
Definition: ui.h:103
signed char * PCHAR
Definition: retypes.h:7
ULONG MenuItemCount
Definition: ui.h:108
#define IN
Definition: typedefs.h:39
LONG MenuTimeRemaining
Definition: ui.h:109
UCHAR UiTextColor
Definition: ui.c:42
VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText)
Definition: ui.c:351
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:109
#define Y(I)
CHAR UiTitleBoxTitleText[260]
Definition: ui.c:48
VOID(* DrawText)(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr)
Definition: ui.h:154
BOOLEAN UiInitialize(BOOLEAN ShowGui)
Definition: ui.c:84
CHAR UiTimeText[]
Definition: ui.c:54
UCHAR UiMessageBoxFgColor
Definition: ui.c:38
static COORD Position
Definition: mouse.c:34
char CHAR
Definition: xmlstorage.h:175
VOID UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr)
Definition: ui.c:244
VOID UiInfoBox(PCSTR MessageText)
Definition: ui.c:259
static WCHAR String[]
Definition: stringtable.c:55
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:463
ULONG UiScreenHeight
Definition: ui.c:29
UCHAR UiTitleBoxBgColor
Definition: ui.c:37
VOID(* FadeInBackdrop)(VOID)
Definition: ui.h:166
VOID UiEscapeString(PCHAR String)
Definition: ui.c:437
BOOLEAN UiCenterMenu
Definition: ui.c:52
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct tagRange Range
UCHAR(* TextToColor)(PCSTR ColorText)
Definition: ui.h:164
PVOID Context
Definition: ui.h:111
UIVTBL UiVtbl
Definition: ui.c:58
ULONG Bottom
Definition: ui.h:116
struct tagUI_MENU_INFO UI_MENU_INFO
VOID(* DrawProgressBarCenter)(ULONG Position, ULONG Range, PCHAR ProgressText)
Definition: ui.h:161
UCHAR UiEditBoxTextColor
Definition: ui.c:45
long LONG
Definition: pedump.c:60
BOOLEAN ShowBootOptions
Definition: ui.h:105
BOOLEAN UiDrawTime
Definition: ui.c:51
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
VOID UiInit(const char *CmdLine)
unsigned char BOOLEAN
ULONG Top
Definition: ui.h:114
VOID(* DrawText2)(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr)
Definition: ui.h:155
VOID UiDrawText(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr)
Definition: ui.c:234
VOID(* MessageBox)(PCSTR MessageText)
Definition: ui.h:159
VOID(* FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: ui.h:151
VOID UiDrawText2(ULONG X, ULONG Y, ULONG MaxNumChars, PCSTR Text, UCHAR Attr)
Definition: ui.c:239
ULONG Right
Definition: ui.h:115
BOOLEAN(* Initialize)(VOID)
Definition: ui.h:147
VOID(* UpdateDateTime)(VOID)
Definition: ui.h:158
BOOLEAN UiMenuBox
Definition: ui.c:53
ULONG SelectedMenuItem
Definition: ui.h:110
UCHAR UiTextToFillStyle(PCSTR FillStyleText)
Definition: ui.c:341
VOID UiShowMessageBoxesInArgv(IN ULONG Argc, IN PCHAR Argv[])
Definition: ui.c:401
VOID(* DrawShadow)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
Definition: ui.h:152
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:153
UCHAR UiBackdropFillStyle
Definition: ui.c:35
UCHAR UiEditBoxBgColor
Definition: ui.c:46
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID UiShowMessageBoxesInSection(IN ULONG_PTR SectionId)
Definition: ui.c:357
VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
Definition: ui.c:229
BOOLEAN(* EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: ui.h:163
CHAR CmdLine[MAX_PATH]
Definition: mach.c:34
UCHAR UiStatusBarBgColor
Definition: ui.c:32
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:249
BOOLEAN(* UiMenuKeyPressFilterCallback)(IN ULONG KeyPress, IN ULONG SelectedMenuItem, IN PVOID Context OPTIONAL)
Definition: ui.h:121
UCHAR UiMenuBgColor
Definition: ui.c:41
UCHAR UiTitleBoxFgColor
Definition: ui.c:36
#define VOID
Definition: acefi.h:82
BOOLEAN UiUseSpecialEffects
Definition: ui.c:50
VOID UiUnInitialize(PCSTR BootText)
Definition: ui.c:205
VOID UiUpdateDateTime(VOID)
Definition: ui.c:254
Definition: ui.h:145
Definition: range.c:39
VOID UiDrawBackdrop(VOID)
Definition: ui.c:214
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:169
UCHAR UiBackdropBgColor
Definition: ui.c:34
ULONG Left
Definition: ui.h:113
VOID(* MessageBoxCritical)(PCSTR MessageText)
Definition: ui.h:160
VOID(* DrawMenu)(PUI_MENU_INFO MenuInfo)
Definition: ui.h:182
BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: ui.c:492
struct tagUIVTBL * PUIVTBL
VOID UiTruncateStringEllipsis(PCHAR StringText, ULONG MaxChars)
Definition: ui.c:455
static LPHIST_ENTRY Bottom
Definition: history.c:54
VOID(* DrawStatusText)(PCSTR StatusText)
Definition: ui.h:157
UCHAR UiSelectedTextBgColor
Definition: ui.c:44
VOID(* DrawProgressBar)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText)
Definition: ui.h:162
VOID UiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
Definition: ui.c:224
struct tagUIVTBL UIVTBL
VOID(* DrawBackdrop)(VOID)
Definition: ui.h:150
UCHAR UiMessageBoxBgColor
Definition: ui.c:39
#define OPTIONAL
Definition: typedefs.h:41
unsigned int * PULONG
Definition: retypes.h:1
VOID(* FadeOut)(VOID)
Definition: ui.h:167
#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:219
unsigned int ULONG
Definition: retypes.h:1
const CHAR UiMonthNames[12][15]
Definition: ui.c:56
UCHAR UiBackdropFgColor
Definition: ui.c:33
UCHAR UiMenuFgColor
Definition: ui.c:40
const char * PCSTR
Definition: typedefs.h:52
PCSTR MenuFooter
Definition: ui.h:104
ULONG UiScreenWidth
Definition: ui.c:28
VOID(* DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr)
Definition: ui.h:156
UCHAR UiTextToColor(PCSTR ColorText)
Definition: ui.c:336
UCHAR(* TextToFillStyle)(PCSTR FillStyleText)
Definition: ui.h:165
VOID UiFadeOut(VOID)
Definition: ui.c:487
static LPHIST_ENTRY Top
Definition: history.c:53
VOID(* UnInitialize)(VOID)
Definition: ui.h:148
VOID UiFadeInBackdrop(VOID)
Definition: ui.c:482
UCHAR UiStatusBarFgColor
Definition: ui.c:31
PCSTR * MenuItemList
Definition: ui.h:107
#define X(b, s)
char * Text
Definition: combotst.c:136
VOID UiMessageBoxCritical(PCSTR MessageText)
Definition: ui.c:331
UCHAR UiSelectedTextColor
Definition: ui.c:43
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
Definition: ui.c:346
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68