aboutsummaryrefslogtreecommitdiff
path: root/contrib/bsddialog/examples_library/theme.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bsddialog/examples_library/theme.c')
-rw-r--r--contrib/bsddialog/examples_library/theme.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/contrib/bsddialog/examples_library/theme.c b/contrib/bsddialog/examples_library/theme.c
index 305692d39cff..689633e624ed 100644
--- a/contrib/bsddialog/examples_library/theme.c
+++ b/contrib/bsddialog/examples_library/theme.c
@@ -8,55 +8,57 @@
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
-#include <stdio.h>
-#include <string.h>
-
#include <bsddialog.h>
#include <bsddialog_theme.h>
+#include <stdio.h>
int main()
{
- int output;
+ int output, focusitem;
struct bsddialog_conf conf;
enum bsddialog_default_theme theme;
struct bsddialog_menuitem items[4] = {
- {"", false, 0, "Dialog", "Current dialog theme", "BSDDIALOG_THEME_DIALOG" },
- {"", false, 0, "BSDDialog", "Future default theme", "BSDDIALOG_THEME_DEFAULT"},
- {"", false, 0, "BlackWhite","Black and White theme", "BSDDIALOG_THEME_BLACKWHITE"},
- {"", false, 0, "Quit", "Exit", "Quit or Cancel to exit" }
+ {"", false, 0, "Flat", "default flat theme",
+ "enum bsddialog_default_theme BSDDIALOG_THEME_FLAT" },
+ {"", false, 0, "3D", "pseudo 3D theme",
+ "enum bsddialog_default_theme BSDDIALOG_THEME_3D" },
+ {"", false, 0, "BlackWhite","black and white theme",
+ "enum bsddialog_default_theme BSDDIALOG_THEME_BLACKWHITE" },
+ {"", false, 0, "Quit", "Exit", "Quit, Cancel or ESC to exit" }
};
+ if (bsddialog_init() == BSDDIALOG_ERROR) {
+ printf("Error: %s\n", bsddialog_geterror());
+ return (1);
+ }
+ bsddialog_initconf(&conf);
+ conf.ascii_lines = true;
+ bsddialog_backtitle(&conf, "Theme Example");
bsddialog_initconf(&conf);
+ conf.key.enable_esc = true;
conf.title = " Theme ";
-
- if (bsddialog_init() == BSDDIALOG_ERROR)
- return BSDDIALOG_ERROR;
-
+ focusitem = -1;
while (true) {
- bsddialog_backtitle(&conf, "Theme Example");
-
- output = bsddialog_menu(&conf, "Choose theme", 15, 40, 4, 4, items, NULL);
+ output = bsddialog_menu(&conf, "Choose theme", 15, 45, 4, 4,
+ items, &focusitem);
if (output != BSDDIALOG_OK || items[3].on)
break;
if (items[0].on) {
- theme = BSDDIALOG_THEME_DIALOG;
- conf.menu.default_item = items[0].name;
- }
- else if (items[1].on) {
- theme = BSDDIALOG_THEME_BSDDIALOG;
- conf.menu.default_item = items[1].name;
- }
- else if (items[2].on) {
+ theme = BSDDIALOG_THEME_FLAT;
+ focusitem = 0;
+ } else if (items[1].on) {
+ theme = BSDDIALOG_THEME_3D;
+ focusitem = 1;
+ } else if (items[2].on) {
theme = BSDDIALOG_THEME_BLACKWHITE;
- conf.menu.default_item = items[2].name;
+ focusitem = 2;
}
-
bsddialog_set_default_theme(theme);
}
- bsddialog_end();
+ bsddialog_end();
- return output;
-}
+ return (0);
+} \ No newline at end of file