/* * Textbox * ------- * This program creates a window, three labels, two fields, a textbox * and a button. The labels are string prompting the user what to * type, the fields and the textbox are for the user's name, phone * number and address, and the button prints out what the user typed * and exits. * * Notice that we resize the rectangle r before creating the address * textbox. By increasing its height to 75 pixels, the address box * is taller that the text fields. * * Notice also that the gettext function works equally well on * single-line text fields as it does on multi-line textboxes. */ #include field name, phone; textbox address; void place_order(button b) { printf("Name = %s\n", gettext(name)); printf("Phone = %s\n", gettext(phone)); printf("Address = %s\n", gettext(address)); 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; newlabel("Address:", 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; r.height = 75; address = newtextbox(NULL, r); newbutton("Order Pizza", rect(50,180,100,30), place_order); show(w); mainloop(); }