watt@eleazar.dartmouth.edu (Gill Watt) (02/18/91)
howdy, I have a quick question that someone in this group might be able to answer without too much trouble. The (WindowPtr).portRect contains the dimensions of a window in the local coordinate system. To translate a point to the global coordinate system one uses LocalToGlobal( &point ). This LocalToGlobal() translation is simply addition or subtraction from some reference point (window location in global coordinates). This information is contained in the WDEFResource boundsRect element, but I don't know where it goes during the GetWindow( ) function call. Where is this reference point stored? (structure? element?). Where is this described? I haven't been able to find anything in IM. Thanks in advance. -- --------------------------------------------------------------------- Gill Watt (watt@eleazar.dartmouth.edu) Thayer School of Engineering, Dartmouth College, Hanover, NH 03755 ---------------------------------------------------------------------
mneerach@iiic.ethz.ch (Matthias Ulrich Neeracher) (02/18/91)
In article <1991Feb17.190448.19116@dartvax.dartmouth.edu>, watt@eleazar.dartmouth.edu (Gill Watt) writes: >The (WindowPtr).portRect contains the dimensions of a window >in the local coordinate system. To translate a point to the >global coordinate system one uses LocalToGlobal( &point ). > >This LocalToGlobal() translation is simply addition or >subtraction from some reference point (window location in >global coordinates). This information is contained in the >WDEFResource boundsRect element, but I don't know where >it goes during the GetWindow( ) function call. > >Where is this reference point stored? (structure? element?). The reference point is the topLeft of portBits.bounds, I think. Matthias -- Matthias Neeracher mneerach@iiic.ethz.ch "These days, though, you have to be pretty technical before you can even aspire to crudeness." -- William Gibson, _Johnny Mnemonic_
Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) (02/25/91)
GW> This LocalToGlobal() translation is simply addition or subtraction GW> from some reference point (window location in global coordinates). GW> This information is contained in the WDEFResource boundsRect GW> element, but I don't know where it goes during the GetWindow( GW> ) function call. Where is this reference point stored? (structure? GW> element?). I think the calls just juse the Window Manager Port. -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!56.12!Chris.Gehlker Internet: Chris.Gehlker@p12.f56.n114.z1.fidonet.org
wdh@well.sf.ca.us (Bill Hofmann) (03/02/91)
In article <3744.27CD13AE@stjhmc.fidonet.org> Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) writes: >GW> This LocalToGlobal() translation is simply addition or subtraction >GW> from some reference point (window location in global coordinates). >GW> This information is contained in the WDEFResource boundsRect >GW> element, but I don't know where it goes during the GetWindow( >GW> ) function call. Where is this reference point stored? (structure? >GW> element?). >I think the calls just juse the Window Manager Port. Nope. Look at the window's portBits.bounds. This is the coordinates of the main screen in the coordinate system of the window. Thus, to convert from local to global, just subtract the top,left of portBits.bounds, and to convert from global to local, just add the top,left of portBits.bounds. This is what LocalToGlobal and GlobalToLocal do. -Bill Hofmann
dundas@granite.jpl.nasa.gov (John Dundas) (03/08/91)
In MPW, the following macros perform the equivalent function to their ROM counterparts. #define GLOBALTOLOCAL(_pt) (((Point * )(_pt))->h += qd.thePort->portBits.bounds.left), \ (((Point * )(_pt))->v += qd.thePort->portBits.bounds.top) #define LOCALTOGLOBAL(_pt) (((Point * )(_pt))->h += -qd.thePort->portBits.bounds.left), \ (((Point * )(_pt))->v += -qd.thePort->portBits.bounds.top) John Dundas
jason@ux1.cso.uiuc.edu (Jason Watts) (03/08/91)
dundas@granite.jpl.nasa.gov (John Dundas) writes: >In MPW, the following macros perform the equivalent function to their >ROM counterparts. >#define GLOBALTOLOCAL(_pt) (((Point * )(_pt))->h += qd.thePort->portBits.bounds.left), \ > (((Point * )(_pt))->v += qd.thePort->portBits.bounds.top) >#define LOCALTOGLOBAL(_pt) (((Point * )(_pt))->h += -qd.thePort->portBits.bounds.left), \ > (((Point * )(_pt))->v += -qd.thePort->portBits.bounds.top) I don't know what this note is responding to, as I missed the beginning of this thread. But, at any rate, it seems like these definitions won't work if qd.thePort is a color port. In such a case ( **( ( CGrafPtr ) qd.thePort )->portPixMap ).bounds would need to be substituted for qd.thePort->portBits.bounds. -- | | |====================| | | | Jason Watts | \ |\ |\ \ | (jazzin@uiuc.edu) | \| \| \|\|====================|
lsr@Apple.COM (Larry Rosenstein) (03/09/91)
In article <1991Mar7.203748.20407@jato.jpl.nasa.gov> dundas@granite.Jpl.Nasa.Gov (John Dundas) writes: >In MPW, the following macros perform the equivalent function to their >ROM counterparts. These macros only work for B&W grafPorts. In a color grafPort the bounds of the pixmap is in a much difference place. -- Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 3-PK Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr
tim@hoptoad.uucp (Tim Maroney) (03/11/91)
In article <1991Mar7.203748.20407@jato.jpl.nasa.gov> dundas@granite.Jpl.Nasa.Gov (John Dundas) writes: >In MPW, the following macros perform the equivalent function to their >ROM counterparts. > >#define GLOBALTOLOCAL(_pt) (((Point * )(_pt))->h += qd.thePort->portBits.bounds.left), \ > (((Point * )(_pt))->v += qd.thePort->portBits.bounds.top) >#define LOCALTOGLOBAL(_pt) (((Point * )(_pt))->h += -qd.thePort->portBits.bounds.left), \ > (((Point * )(_pt))->v += -qd.thePort->portBits.bounds.top) Except on color systems, on which they give nonsensical results.... -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Every year, thousands of new Randoids join the ranks. Most tend to be either too-rich self-made tycoons or picked-on computer nerds (the romantic, heroic individualism of Rand's novels flatters the former and fuels the latter's revenge fantasies)." -- Bob Mack, SPY, July 1989