shatara@memit.dec.com (Chris: 223-8753, TECHNOLOGY OFFICE, MLO1-4/T35) (05/29/89)
I wrote a WordSearch game for my kids on the Apple IIgs using TML Pascal. The program basically draws a user specified grid on the desktop, and allows the user to point to a particular cell, click the mouse, and keyboard input will be placed on this cell and adjacent cells. The user places words on the grid, and then the program fills the blank cells with random letters. The grid is printed and the kids have to find the words. Now problem #1 I decided to get fancy. In order to allow for a larger grid than presently available, I needed to draw this grid in a window and allow scrolling to pan through various areas of the grid. The problem I am having is when I click on a particular cell, the mouse loacation is always the location ON THE WINDOW, rather than the location of THAT WHICH I AM SEEING THROUGH THE WINDOW. For example... I'll click the mouse on a particular area of the window and get the following coordiantes: Local X = 415 Global X = 575 Local Y = 115 Global Y = 185 Scrolling the window 15 pixels and clicking the mouse on the same location ON THE WINDOW yields the same results, even though the point on the "PICTURE" I was pointing to has moved UP 15 PIXELS. I've tried using the LOCALTOGLOBAL call to convert the location returned from GETMOUSE to global coordinates, but this doesn't help since the origin of window is always 0,0. I've also tried using the STARTDRAWING call with the same result. I think the problem here is I'm using taskmaster to tell me of mouse activity and its probably resetting the origin to 0,0. Any ideas of what I might do here? Related question..if I have an info bar of say a height of 30, when a mouse is in the info bar area, the coordinates returned are what (local, global, local to what?) Problem #2 I have also had a problem generating a window with an information bar in it. I would set the wFRAMEBITS bit-4 to 1 to signify that I want an info bar. I have the wINFODEFPROC pointing to a procedure which does nothing! (begin, end) and I have the height set to 20 (wINFOHEIGHT). When the window is drawn, the info bar is there, no title is written, scroll bars do not work and the program appears to be hung although I still can move the pointer. Resetting bit 4 of wFRAMEBITS clears up the probelem so it appears to be somehow related to the Ident bar. Any thoughts on this? As alway your inputs are always valued...Chris Shatara
dlyons@Apple.COM (David Lyons) (05/31/89)
In article <8905290010.AA26741@decwrl.dec.com> shatara@memit.dec.com (Chris: 223-8753, TECHNOLOGY OFFICE, MLO1-4/T35) writes: >[...] > For example... I'll click the mouse on a particular area of > the window and get the following coordiantes: > Local X = 415 Global X = 575 > Local Y = 115 Global Y = 185 How did you calculate these values? I assume the globals ones came right out of the record you passed to TaskMaster, but where did you get the local values? > Scrolling the window 15 pixels and clicking the mouse on the > same location ON THE WINDOW yields the same results, > even though the point on the "PICTURE" I was pointing to has > moved UP 15 PIXELS. > > I've tried using the LOCALTOGLOBAL call to convert the location > returned from GETMOUSE to global coordinates, but this doesn't > help since the origin of window is always 0,0. Why do you want to convert back to global coordinates? GetMouse already goes to the trouble of converting to local coordinates for you. If you want global coordinates, just get the value out of your event record. > I've also tried using the STARTDRAWING call with the same result. > I think the problem here is I'm using taskmaster to tell me of > mouse activity and its probably resetting the origin to 0,0. StartDrawing before a GlobalToLocal is perfectly reasonable. (You should SetOrigin(0,0) on your port before you call TaskMaster again.) Note that StartDrawing sets the origin the same way you could by using SetOrigin on the result of GetContentOrigin, and that a window's origin should normally be (0,0) when you aren't doing anything with it. > Related question..if I have an info bar of say a height of 30, > when a mouse is in the info bar area, the coordinates returned are > what (local, global, local to what?) I believe you get global coordinates, which you should compare against the info bar rectangle (get it with GetRectInfo). > I have also had a problem generating a window with an information > bar in it. I would set the wFRAMEBITS bit-4 to 1 to signify that > I want an info bar. I have the wINFODEFPROC pointing to a > procedure which does nothing! (begin, end) and I have the height > set to 20 (wINFOHEIGHT). When the window is drawn, the info bar > is there, no title is written, scroll bars do not work and the > program appears to be hung although I still can move the pointer. > > Resetting bit 4 of wFRAMEBITS clears up the probelem so it > appears to be somehow related to the Ident bar. Exactly how did you declare the parameters to your info bar routine? It's important that it have exactly 12 bytes of input parameters, even if it doesn't do anything, since the procedure needs to remove these bytes from the stack before returning. (The compiler takes care of that, but you have to declare the parameters.) Try something a lot like this: procedure MyInfoDraw(var infoRect: rect; infoData: longint; window: GrafPtr); --Dave Lyons, Apple Computer, Inc. | DAL Systems AppleLink--Apple Edition: DAVE.LYONS | P.O. Box 875 AppleLink--Personal Edition: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.