FS2_Open
Open source remastering of the Freespace 2 engine
uidraw.cpp
Go to the documentation of this file.
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 the
6  * source.
7  *
8 */
9 
10 
11 
12 #include "globalincs/alphacolors.h"
13 #include "ui/ui.h"
14 #include "ui/uidefs.h"
15 
16 
17 
18 void ui_hline(int x1, int x2, int y )
19 {
20  gr_line(x1,y,x2,y,GR_RESIZE_MENU);
21 }
22 
23 void ui_vline(int y1, int y2, int x )
24 {
25  gr_line(x,y1,x,y2,GR_RESIZE_MENU);
26 }
27 
28 void ui_string_centered( int x, int y, char * s )
29 {
30  int height, width;
31 
32  gr_get_string_size( &width, &height, s );
33 
34  gr_string(x-((width-1)/2), y-((height-1)/2), s, GR_RESIZE_MENU );
35 }
36 
37 
38 void ui_draw_shad( int x1, int y1, int x2, int y2, color * c1, color *c2 )
39 {
40  gr_set_color_fast( c1 );
41 
42  ui_hline( x1+0, x2-1, y1+0 );
43  ui_vline( y1+1, y2+0, x1+0 );
44 
45  gr_set_color_fast( c2 );
46  ui_hline( x1+1, x2, y2-0 );
47  ui_vline( y1+0, y2-1, x2-0 );
48 }
49 
50 void ui_draw_frame( int x1, int y1, int x2, int y2 )
51 {
52  ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CBRIGHT, &CGRAY );
53  ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CBRIGHT, &CGRAY );
54 
55  ui_draw_shad( x1+2, y1+2, x2-2, y2-2, &CWHITE, &CWHITE );
56  ui_draw_shad( x1+3, y1+3, x2-3, y2-3, &CWHITE, &CWHITE );
57  ui_draw_shad( x1+4, y1+4, x2-4, y2-4, &CWHITE, &CWHITE );
58  ui_draw_shad( x1+5, y1+5, x2-5, y2-5, &CWHITE, &CWHITE );
59 
60  ui_draw_shad( x1+6, y1+6, x2-6, y2-6, &CGRAY, &CBRIGHT );
61  ui_draw_shad( x1+7, y1+7, x2-7, y2-7, &CGRAY, &CBRIGHT );
62 }
63 
64 void ui_rect( int x1, int y1, int x2, int y2 )
65 {
66  gr_rect( x1, y1, x2-x1+1, y2-y1+1, GR_RESIZE_MENU_NO_OFFSET );
67 }
68 
69 void ui_draw_box_out( int x1, int y1, int x2, int y2 )
70 {
71 
73  gr_rect( x1+2, y1+2, (x2-2)-(x1+2)+1, (y2-2)-(y1+2)+1, GR_RESIZE_MENU_NO_OFFSET );
74 
75  ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CBRIGHT, &CGRAY );
76  ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CBRIGHT, &CGRAY );
77 
78 }
79 
80 void ui_draw_box_in( int x1, int y1, int x2, int y2 )
81 {
82 
84  gr_rect( x1+2, y1+2, (x2-2)-(x1+2)+1, (y2-2)-(y1+2)+1, GR_RESIZE_MENU_NO_OFFSET );
85 
86  ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CGRAY, &CBRIGHT );
87  ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CGRAY, &CBRIGHT );
88 }
89 
90 
91 void ui_draw_line_in( int x1, int y1, int x2, int y2 )
92 {
94  ui_hline( x1, x2, y1 );
95  ui_hline( x1, x2-1, y2-1 );
96  ui_vline( y1+1, y2-2, x1 );
97  ui_vline( y1+1, y2-2, x2-1 );
98 
100  ui_hline( x1+1, x2-1, y1+1 );
101  ui_hline( x1, x2, y2 );
102  ui_vline( y1+2, y2-2, x1+1 );
103  ui_vline( y1+1, y2-1, x2 );
104 }
105 
106 void ui_draw_sunken_border( int x1, int y1, int x2, int y2 )
107 {
108 
110  ui_hline( x1-1, x2+1, y1-1);
111  ui_vline( y1-1, y2+1, x1-1);
112 
114  ui_hline( x1-1, x2+1, y2+1);
115  ui_vline( y1, y2+1, x2+1);
116 }
117 
void gr_rect(int x, int y, int w, int h, int resize_mode)
Definition: 2d.cpp:2068
#define GR_RESIZE_MENU_NO_OFFSET
Definition: 2d.h:686
#define GR_RESIZE_MENU
Definition: 2d.h:684
void ui_draw_frame(int x1, int y1, int x2, int y2)
Definition: uidraw.cpp:50
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:769
Definition: 2d.h:95
void ui_string_centered(int x, int y, char *s)
Definition: uidraw.cpp:28
void ui_vline(int y1, int y2, int x)
Definition: uidraw.cpp:23
void gr_set_color_fast(color *dst)
Definition: 2d.cpp:1197
GLint GLsizei width
Definition: Gl.h:1505
void ui_draw_box_in(int x1, int y1, int x2, int y2)
Definition: uidraw.cpp:80
#define CWHITE
Definition: uidefs.h:25
void ui_draw_shad(int x1, int y1, int x2, int y2, color *c1, color *c2)
Definition: uidraw.cpp:38
#define CGRAY
Definition: uidefs.h:23
GLdouble s
Definition: Glext.h:5321
void ui_draw_line_in(int x1, int y1, int x2, int y2)
Definition: uidraw.cpp:91
void ui_draw_sunken_border(int x1, int y1, int x2, int y2)
Definition: uidraw.cpp:106
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
#define CBRIGHT
Definition: uidefs.h:26
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:791
void ui_draw_box_out(int x1, int y1, int x2, int y2)
Definition: uidraw.cpp:69
GLint GLsizei GLsizei height
Definition: Gl.h:1505
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
Definition: font.cpp:196
void ui_rect(int x1, int y1, int x2, int y2)
Definition: uidraw.cpp:64
void ui_hline(int x1, int x2, int y)
Definition: uidraw.cpp:18
GLint y
Definition: Gl.h:1505