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 <bsddialog.h> 12 #include <bsddialog_theme.h> 13 #include <stdio.h> 14 #include <string.h> 15 16 int main() 17 { 18 int output, focusitem; 19 struct bsddialog_conf conf; 20 enum bsddialog_default_theme theme; 21 struct bsddialog_menuitem items[5] = { 22 {"", false, 0, "Flat", "dialog-like", 23 "BSDDIALOG_THEME_FLAT" }, 24 {"", false, 0, "Dialog", "dialog clone", 25 "BSDDIALOG_THEME_DIALOG" }, 26 {"", false, 0, "BSDDialog", "new theme", 27 "BSDDIALOG_THEME_BSDDIALOG" }, 28 {"", false, 0, "BlackWhite","black and white", 29 "BSDDIALOG_THEME_BLACKWHITE" }, 30 {"", false, 0, "Quit", "Exit", "Quit or Cancel to exit" } 31 }; 32 33 if (bsddialog_init() == BSDDIALOG_ERROR) { 34 printf("Error: %s\n", bsddialog_geterror()); 35 return (1); 36 } 37 38 bsddialog_initconf(&conf); 39 40 bsddialog_backtitle(&conf, "Theme Example"); 41 42 conf.title = " Theme "; 43 focusitem = -1; 44 while (true) { 45 output = bsddialog_menu(&conf, "Choose theme", 15, 45, 5, 5, 46 items, &focusitem); 47 48 if (output != BSDDIALOG_OK || items[4].on) 49 break; 50 51 if (items[0].on) { 52 theme = BSDDIALOG_THEME_FLAT; 53 focusitem = 0; 54 } 55 else if (items[1].on) { 56 theme = BSDDIALOG_THEME_DIALOG; 57 focusitem = 1; 58 } 59 else if (items[2].on) { 60 theme = BSDDIALOG_THEME_BSDDIALOG; 61 focusitem = 2; 62 } 63 else if (items[3].on) { 64 theme = BSDDIALOG_THEME_BLACKWHITE; 65 focusitem = 3; 66 } 67 68 bsddialog_set_default_theme(theme); 69 } 70 71 bsddialog_end(); 72 73 return (output); 74 }