File: uidraw.cpp

package info (click to toggle)
freespace2 24.2.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,716 kB
  • sloc: cpp: 595,001; ansic: 21,741; python: 1,174; sh: 457; makefile: 248; xml: 181
file content (117 lines) | stat: -rw-r--r-- 2,777 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright (C) Volition, Inc. 1999.  All rights reserved.
 *
 * All source code herein is the property of Volition, Inc. You may not sell 
 * or otherwise commercially exploit the source or things you created based on the 
 * source.
 *
*/



#include "globalincs/alphacolors.h"
#include "ui/ui.h"
#include "ui/uidefs.h"



void ui_hline(int x1, int x2, int y )
{
	gr_line(x1,y,x2,y,GR_RESIZE_MENU);
}

void ui_vline(int y1, int y2, int x )
{
	gr_line(x,y1,x,y2,GR_RESIZE_MENU);
}

void ui_string_centered( int x, int y, const char * s )
{
	int height, width;

	gr_get_string_size( &width, &height, s );

	gr_string(x-((width-1)/2), y-((height-1)/2), s, GR_RESIZE_MENU );
}


void ui_draw_shad( int x1, int y1, int x2, int y2, color * c1, color *c2 )
{
	gr_set_color_fast( c1 );

	ui_hline( x1+0, x2-1, y1+0 );
	ui_vline( y1+1, y2+0, x1+0 );

	gr_set_color_fast( c2 );
	ui_hline( x1+1, x2, y2-0 );
	ui_vline( y1+0, y2-1, x2-0 );
}

void ui_draw_frame( int x1, int y1, int x2, int y2 )
{
	ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CBRIGHT, &CGRAY );
	ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CBRIGHT, &CGRAY );

	ui_draw_shad( x1+2, y1+2, x2-2, y2-2, &CWHITE, &CWHITE );
	ui_draw_shad( x1+3, y1+3, x2-3, y2-3, &CWHITE, &CWHITE );
	ui_draw_shad( x1+4, y1+4, x2-4, y2-4, &CWHITE, &CWHITE );
	ui_draw_shad( x1+5, y1+5, x2-5, y2-5, &CWHITE, &CWHITE );

	ui_draw_shad( x1+6, y1+6, x2-6, y2-6, &CGRAY, &CBRIGHT );
	ui_draw_shad( x1+7, y1+7, x2-7, y2-7, &CGRAY, &CBRIGHT );
}

void ui_rect( int x1, int y1, int x2, int y2 )
{
	gr_rect( x1, y1, x2-x1+1, y2-y1+1, GR_RESIZE_MENU_NO_OFFSET );
}

void ui_draw_box_out( int x1, int y1, int x2, int y2 )
{

	gr_set_color_fast( &CWHITE );
	gr_rect( x1+2, y1+2, (x2-2)-(x1+2)+1, (y2-2)-(y1+2)+1, GR_RESIZE_MENU_NO_OFFSET );

	ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CBRIGHT, &CGRAY );
	ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CBRIGHT, &CGRAY );

}

void ui_draw_box_in( int x1, int y1, int x2, int y2 )
{

	gr_set_color_fast( &CWHITE );
	gr_rect( x1+2, y1+2, (x2-2)-(x1+2)+1, (y2-2)-(y1+2)+1, GR_RESIZE_MENU_NO_OFFSET );

	ui_draw_shad( x1+0, y1+0, x2-0, y2-0, &CGRAY, &CBRIGHT );
	ui_draw_shad( x1+1, y1+1, x2-1, y2-1, &CGRAY, &CBRIGHT );
}


void ui_draw_line_in( int x1, int y1, int x2, int y2 )
{
	gr_set_color_fast( &CGRAY );
	ui_hline( x1, x2, y1 );
	ui_hline( x1, x2-1, y2-1 );
	ui_vline( y1+1, y2-2, x1 );
	ui_vline( y1+1, y2-2, x2-1 );

	gr_set_color_fast( &CBRIGHT );
	ui_hline( x1+1, x2-1, y1+1 );
	ui_hline( x1, x2, y2 );
	ui_vline( y1+2, y2-2, x1+1 );
	ui_vline( y1+1, y2-1, x2 );
}

void ui_draw_sunken_border( int x1, int y1, int x2, int y2 )
{

	gr_set_color_fast( &CGRAY );
	ui_hline( x1-1, x2+1, y1-1);
	ui_vline( y1-1, y2+1, x1-1);

	gr_set_color_fast( &CBRIGHT );
	ui_hline( x1-1, x2+1, y2+1);
	ui_vline( y1, y2+1, x2+1);
}