Path: utzoo!mnetor!uunet!mcvax!guido From: guido@cwi.nl (Guido van Rossum) Newsgroups: comp.windows.misc Subject: Re: Does anyone really understand windows? Message-ID: <204@piring.cwi.nl> Date: 17 Feb 88 15:02:15 GMT References: <1457@sugar.UUCP> Reply-To: guido@cwi.nl (Guido van Rossum) Organization: The Royal Society for Prevention of Cruelty to Amoebae Lines: 62 Now that we seem to be sending in "hello world" for our favourite window programming system, here's mine for "STDWIN". No preprocessing needed, just compile and link with the appropriate libraries. STDWIN is not a window system in its own right; it is a toolbox which interfaces to several existing window systems. Versions exist for: Whitechapel MG-1, X version 11, Apple Macintosh, Atari ST (soon), and (a text-only subset) for ASCII terminals supported by termcap. Inquire at address below. Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam guido@cwi.nl or mcvax!guido or (from ARPAnet) guido%cwi.nl@uunet.uu.net /* The "Hello, world" koan according to David Rosenthal, recoded for STDWIN. Requirements: print "Hello, world" centered in a window, recented after window resizes, redraw after window exposures. Check error returns. */ #include char *string= "Hello, world"; int text_h, text_v; placetext(win) WINDOW *win; { int width, height; wgetwinsize(win, &width, &height); text_v= (height - wlineheight()) / 2; text_h= (width - wtextwidth(string, -1)) / 2; } drawproc(win, left, top, right, bottom) WINDOW *win; { wdrawtext(text_h, text_v, string, -1); } main() { WINDOW *win; winit(); win= wopen("Hello", drawproc); if (win != 0) { placetext(win); for (;;) { EVENT e; wgetevent(&e); if (e.type == WE_COMMAND && (e.u.command == WC_CLOSE || e.u.command == WC_CANCEL)) break; if (e.type == WE_SIZE) placetext(win); } } wdone(); exit(0); }