| 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 |
const auto &&[width, height] = gr_get_string_size(*canvas.cv_font, s); |
| 41 |
gr_ustring(canvas, *canvas.cv_font, x - ((width - 1) / 2), y - ((height - 1) / 2), s); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
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) |
| 46 |
{ |
| 47 |
Hline(canvas, x1, x2 - 1, y1, c1); |
| 48 |
Vline(canvas, y1 + 1, y2, x1, c1); |
| 49 |
|
| 50 |
Hline(canvas, x1 + 1, x2, y2, c2); |
| 51 |
Vline(canvas, y1, y2 - 1, x2, c2); |
| 52 |
} |
| 53 |
|
| 54 |
void ui_draw_box_out(grs_canvas &canvas, const unsigned x1, const unsigned y1, const unsigned x2, const unsigned y2) |
| 55 |
{ |
| 56 |
const auto color{CWHITE}; |
| 57 |
const auto cbright{CBRIGHT}; |
| 58 |
const auto cgrey{CGREY}; |
| 59 |
gr_urect(canvas, x1 + 2, y1 + 2, x2 - 2, y2 - 2, color); |
| 60 |
|
| 61 |
ui_draw_shad(canvas, x1 + 0, y1 + 0, x2 - 0, y2 - 0, cbright, cgrey); |
| 62 |
ui_draw_shad(canvas, x1 + 1, y1 + 1, x2 - 1, y2 - 1, cbright, cgrey); |
| 63 |
} |
| 64 |
|
| 65 |
void ui_draw_box_in(grs_canvas &canvas, const unsigned x1, const unsigned y1, const unsigned x2, const unsigned y2) |
| 66 |
{ |
| 67 |
const auto cbright{CBRIGHT}; |
| 68 |
const auto cgrey{CGREY}; |
| 69 |
ui_draw_shad(canvas, x1, y1, x2, y2, cgrey, cbright); |
| 70 |
ui_draw_shad(canvas, x1 + 1, y1 + 1, x2 - 1, y2 - 1, cgrey, cbright); |
| 71 |
} |
| 72 |
|
| 73 |
} |