Category : C Source Code
Archive   : WIND.ZIP
Filename : WINDDEMO.C

 
Output of file : WINDDEMO.C contained in archive : WIND.ZIP

/* winddemo.c - quick demo of stacked windows
*/

#include
#include
#include
#include "windows.h"
#define WINDOWS 5

main()
{
Window *array[WINDOWS], *message_w;
unsigned int i;
void fill(), crs_on(), crs_off();

w_init(); /* call standard initialization in Windows package */
crs_off();

/* put instructions in message window at top of screen */
message_w = w_create(1, 1, 1, 78, single, "INSTRUCTIONS");
w_open(message_w);
w_center("Press RETURN to continue ...", message_w, 0);
/* set up array of 5 windows; reverse-video for 4th window */
array[0] = w_create( 4, 10, 11, 35, doubl, "Window 1");
array[1] = w_create( 7, 20, 14, 45, single, "Window 2");
array[2] = w_create(10, 30, 17, 55, doubl, "Window 3");
array[3] = w_create(13, 40, 20, 65, single, "Window 4");
array[4] = w_create(16, 50, 23, 75, doubl, "Window 5");
array[3]->attribute = REVERSE;
getch(); /* wait for keypress */

/* open the windows one by one, filling them with garbage */
for (i = 0; i < WINDOWS; i++) {
w_open(array[i]);
fill(array[i]);
}

/* demonstrate pulling a window out from the middle of the stack */
w_clear(array[1]);
w_center("Look -- I got pulled out", array[1], 3);
w_center("from behind the others!!", array[1], 4);
w_select(array[1]);

/* close the windows down, one by one */
while (layers_w > 1) {
getch();
w_close(top_w);
}

/* say goodbye & restore the original cursor */
w_draw(main_w);
w_clear(message_w);
w_draw(message_w);
w_center("<<<< ALL DONE! >>>>", message_w, 0);
crs_on();
}

void fill (w)
Window *w;
{
while (!kbhit())
w_putc (rand() & 0xff, w);
getch();
}