xref: /freebsd/contrib/bsddialog/lib/theme.c (revision 263660c061ac76d449cbca7bdd0db2ecdfad76d9)
1c76f0793SBaptiste Daroussin /*-
2c76f0793SBaptiste Daroussin  * SPDX-License-Identifier: BSD-2-Clause
3c76f0793SBaptiste Daroussin  *
4*263660c0SAlfonso Siciliano  * Copyright (c) 2021-2022 Alfonso Sabato Siciliano
5c76f0793SBaptiste Daroussin  *
6c76f0793SBaptiste Daroussin  * Redistribution and use in source and binary forms, with or without
7c76f0793SBaptiste Daroussin  * modification, are permitted provided that the following conditions
8c76f0793SBaptiste Daroussin  * are met:
9c76f0793SBaptiste Daroussin  * 1. Redistributions of source code must retain the above copyright
10c76f0793SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer.
11c76f0793SBaptiste Daroussin  * 2. Redistributions in binary form must reproduce the above copyright
12c76f0793SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer in the
13c76f0793SBaptiste Daroussin  *    documentation and/or other materials provided with the distribution.
14c76f0793SBaptiste Daroussin  *
15c76f0793SBaptiste Daroussin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16c76f0793SBaptiste Daroussin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17c76f0793SBaptiste Daroussin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18c76f0793SBaptiste Daroussin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19c76f0793SBaptiste Daroussin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20c76f0793SBaptiste Daroussin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21c76f0793SBaptiste Daroussin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22c76f0793SBaptiste Daroussin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23c76f0793SBaptiste Daroussin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24c76f0793SBaptiste Daroussin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25c76f0793SBaptiste Daroussin  * SUCH DAMAGE.
26c76f0793SBaptiste Daroussin  */
27c76f0793SBaptiste Daroussin 
28*263660c0SAlfonso Siciliano #include <curses.h>
29c76f0793SBaptiste Daroussin 
30c76f0793SBaptiste Daroussin #include "bsddialog.h"
31c76f0793SBaptiste Daroussin #include "bsddialog_theme.h"
32*263660c0SAlfonso Siciliano #include "lib_util.h"
33c76f0793SBaptiste Daroussin 
34c76f0793SBaptiste Daroussin #define GET_COLOR(bg, fg) (COLOR_PAIR(bg * 8 + fg +1))
35c76f0793SBaptiste Daroussin 
36c76f0793SBaptiste Daroussin struct bsddialog_theme t;
37c76f0793SBaptiste Daroussin 
38c76f0793SBaptiste Daroussin static struct bsddialog_theme bsddialogtheme = {
39c76f0793SBaptiste Daroussin #define bgwidget  COLOR_WHITE
40c76f0793SBaptiste Daroussin #define bgcurr    COLOR_YELLOW
41*263660c0SAlfonso Siciliano 	.screen.color = GET_COLOR(COLOR_BLACK, COLOR_CYAN),
428c4f4028SBaptiste Daroussin 
43f499134dSBaptiste Daroussin 	.shadow.color   = GET_COLOR(COLOR_BLACK, COLOR_BLACK),
44f499134dSBaptiste Daroussin 	.shadow.h       = 1,
45f499134dSBaptiste Daroussin 	.shadow.w       = 2,
46c76f0793SBaptiste Daroussin 
478c4f4028SBaptiste Daroussin 	.dialog.delimtitle       = true,
488c4f4028SBaptiste Daroussin 	.dialog.titlecolor       = GET_COLOR(COLOR_YELLOW, bgwidget),
498c4f4028SBaptiste Daroussin 	.dialog.lineraisecolor   = GET_COLOR(COLOR_BLACK,  bgwidget),
508c4f4028SBaptiste Daroussin 	.dialog.linelowercolor   = GET_COLOR(COLOR_BLACK,  bgwidget),
518c4f4028SBaptiste Daroussin 	.dialog.color            = GET_COLOR(COLOR_BLACK,  bgwidget),
528c4f4028SBaptiste Daroussin 	.dialog.bottomtitlecolor = GET_COLOR(COLOR_BLACK,  bgwidget),
53c76f0793SBaptiste Daroussin 
54f499134dSBaptiste Daroussin 	.menu.arrowcolor      = GET_COLOR(COLOR_YELLOW, bgwidget),
558c4f4028SBaptiste Daroussin 	.menu.selectorcolor   = GET_COLOR(COLOR_BLACK,  bgwidget) | A_BOLD,
56f499134dSBaptiste Daroussin 	.menu.f_desccolor     = GET_COLOR(COLOR_WHITE,  bgcurr),
57f499134dSBaptiste Daroussin 	.menu.desccolor       = GET_COLOR(COLOR_BLACK,  bgwidget),
58f499134dSBaptiste Daroussin 	.menu.f_namecolor     = GET_COLOR(COLOR_BLACK,  bgcurr),
59f499134dSBaptiste Daroussin 	.menu.namecolor       = GET_COLOR(COLOR_YELLOW, bgwidget),
60f499134dSBaptiste Daroussin 	.menu.namesepcolor    = GET_COLOR(COLOR_YELLOW, bgwidget),
61f499134dSBaptiste Daroussin 	.menu.descsepcolor    = GET_COLOR(COLOR_YELLOW, bgwidget),
628c4f4028SBaptiste Daroussin 	.menu.f_shortcutcolor = GET_COLOR(COLOR_RED,    bgcurr),
638c4f4028SBaptiste Daroussin 	.menu.shortcutcolor   = GET_COLOR(COLOR_RED,    bgwidget),
64c76f0793SBaptiste Daroussin 
65f499134dSBaptiste Daroussin 	.form.f_fieldcolor  = GET_COLOR(COLOR_WHITE,  COLOR_BLUE),
66f499134dSBaptiste Daroussin 	.form.fieldcolor    = GET_COLOR(COLOR_WHITE,  COLOR_CYAN),
67f499134dSBaptiste Daroussin 	.form.readonlycolor = GET_COLOR(COLOR_CYAN,COLOR_WHITE),
68c76f0793SBaptiste Daroussin 
69f499134dSBaptiste Daroussin 	.bar.f_color = GET_COLOR(COLOR_WHITE, COLOR_BLUE),
70f499134dSBaptiste Daroussin 	.bar.color   = GET_COLOR(COLOR_BLUE,  COLOR_WHITE),
71c76f0793SBaptiste Daroussin 
72f499134dSBaptiste Daroussin 	.button.space        = 3,
73f499134dSBaptiste Daroussin 	.button.leftch       = '[',
74f499134dSBaptiste Daroussin 	.button.rightch      = ']',
75f499134dSBaptiste Daroussin 	.button.f_delimcolor = GET_COLOR(COLOR_WHITE,  bgcurr),
76f499134dSBaptiste Daroussin 	.button.delimcolor   = GET_COLOR(COLOR_BLACK,  bgwidget),
77f499134dSBaptiste Daroussin 	.button.f_color      = GET_COLOR(COLOR_WHITE,  bgcurr)    | A_UNDERLINE,
78f499134dSBaptiste Daroussin 	.button.color        = GET_COLOR(COLOR_BLACK,  bgwidget)  | A_UNDERLINE,
79f499134dSBaptiste Daroussin 	.button.f_shortcutcolor = GET_COLOR(COLOR_BLACK, bgcurr)  | A_UNDERLINE,
80f499134dSBaptiste Daroussin 	.button.shortcutcolor = GET_COLOR(COLOR_YELLOW, bgwidget) | A_UNDERLINE
81c76f0793SBaptiste Daroussin };
82c76f0793SBaptiste Daroussin 
83c76f0793SBaptiste Daroussin static struct bsddialog_theme blackwhite = {
84c76f0793SBaptiste Daroussin #define fg  COLOR_WHITE
85d93b4d32SBaptiste Daroussin #define bk  COLOR_BLACK
86*263660c0SAlfonso Siciliano 	.screen.color = GET_COLOR(fg, bk),
878c4f4028SBaptiste Daroussin 
88f499134dSBaptiste Daroussin 	.shadow.color   = GET_COLOR(COLOR_BLACK, COLOR_BLACK),
89f499134dSBaptiste Daroussin 	.shadow.h       = 1,
90f499134dSBaptiste Daroussin 	.shadow.w       = 2,
91c76f0793SBaptiste Daroussin 
928c4f4028SBaptiste Daroussin 	.dialog.delimtitle       = true,
938c4f4028SBaptiste Daroussin 	.dialog.titlecolor       = GET_COLOR(fg, bk),
948c4f4028SBaptiste Daroussin 	.dialog.lineraisecolor   = GET_COLOR(fg, bk),
958c4f4028SBaptiste Daroussin 	.dialog.linelowercolor   = GET_COLOR(fg, bk),
968c4f4028SBaptiste Daroussin 	.dialog.color            = GET_COLOR(fg, bk),
978c4f4028SBaptiste Daroussin 	.dialog.bottomtitlecolor = GET_COLOR(fg, bk),
98c76f0793SBaptiste Daroussin 
99f499134dSBaptiste Daroussin 	.menu.arrowcolor      = GET_COLOR(fg, bk),
1008c4f4028SBaptiste Daroussin 	.menu.selectorcolor   = GET_COLOR(fg, bk),
101f499134dSBaptiste Daroussin 	.menu.f_desccolor     = GET_COLOR(fg, bk) | A_REVERSE,
102f499134dSBaptiste Daroussin 	.menu.desccolor       = GET_COLOR(fg, bk),
103f499134dSBaptiste Daroussin 	.menu.f_namecolor     = GET_COLOR(fg, bk) | A_REVERSE,
104f499134dSBaptiste Daroussin 	.menu.namecolor       = GET_COLOR(fg, bk),
105f499134dSBaptiste Daroussin 	.menu.namesepcolor    = GET_COLOR(fg, bk),
106f499134dSBaptiste Daroussin 	.menu.descsepcolor    = GET_COLOR(fg, bk),
1078c4f4028SBaptiste Daroussin 	.menu.f_shortcutcolor = GET_COLOR(fg, bk) | A_UNDERLINE | A_REVERSE,
1088c4f4028SBaptiste Daroussin 	.menu.shortcutcolor   = GET_COLOR(fg, bk) | A_UNDERLINE,
109c76f0793SBaptiste Daroussin 
110f499134dSBaptiste Daroussin 	.form.f_fieldcolor  = GET_COLOR(fg, bk) | A_REVERSE,
111f499134dSBaptiste Daroussin 	.form.fieldcolor    = GET_COLOR(fg, bk),
112f499134dSBaptiste Daroussin 	.form.readonlycolor = GET_COLOR(fg, bk),
113c76f0793SBaptiste Daroussin 
114f499134dSBaptiste Daroussin 	.bar.f_color = GET_COLOR(fg, bk) | A_REVERSE,
115f499134dSBaptiste Daroussin 	.bar.color   = GET_COLOR(fg, bk),
116c76f0793SBaptiste Daroussin 
117f499134dSBaptiste Daroussin 	.button.space           = 3,
118f499134dSBaptiste Daroussin 	.button.leftch          = '[',
119f499134dSBaptiste Daroussin 	.button.rightch         = ']',
120f499134dSBaptiste Daroussin 	.button.f_delimcolor    = GET_COLOR(fg, bk),
121f499134dSBaptiste Daroussin 	.button.delimcolor      = GET_COLOR(fg, bk),
122f499134dSBaptiste Daroussin 	.button.f_color         = GET_COLOR(fg, bk) | A_UNDERLINE | A_REVERSE,
123f499134dSBaptiste Daroussin 	.button.color           = GET_COLOR(fg, bk) | A_UNDERLINE,
124f499134dSBaptiste Daroussin 	.button.f_shortcutcolor = GET_COLOR(fg, bk) | A_UNDERLINE | A_REVERSE,
125f499134dSBaptiste Daroussin 	.button.shortcutcolor   = GET_COLOR(fg, bk) | A_UNDERLINE
126c76f0793SBaptiste Daroussin };
127c76f0793SBaptiste Daroussin 
128c76f0793SBaptiste Daroussin static struct bsddialog_theme dialogtheme = {
129*263660c0SAlfonso Siciliano 	.screen.color = GET_COLOR(COLOR_CYAN,  COLOR_BLUE)  | A_BOLD,
1308c4f4028SBaptiste Daroussin 
131f499134dSBaptiste Daroussin 	.shadow.color   = GET_COLOR(COLOR_BLACK, COLOR_BLACK),
132f499134dSBaptiste Daroussin 	.shadow.h       = 1,
133f499134dSBaptiste Daroussin 	.shadow.w       = 2,
134c76f0793SBaptiste Daroussin 
1358c4f4028SBaptiste Daroussin 	.dialog.delimtitle       = false,
1368c4f4028SBaptiste Daroussin 	.dialog.titlecolor       = GET_COLOR(COLOR_BLUE,  COLOR_WHITE) | A_BOLD,
1378c4f4028SBaptiste Daroussin 	.dialog.lineraisecolor   = GET_COLOR(COLOR_WHITE, COLOR_WHITE) | A_BOLD,
1388c4f4028SBaptiste Daroussin 	.dialog.linelowercolor   = GET_COLOR(COLOR_BLACK, COLOR_WHITE) | A_BOLD,
1398c4f4028SBaptiste Daroussin 	.dialog.color            = GET_COLOR(COLOR_BLACK, COLOR_WHITE),
1408c4f4028SBaptiste Daroussin 	.dialog.bottomtitlecolor = GET_COLOR(COLOR_BLACK, COLOR_WHITE) | A_BOLD,
141c76f0793SBaptiste Daroussin 
142f499134dSBaptiste Daroussin 	.menu.arrowcolor      = GET_COLOR(COLOR_GREEN,  COLOR_WHITE),
143*263660c0SAlfonso Siciliano 	.menu.selectorcolor   = GET_COLOR(COLOR_BLACK,  bgwidget),
144*263660c0SAlfonso Siciliano 	.menu.f_desccolor     = GET_COLOR(COLOR_WHITE,  COLOR_BLUE),
145*263660c0SAlfonso Siciliano 	.menu.desccolor       = GET_COLOR(COLOR_BLACK,  COLOR_WHITE),
146*263660c0SAlfonso Siciliano 	.menu.f_namecolor     = GET_COLOR(COLOR_YELLOW, COLOR_BLUE),
147*263660c0SAlfonso Siciliano 	.menu.namecolor       = GET_COLOR(COLOR_BLUE,   COLOR_WHITE),
148f499134dSBaptiste Daroussin 	.menu.namesepcolor    = GET_COLOR(COLOR_RED,    COLOR_WHITE),
149f499134dSBaptiste Daroussin 	.menu.descsepcolor    = GET_COLOR(COLOR_RED,    COLOR_WHITE),
150*263660c0SAlfonso Siciliano 	.menu.f_shortcutcolor = GET_COLOR(COLOR_RED,    COLOR_BLUE),
151*263660c0SAlfonso Siciliano 	.menu.shortcutcolor   = GET_COLOR(COLOR_RED,    COLOR_WHITE),
152c76f0793SBaptiste Daroussin 
153f499134dSBaptiste Daroussin 	.form.f_fieldcolor  = GET_COLOR(COLOR_WHITE, COLOR_BLUE) | A_BOLD,
154f499134dSBaptiste Daroussin 	.form.fieldcolor    = GET_COLOR(COLOR_WHITE, COLOR_CYAN) | A_BOLD,
155f499134dSBaptiste Daroussin 	.form.readonlycolor = GET_COLOR(COLOR_CYAN,  COLOR_WHITE)| A_BOLD,
156c76f0793SBaptiste Daroussin 
157f499134dSBaptiste Daroussin 	.bar.f_color = GET_COLOR(COLOR_WHITE, COLOR_BLUE)  | A_BOLD,
158f499134dSBaptiste Daroussin 	.bar.color   = GET_COLOR(COLOR_BLUE,  COLOR_WHITE) | A_BOLD,
159c76f0793SBaptiste Daroussin 
160f499134dSBaptiste Daroussin 	.button.space           = 3,
161f499134dSBaptiste Daroussin 	.button.leftch          = '<',
162f499134dSBaptiste Daroussin 	.button.rightch         = '>',
163f499134dSBaptiste Daroussin 	.button.f_delimcolor    = GET_COLOR(COLOR_WHITE,  COLOR_BLUE)  | A_BOLD,
164f499134dSBaptiste Daroussin 	.button.delimcolor      = GET_COLOR(COLOR_BLACK,  COLOR_WHITE),
165f499134dSBaptiste Daroussin 	.button.f_color         = GET_COLOR(COLOR_YELLOW, COLOR_BLUE)  | A_BOLD,
166f499134dSBaptiste Daroussin 	.button.color           = GET_COLOR(COLOR_BLACK,  COLOR_WHITE),
167f499134dSBaptiste Daroussin 	.button.f_shortcutcolor = GET_COLOR(COLOR_WHITE,  COLOR_BLUE)  | A_BOLD,
168f499134dSBaptiste Daroussin 	.button.shortcutcolor   = GET_COLOR(COLOR_RED,    COLOR_WHITE) | A_BOLD
169c76f0793SBaptiste Daroussin };
170c76f0793SBaptiste Daroussin 
1718c4f4028SBaptiste Daroussin static void
1728c4f4028SBaptiste Daroussin set_theme(struct bsddialog_theme *dst, struct bsddialog_theme *src)
173c76f0793SBaptiste Daroussin {
174*263660c0SAlfonso Siciliano 	dst->screen.color = src->screen.color;
175*263660c0SAlfonso Siciliano 
1768c4f4028SBaptiste Daroussin 	dst->shadow.color = src->shadow.color;
1778c4f4028SBaptiste Daroussin 	dst->shadow.h     = src->shadow.h;
1788c4f4028SBaptiste Daroussin 	dst->shadow.w     = src->shadow.w;
179c76f0793SBaptiste Daroussin 
1808c4f4028SBaptiste Daroussin 	dst->dialog.delimtitle       = src->dialog.delimtitle;
1818c4f4028SBaptiste Daroussin 	dst->dialog.titlecolor       = src->dialog.titlecolor;
1828c4f4028SBaptiste Daroussin 	dst->dialog.lineraisecolor   = src->dialog.lineraisecolor;
1838c4f4028SBaptiste Daroussin 	dst->dialog.linelowercolor   = src->dialog.linelowercolor;
1848c4f4028SBaptiste Daroussin 	dst->dialog.color            = src->dialog.color;
1858c4f4028SBaptiste Daroussin 	dst->dialog.bottomtitlecolor = src->dialog.bottomtitlecolor;
186c76f0793SBaptiste Daroussin 
1878c4f4028SBaptiste Daroussin 	dst->menu.arrowcolor      = src->menu.arrowcolor;
1888c4f4028SBaptiste Daroussin 	dst->menu.selectorcolor   = src->menu.selectorcolor;
1898c4f4028SBaptiste Daroussin 	dst->menu.f_desccolor     = src->menu.f_desccolor;
1908c4f4028SBaptiste Daroussin 	dst->menu.desccolor       = src->menu.desccolor;
1918c4f4028SBaptiste Daroussin 	dst->menu.f_namecolor     = src->menu.f_namecolor;
1928c4f4028SBaptiste Daroussin 	dst->menu.namecolor       = src->menu.namecolor;
1938c4f4028SBaptiste Daroussin 	dst->menu.namesepcolor    = src->menu.namesepcolor;
1948c4f4028SBaptiste Daroussin 	dst->menu.descsepcolor    = src->menu.descsepcolor;
1958c4f4028SBaptiste Daroussin 	dst->menu.f_shortcutcolor = src->menu.f_shortcutcolor;
1968c4f4028SBaptiste Daroussin 	dst->menu.shortcutcolor   = src->menu.shortcutcolor;
197c76f0793SBaptiste Daroussin 
1988c4f4028SBaptiste Daroussin 	dst->form.f_fieldcolor  = src->form.f_fieldcolor;
1998c4f4028SBaptiste Daroussin 	dst->form.fieldcolor    = src->form.fieldcolor;
2008c4f4028SBaptiste Daroussin 	dst->form.readonlycolor = src->form.readonlycolor;
201c76f0793SBaptiste Daroussin 
2028c4f4028SBaptiste Daroussin 	dst->bar.f_color = src->bar.f_color;
2038c4f4028SBaptiste Daroussin 	dst->bar.color   = src->bar.color;
204c76f0793SBaptiste Daroussin 
2058c4f4028SBaptiste Daroussin 	dst->button.space           = src->button.space;
2068c4f4028SBaptiste Daroussin 	dst->button.leftch          = src->button.leftch;
2078c4f4028SBaptiste Daroussin 	dst->button.rightch         = src->button.rightch;
2088c4f4028SBaptiste Daroussin 	dst->button.f_delimcolor    = src->button.f_delimcolor;
2098c4f4028SBaptiste Daroussin 	dst->button.delimcolor      = src->button.delimcolor;
2108c4f4028SBaptiste Daroussin 	dst->button.f_color         = src->button.f_color;
2118c4f4028SBaptiste Daroussin 	dst->button.color           = src->button.color;
2128c4f4028SBaptiste Daroussin 	dst->button.f_shortcutcolor = src->button.f_shortcutcolor;
2138c4f4028SBaptiste Daroussin 	dst->button.shortcutcolor   = src->button.shortcutcolor;
214c76f0793SBaptiste Daroussin 
215*263660c0SAlfonso Siciliano 	bkgd(dst->screen.color);
216c76f0793SBaptiste Daroussin 	refresh();
217c76f0793SBaptiste Daroussin }
218c76f0793SBaptiste Daroussin 
2198c4f4028SBaptiste Daroussin /* API */
2208c4f4028SBaptiste Daroussin int bsddialog_get_theme(struct bsddialog_theme *theme)
2218c4f4028SBaptiste Daroussin {
2228c4f4028SBaptiste Daroussin 	if (theme == NULL)
2238c4f4028SBaptiste Daroussin 		RETURN_ERROR("theme is NULL");
2248c4f4028SBaptiste Daroussin 	if (sizeof(*theme) != sizeof(struct bsddialog_theme))
2258c4f4028SBaptiste Daroussin 		RETURN_ERROR("Bad suze struct bsddialog_theme");
2268c4f4028SBaptiste Daroussin 
2278c4f4028SBaptiste Daroussin 	set_theme(theme, &t);
2288c4f4028SBaptiste Daroussin 
2298c4f4028SBaptiste Daroussin 	return (0);
2308c4f4028SBaptiste Daroussin }
2318c4f4028SBaptiste Daroussin 
2328c4f4028SBaptiste Daroussin int bsddialog_set_theme(struct bsddialog_theme *theme)
2338c4f4028SBaptiste Daroussin {
2348c4f4028SBaptiste Daroussin 	if (theme == NULL)
2358c4f4028SBaptiste Daroussin 		RETURN_ERROR("theme is NULL");
2368c4f4028SBaptiste Daroussin 	if (sizeof(*theme) != sizeof(struct bsddialog_theme))
2378c4f4028SBaptiste Daroussin 		RETURN_ERROR("Bad size struct bsddialog_theme");
2388c4f4028SBaptiste Daroussin 
2398c4f4028SBaptiste Daroussin 	set_theme(&t, theme);
2408c4f4028SBaptiste Daroussin 
2418c4f4028SBaptiste Daroussin 	return (0);
2428c4f4028SBaptiste Daroussin }
2438c4f4028SBaptiste Daroussin 
244c76f0793SBaptiste Daroussin int bsddialog_set_default_theme(enum bsddialog_default_theme newtheme)
245c76f0793SBaptiste Daroussin {
246c76f0793SBaptiste Daroussin 
2478c4f4028SBaptiste Daroussin 	if (newtheme == BSDDIALOG_THEME_DEFAULT) {
2488c4f4028SBaptiste Daroussin 		bsddialog_set_theme(&dialogtheme);
2498c4f4028SBaptiste Daroussin 		t.dialog.lineraisecolor = t.dialog.linelowercolor;
250*263660c0SAlfonso Siciliano 		t.dialog.delimtitle     = true;
251*263660c0SAlfonso Siciliano 		t.button.leftch         = '[';
252*263660c0SAlfonso Siciliano 		t.button.rightch        = ']';
2538c4f4028SBaptiste Daroussin 	}
254c76f0793SBaptiste Daroussin 	else if (newtheme == BSDDIALOG_THEME_BSDDIALOG)
2558c4f4028SBaptiste Daroussin 		bsddialog_set_theme(&bsddialogtheme);
256c76f0793SBaptiste Daroussin 	else if (newtheme == BSDDIALOG_THEME_BLACKWHITE)
2578c4f4028SBaptiste Daroussin 		bsddialog_set_theme(&blackwhite);
258c76f0793SBaptiste Daroussin 	else if (newtheme == BSDDIALOG_THEME_DIALOG)
2598c4f4028SBaptiste Daroussin 		bsddialog_set_theme(&dialogtheme);
260c76f0793SBaptiste Daroussin 	else
261c76f0793SBaptiste Daroussin 		RETURN_ERROR("Unknow default theme");
262c76f0793SBaptiste Daroussin 
2638c4f4028SBaptiste Daroussin 	return (0);
264c76f0793SBaptiste Daroussin }
265c76f0793SBaptiste Daroussin 
266c76f0793SBaptiste Daroussin int
267d93b4d32SBaptiste Daroussin bsddialog_color(enum bsddialog_color foreground,
268d93b4d32SBaptiste Daroussin     enum bsddialog_color background, unsigned int flags)
269c76f0793SBaptiste Daroussin {
2708c4f4028SBaptiste Daroussin 	unsigned int cursesflags = 0;
271c76f0793SBaptiste Daroussin 
2728c4f4028SBaptiste Daroussin 	if (flags & BSDDIALOG_BOLD)
2738c4f4028SBaptiste Daroussin 		cursesflags |= A_BOLD;
2748c4f4028SBaptiste Daroussin 	if (flags & BSDDIALOG_REVERSE)
2758c4f4028SBaptiste Daroussin 		cursesflags |= A_REVERSE;
2768c4f4028SBaptiste Daroussin 	if (flags & BSDDIALOG_UNDERLINE)
2778c4f4028SBaptiste Daroussin 		cursesflags |= A_UNDERLINE;
278c76f0793SBaptiste Daroussin 
279d93b4d32SBaptiste Daroussin 	return (GET_COLOR(foreground, background) | cursesflags);
280c76f0793SBaptiste Daroussin }