/* *****                                                            *****
** *****           Program created by Ken Farinsky, 1986.           *****
** *****                                                            *****
**
** All material contained herein may be used in any way desired.
**                    >>>>> i.e.  PUBLIC DOMAIN. <<<<<
** Not limited to any single bulletin board - can be freely transferred.
**
** Original distribution through:
**     Slipped Disk, Inc.
**     Madison Heights,  MI  48071
**     (313) 583-9803
**
** Distributed in the hopes of increasing the level of understanding of the
** Amiga personal computer.  Even the best computer can only succeed with
** the proper software support.
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <functions.h>
#include "view.h"

extern struct Library	   *IntuitionBase ;
extern struct Library	   *GfxBase ;
extern struct Library	   *DosBase ;


/*----------------------------------------------------------------------
** process_gadgetup() - process the proportional gadgets.  the one on the
** side (changes line number) is number 30, the one on the bottom (changes
** the y offset or indent) is number 31.
*/
void process_gadgetup(The_Window,gad_addr,top,tot_recs,
						win_size,cur_offset,data,cur_indent)
struct Window  *The_Window ;
struct Gadget  *gad_addr ;
UBYTE		 ***top ;
SHORT			tot_recs ;
SHORT			win_size ;
SHORT		   *cur_offset ;
UBYTE		  **data ;
SHORT		   *cur_indent ;
{
void 	install_data() ;
USHORT	gad_id ;

gad_id = gad_addr->GadgetID ;

/* up/down prop gadget.  compute the new line offset, see if it is a
** valid position in the file, and redisplay the data.
*/
if ( 30 == gad_id)
	{
	*cur_offset = (USHORT)(((long)(tot_recs - win_size) *
		(long)(((struct PropInfo *)(gad_addr->SpecialInfo))->VertPot)) /
		0xffffL) ;
	if ( (*cur_offset + win_size) > tot_recs)
		*cur_offset = tot_recs - win_size ;
	if ( *cur_offset < 0)
		*cur_offset = 0 ;
	*top = &data[*cur_offset] ;
	install_data( The_Window, *top, win_size, *cur_offset, *cur_indent) ;
	}
/* left/right prop gadget.  compute the indent offset, and redisplay the data.
** the line number does not change.
*/
else if ( 31 == gad_id)
	{
	*cur_indent = (USHORT)((long)(
		(long)(((struct PropInfo *)(gad_addr->SpecialInfo))->HorizPot)) >> 8);
	install_data( The_Window, *top, win_size, *cur_offset, *cur_indent) ;
	}
}
