View Single Post
Old 27 June 2021, 21:26   #1
Crispy
Registered User
 
Join Date: Oct 2020
Location: Sunhillow
Posts: 6
Bug in v34 prop gadget?

I have a vertical prop gadget attached to a window. The gadget is 25 lines tall, and VertBody is set to 32768. I'm running the program in OS 1.3, and when I click in the container below the knob, the knob moves all the way to the bottom, and VertPot is set to 65535, as it should be. However, if I drag the knob all the way to the bottom, then VertPot gets set to a value less than 65535. Usually this value is 58982, but not always.

I've been through the Intuition documentation several times, and I really can't see where the problem lies. Is this a v34 intuition.library bug, or am I doing something wrong in my code?

Code:
/*---------------------------------------------------------------------
//---------------------------------------------------------------------
//
//	Title: Prop Gadget Test
//
//  File - proptest.c
//  Project - _PRODUCT
//  Version - _VERSION
//  Author - _AUTHOR 
//
//	Compiler - Lattice C 5.04
//	lc gui.c
//	blink from lib:c.o proptest.o lib lib:lc.lib lib:amiga.lib to proptest
//
//---------------------------------------------------------------------
//-------------------------------------------------------------------*/

/********************************************************************** 
* INCLUDE
**********************************************************************/

#include <stdio.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <proto/exec.h>
#include <proto/intuition.h>


/********************************************************************** 
* DEFINES
**********************************************************************/

#define VERSION "\0$VER: proptest 1.0 (27.6.2021)"


/********************************************************************** 
* PROTOTYPES
**********************************************************************/

void Cleanup(void);


/********************************************************************** 
* GLOBAL VARIABLES
**********************************************************************/

struct Window *Window = NULL;
struct Gadget ScrollGadget;
struct Image ScrollImage;
struct PropInfo ScrollInfo;
BYTE *VersionStr = VERSION;


/********************************************************************** 
* MAIN CODE
**********************************************************************/

int main(int argc, char *argv[])
{
	int	run = 1;
	struct Gadget *GadgetPtr;
	struct NewWindow NewWindow;
	struct IntuiMessage *Msg;
	struct PropInfo *PropPtr;


	IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0);
	if (IntuitionBase == NULL)
		return 10;

	ScrollGadget.NextGadget = NULL;
	ScrollGadget.LeftEdge = 240;
	ScrollGadget.TopEdge = 10;
	ScrollGadget.Width = 16;
	ScrollGadget.Height = -10;
	ScrollGadget.Flags = GADGHNONE|GRELHEIGHT;
	ScrollGadget.Activation = GADGIMMEDIATE|RELVERIFY;
	ScrollGadget.GadgetType = PROPGADGET;
	ScrollGadget.GadgetRender = (APTR)&ScrollImage;
	ScrollGadget.SelectRender = NULL;
	ScrollGadget.GadgetText = NULL;
	ScrollGadget.MutualExclude = 0;
	ScrollGadget.SpecialInfo = (APTR)&ScrollInfo;
	ScrollGadget.GadgetID = 0x100;
	ScrollGadget.UserData = NULL;

	ScrollInfo.Flags = AUTOKNOB|FREEVERT;
	ScrollInfo.HorizPot = 0;
	ScrollInfo.VertPot = 0;
	ScrollInfo.HorizBody = MAXBODY;
	ScrollInfo.VertBody = 32768;

	NewWindow.TopEdge = 11;
	NewWindow.LeftEdge = 0;
	NewWindow.Width = 256;
	NewWindow.Height = 35;
	NewWindow.DetailPen = 0;
	NewWindow.BlockPen = 1;
	NewWindow.Title = "Prop Test";
	NewWindow.Flags = WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|SMART_REFRESH|ACTIVATE;
	NewWindow.IDCMPFlags = CLOSEWINDOW|REFRESHWINDOW|GADGETUP;
	NewWindow.Type = WBENCHSCREEN;
	NewWindow.FirstGadget = &ScrollGadget;
	NewWindow.CheckMark = NULL;
	NewWindow.Screen = NULL;
	NewWindow.BitMap = NULL;
	NewWindow.MinWidth = 256;
	NewWindow.MinHeight = 35;
	NewWindow.MaxWidth = 256;
	NewWindow.MaxHeight = 58;

	if ((Window = (struct Window *)OpenWindow(&NewWindow)) == NULL) {
		Cleanup();
		return 10;
	}

	while (run) {
		Wait(1L << Window->UserPort->mp_SigBit);
		while ((Msg = (struct IntuiMessage *) GetMsg(Window->UserPort)) != NULL) {
			GadgetPtr = (struct Gadget *)Msg->IAddress;
			switch (Msg->Class) {
				case CLOSEWINDOW :
					run = 0;
					break;
				case REFRESHWINDOW :
					BeginRefresh(Window);
					EndRefresh(Window, TRUE);
					break;
				case GADGETUP :
					printf("** GADGETUP **\n");
					if (GadgetPtr->GadgetID == 0x100) {
						PropPtr = (struct PropInfo *)ScrollGadget.SpecialInfo;
						printf("VertPot: %u\n\n", PropPtr->VertPot);
					}
					break;
				default :
					break;
			}
			ReplyMsg((struct Message *)Msg);
		}
	}				

	Cleanup();
	return 0;
}


/********************************************************************** 
* CLEANUP
**********************************************************************/

void Cleanup(void)
{
	
	if (Window != NULL) {
		CloseWindow(Window);
		Window = NULL;
	}

	if (IntuitionBase != NULL) {
		CloseLibrary((struct Library *)IntuitionBase);
		IntuitionBase = NULL;
	}

}
Crispy is offline  
 
Page generated in 0.04239 seconds with 11 queries