/* * Radio Check * ----------- * This program demonstates the use of radio buttons and checkboxes. * * Radio buttons are similar to checkboxes, except that they are * used to signify mutually exclusive options. */ #include checkbox topping[2]; radiobutton tomato, barbeque; void place_order(button b) { printf("Topping:\n"); if (ischecked(topping[0])) printf(" Egg\n"); if (ischecked(topping[1])) printf(" Bacon\n"); printf("Sauce:\n"); if (ischecked(tomato)) printf(" Tomato\n"); if (ischecked(barbeque)) printf(" Barbeque\n"); exitapp(); } void main(void) { window w; rect r; w = newwindow("Pizza", rect(0,0,200,250), StandardWindow); r = rect(10,10,100,30); newlabel("Choose:", r, AlignLeft); r.y += 35; topping[0] = newcheckbox("Egg", r, NULL); r.y += 35; topping[1] = newcheckbox("Bacon", r, NULL); r.y += 35; tomato = newradiobutton("Tomato", r, NULL); r.y += 35; barbeque = newradiobutton("BBQ", r, NULL); r.y += 35; check(tomato); newbutton("Order Pizza", r, place_order); show(w); mainloop(); }