
/*
 *  SetWin:
 *      Small program useable ONLY under kickstart 2.0+.  It modifies the
 *      size of the current CLI window, both for the normal size, and the
 *      zoomed size.  I use it in my startup-sequence.  I usually leave
 *      the initial window open, and I used to resize it with the cwin
 *      program.  However, I was extremely annoyed since I used to size it
 *      to large size (and leave the screen title bar showing), and when I
 *      clicked on the zoom gadget the window sized to full screen size,
 *      since I usually wanted it to zoom nice and small down the bottom
 *      so I can use the workbench.
 *
 *      This program allows you to set the size of the currently selected
 *      window when both zoomed and unzoomed.  The format:
 *
 *      SetWin <x> <y> <width> <height> <zoomed x> <z.. y> <z.. w> <z.. h>
 *
 *      I use it as follows in my SSequence:
 *
 *          SetWin 0 12 640 244 0 200 640 56
 *
 *      (Which performs the task described above)
 *
 *      Have fun, and check out the source if you are learning to C program.
 *
 *
 */


/*  Intended for use on startup, will move the window to the desiried  */
/*  size and location, for both the zoomed and normal state.  */

#include <stdio.h>
#include <stdlib.h>

#include <dos/dos.h>
#include <dos/dosextens.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>

#include <clib/dos_protos.h>
#include <clib/intuition_protos.h>

char *template="NORMX/N/R, NORMY/N/R, NORMW/N/R, NORMH/N/R, ZIPX/N/R, ZIPY/N/R, ZIPW/N/R, ZIPH/N/R";
/*  Arguments:
 *      normx, normy, normw, normh, zipx, zipy, zipw, ziph
 */

extern struct IntuitionBase *IntuitionBase;

LONG *sizes[8];
struct RDArgs *rdargs;

void FreeAll( void );

void main( void )
    {
    struct Window *window;
    ULONG lock;

    rdargs = ReadArgs( template, (LONG *)sizes, NULL );
    if( !rdargs )
        {
        /*  Command line error  */
        puts( "SetWin:  Sets window sizes in normal and zoomed state." );
        puts( template );
        puts( "" );
        exit( 20 );
        }

    lock = LockIBase( 0 );

    /*  Get pointer to the currently selected window  */
    window = IntuitionBase->ActiveWindow;
    if( !window )
        {
        puts( "" );
        window = IntuitionBase->ActiveWindow;
        if( !window )
            exit( 20 );
        }

    UnlockIBase( lock );

    /*  Set the sizes:  Zoomed  */
    ZipWindow( window );
    ChangeWindowBox( window, *sizes[4], *sizes[5], *sizes[6], *sizes[7] );

    /*  Normaled  */
    ZipWindow( window );
    ChangeWindowBox( window, *sizes[0], *sizes[1], *sizes[2], *sizes[3] );

    FreeAll();
    }

void FreeAll( void )
    {
    FreeArgs( rdargs );
    }
