/* "WDEMO.C      ver 0.0a         11/23/87"
   Copyright (c) 1987 John G. Donohue
*/

#include <defines.h>
#include <wdef.h>

int                    x,y,k;
extern ERRCODE         werrnum;
extern struct _window  windows[MAXWIN], *cw;

#ifdef DEBUG
extern WNUM            cwnum;
extern WATTR           scn_attr;
#endif

/*
extern WNUM            wstack[MAXWIN];
extern int             wstkhgt;
extern COORD           scn_row, scn_column;
extern SCN             screens[2];
extern struct REGS     reg;
*/

/*****************************************************************************/
int main()
{
        WNUM    w1, w2, w3, w4, w5 /*, w6 */;
        int     i;
#ifdef DEBUG
        WNUM    w;
#endif

        w_init();               /* always call this function first */

        /* define 4 windows */
        w1 = w_def( -1, WNORMAL_,      10, 47, FG_GREEN|BG_BLUE   ,
                    (BITS) 0,    FG_BROWN|BG_BLUE );
        w2 = w_def( -1, WNORMAL_,       8, 38, FG_BLUE |BG_CYAN,
                    (BITS) 0xa5|BORD_SHADOW, FG_RED|BG_CYAN );
        w3 = w_def( -1, WNORMAL_,      10, 37, FG_GREEN|BG_RED  ,
                    (BITS) 0x5a, FG_CYAN|BG_RED );
        w4 = w_def( -1, CLEAR_ON_OPEN,  6, 35, FG_MAGENTA|BG_WHITE,
                    (BITS) 0xc0, FG_BLACK|BG_WHITE );
        w5 = w_def( -1, CLEAR_ON_OPEN, STDHGT, STDWID, FG_BLUE|BG_BROWN,
                    (BITS) 0xc0|BORD_EDGE, BRIGHT|FG_BROWN|BG_RED );
/*
        w6 = w_def( -1, CLEAR_ON_OPEN, STDHGT, 10, FG_WHITE|BG_BLUE,
                    (BITS) 0xaa, BRIGHT|FG_WHITE|BG_BLUE );
*/
        w_open(w1, 3, 30);
        w_puts("\n You are about to see a DAZZLING demonstration\n");
        w_puts("          of windowing software from\n\n");

        for (i = 1000; i--; )
                ;

        w_open(w2, 6, 21);
        w_setattr(FGC_, FG_WHITE);
        bright();
        w_puts("\n   Donohue&Co.  Computer Services\n");
        nobright();
        w_setattr(ENTIRE_, cw->wdftattr);
        w_puts("              Box 255\n");
        w_puts("      Hannibal, New York 13074\n");
        w_puts("           (315) 564-6213\n");
        w_cursor(POSITION, 8);
        w_setattr(FGC_, FG_RED);
          w_puts(" Press any key to continue");
        w_setattr(ENTIRE_, cw->wdftattr);
        getv();
        w_cursor(POSITION, 8);
        w_puts("                           ");

        w_open(w3, 12, 3);
        w_puts("If you're a C programmer that\n");
        w_puts("needs better control than you've\n");
        w_puts("been getting from other packages,\n");
        w_puts("               AND...\n\n");
        w_puts(" Press any key to continue\n");
        getv();

        w_setattr(FGC_, FG_WHITE);
        w_puts("\n\n\n\nC SOURCE CODE FOR WINDOWS\n");
        w_setattr(ENTIRE_, cw->wdftattr);
        w_puts("which is\n");
        w_setattr(FGC_, FG_WHITE);
        w_puts("PORTABLE TO OTHER ENVIRONMENTS,\n");
        blink();
        w_puts("      INCLUDING TERMINALS!!!,\n");
        noblink();
        w_setattr(ENTIRE_, cw->wdftattr);
        w_puts("then you're about to be amazed.\n");

        w_puts("Here's why...\n");
        w_puts("         Press any key to continue");
        getv();

        w_puts("\n\n\n\nFirst of all, you can ");

        w_setattr(FGC_, FG_WHITE);
        w_puts("SCROLL ");
        w_setattr(ENTIRE_, cw->wdftattr);
        w_puts("the\n");
        w_puts("window.  But you figured that out\n");
        w_puts("already.\n\n\n");

        w_puts(" Press any key to continue");
        getv();

        w_puts("\n\n\n\nYou can use 3 kinds of borders,\n");
        w_puts("or NO BORDERS, and control each\n");
        w_puts("side of your window SEPARATELY!\n");

        w_puts("Don't want sides or a bottom, just\n");
        w_puts("a block top border with a title?\n\n");

        w_puts(" Press any key to continue\n");
        getv();

        w_open(w4, 16, 41);
        w_cursor(-1,6);
        w_setattr(ENTIRE_, cw->wbordattr);
        w_puts("The Window as specified\n");

        w_setattr(ENTIRE_, cw->wdftattr);
        w_cursor(0, 0);
        w_puts("\nThen that's what you get!\n");
        w_cursor(cw->wpane.rhgt-1, 25);
        w_setattr(ENTIRE_, cw->wbordattr);
        w_puts("Hit a key: ");
        w_setattr(ENTIRE_, cw->wdftattr);
        getv();

        w_current(w3);
        w_puts("\n\n\n\nYou can come back to where you\n");
        w_puts("left off, even while a later\n");
        w_puts("window is still on the screen,\n");
        w_puts("if you don't overlap.\n");
        for (i = 1000; i--; )
                ;
        w_puts(" Press any key to continue ");
        getv();

        w_open(w5, 0, 0);
        w_cursor(10, 25);
        w_puts("Is this not a thing of beauty?\n");
        w_setattr(ENTIRE_, cw->wbordattr);
        blink();
        w_cursor(-1, 51);
        w_puts(" Press any key to continue ");
        noblink();
        getv();
        w_close(w5);

        w_current(w3);
        w_puts("\nYou can open the windows in any\n");
        w_puts("order, at different locations on\n");
        w_puts("the screen, and close them without\n");
        w_puts("losing a character!  It's as easy\n");
        w_puts("as shuffling a deck of cards.\n");
        w_puts("Just watch this!\n\n");
        blink();
        w_puts("     Press any key and WATCH!");
        noblink();
        getv();

        w_close(w4);
        w_close(w3);
        w_close(w2);
        w_open(w4, 0, 0);
        w_open(w2, 14, 40);
        w_close(w2);
        w_close(w4);
        w_close(w1);
        w_open(w2, 14, 1);
        w_open(w4, 14, 35);
        w_open(w3, 0, 40);
        w_close(w3);
        w_close(w4);
        w_open(w1, 10, 10);
        w_close(w1);
        w_close(w2);
        w_open(w2, 4, 41);
        w_open(w3, 1, 1);
	w_puts("\n\n");

        for (i = 30000; i--; )
                ;
        for (k = 0; k < 8; ++k)
        {
                w_cursor(POSITION, k);
                w_setattr(FGC_, k);
                w_puts("Were you watching?\n");
                for (i = 30000; i--; )
                {
                        ++i;
                        --i;
                }
        }
        for (i = 30000; i--; )
                ;
        w_close(w3);

        for (i = 30000; i--; )
        {
                ++i;
                --i;
        }
        w_cursor(POSITION, 0);
        w_setattr(FGC_, FG_RED);
        w_puts("   PORTABLE SOURCE CODE IN C: $45  ");

        w_cursor(21,0);
        w_cursor(POSITION, POSITION);   /* force physical cursor there. */
}
