summaryrefslogtreecommitdiff
path: root/EDK/MiniSetup/BootOnly/box.c
blob: 535995e5e269ad54d1cc11e455d18b86536ea8ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
//*****************************************************************//
//*****************************************************************//
//*****************************************************************//
//**                                                             **//
//**         (C)Copyright 2010, American Megatrends, Inc.        **//
//**                                                             **//
//**                     All Rights Reserved.                    **//
//**                                                             **//
//**   5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093  **//
//**                                                             **//
//**                     Phone (770)-246-8600                    **//
//**                                                             **//
//*****************************************************************//
//*****************************************************************//
//*****************************************************************//
// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.c $
//
// $Author: Arunsb $
//
// $Revision: 5 $
//
// $Date: 10/18/12 5:58a $
//
//*****************************************************************//
//*****************************************************************//
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.c $
// 
// 5     10/18/12 5:58a Arunsb
// Updated for 2.16.1235 QA submission
// 
// 8     10/10/12 12:36p Arunsb
// Synched the source for v2.16.1232, backup with Aptio
// 
// 4     2/19/10 1:01p Madhans
// Updated for TSE 2.01. Refer Changelog.log for File change history.
// 
// 5     2/19/10 8:14a Mallikarjunanv
// updated year in copyright message
// 
// 4     12/10/09 2:59p Presannar
// Modified DrawBorder fn to  check if Width or Height is zero. This is a
// solution to address EiP - 32242
// 
// 3     6/23/09 6:56p Blaines
// Coding standard update, 
// Remove spaces from file header to allow proper chm function list
// creation.
// 
// 2     6/12/09 7:41p Presannar
// Initial implementation of coding standards
// 
// 1     6/04/09 8:05p Madhans
// 
// 1     4/28/09 11:11p Madhans
// Tse 2.0 Code complete Checkin.
// 
// 2     1/30/09 6:06p Madhans
// Function headers added. 
// 
// 1     12/18/08 7:58p Madhans
// Intial version of TSE Lite sources
//*****************************************************************//
//*****************************************************************//

#include "minisetup.h"

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:	DrawLineWithAttribute
//
// Description:	function to draw the lines with attributes
//
// Input:		UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib
//
// Output:		void
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
VOID DrawLineWithAttribute( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib )
{
	UINTN	Index;
	CHAR16	*Line;

	Line = EfiLibAllocatePool( sizeof(CHAR16) * (Length + 1) );
	if ( Line == NULL )
		return;

	for ( Index = 0; Index < Length; Index++ )
		Line[Index] = Type;

	Line[Index] = 0;

	DrawStringWithAttribute( Col, Row, Line, Attrib );

	MemFreePointer( (VOID **)&Line );
}

VOID DrawLine( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type )
{
	DrawLineWithAttribute( Col, Row, Length, Type, 0 );
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:	DrawBorder
//
// Description:	function to draw the border
//
// Input:		UINTN Left, UINTN Top, UINTN Width, UINTN Height
//
// Output:		void
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
VOID DrawBorder( UINTN Left, UINTN Top, UINTN Width, UINTN Height )
{
	UINTN	Index;
	CHAR16	*Line;
	UINTN	Right, Bottom;

	if( Width == 0 || Height == 0 )
		return;

	Line = EfiLibAllocateZeroPool( (Width + 6) * sizeof(CHAR16) );
	if ( Line == NULL )
		return;

	Right = Left + Width - 1;
	Bottom = Top + Height - 1;

	for ( Index = 1; Index < Width - 1; Index++ )
		Line[Index] = BOXDRAW_HORIZONTAL;

	Line[0] = BOXDRAW_DOWN_RIGHT;
	Line[Index] = BOXDRAW_DOWN_LEFT;
	DrawString( Left, Top, Line );
	Line[0] = BOXDRAW_UP_RIGHT;
	Line[Index] = BOXDRAW_UP_LEFT;
	DrawString( Left, Bottom, Line );

	Line[0] = BOXDRAW_VERTICAL;
	Line[1] = 0;

	for ( Index = Top + 1; Index < Bottom; Index++ )
	{
		DrawString( Left, Index, Line );
		DrawString( Right, Index, Line );
	}

	MemFreePointer( (VOID **)&Line );
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:	DrawWindow
//
// Description:	function to draw a window
//
// Input:		UINTN Left, UINTN Top, UINTN Width, UINTN Height,
//				UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow
//
// Output:		void
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
VOID DrawWindow( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow )
{
	if ( Shadow )
		DrawBox( Left + 2, Top + 1, Width, Height, 0 );

	DrawBox( Left, Top, Width, Height, Attrib );

	if ( Border )
		DrawBorder( Left, Top, Width, Height );
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:	DrawBox
//
// Description:	function to draw a box
//
// Input:		UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib
//
// Output:		void
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
VOID DrawBox( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib )
{
	UINTN	Bottom, Right;
	UINTN	Index;
	UINTN	Offset;
	CHAR16	WindowLine[MAX_COLS];
	UINT8	AttribLine[MAX_COLS];

	Bottom = Top + Height;
	if ( Bottom >= gMaxRows )
	{
		Bottom = gMaxRows - 1;
		Height = Bottom - Top;
	}

	Right = Left + Width;
	if ( Right >= gMaxCols )
	{
		Right = gMaxCols - 1;
		Width = Right - Left;
	}

	MemSet( AttribLine, Width, Attrib );
	for ( Index = 0; Index < Width; Index++ )
		WindowLine[Index] = L' ';

	Offset = Top * gMaxCols + Left;
	for ( Index = Top; Index < Bottom; Index++, Offset += gMaxCols )
	{
		// to resolve the wide char corruption when box is drawn
		if((Left) && ( IsCharWide( gFlushBuffer->Chars[Offset-1]) == TRUE ))
				gActiveBuffer->Chars[Offset-1]=L' ';

		MemCopy( &gActiveBuffer->Chars[Offset], WindowLine, sizeof(CHAR16) * Width );
		MemCopy( &gActiveBuffer->Attribs[Offset], AttribLine, Width );
	}
}

//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**     5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093     **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************