8aeb842bd9c89228f084866f7a6ef7e610441456
[reactos.git] / reactos / boot / freeldr / freeldr / ui / tui.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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __TUI_H
21 #define __TUI_H
22
23 #define TUI_SCREEN_MEM 0xB8000
24 #define TUI_TITLE_BOX_CHAR_HEIGHT 5
25
26 ///////////////////////////////////////////////////////////////////////////////////////
27 //
28 // Textual User Interface Functions
29 //
30 ///////////////////////////////////////////////////////////////////////////////////////
31 BOOL TuiInitialize(VOID); // Initialize User-Interface
32 VOID TuiUnInitialize(VOID); // Un-initialize User-Interface
33
34 VOID TuiDrawBackdrop(VOID); // Fills the entire screen with a backdrop
35 VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */); // Fills the area specified with FillChar and Attr
36 VOID TuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom); // Draws a shadow on the bottom and right sides of the area specified
37 VOID TuiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr); // Draws a box around the area specified
38 VOID TuiDrawText(ULONG X, ULONG Y, PUCHAR Text, UCHAR Attr); // Draws text at coordinates specified
39 VOID TuiDrawCenteredText(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, PUCHAR TextString, UCHAR Attr); // Draws centered text at the coordinates specified and clips the edges
40 VOID TuiDrawStatusText(PUCHAR StatusText); // Draws text at the very bottom line on the screen
41 VOID TuiUpdateDateTime(VOID); // Updates the date and time
42 VOID TuiSaveScreen(PUCHAR Buffer); // Saves the screen so that it can be restored later
43 VOID TuiRestoreScreen(PUCHAR Buffer); // Restores the screen from a previous save
44 VOID TuiMessageBox(PUCHAR MessageText); // Displays a message box on the screen with an ok button
45 VOID TuiMessageBoxCritical(PUCHAR MessageText); // Displays a message box on the screen with an ok button using no system resources
46 VOID TuiDrawProgressBarCenter(ULONG Position, ULONG Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
47 VOID TuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
48 BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, ULONG Length);
49
50 UCHAR TuiTextToColor(PUCHAR ColorText); // Converts the text color into it's equivalent color value
51 UCHAR TuiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill into it's equivalent fill value
52
53 VOID TuiFadeInBackdrop(VOID); // Draws the backdrop and fades the screen in
54 VOID TuiFadeOut(VOID); // Fades the screen out
55
56 ///////////////////////////////////////////////////////////////////////////////////////
57 //
58 // Menu Functions
59 //
60 ///////////////////////////////////////////////////////////////////////////////////////
61
62 typedef struct
63 {
64 PUCHAR *MenuItemList;
65 ULONG MenuItemCount;
66 LONG MenuTimeRemaining;
67 ULONG SelectedMenuItem;
68
69 ULONG Left;
70 ULONG Top;
71 ULONG Right;
72 ULONG Bottom;
73
74 } TUI_MENU_INFO, *PTUI_MENU_INFO;
75
76 VOID TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo);
77 VOID TuiDrawMenu(PTUI_MENU_INFO MenuInfo);
78 VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo);
79 VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, ULONG MenuItemNumber);
80 ULONG TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter);
81 BOOL TuiDisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);
82
83
84 /*
85 * Combines the foreground and background colors into a single attribute byte
86 */
87 #define ATTR(cFore, cBack) ((cBack << 4)|cFore)
88
89 /*
90 * Fill styles for DrawBackdrop()
91 */
92 #define LIGHT_FILL 0xB0
93 #define MEDIUM_FILL 0xB1
94 #define DARK_FILL 0xB2
95
96 /*
97 * Screen colors
98 */
99 #define COLOR_BLACK 0
100 #define COLOR_BLUE 1
101 #define COLOR_GREEN 2
102 #define COLOR_CYAN 3
103 #define COLOR_RED 4
104 #define COLOR_MAGENTA 5
105 #define COLOR_BROWN 6
106 #define COLOR_GRAY 7
107
108 #define COLOR_DARKGRAY 8
109 #define COLOR_LIGHTBLUE 9
110 #define COLOR_LIGHTGREEN 10
111 #define COLOR_LIGHTCYAN 11
112 #define COLOR_LIGHTRED 12
113 #define COLOR_LIGHTMAGENTA 13
114 #define COLOR_YELLOW 14
115 #define COLOR_WHITE 15
116
117 /* Add COLOR_BLINK to a background to cause blinking */
118 #define COLOR_BLINK 8
119
120 /*
121 * Defines for IBM box drawing characters
122 */
123 #define HORZ (0xc4) /* Single horizontal line */
124 #define D_HORZ (0xcd) /* Double horizontal line.*/
125 #define VERT (0xb3) /* Single vertical line */
126 #define D_VERT (0xba) /* Double vertical line. */
127
128 /* Definitions for corners, depending on HORIZ and VERT */
129 #define UL (0xda)
130 #define UR (0xbf) /* HORZ and VERT */
131 #define LL (0xc0)
132 #define LR (0xd9)
133
134 #define D_UL (0xc9)
135 #define D_UR (0xbb) /* D_HORZ and D_VERT */
136 #define D_LL (0xc8)
137 #define D_LR (0xbc)
138
139 #define HD_UL (0xd5)
140 #define HD_UR (0xb8) /* D_HORZ and VERT */
141 #define HD_LL (0xd4)
142 #define HD_LR (0xbe)
143
144 #define VD_UL (0xd6)
145 #define VD_UR (0xb7) /* HORZ and D_VERT */
146 #define VD_LL (0xd3)
147 #define VD_LR (0xbd)
148
149
150 #endif // #defined __TUI_H