rfl@oddjob.UUCP (Bob Loewenstein) (08/05/86)
Here is a problem I am having with regions: I create a region and set it equal to a rectangle with a call to RectRgn. I then check to see if the mouse is clicked within the region and if it is, I call DragGrayRgn with a nil for the actionProc. After dragging the region across the window, I release the mouse button. If I try to drag the region again, however, I find that the region is defined as the frame, not the enclosed area of the rectangle. What gives?!! I have to grab it by its border (PtInRgn is true for only this condition). Obviously I want the region to remain unchanged. Hoping for an answer......
dubois@uwmacc.UUCP (Paul DuBois) (08/06/86)
> Here is a problem I am having with regions: > > I create a region and set it equal to a rectangle with a call to RectRgn. > I then check to see if the mouse is clicked within the region and > if it is, I call DragGrayRgn with a nil for the actionProc. After > dragging the region across the window, I release the mouse button. If I > try to drag the region again, however, I find that the region is > defined as the frame, not the enclosed area of the rectangle. > > What gives?!! I have to grab it by its border (PtInRgn is true for only > this condition). Obviously I want the region to remain unchanged. Amazing how these coincidences happen... Presumably this is a description of the same problem Greg Stein is having. I just checked it out myself, and indeed, DragGrayRgn not only returns the horizontal and vertical offsets of the drag in the result value, IT CHANGES THE REGION THAT IS PASSED TO IT! Phonebook IM gives no hint that this behavior will occur. It just says that an outline of the region will be dragged around, with no indication that the region passed in will either be moved or changed in character. Moral: pass a COPY of the region you want to drag, then after DragGrayRgn returns, offset the original region by the amounts in the return value, if it's not a bad drag. Remember that the code for a bad drag is not $8000, as the phonebook IM says, but $80008000 (i.e., $8000 in both the high and low words - fixed in Addison-Wesley edition). -- Paul DuBois UUCP: {allegra,ihnp4,seismo}!uwvax!uwmacc!dubois | ARPA: dubois@easter --+-- | Begin at my sanctuary... | Ezekiel 9:6
sdh@joevax.UUCP (The Doctor) (08/06/86)
> Here is a problem I am having with regions: > > I create a region and set it equal to a rectangle with a call to RectRgn. > I then check to see if the mouse is clicked within the region and > if it is, I call DragGrayRgn with a nil for the actionProc. After > dragging the region across the window, I release the mouse button. If I > try to drag the region again, however, I find that the region is > defined as the frame, not the enclosed area of the rectangle. > > What gives?!! I have to grab it by its border (PtInRgn is true for only > this condition). Obviously I want the region to remain unchanged. > I believe a region is defined by the bits that are contained in it, not what necessarily what they enclose. Try defining the region as a solid rectangle, not a frame. Also, whay wouldn't you use PtInRect instead of PtInRgn? Seems to me that if you kept a copy of the rectangle that is the region around the program would go a great deal faster since Rects are far more uniform than Regions, hence the routine to decind is a point is contained within its boundries would be more specific, thus faster. Steve Hawley joevax!sdh
seth@hera.cs.ucla.edu (Seth Goldman) (08/06/86)
The fact that DragGrayRgn alters the region passed to it is documented in the AW edition of IM as follows: Note: DragGrayRgn alters the region; if you don't want the original region changed, pass DragGrayRgn a handle to a copy. Obviously you already figured this out, just making it official. Seth Goldman ARPA: seth@LOCUS.UCLA.EDU UUCP: ...!{ihnp4,cepu,trwspp,sdcrdcf,ucbvax}!ucla-cs!seth USMail: A.I. Lab, 3531 Boelter Hall, UCLA, Los Angeles, CA 90024 MaBell: (213) 825-5199
marchesi@cernvax.UUCP (marchesi) (08/08/86)
In article <1434@oddjob.UUCP> rfl@oddjob.UUCP writes: >Here is a problem I am having with regions: > >I create a region and set it equal to a rectangle with a call to RectRgn. >I then check to see if the mouse is clicked within the region and >if it is, I call DragGrayRgn with a nil for the actionProc. After >dragging the region across the window, I release the mouse button. If I >try to drag the region again, however, I find that the region is >defined as the frame, not the enclosed area of the rectangle. > > Obviously I want the region to remain unchanged. > >Hoping for an answer...... Inside Macintosh, Vol I, FUNCTION DragGrayRgn: 'NOTE: DragGrayRgn alters the region; if you don't want the original changed, pass DragGrayRgn a handle to a copy.' Just use NewRgn and CopyRgn first - and pass the copy. OK? ciao Paolo ---------------------------------------------------------------------------- Paolo Petta p-mail: DD Division CERN CH-1211 Geneva 23 Switzerland e-mail: ...{seismo,philabs,decvax,...}!mcvax!cernvax!marchesi
bhyde@inmet.UUCP (08/11/86)
DragGreyRegion will change the region dragged. This is now documented in the AW version of IM. It isn't documented how it changes it, it currently changes it into the frame of the region (an operation on a region that is impossible to do in any other way but isn't really very useful). - ben hyde, cambridge
dubois@uwmacc.UUCP (Paul DuBois) (08/12/86)
> > DragGreyRegion will change the region dragged. This is now documented in > the AW version of IM. It isn't documented how it changes it, it currently > changes it into the frame of the region (an operation on a region that is > impossible to do in any other way but isn't really very useful). Why is this impossible? Why wouldn't r = the region to turn into a frame r2 = NewRgn (); CopyRgn (r, r2); InsetRgn (r2, 1, 1); DiffRgn (r, r2, r2); work? -- Paul DuBois UUCP: {allegra,ihnp4,seismo}!uwvax!uwmacc!dubois | ARPA: dubois@easter --+-- | Begin at my sanctuary... | Ezekiel 9:6
lsr@apple.UUCP (Larry Rosenstein) (08/12/86)
In article <26700063@inmet> bhyde@inmet.UUCP writes: > > It isn't documented how it changes it, it currently >changes it into the frame of the region (an operation on a region that is >impossible to do in any other way but isn't really very useful). To get the same effect as DragGrayRegion, you simply take the difference between the original region and a copy of the region inset by (1,1). -- Larry Rosenstein Object Specialist Apple Computer AppleLink: Rosenstein1 UUCP: {sun, voder, nsc, mtxinu, dual}!apple!lsr CSNET: lsr@Apple.CSNET
bhyde@inmet.UUCP (08/14/86)
It is undocumented that dragGreyRegion, when it changes the region passed to it, creates the frame of the region passed to it. I said that it was interesting that it isn't possible to create a frame of a region in any other way. Others have then asked if you can't use insetRgn as a primitive to frame a region... well you can create something like a frame that way, but it isn't a frame. If you do this on an oval the frame you get will not be uniformly one pixel wide... i.e. pouring paint into it will leak, or it will have large thick lines in it. You can't change a bit map into a region either, if you could then you might use the outline capablity in the font generation machinery. - ben hyde, cambridge.
bhyde@inmet.UUCP (08/18/86)
| /* Written 12:14 pm Aug 12, 1986 by lsr@apple.UUCP in inmet:net.micro.mac */ | In article <26700063@inmet> bhyde@inmet.UUCP writes: | > | > It isn't documented how it changes it, it currently | >changes it into the frame of the region (an operation on a region that is | >impossible to do in any other way but isn't really very useful). | | To get the same effect as DragGrayRegion, you simply take the difference | between the original region and a copy of the region inset by (1,1). | | -- | Larry Rosenstein | Object Specialist | Apple Computer Funny thing is that Larry and I discussed this very topic about 2 years ago in a series of mail about detecting a mouse down on the edge of a region. At that time I built a program to do just that. The difference of a Inset by (1,1) does not work, sad to say. The reason is that you sometimes get gaps in your perimeter, that maybe OK if you all you are doing is using it for some animation purpose, like DragGreyRegion does. I will admit that for all I know DragGreyRegion is in fact displaying the difference of the original region and one inset by (1,1). If you want to detect mouse down on the edge of a region then FrameRgn coupled with an off-screen bitmap consisting of only a single pixel is the way I do it. - ben hyde, cambridge