Path: blob/main/contrib/bsddialog/examples_library/theme.c
39476 views
/*-1* SPDX-License-Identifier: CC0-1.02*3* Written in 2021 by Alfonso Sabato Siciliano.4* To the extent possible under law, the author has dedicated all copyright5* and related and neighboring rights to this software to the public domain6* worldwide. This software is distributed without any warranty, see:7* <http://creativecommons.org/publicdomain/zero/1.0/>.8*/910#include <bsddialog.h>11#include <bsddialog_theme.h>12#include <stdio.h>1314int main()15{16int output, focusitem;17struct bsddialog_conf conf;18enum bsddialog_default_theme theme;19struct bsddialog_menuitem items[4] = {20{"", false, 0, "Flat", "default flat theme",21"enum bsddialog_default_theme BSDDIALOG_THEME_FLAT" },22{"", false, 0, "3D", "pseudo 3D theme",23"enum bsddialog_default_theme BSDDIALOG_THEME_3D" },24{"", false, 0, "BlackWhite","black and white theme",25"enum bsddialog_default_theme BSDDIALOG_THEME_BLACKWHITE" },26{"", false, 0, "Quit", "Exit", "Quit, Cancel or ESC to exit" }27};2829if (bsddialog_init() == BSDDIALOG_ERROR) {30printf("Error: %s\n", bsddialog_geterror());31return (1);32}33bsddialog_initconf(&conf);34conf.ascii_lines = true;35bsddialog_backtitle(&conf, "Theme Example");36bsddialog_initconf(&conf);37conf.key.enable_esc = true;38conf.title = " Theme ";39focusitem = -1;40while (true) {41output = bsddialog_menu(&conf, "Choose theme", 15, 45, 4, 4,42items, &focusitem);4344if (output != BSDDIALOG_OK || items[3].on)45break;4647if (items[0].on) {48theme = BSDDIALOG_THEME_FLAT;49focusitem = 0;50} else if (items[1].on) {51theme = BSDDIALOG_THEME_3D;52focusitem = 1;53} else if (items[2].on) {54theme = BSDDIALOG_THEME_BLACKWHITE;55focusitem = 2;56}57bsddialog_set_default_theme(theme);58}5960bsddialog_end();6162return (0);63}6465