[comp.sys.amiga] Prop Gadgets

scott@applix.UUCP (Scott Evernden) (02/19/88)

The following code illustrates a problem with PropGadgets which I keep
running into.  This bug was introduced in version 1.2 of the Amiga OS.
Simply stated, a PropGadget with a LeftEdge/TopEdge of 0 (i.e., butted
against the window border) doesn't work properly.  Make LeftEdge 1 or
-1 and everything works fine.  This annoyance makes it difficult to
place sliders squarely along the window edges.

This program expects 1 argument- the value of a horizontal PropGadget's
LeftEdge.  As you move the slider, the program prints the Prop's Pot
value.  Note that when you run with an argument of 0, and move the
slider away, and then back to the left side, it will not read 0 ever.
Instead, some other random and nonsense value is returned.

	> prop 1	both of these ...
	> prop -1	... work just fine
	> prop 0	demonstrates the never-0 gadget

-scott

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* prop.c */

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

#define HTOP	-11
#define HHYT	12
#define HBODY	0x1FFF

struct Image hi;

/* horizontal gadget */
struct PropInfo hpi = {
	AUTOKNOB | FREEHORIZ, 0, 0, HBODY, MAXBODY
};
struct Gadget hg = {
	NULL, 0, HTOP, 0, HHYT, GADGHNONE | GRELBOTTOM | GRELWIDTH,
	GADGIMMEDIATE | RELVERIFY, PROPGADGET,
	(APTR) &hi, NULL, NULL, 0, (APTR) &hpi, 99
};
struct NewWindow nw = {
	20, 10, 320, 40, 0, 1,
	GADGETUP | CLOSEWINDOW,
	NOCAREREFRESH | WINDOWDRAG | WINDOWCLOSE | ACTIVATE,
	&hg, NULL, NULL, NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
};

struct IntuitionBase *IntuitionBase, *OpenLibrary();
struct Window *w, *OpenWindow();
struct IntuiMessage *GetMsg();

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

main(argc, argv)
char *argv[];
{
	extern int Enable_Abort;
	struct IntuiMessage *msg;
	ULONG class;
	int quit;

	quit = Enable_Abort = 0;

	/* install LeftEdge */
	if (1 < argc) {
		hg.LeftEdge = atoi(argv[1]);
		hg.Width = -hg.LeftEdge;
	}

	/* opens; (skipping checks) */
	IntuitionBase = OpenLibrary("intuition.library", 0L);
	w = OpenWindow(&nw);

	while (!quit) {
		Wait(1L << w->UserPort->mp_SigBit);
		while (msg = GetMsg(w->UserPort)) {
			class = msg->Class;
			ReplyMsg(msg);

			switch (class) {
			/* read current pot value */
			case GADGETUP:
				printf("horizProp: val 0x%x\n", hpi.HorizPot);
				break;
			case CLOSEWINDOW:
				quit = 1;
				break;
			}
		}
	}

	/* bye */
	CloseWindow(w);
	CloseLibrary(IntuitionBase);
}

David.Plummer@f70.n140.z1.FIDONET.ORG (David Plummer) (12/19/90)

What's a handy way (other than req.library) to determine your proper
place in a list (ie:file requester type list) given the information from 
VertPot portion of your prop gadget info structure?  I've got this:
 
if (GadgetID==PropGad1) {                                               
      list_pos=(Num-LISTSIZE)*(MAXPOT/PropGad1DefSInfo.VertPot);
      DrawDList(Selected, list_pos);                                    
}
 
But this seems to return the wrong value (guru in DrawDList).  Can I get
by without floating point (it's the only place I'd need it in the
program, so I'd like to avoid it).  Does anyone have any nice simple 
code to achieve this?
 
Thanks, 
Dave
 
(Sorry I couldn't think of a way to work this into the NeXT thread.  I
apologize for the actually useful question).



--  
David Plummer - via FidoNet node 1:140/22
UUCP: ...!herald!weyr!70!David.Plummer
Domain: David.Plummer@f70.n140.z1.FIDONET.ORG
Standard Disclaimers Apply...