Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uw-beaver!cornell!johnhlee From: johnhlee@viola.cs.cornell.edu (John H. Lee) Newsgroups: comp.sys.amiga.programmer Subject: Re: Prop gadgets and FOLLOWMOUSE Message-ID: <52041@cornell.UUCP> Date: 14 Feb 91 19:16:42 GMT References: <1991Feb8.213305.15745@ssd.kodak.com> <51884@cornell.UUCP> Sender: nobody@cornell.UUCP Reply-To: johnhlee@cs.cornell.edu (John H. Lee) Organization: Cornell Univ. CS Dept, Ithaca NY Lines: 153 Summary: Followup-To: In article dgg@ksr.com (David Grubbs) writes: >Why all the text descriptions? If you have an efficient algorithm, then >include it. An English description of a C program is useful only to a CompSci >teacher, not the students. Uh oh! I hope that English isn't your second language, with as your first! :-) I thought the concept was rather simple, but I have enclosed some excerpts from my test program that demonstrate the work-around I came up with. (BTW, the idea behind the program was to demonstrate the ability to design and create prop gadgets that work like the sliders in DECwindows or the VAXstation VWS windowing system. The numerical value of the slider is displayed directly above the knob and is updated and moved with the knob as the user drags the knob.) [...] #define G_PROP1 1 #define G_PROP2 2 #define GADGET(g) ((struct Gadget *)(g)) [...] static struct Gadget prop2 = { NULL, 10, 25, 200, 12, GADGHNONE | GADGIMAGE, GADGIMMEDIATE | FOLLOWMOUSE | RELVERIFY, PROPGADGET, (APTR)&thumb2_img, NULL, NULL, 0L, (APTR)&prop2_info, G_PROP2, (APTR)&pv2_info }, prop1 = { &prop2, 10, 55, 200, 12, GADGHNONE | GADGIMAGE, GADGIMMEDIATE | FOLLOWMOUSE | RELVERIFY, PROPGADGET, (APTR)&thumb1_img, NULL, NULL, 0L, (APTR)&prop1_info, G_PROP1, (APTR)&pv1_info }; static struct NewWindow windowdata = { 10, 10, 300, 70, -1, -1, CLOSEWINDOW | GADGETUP | GADGETDOWN | MOUSEMOVE, WINDOWCLOSE | WINDOWDRAG | SMART_REFRESH | ACTIVATE, &prop1, NULL, "Prop Gadget Test", NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN }; static struct Window *window = NULL; void CloseAll(void), FatalError(char *), UpdateProp(struct Gadget *, struct Window *); main() { BOOL notDone = TRUE; ULONG sigm_ctlc = SIGBREAKF_CTRL_C, sigm_window, sigs; struct IntuiMessage *msg; ULONG class; APTR iaddr; struct Gadget *g_iaddr = NULL; if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0L)) == NULL) FatalError("Unable to open intuition.library"); if ((window = OpenWindow(&windowdata)) == NULL) FatalError("Unable to open window"); sigm_window = 1L << window->UserPort->mp_SigBit; UpdateProp(&prop1, window); UpdateProp(&prop2, window); while (notDone) { sigs = Wait(sigm_ctlc | sigm_window); if (sigs & sigm_ctlc) notDone = FALSE; else { while (msg = (struct IntuiMessage *)GetMsg(window->UserPort)) { class = msg->Class; iaddr = msg->IAddress; ReplyMsg((struct Message *)msg); switch (class) { case CLOSEWINDOW: notDone = FALSE; break; case GADGETDOWN: if (GADGET(iaddr)->GadgetType == PROPGADGET) g_iaddr = GADGET(iaddr); break; case GADGETUP: if ((g_iaddr != NULL) && (g_iaddr == GADGET(iaddr))) { UpdateProp(g_iaddr, window); g_iaddr = NULL; } /* if */ break; case MOUSEMOVE: if (g_iaddr != NULL) UpdateProp(g_iaddr, window); break; default: break; } /* case */ } /* while */ } /* else */ } /* while */ CloseAll(); exit(0); } /* main */ [...] ------------------------------------------------------------------------------- The DiskDoctor threatens the crew! Next time on AmigaDos: The Next Generation. John Lee Internet: johnhlee@cs.cornell.edu The above opinions of those of the user, and not of this machine.