
/***************************************************************************
    1/89

        DIRK v2.0 -- Tune workbench colors to system performance

        Copyright (C) 1989 by Daniel Elbaum

        This software is freely redistributable provided that:
        the four files which comprise it (dirk, dirk.doc, dirk.h,
        adjust.c, main.c, sys, window.c) remain intact; all
        copyright notices contained in any of the aforementioned
        files remain intact; and no fee beyond reasonable remuneration
        for collation and distribution be charged for use and/or
        distribution.

***************************************************************************/


#include "dirk.h"

/*
    Just give me a window and don't make me
    put endless initializations into main()
    or global space, okay?
*/

/*
    sp arg is more for symmetry than for anything else.
*/

struct Window *
getwin(sp)
struct Screen *sp;
{
    struct NewWindow nw;
    struct Window *wp;

    memset(&nw, 0, sizeof(nw));
    nw.LeftEdge = (sp->Width/2)-(WINWD/2);
    nw.TopEdge = WINTOP;
    nw.Width = WINWD;
    nw.Height = WINHT1;
    nw.DetailPen = sp->DetailPen;
    nw.BlockPen = sp->BlockPen;
    nw.Flags = WINFLAGS;
    nw.IDCMPFlags = WINIFLAGS;
    nw.Title=WINNAME;
    nw.Type=WBENCHSCREEN;
    nw.MinHeight=WINHT1;
    nw.MaxHeight=WINHT1+WINHT2;
    if (!(wp = OpenWindow(&nw))) {
        return((struct Window *)NULL);
    }
    else return(wp);
}

void
redowin(wp, oldstatus)
struct Window *wp;
{
    int d2bot;

    if (oldstatus==W_OPEN) SizeWindow(wp, 0, -(WINHT2-WINHT1));
    else {
        d2bot=(wp->WScreen->Height-wp->TopEdge)&0xFFFF;
        if (d2bot<WINHT2)
            MoveWindow(wp, 0, -(WINHT2-d2bot));
        SizeWindow(wp, 0, WINHT2-WINHT1);
    }
}

