]> icculus.org git repositories - taylor/freespace2.git/blob - src/ui/uidraw.cpp
merge updated pxo code and related fixes
[taylor/freespace2.git] / src / ui / uidraw.cpp
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
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
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/UI/UIDRAW.cpp $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Routines to draw UI sort of stuff.
16  *
17  * $Log$
18  * Revision 1.2  2002/06/09 04:41:29  relnev
19  * added copyright header
20  *
21  * Revision 1.1.1.1  2002/05/03 03:28:11  root
22  * Initial import.
23  *
24  * 
25  * 3     10/13/98 9:29a Dave
26  * Started neatening up freespace.h. Many variables renamed and
27  * reorganized. Added AlphaColors.[h,cpp]
28  * 
29  * 2     10/07/98 10:54a Dave
30  * Initial checkin.
31  * 
32  * 1     10/07/98 10:51a Dave
33  * 
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
39  * global variable.
40  * 
41  * 3     2/03/98 4:21p Hoffoss
42  * Made UI controls draw white text when disabled.
43  * 
44  * 2     6/11/97 1:13p John
45  * Started fixing all the text colors in the game.
46  * 
47  * 1     11/14/96 6:55p John
48  *
49  * $NoKeywords: $
50  */
51
52 #include "uidefs.h"
53 #include "ui.h"
54 #include "alphacolors.h"
55
56 void ui_hline(int x1, int x2, int y )
57 {
58         gr_line(x1,y,x2,y);
59 }
60
61 void ui_vline(int y1, int y2, int x )
62 {
63         gr_line(x,y1,x,y2);
64 }
65
66 void ui_string_centered( int x, int y, const char * s )
67 {
68         int height, width;
69
70         gr_get_string_size( &width, &height, s );
71
72         //baseline = height-grd_curcanv->cv_font->ft_baseline;
73
74         gr_string(x-((width-1)/2), y-((height-1)/2), s );
75 }
76
77
78 void ui_draw_shad( int x1, int y1, int x2, int y2, color * c1, color *c2 )
79 {
80         gr_set_color_fast( c1 );
81
82         ui_hline( x1+0, x2-1, y1+0 );
83         ui_vline( y1+1, y2+0, x1+0 );
84
85         gr_set_color_fast( c2 );
86         ui_hline( x1+1, x2, y2-0 );
87         ui_vline( y1+0, y2-1, x2-0 );
88 }
89
90 void ui_draw_frame( int x1, int y1, int x2, int y2 )
91 {
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 );
94
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 );
99
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 );
102 }
103
104 void ui_rect( int x1, int y1, int x2, int y2 )
105 {
106         gr_rect( x1, y1, x2-x1+1, y2-y1+1 );
107 }
108
109
110
111 void ui_draw_box_out( 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, &CBRIGHT, &CGRAY );
118         ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CBRIGHT, &CGRAY );
119
120 }
121
122 void ui_draw_box_in( int x1, int y1, int x2, int y2 )
123 {
124
125         gr_set_color_fast( &CWHITE );
126         gr_rect( x1+2, y1+2, (x2-2)-(x1+2)+1, (y2-2)-(y1+2)+1 );
127
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 );
130 }
131
132
133 void ui_draw_line_in( int x1, int y1, int x2, int y2 )
134 {
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 );
140
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 );
146 }
147
148 void ui_draw_sunken_border( int x1, int y1, int x2, int y2 )
149 {
150
151         gr_set_color_fast( &CGRAY );
152         ui_hline( x1-1, x2+1, y1-1);
153         ui_vline( y1-1, y2+1, x1-1);
154
155         gr_set_color_fast( &CBRIGHT );
156         ui_hline( x1-1, x2+1, y2+1);
157         ui_vline( y1, y2+1, x2+1);
158 }
159