Utilities 3 (Disk 38) (Mar 1987) : c / ScnSizer.c

/* ScnSizer.c
 *
 * Thad Floryan, 7 March 1987
 *
 * Sets the Preferences data for increasing the window bounds.  From the
 * default parameters, RowSizeChange and ColumnSizeChange are the values
 * added to the window size.  ViewXOffset and ViewYOffset are the delta
 * from the default upper left corner.
 *
 * Usage:
 *
 *	CLI> ScnSizer [ row.delta  col.delta  [ -xoffset  -yoffset ] ]
 *
 * argv:	 [0]      [1]	      [2]	  [3]	     [4]
 * argc:	  1        2	       3	   4	      5
 *
 *		no args causes the present values to be displayed, else
 *		row.delta is the number of rows (V) to be added
 *		col.delta is the number of columns (H) to be added
 *		xoffset is the upper left corner x delta, usually negative
 *		yoffset is the upper left corner y delta, usually negative
 *
 * Note: the Preferences structure is exactly the size of and is stored in
 *	 SYS:DEVS/system-configuration.  This program calls RethinkDisplay()
 *	 for an immediate screen update if parameters are changed; to save
 *	 the parameters permanently, use the Preferences program.
 *
 * This program inspired by Neil Katin's "MoreRows" and enhanced/fixed from
 * Marco Papa's "MyMoreRows".  Compiled and linking using the Manx Axtec C
 * version 3.4a package per:
 *
 *	CLI> cc ScnSizer.c
 *	CLI> ln ScnSizer.o -lc
 *
 * Note also that the AmigaDOS version 1.2 "final" includes must be used
 * else certain definitions (esp. in intuition.h) won't be available.
 */

#include <functions.h>
#include <exec/types.h>
#include <intuition/intuition.h>

#define INTUITION_REV 33L  /* Must be Kick & Work 33.180 & 33.46|33.47 */

struct IntuitionBase *IntuitionBase;

main(argc, argv)
int argc;
char *argv[];
{
   struct Preferences *PrefBuffer;
   char *malloc();
   BYTE  rowsizechange, columnsizechange;
   BYTE  viewxoffset, viewyoffset;

   IntuitionBase = (struct IntuitionBase *)
		    OpenLibrary("intuition.library", INTUITION_REV);
   if( IntuitionBase == NULL ) {
	puts("Can't open intuition library");
	exit(TRUE);
   }

   PrefBuffer = (struct Preferences *)
	         malloc((unsigned) sizeof(struct Preferences));

   GetPrefs(PrefBuffer, (long) sizeof(struct Preferences));

   if (argc>2) {
      if (argc>4) {
	 viewxoffset = atoi(argv[3]);
	 viewyoffset = atoi(argv[4]);
      }
      else {
	 viewxoffset = PrefBuffer->ViewXOffset;
	 viewyoffset = PrefBuffer->ViewYOffset;
      }
      rowsizechange    = atoi(argv[1]);
      columnsizechange = atoi(argv[2]);

      PrefBuffer->RowSizeChange    = rowsizechange;
      PrefBuffer->ColumnSizeChange = columnsizechange;
      PrefBuffer->ViewXOffset      = viewxoffset;
      PrefBuffer->ViewYOffset      = viewyoffset;
      SetPrefs(PrefBuffer, (long) sizeof(struct Preferences), TRUE);
      RethinkDisplay();
   }
   else {
      printf("\tAlters the present default Workbench screen parameters by\n");
      printf("\tincreasing the rows & columns and offsetting the base.\n");
      printf("Usage:\n");
      printf("\t%s [row.delta col.delta [x.offset y.offset]]\n", argv[0]);
      printf("Present values:\n");
      printf("\trow.delta = %d\n", (int) PrefBuffer->RowSizeChange);
      printf("\tcol.delta = %d\n", (int) PrefBuffer->ColumnSizeChange);
      printf("\tx.offset  = %d\n", (int) PrefBuffer->ViewXOffset);
      printf("\ty.offset  = %d\n", (int) PrefBuffer->ViewYOffset);
   }

   free(PrefBuffer);
   CloseLibrary(IntuitionBase);
}