bbc36a82dd84a49cde3273e20e4cb6e8dd14b79e
[reactos.git] / boot / freeldr / freeldr / ui / minitui.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: FreeLoader
4 * FILE: freeldr/ui/minitui.c
5 * PURPOSE: Mini Text UI interface
6 * PROGRAMMERS: Brian Palmer <brianp@sginet.com>
7 * Hervé Poussineau
8 */
9
10 #include <freeldr.h>
11
12 VOID MiniTuiDrawBackdrop(VOID)
13 {
14 //
15 // Fill in a black background
16 //
17 TuiFillArea(0,
18 0,
19 UiScreenWidth - 1,
20 UiScreenHeight - 1,
21 0,
22 0);
23
24 //
25 // Update the screen buffer
26 //
27 VideoCopyOffScreenBufferToVRAM();
28 }
29
30 VOID MiniTuiDrawStatusText(PCSTR StatusText)
31 {
32 //
33 // Minimal UI doesn't have a status bar
34 //
35 }
36
37 VOID MiniTuiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
38 {
39 ULONG Left, Top, Right, Bottom;
40 ULONG Width = 50; // Allow for 50 "bars"
41 ULONG Height = 2;
42
43 Width = 80;
44 Left = 0;
45 Right = Left + Width;
46 Top = UiScreenHeight - Height - 4;
47 Bottom = Top + Height + 1;
48
49 MiniTuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
50 }
51
52 VOID MiniTuiDrawProgressBar(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, ULONG Position, ULONG Range, PCHAR ProgressText)
53 {
54 ULONG i;
55 ULONG ProgressBarWidth = (Right - Left) - 3;
56
57 // First make sure the progress bar text fits
58 UiTruncateStringEllipsis(ProgressText, ProgressBarWidth - 4);
59
60 if (Position > Range)
61 {
62 Position = Range;
63 }
64
65 //
66 // Draw the "Loading..." text
67 //
68 TuiDrawCenteredText(Left + 2, Top + 1, Right - 2, Top + 1, ProgressText, ATTR(7, 0));
69
70 // Draw the percent complete
71 for (i=0; i<(Position*ProgressBarWidth)/Range; i++)
72 {
73 TuiDrawText(Left+2+i, Top+2, "\xDB", ATTR(UiTextColor, UiMenuBgColor));
74 }
75
76 TuiUpdateDateTime();
77 VideoCopyOffScreenBufferToVRAM();
78 }
79
80 VOID
81 MiniTuiDrawMenu(PUI_MENU_INFO MenuInfo)
82 {
83 ULONG i;
84
85 //
86 // Draw the backdrop
87 //
88 UiDrawBackdrop();
89
90 //
91 // No GUI status bar text, just minimal text. first to tell the user to
92 // choose.
93 //
94 UiVtbl.DrawText(0,
95 MenuInfo->Top - 2,
96 "Please select the operating system to start:",
97 ATTR(UiMenuFgColor, UiMenuBgColor));
98
99 //
100 // Now tell him how to choose
101 //
102 UiVtbl.DrawText(0,
103 MenuInfo->Bottom + 1,
104 "Use the up and down arrow keys to move the highlight to "
105 "your choice.",
106 ATTR(UiMenuFgColor, UiMenuBgColor));
107 UiVtbl.DrawText(0,
108 MenuInfo->Bottom + 2,
109 "Press ENTER to choose.",
110 ATTR(UiMenuFgColor, UiMenuBgColor));
111
112 //
113 // And offer F8 options
114 //
115 UiVtbl.DrawText(0,
116 UiScreenHeight - 4,
117 "For troubleshooting and advanced startup options for "
118 "ReactOS, press F8.",
119 ATTR(UiMenuFgColor, UiMenuBgColor));
120
121 //
122 // Draw the menu box
123 //
124 TuiDrawMenuBox(MenuInfo);
125
126 //
127 // Draw each line of the menu
128 //
129 for (i = 0; i < MenuInfo->MenuItemCount; i++) TuiDrawMenuItem(MenuInfo, i);
130 VideoCopyOffScreenBufferToVRAM();
131 }
132
133 const UIVTBL MiniTuiVtbl =
134 {
135 TuiInitialize,
136 TuiUnInitialize,
137 MiniTuiDrawBackdrop,
138 TuiFillArea,
139 TuiDrawShadow,
140 TuiDrawBox,
141 TuiDrawText,
142 TuiDrawCenteredText,
143 MiniTuiDrawStatusText,
144 TuiUpdateDateTime,
145 TuiMessageBox,
146 TuiMessageBoxCritical,
147 MiniTuiDrawProgressBarCenter,
148 MiniTuiDrawProgressBar,
149 TuiEditBox,
150 TuiTextToColor,
151 TuiTextToFillStyle,
152 MiniTuiDrawBackdrop, /* no FadeIn */
153 TuiFadeOut,
154 TuiDisplayMenu,
155 MiniTuiDrawMenu,
156 };