/* * Radio * ----- * This program demonstates the use of radio buttons. * * Radio buttons are similar to checkboxes, except that they are * used to signify mutually exclusive options. * * The radio button call-back function is called whenever a change * occurs. */ #include radiobutton tomato, barbeque; void place_order(button b) { printf("Sauce:\n"); if (ischecked(tomato)) printf(" Tomato\n"); if (ischecked(barbeque)) printf(" Barbeque\n"); exitapp(); } void choose(radiobutton sauce) { if (sauce == tomato) printf("Love tomato sauce!\n"); else if (sauce == barbeque) printf("Hmm, hmm, BBQ sauce.\n"); } void main(void) { window w; rect r; w = newwindow("Pizza", rect(0,0,200,180), StandardWindow); r = rect(10,10,100,30); tomato = newradiobutton("Tomato", r, choose); r.y += 35; barbeque = newradiobutton("BBQ", r, choose); r.y += 35; check(tomato); newbutton("Order Pizza", r, place_order); show(w); mainloop(); }