]> icculus.org git repositories - taylor/freespace2.git/blob - src/ui/uidraw.cpp
Initial revision
[taylor/freespace2.git] / src / ui / uidraw.cpp
1 /*
2  * $Logfile: /Freespace2/code/UI/UIDRAW.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Routines to draw UI sort of stuff.
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:11  root
11  * Initial revision
12  *
13  * 
14  * 3     10/13/98 9:29a Dave
15  * Started neatening up freespace.h. Many variables renamed and
16  * reorganized. Added AlphaColors.[h,cpp]
17  * 
18  * 2     10/07/98 10:54a Dave
19  * Initial checkin.
20  * 
21  * 1     10/07/98 10:51a Dave
22  * 
23  * 4     3/10/98 4:19p John
24  * Cleaned up graphics lib.  Took out most unused gr functions.   Made D3D
25  * & Glide have popups and print screen.  Took out all >8bpp software
26  * support.  Made Fred zbuffer.  Made zbuffer allocate dynamically to
27  * support Fred.  Made zbuffering key off of functions rather than one
28  * global variable.
29  * 
30  * 3     2/03/98 4:21p Hoffoss
31  * Made UI controls draw white text when disabled.
32  * 
33  * 2     6/11/97 1:13p John
34  * Started fixing all the text colors in the game.
35  * 
36  * 1     11/14/96 6:55p John
37  *
38  * $NoKeywords: $
39  */
40
41 #include "uidefs.h"
42 #include "ui.h"
43 #include "alphacolors.h"
44
45 void ui_hline(int x1, int x2, int y )
46 {
47         gr_line(x1,y,x2,y);
48 }
49
50 void ui_vline(int y1, int y2, int x )
51 {
52         gr_line(x,y1,x,y2);
53 }
54
55 void ui_string_centered( int x, int y, char * s )
56 {
57         int height, width;
58
59         gr_get_string_size( &width, &height, s );
60
61         //baseline = height-grd_curcanv->cv_font->ft_baseline;
62
63         gr_string(x-((width-1)/2), y-((height-1)/2), s );
64 }
65
66
67 void ui_draw_shad( int x1, int y1, int x2, int y2, color * c1, color *c2 )
68 {
69         gr_set_color_fast( c1 );
70
71         ui_hline( x1+0, x2-1, y1+0 );
72         ui_vline( y1+1, y2+0, x1+0 );
73
74         gr_set_color_fast( c2 );
75         ui_hline( x1+1, x2, y2-0 );
76         ui_vline( y1+0, y2-1, x2-0 );
77 }
78
79 void ui_draw_frame( int x1, int y1, int x2, int y2 )
80 {
81         ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CBRIGHT, &CGRAY );
82         ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CBRIGHT, &CGRAY );
83
84         ui_draw_shad( x1+2, y1+2, x2-2, y2-2, &CWHITE, &CWHITE );
85         ui_draw_shad( x1+3, y1+3, x2-3, y2-3, &CWHITE, &CWHITE );
86         ui_draw_shad( x1+4, y1+4, x2-4, y2-4, &CWHITE, &CWHITE );
87         ui_draw_shad( x1+5, y1+5, x2-5, y2-5, &CWHITE, &CWHITE );
88
89         ui_draw_shad( x1+6, y1+6, x2-6, y2-6, &CGRAY, &CBRIGHT );
90         ui_draw_shad( x1+7, y1+7, x2-7, y2-7, &CGRAY, &CBRIGHT );
91 }
92
93 void ui_rect( int x1, int y1, int x2, int y2 )
94 {
95         gr_rect( x1, y1, x2-x1+1, y2-y1+1 );
96 }
97
98
99
100 void ui_draw_box_out( int x1, int y1, int x2, int y2 )
101 {
102
103         gr_set_color_fast( &CWHITE );
104         gr_rect( x1+2, y1+2, (x2-2)-(x1+2)+1, (y2-2)-(y1+2)+1 );
105
106         ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CBRIGHT, &CGRAY );
107         ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CBRIGHT, &CGRAY );
108
109 }
110
111 void ui_draw_box_in( int x1, int y1, int x2, int y2 )
112 {
113
114         gr_set_color_fast( &CWHITE );
115         gr_rect( x1+2, y1+2, (x2-2)-(x1+2)+1, (y2-2)-(y1+2)+1 );
116
117         ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CGRAY, &CBRIGHT );
118         ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CGRAY, &CBRIGHT );
119 }
120
121
122 void ui_draw_line_in( int x1, int y1, int x2, int y2 )
123 {
124         gr_set_color_fast( &CGRAY );
125         ui_hline( x1, x2, y1 );
126         ui_hline( x1, x2-1, y2-1 );
127         ui_vline( y1+1, y2-2, x1 );
128         ui_vline( y1+1, y2-2, x2-1 );
129
130         gr_set_color_fast( &CBRIGHT );
131         ui_hline( x1+1, x2-1, y1+1 );
132         ui_hline( x1, x2, y2 );
133         ui_vline( y1+2, y2-2, x1+1 );
134         ui_vline( y1+1, y2-1, x2 );
135 }
136
137 void ui_draw_sunken_border( int x1, int y1, int x2, int y2 )
138 {
139
140         gr_set_color_fast( &CGRAY );
141         ui_hline( x1-1, x2+1, y1-1);
142         ui_vline( y1-1, y2+1, x1-1);
143
144         gr_set_color_fast( &CBRIGHT );
145         ui_hline( x1-1, x2+1, y2+1);
146         ui_vline( y1, y2+1, x2+1);
147 }
148