Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | /* |
2 | * Portions of this file are copyright Rebirth contributors and licensed as |
||
3 | * described in COPYING.txt. |
||
4 | * Portions of this file are copyright Parallax Software and licensed |
||
5 | * according to the Parallax license below. |
||
6 | * See COPYING.txt for license details. |
||
7 | |||
8 | THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
||
9 | SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
||
10 | END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
||
11 | ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
||
12 | IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
||
13 | SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
||
14 | FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
||
15 | CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
||
16 | AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
||
17 | COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
||
18 | */ |
||
19 | |||
20 | |||
21 | #include "maths.h" |
||
22 | #include "pstypes.h" |
||
23 | #include "gr.h" |
||
24 | #include "ui.h" |
||
25 | |||
26 | namespace dcx { |
||
27 | |||
28 | void Hline(grs_canvas &canvas, const fix x1, const fix x2, const fix y, const color_palette_index color) |
||
29 | { |
||
30 | gr_uline(canvas, i2f(x1), i2f(y), i2f(x2), i2f(y), color); |
||
31 | } |
||
32 | |||
33 | void Vline(grs_canvas &canvas, const fix y1, const fix y2, const fix x, const color_palette_index color) |
||
34 | { |
||
35 | gr_uline(canvas, i2f(x), i2f(y1), i2f(x), i2f(y2), color); |
||
36 | } |
||
37 | |||
38 | void ui_string_centered(grs_canvas &canvas, const unsigned x, const unsigned y, const char *const s) |
||
39 | { |
||
40 | int height, width; |
||
41 | |||
42 | gr_get_string_size(*canvas.cv_font, s, &width, &height, nullptr); |
||
43 | |||
44 | //baseline = height-grd_curcanv->cv_font->ft_baseline; |
||
45 | |||
46 | gr_ustring(canvas, *canvas.cv_font, x - ((width - 1) / 2), y - ((height - 1) / 2), s); |
||
47 | } |
||
48 | |||
49 | |||
50 | void ui_draw_shad(grs_canvas &canvas, const unsigned x1, const unsigned y1, const unsigned x2, const unsigned y2, const color_palette_index c1, const color_palette_index c2) |
||
51 | { |
||
52 | Hline(canvas, x1, x2 - 1, y1, c1); |
||
53 | Vline(canvas, y1 + 1, y2, x1, c1); |
||
54 | |||
55 | Hline(canvas, x1 + 1, x2, y2, c2); |
||
56 | Vline(canvas, y1, y2 - 1, x2, c2); |
||
57 | } |
||
58 | |||
59 | void ui_draw_frame(grs_canvas &canvas, const unsigned x1, const unsigned y1, const unsigned x2, const unsigned y2) |
||
60 | { |
||
61 | const auto cbright = CBRIGHT; |
||
62 | const auto cgrey = CGREY; |
||
63 | const auto cwhite = CWHITE; |
||
64 | ui_draw_shad(canvas, x1 + 0, y1 + 0, x2 - 0, y2 - 0, cbright, cgrey); |
||
65 | ui_draw_shad(canvas, x1 + 1, y1 + 1, x2 - 1, y2 - 1, cbright, cgrey); |
||
66 | |||
67 | ui_draw_shad(canvas, x1 + 2, y1 + 2, x2 - 2, y2 - 2, cwhite, cwhite); |
||
68 | ui_draw_shad(canvas, x1 + 3, y1 + 3, x2 - 3, y2 - 3, cwhite, cwhite); |
||
69 | ui_draw_shad(canvas, x1 + 4, y1 + 4, x2 - 4, y2 - 4, cwhite, cwhite); |
||
70 | ui_draw_shad(canvas, x1 + 5, y1 + 5, x2 - 5, y2 - 5, cwhite, cwhite); |
||
71 | |||
72 | ui_draw_shad(canvas, x1 + 6, y1 + 6, x2 - 6, y2 - 6, cgrey, cbright); |
||
73 | ui_draw_shad(canvas, x1 + 7, y1 + 7, x2 - 7, y2 - 7, cgrey, cbright); |
||
74 | } |
||
75 | |||
76 | void ui_draw_box_out(grs_canvas &canvas, const unsigned x1, const unsigned y1, const unsigned x2, const unsigned y2) |
||
77 | { |
||
78 | const auto color = CWHITE; |
||
79 | const auto cbright = CBRIGHT; |
||
80 | const auto cgrey = CGREY; |
||
81 | gr_urect(canvas, x1 + 2, y1 + 2, x2 - 2, y2 - 2, color); |
||
82 | |||
83 | ui_draw_shad(canvas, x1 + 0, y1 + 0, x2 - 0, y2 - 0, cbright, cgrey); |
||
84 | ui_draw_shad(canvas, x1 + 1, y1 + 1, x2 - 1, y2 - 1, cbright, cgrey); |
||
85 | } |
||
86 | |||
87 | void ui_draw_box_in(grs_canvas &canvas, const unsigned x1, const unsigned y1, const unsigned x2, const unsigned y2) |
||
88 | { |
||
89 | const auto cbright = CBRIGHT; |
||
90 | const auto cgrey = CGREY; |
||
91 | ui_draw_shad(canvas, x1, y1, x2, y2, cgrey, cbright); |
||
92 | ui_draw_shad(canvas, x1 + 1, y1 + 1, x2 - 1, y2 - 1, cgrey, cbright); |
||
93 | } |
||
94 | |||
95 | } |