harrow@exodus.dec.com (06/12/86)
In my random attempts to learn Rascal and do some useful prototyping on the Mac, I'm attempting, as part of a user interface simulation, to allow the creation of a "map" made up of various icons, with those icons interconnected by lines. So far, no problem. But, I want the user to be able to "drag" the icons around to manually re-position them, so I attempted to experiment with a simple oval region and get use DragGreyRgn to do the pulling around (of the outline) for me. For this test, I use the following two code fragments to generate (and remember) the placement of the region, and (in the second segment) to handle the mousedown event to invoke DragGreyRgn and pull the outline around. However, as indicated, I can't even get PtInRgn to agree that I did a mousedown IN the oval region! Hummm. (Please note that this is junky code with a bunch of diagnostic things left in... NOT representative (I hope)). PROCEDURE DoAddRegion(); VAR tempRect : RECT; BEGIN SetPort (FrontWindow()); (* Make sure we're using the right window *) OpenRgn(); SetRect(temprect,20,20,50,70); FrameOval(tempRect); CloseRgn(RegionHandle); InvalRect(RegionHandle^^.RgnBbox); (* Force an update *) END; . . . (now part of the Event loop...) CASE theEvent.What OF mouseDown: BEGIN SetPort (MapWindowPtr); (* Use our window *) GetMouse(@temppoint); writeln(); writestring("From mouseDown..."); writeint(temppoint.v); writeint(temppoint.h); writeln(); writestring("Region's Rect = "); writeint(RegionHandle^^.RgnBbox.topLeft.v); writestring(" "); writeint(RegionHandle^^.RgnBbox.topLeft.h); writeln(); writeint(RegionHandle^^.RgnBbox.botRight.v); writestring(" "); writeint(RegionHandle^^.RgnBbox.botRight.h); writeln(); in := PtInRgn(temppoint, RegionHandle); IF in = TRUE THEN writestring("in = TRUE") ELSE writestring("in = FALSE"); (* >>> I CAN"T EVEN GET THIS TO ACKNOWLEDGE THAT I CLICK IN THE REGION <<< *) writeln(); writestring("PtInRgn = TRUE..."); writeint(temppoint.v); writeint(temppoint.h); junklong := DragGrayRgn(RegionHandle,temppoint,MapWindowRect, MapWindowRect,INTEGER(NIL),NIL); Now, all is OK in that I can CREATE the window and its oval region where I want them, but I can NOT get the DragGreyRgn to do anything (I expect it to pull an outline of the oval region around for me, perhaps inappropriately). As a matter of fact, I can not even get the PtInRgn call to return TRUE when I click the mouse directly in the oval region painted on the screen. What am I doing wrong? Thanks, Jeff
maclab@reed.UUCP (Mac DLab) (06/13/86)
In response to Jeff's question about PtInRgn:
> inCorrect --> in := PtInRgn(temppoint, RegionHandle);
Correct --> in := PtInRgn(temppoint.vh,RegionHandle);
You have to pass temppoint with the '.vh' extension, since Rascal wants
to pass a Point record by address. Check out appendix A of the Language
manual for a complete discussion.
Scott Gillespie
dubois@uwmacc.UUCP (Paul DuBois) (06/16/86)
> In my random attempts to learn Rascal and do some useful > prototyping on the Mac, I'm attempting, as part of a user > interface simulation, to allow the creation of a "map" made up of > various icons, with those icons interconnected by lines. So far, > no problem. > > But, I want the user to be able to "drag" the icons around to > manually re-position them, so I attempted to experiment with a > simple oval region and get use DragGreyRgn to do the pulling > around (of the outline) for me. For this test, I use the > following two code fragments to generate (and remember) the > placement of the region, and (in the second segment) to handle the > mousedown event to invoke DragGreyRgn and pull the outline > around. However, as indicated, I can't even get PtInRgn to agree > that I did a mousedown IN the oval region! Hummm. [code follows, containg...] > in := PtInRgn(temppoint, RegionHandle); In Rascal, all structures (including points) are passed by address. Lisa Pascal passes all structures by address, unless they are four bytes or less, in which case it passes them by value. So for all ToolBox expecting non-VAR points, you need to pass the .vh of the point, e.g., in := PtInRgn(temppoint.vh, RegionHandle); PS. DragGrayRgn, not DragGreyRgn. -- Paul DuBois UUCP: {allegra,ihnp4,seismo}!uwvax!uwmacc!dubois | ARPA: dubois@easter --+-- | Doth the hawk fly by thy wisdom, and stretch her wings | toward the south? Job 39:26