Пример #1
0
/* Traverse over an internal menu */
Boolean
dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons)
{
    int n, rval = 0;
    dialogMenuItem *items;

    items = menu->items;
    if (buttons)
	items += 2;
    /* Count up all the items */
    for (n = 0; items[n].title; n++);

    while (1) {
	char buf[FILENAME_MAX];
	WINDOW *w = savescr();

	/* Any helpful hints, put 'em up! */
	use_helpline(menu->helpline);
	use_helpfile(systemHelpFile(menu->helpfile, buf));
	dialog_clear_norefresh();
	/* Pop up that dialog! */
	if (menu->type & DMENU_NORMAL_TYPE)
	    rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt,
		-1, -1, menu_height(menu, n), -n, items,
		(char *)(uintptr_t)buttons, choice, scroll);

	else if (menu->type & DMENU_RADIO_TYPE)
	    rval = dialog_radiolist((u_char *)menu->title,
		(u_char *)menu->prompt, -1, -1, menu_height(menu, n), -n,
		items, (char *)(uintptr_t)buttons);

	else if (menu->type & DMENU_CHECKLIST_TYPE)
	    rval = dialog_checklist((u_char *)menu->title,
		(u_char *)menu->prompt, -1, -1, menu_height(menu, n), -n,
		items, (char *)(uintptr_t)buttons);
	else
	    msgFatal("Menu: `%s' is of an unknown type\n", menu->title);
	if (exited) {
	    exited = FALSE;
	    restorescr(w);
	    return TRUE;
	}
	else if (rval) {
	    restorescr(w);
	    return FALSE;
	}
	else if (menu->type & DMENU_SELECTION_RETURNS) {
	    restorescr(w);
	    return TRUE;
	}
    }
}
Пример #2
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
    int retval;
    
    init_dialog();
    
    retval = dialog_radiolist("this is dialog_radiolist() in action, test #2",
			      "Welcome to \"The Love Blender!\" - America's favorite game show\n"
			      "where YOU, the contestant, get to choose which of these two\n"
			      "fine specimens of humanity will go home together, whether they\n"
			      "like it or not!", -1, -1, 7, -7, menu6, NULL);
    dialog_clear();
    fprintf(stderr, "I'm sure that %s and %s will be very happy together!\n", bachelor, bachelette);
    
    end_dialog();
    return 0;
}
Пример #3
0
static void
preinsure(dialogMenuItem *self, int is_selected)
{
    if (is_selected) {
	static WINDOW *w;
	
	/* This has to be here first if you want to see selection traverse properly in the invoking menu */
	refresh();

	w = dupwin(newscr);
	DialogX = 1;
	DialogY = 13;
	dialog_radiolist("How much insurance would you like to take out?",
			 "If you're really going to do this, we recommend some insurance\n"
			 "first!  What kind of life insurance policy would you like?",
			 -1, -1, 3, 3, insurance, NULL);
	touchwin(w);
	wrefresh(w);
	delwin(w);
    }
}
Пример #4
0
/* Kick it off, James! */
int
main(int argc, char **argv)
{
    int retval;
    
    init_dialog();
    
    
    DialogX = 5;
    DialogY = 1;
    retval = dialog_radiolist("this is dialog_radiolist() in action, test #3",
			      "This radio menu shows off the ability to put dialog menus and other\n"
			      "controls at different locations, as well as the `selected' hook which\n"
			      "lets you follow the traversal of the selection bar as well as what's\n"
			      "selected.",
			      -1, -1, 3, -3, menu5, NULL);
    dialog_clear();
    fprintf(stderr, "returned value for dialog_radiolist was %d (money set to %d)\n", retval, spending);
    
    end_dialog();
    return 0;
}
Пример #5
0
void		/* ANSI C can bite me */
main()
{
    int rc;
    char result[20];
    int sc=0, ch=0;

    extern int LINES, COLS;

    init_dialog();

    while (1) {
	rc = dialog_menu(0, "Choose a dialog function to test",
			    LINES-2, COLS-2, NRCHOICES, NRCHOICES,
			    choices, result, &sc, &ch);

	if (rc != 0)
	    break;

	if (strstr(result, "menu")) {
	    int sc2=0, ch2=0;
	    rc = dialog_menu("menu", "menu box",
				-1, -1, 4, 7, menu, result, &sc2, &ch2);
	    if (rc == 0)
		dialog_notify(result);
	    else if (rc == 1)
		dialog_notify("CANCEL");
	    else
		dialog_notify("Ooops");

	    sc2=0, ch2=0;
	    rc = dialog_menu("menu", "menu box\nnumber 2",
				13, 35, 4, 7, menu, result, &sc2, &ch2);
	    if (rc == 0)
		dialog_notify(result);
	    else if (rc == 1)
		dialog_notify("CANCEL");
	    else
		dialog_notify("Ooops");
	}
	else if (strstr(result,"check")) {
	    rc = dialog_checklist("checklist", "checklist box",
				    -1, -1, 4, 7, checklist, result);
	    if (rc == 0)
		dialog_notify(result);
	    else if (rc == 1)
		dialog_notify("CANCEL");
	    else
		dialog_notify("Ooops");
	}
	else if (strstr(result,"radio")) {
	    rc = dialog_radiolist("radiolist", "radiolist box",
				    -1, -1, 4, 7, checklist, result);
	    if (rc == 0)
		dialog_notify(result);
	    else if (rc == 1)
		dialog_notify("CANCEL");
	    else
		dialog_notify("Ooops");
	}
	else if (strstr(result, "notify"))
	    dialog_notify("A Notification box");
	else if (strstr(result, "msg")) {
	    dialog_msgbox("msgbox", "Sleeping 2 seconds on a\n"
				    "msg box without user input", -1, -1, 0);
	    sleep(1);
	    dialog_msgbox("msgbox", "Sleeping 1 second on a\n"
				    "msg box without user input", -1, -1, 0);
	    sleep(1);
	    dialog_msgbox("msgbox", "A msg box that wants user input",
				    -1, -1, 1);
	}
	else if (strstr(result, "mesg"))
	    dialog_mesgbox("mesgbox", "A mesg box", -1, -1);
	else if (strstr(result, "yesno")) {
	    rc = dialog_yesno("yesno", "Test me\nPress YES or NO", -1, -1);

	    if (rc == 0)
		dialog_notify("You pressed YES");
	    else if (rc > 0)
		dialog_notify("You pressed NO");
	    else
		dialog_notify("Something Wicked Happened!");
	}
	else if (strstr(result, "gauge")) { 
	    int x;
	    for (x=0; x<=20; x++) {
		dialog_gauge("test", "gauge", -1, -1, -1, 40, x*5);
		usleep(300000);
	    }
	}
    }
    end_dialog();
    exit((rc < 0) ? 1 : 0);
}