1 /*- 2 * SPDX-License-Identifier: CC0-1.0 3 * 4 * Written in 2021 by Alfonso Sabato Siciliano. 5 * To the extent possible under law, the author has dedicated all copyright 6 * and related and neighboring rights to this software to the public domain 7 * worldwide. This software is distributed without any warranty, see: 8 * <http://creativecommons.org/publicdomain/zero/1.0/>. 9 */ 10 11 #include <stdio.h> 12 #include <string.h> 13 14 #include <bsddialog.h> 15 #include <bsddialog_theme.h> 16 17 int main() 18 { 19 int output; 20 struct bsddialog_conf conf; 21 enum bsddialog_default_theme theme; 22 struct bsddialog_menuitem items[4] = { 23 {"", false, 0, "Dialog", "Current dialog theme", "BSDDIALOG_THEME_DIALOG" }, 24 {"", false, 0, "BSDDialog", "Future default theme", "BSDDIALOG_THEME_DEFAULT"}, 25 {"", false, 0, "BlackWhite","Black and White theme", "BSDDIALOG_THEME_BLACKWHITE"}, 26 {"", false, 0, "Quit", "Exit", "Quit or Cancel to exit" } 27 }; 28 29 bsddialog_initconf(&conf); 30 conf.title = " Theme "; 31 32 if (bsddialog_init() == BSDDIALOG_ERROR) 33 return BSDDIALOG_ERROR; 34 35 while (true) { 36 bsddialog_backtitle(&conf, "Theme Example"); 37 38 output = bsddialog_menu(&conf, "Choose theme", 15, 40, 4, 4, items, NULL); 39 40 if (output != BSDDIALOG_OK || items[3].on) 41 break; 42 43 if (items[0].on) { 44 theme = BSDDIALOG_THEME_DIALOG; 45 conf.menu.default_item = items[0].name; 46 } 47 else if (items[1].on) { 48 theme = BSDDIALOG_THEME_BSDDIALOG; 49 conf.menu.default_item = items[1].name; 50 } 51 else if (items[2].on) { 52 theme = BSDDIALOG_THEME_BLACKWHITE; 53 conf.menu.default_item = items[2].name; 54 } 55 56 bsddialog_set_default_theme(theme); 57 } 58 59 bsddialog_end(); 60 61 return output; 62 } 63