xref: /freebsd/contrib/bsddialog/lib/bsddialog_theme.h (revision 13ec1e3155c7e9bf037b12af186351b7fa9b9450)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2021-2022 Alfonso Sabato Siciliano
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #ifndef _LIBBSDDIALOG_THEME_H_
29 #define _LIBBSDDIALOG_THEME_H_
30 
31 /* color flags */
32 #define BSDDIALOG_BOLD         1U
33 #define BSDDIALOG_REVERSE      2U
34 #define BSDDIALOG_UNDERLINE    4U
35 
36 struct bsddialog_theme {
37 	struct {
38 		int color;
39 	} screen;
40 	struct {
41 		int color;
42 		unsigned int h;
43 		unsigned int w;
44 	} shadow;
45 	struct {
46 		int  color;
47 		bool delimtitle;
48 		int  titlecolor;
49 		int  lineraisecolor;
50 		int  linelowercolor;
51 		int  bottomtitlecolor;
52 	} dialog;
53 	struct {
54 		int arrowcolor;
55 		int selectorcolor;
56 		int f_namecolor;
57 		int namecolor;
58 		int f_desccolor;
59 		int desccolor;
60 		int namesepcolor;
61 		int descsepcolor;
62 		int f_shortcutcolor;
63 		int shortcutcolor;
64 	} menu;
65 	struct {
66 		int f_fieldcolor;
67 		int fieldcolor;
68 		int readonlycolor;
69 	} form;
70 	struct {
71 		int f_color;
72 		int color;
73 	} bar;
74 	struct {
75 		unsigned int space;
76 		int leftch;
77 		int rightch;
78 		int delimcolor;
79 		int f_delimcolor;
80 		int color;
81 		int f_color;
82 		int shortcutcolor;
83 		int f_shortcutcolor;
84 	} button;
85 };
86 
87 enum bsddialog_default_theme {
88 	BSDDIALOG_THEME_BLACKWHITE,
89 	BSDDIALOG_THEME_BSDDIALOG,
90 	BSDDIALOG_THEME_DEFAULT,
91 	BSDDIALOG_THEME_DIALOG
92 };
93 
94 enum bsddialog_color {
95 	BSDDIALOG_BLACK = 0,
96 	BSDDIALOG_RED,
97 	BSDDIALOG_GREEN,
98 	BSDDIALOG_YELLOW,
99 	BSDDIALOG_BLUE,
100 	BSDDIALOG_MAGENTA,
101 	BSDDIALOG_CYAN,
102 	BSDDIALOG_WHITE
103 };
104 
105 int
106 bsddialog_color(enum bsddialog_color foreground,
107     enum bsddialog_color background, unsigned int flags);
108 int bsddialog_get_theme(struct bsddialog_theme *theme);
109 int bsddialog_set_default_theme(enum bsddialog_default_theme theme);
110 int bsddialog_set_theme(struct bsddialog_theme *theme);
111 
112 #endif