2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/UI/UIDRAW.cpp $
15 * Routines to draw UI sort of stuff.
18 * Revision 1.2 2002/06/09 04:41:29 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:11 root
25 * 3 10/13/98 9:29a Dave
26 * Started neatening up freespace.h. Many variables renamed and
27 * reorganized. Added AlphaColors.[h,cpp]
29 * 2 10/07/98 10:54a Dave
32 * 1 10/07/98 10:51a Dave
34 * 4 3/10/98 4:19p John
35 * Cleaned up graphics lib. Took out most unused gr functions. Made D3D
36 * & Glide have popups and print screen. Took out all >8bpp software
37 * support. Made Fred zbuffer. Made zbuffer allocate dynamically to
38 * support Fred. Made zbuffering key off of functions rather than one
41 * 3 2/03/98 4:21p Hoffoss
42 * Made UI controls draw white text when disabled.
44 * 2 6/11/97 1:13p John
45 * Started fixing all the text colors in the game.
47 * 1 11/14/96 6:55p John
54 #include "alphacolors.h"
56 void ui_hline(int x1, int x2, int y )
61 void ui_vline(int y1, int y2, int x )
66 void ui_string_centered( int x, int y, const char * s )
70 gr_get_string_size( &width, &height, s );
72 //baseline = height-grd_curcanv->cv_font->ft_baseline;
74 gr_string(x-((width-1)/2), y-((height-1)/2), s );
78 void ui_draw_shad( int x1, int y1, int x2, int y2, color * c1, color *c2 )
80 gr_set_color_fast( c1 );
82 ui_hline( x1+0, x2-1, y1+0 );
83 ui_vline( y1+1, y2+0, x1+0 );
85 gr_set_color_fast( c2 );
86 ui_hline( x1+1, x2, y2-0 );
87 ui_vline( y1+0, y2-1, x2-0 );
90 void ui_draw_frame( int x1, int y1, int x2, int y2 )
92 ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CBRIGHT, &CGRAY );
93 ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CBRIGHT, &CGRAY );
95 ui_draw_shad( x1+2, y1+2, x2-2, y2-2, &CWHITE, &CWHITE );
96 ui_draw_shad( x1+3, y1+3, x2-3, y2-3, &CWHITE, &CWHITE );
97 ui_draw_shad( x1+4, y1+4, x2-4, y2-4, &CWHITE, &CWHITE );
98 ui_draw_shad( x1+5, y1+5, x2-5, y2-5, &CWHITE, &CWHITE );
100 ui_draw_shad( x1+6, y1+6, x2-6, y2-6, &CGRAY, &CBRIGHT );
101 ui_draw_shad( x1+7, y1+7, x2-7, y2-7, &CGRAY, &CBRIGHT );
104 void ui_rect( int x1, int y1, int x2, int y2 )
106 gr_rect( x1, y1, x2-x1+1, y2-y1+1 );
111 void ui_draw_box_out( int x1, int y1, int x2, int y2 )
114 gr_set_color_fast( &CWHITE );
115 gr_rect( x1+2, y1+2, (x2-2)-(x1+2)+1, (y2-2)-(y1+2)+1 );
117 ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CBRIGHT, &CGRAY );
118 ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CBRIGHT, &CGRAY );
122 void ui_draw_box_in( int x1, int y1, int x2, int y2 )
125 gr_set_color_fast( &CWHITE );
126 gr_rect( x1+2, y1+2, (x2-2)-(x1+2)+1, (y2-2)-(y1+2)+1 );
128 ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CGRAY, &CBRIGHT );
129 ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CGRAY, &CBRIGHT );
133 void ui_draw_line_in( int x1, int y1, int x2, int y2 )
135 gr_set_color_fast( &CGRAY );
136 ui_hline( x1, x2, y1 );
137 ui_hline( x1, x2-1, y2-1 );
138 ui_vline( y1+1, y2-2, x1 );
139 ui_vline( y1+1, y2-2, x2-1 );
141 gr_set_color_fast( &CBRIGHT );
142 ui_hline( x1+1, x2-1, y1+1 );
143 ui_hline( x1, x2, y2 );
144 ui_vline( y1+2, y2-2, x1+1 );
145 ui_vline( y1+1, y2-1, x2 );
148 void ui_draw_sunken_border( int x1, int y1, int x2, int y2 )
151 gr_set_color_fast( &CGRAY );
152 ui_hline( x1-1, x2+1, y1-1);
153 ui_vline( y1-1, y2+1, x1-1);
155 gr_set_color_fast( &CBRIGHT );
156 ui_hline( x1-1, x2+1, y2+1);
157 ui_vline( y1, y2+1, x2+1);