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 16 int main() 17 { 18 int i, j, output; 19 struct bsddialog_conf conf; 20 struct bsddialog_menuitem item; 21 struct bsddialog_menuitem check[5] = { 22 { "+", true, 0, "Name 1", "Desc 1", "Bottom Desc 1" }, 23 { "" , false, 0, "Name 2", "Desc 2", "Bottom Desc 2" }, 24 { "+", true, 0, "Name 3", "Desc 3", "Bottom Desc 3" }, 25 { "" , false, 0, "Name 4", "Desc 4", "Bottom Desc 4" }, 26 { "+", true, 0, "Name 5", "Desc 5", "Bottom Desc 5" } 27 }; 28 struct bsddialog_menuitem sep[1] = { 29 { "", true, 0, "Radiolist", "(desc)", "" } 30 }; 31 struct bsddialog_menuitem radio[5] = { 32 { "", true, 0, "Name 1", "Desc 1", "Bottom Desc 1" }, 33 { "+", false, 0, "Name 2", "Desc 2", "Bottom Desc 2" }, 34 { "", false, 0, "Name 3", "Desc 3", "Bottom Desc 3" }, 35 { "+", false, 0, "Name 4", "Desc 4", "Bottom Desc 4" }, 36 { "", false, 0, "Name 5", "Desc 5", "Bottom Desc 5" } 37 }; 38 struct bsddialog_menugroup group[3] = { 39 { BSDDIALOG_CHECKLIST, 5, check }, 40 { BSDDIALOG_SEPARATOR, 1, sep }, 41 { BSDDIALOG_RADIOLIST, 5, radio } 42 }; 43 44 bsddialog_initconf(&conf); 45 conf.title = "mixedmenu"; 46 47 if (bsddialog_init() < 0) 48 return -1; 49 50 output = bsddialog_mixedlist(&conf, "dialog4ports", 20, 30, 11, 3, group, 51 NULL,NULL); 52 53 bsddialog_end(); 54 55 printf("Mixedlist:\n"); 56 for (i=0; i<3; i++) { 57 for (j=0; j<group[i].nitems; j++) { 58 item = group[i].items[j]; 59 if (group[i].type == BSDDIALOG_SEPARATOR) 60 printf("----- %s -----\n", item.name); 61 else if (group[i].type == BSDDIALOG_RADIOLIST) 62 printf(" (%c) %s\n", item.on ? '*' : ' ', item.name); 63 else /* BSDDIALOG_PORTCHECKLIST */ 64 printf(" [%c] %s\n", item.on ? 'X' : ' ', item.name); 65 } 66 } 67 68 69 return output; 70 } 71