/* * Window Events * ------------- * This program demonstrates the use of three window call-back * functions: setresize, setredraw and setclose. * * If a window is resized, the resize callback happens first, * then the redraw callback. If the used closes the window using * the button in the top-left of the titlebar, the close function * is called. * * Note that if you supply a close function the window will not * automatically vanish any more. You must explicitly hide the * window using the hide function. The hide function works with * buttons, checkboxes etc as well as windows. */ #include void resize_it(window w, rect r) { printf("Resize event! New rectangle=(%d,%d,%d,%d)\n", r.x, r.y, r.width, r.height); } void redraw_it(window w, rect r) { printf("Draw event! New rectangle=(%d,%d,%d,%d)\n", r.x, r.y, r.width, r.height); } void close_it(window w) { printf("Close event!\n"); hide(w); } void main(void) { window w; w = newwindow("Watch stdout", rect(0,0,200,150), StandardWindow); setresize(w, resize_it); setredraw(w, redraw_it); setclose(w, close_it); show(w); mainloop(); }