/* * Fields * ------ * This program creates a window, two labels, two text fields * and a button for ordering pizza. * * The labels are created with the flag AlignRight so that the * text lines up on the right. You could also use AlignLeft or * Center to change the alignment of text. * * A field is a one-line text editing control. You can give it * some initial text, as in this example. * * The button's call-back uses the gettext function to discover * what strings are contained in the text fields, before exiting * the application using exitapp. */ #include field name, phone; void place_order(button b) { printf("Name = %s\n", gettext(name)); printf("Phone = %s\n", gettext(phone)); exitapp(); } void main(void) { window w; rect r; w = newwindow("Pizza", rect(0,0,400,230), StandardWindow); r = rect(10,10,80,30); newlabel("Name:", r, AlignRight); r.y += 35; newlabel("Phone:", r, AlignRight); r.y += 35; r = rect(100,10,250,30); name = newfield("Type your name here", r); r.y += 35; phone = newfield(NULL, r); r.y += 35; newbutton("Order Pizza", rect(50,100,100,30), place_order); show(w); mainloop(); }