[FREELDR]
[reactos.git] / reactos / boot / freeldr / freeldr / include / ui.h
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
52 ///////////////////////////////////////////////////////////////////////////////////////
53 //
54 // User Interface Functions
55 //
56 ///////////////////////////////////////////////////////////////////////////////////////
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 UiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges
65 VOID UiDrawStatusText(PCSTR StatusText); // Draws text at the very bottom line on the screen
66 VOID UiUpdateDateTime(VOID); // Updates the date and time
67 VOID UiInfoBox(PCSTR MessageText); // Displays a info box on the screen
68 VOID UiMessageBox(PCSTR MessageText); // Displays a message box on the screen with an ok button
69 VOID UiMessageBoxCritical(PCSTR MessageText); // Displays a message box on the screen with an ok button using no system resources
70 VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled
71 VOID UiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText); // Draws the progress bar showing nPos percent filled
72 VOID UiShowMessageBoxesInSection(PCSTR SectionName); // Displays all the message boxes in a given section
73 VOID UiEscapeString(PCHAR String); // Processes a string and changes all occurances of "\n" to '\n'
74 BOOLEAN UiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
75
76 UCHAR UiTextToColor(PCSTR ColorText); // Converts the text color into it's equivalent color value
77 UCHAR UiTextToFillStyle(PCSTR FillStyleText); // Converts the text fill into it's equivalent fill value
78
79 VOID UiTruncateStringEllipsis(PCHAR StringText, ULONG MaxChars); // Truncates a string to MaxChars by adding an ellipsis on the end '...'
80
81 VOID UiFadeInBackdrop(VOID); // Draws the backdrop and fades the screen in
82 VOID UiFadeOut(VOID); // Fades the screen out
83
84 ///////////////////////////////////////////////////////////////////////////////////////
85 //
86 // Menu Functions
87 //
88 ///////////////////////////////////////////////////////////////////////////////////////
89
90 struct tagUI_MENU_INFO;
91 typedef struct tagUI_MENU_INFO UI_MENU_INFO, *PUI_MENU_INFO;
92
93 typedef BOOLEAN (*UiMenuKeyPressFilterCallback)(ULONG KeyPress);
94
95 BOOLEAN UiDisplayMenu(PCSTR MenuTitle, PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);
96
97 ///////////////////////////////////////////////////////////////////////////////////////
98 //
99 // UI virtual table
100 //
101 ///////////////////////////////////////////////////////////////////////////////////////
102 typedef struct tagUIVTBL
103 {
104 BOOLEAN (*Initialize)(VOID);
105 VOID (*UnInitialize)(VOID);
106
107 VOID (*DrawBackdrop)(VOID);
108 VOID (*FillArea)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr);
109 VOID (*DrawShadow)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom);
110 VOID (*DrawBox)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr);
111 VOID (*DrawText)(ULONG X, ULONG Y, PCSTR Text, UCHAR Attr);
112 VOID (*DrawCenteredText)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PCSTR TextString, UCHAR Attr);
113 VOID (*DrawStatusText)(PCSTR StatusText);
114 VOID (*UpdateDateTime)(VOID);
115 VOID (*MessageBox)(PCSTR MessageText);
116 VOID (*MessageBoxCritical)(PCSTR MessageText);
117 VOID (*DrawProgressBarCenter)(ULONG Position, ULONG Range, PCHAR ProgressText);
118 VOID (*DrawProgressBar)(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText);
119 BOOLEAN (*EditBox)(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length);
120 UCHAR (*TextToColor)(PCSTR ColorText);
121 UCHAR (*TextToFillStyle)(PCSTR FillStyleText);
122 VOID (*FadeInBackdrop)(VOID);
123 VOID (*FadeOut)(VOID);
124
125 BOOLEAN (*DisplayMenu)(PCSTR MenuTitle, PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);
126 VOID (*DrawMenu)(PUI_MENU_INFO MenuInfo);
127 } UIVTBL, *PUIVTBL;
128
129 VOID UiInit(const char *CmdLine);
130
131 extern UIVTBL UiVtbl;
132
133 /*
134 * Combines the foreground and background colors into a single attribute byte
135 */
136 #define ATTR(cFore, cBack) ((cBack << 4)|cFore)
137
138 /*
139 * Fill styles for DrawBackdrop()
140 */
141 #define LIGHT_FILL 0xB0
142 #define MEDIUM_FILL 0xB1
143 #define DARK_FILL 0xB2
144
145 /*
146 * Screen colors
147 */
148 #define COLOR_BLACK 0
149 #define COLOR_BLUE 1
150 #define COLOR_GREEN 2
151 #define COLOR_CYAN 3
152 #define COLOR_RED 4
153 #define COLOR_MAGENTA 5
154 #define COLOR_BROWN 6
155 #define COLOR_GRAY 7
156
157 #define COLOR_DARKGRAY 8
158 #define COLOR_LIGHTBLUE 9
159 #define COLOR_LIGHTGREEN 10
160 #define COLOR_LIGHTCYAN 11
161 #define COLOR_LIGHTRED 12
162 #define COLOR_LIGHTMAGENTA 13
163 #define COLOR_YELLOW 14
164 #define COLOR_WHITE 15
165
166 /* Add COLOR_BLINK to a background to cause blinking */
167 //#define COLOR_BLINK 8
168
169 /*
170 * Defines for IBM box drawing characters
171 */
172 #define HORZ (0xc4) /* Single horizontal line */
173 #define D_HORZ (0xcd) /* Double horizontal line.*/
174 #define VERT (0xb3) /* Single vertical line */
175 #define D_VERT (0xba) /* Double vertical line. */