Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!apple!darin From: darin@Apple.COM (Darin Adler) Newsgroups: comp.sys.mac.programmer Subject: Re: "DeltaMoveWindow"? Message-ID: <1658@internal.Apple.COM> Date: 4 May 89 05:49:01 GMT References: <1907@etive.ed.ac.uk> <1908@etive.ed.ac.uk> Organization: Apple Lines: 38 In article <1908@etive.ed.ac.uk> nick@lfcs.ed.ac.uk (Nick Rothwell) writes: > I was rather surprised to find that the Window Manager doesn't have a > DeltaMoveWindow trap - there's only MoveWindow, which is absolute. I have > an application where each "document" (for want of a better word) appears > in a number of small windows with WIND templates held in a resource file. > If I'm opening several "documents" at once, I want the appearance of the > windows to be staggered slightly in a diagonal down the screen, so that > they're all visible. So, I had to hack up a "DeltaMoveWindow". This is what > I came up with - ugly, but it seems to work. If anybody has a nicer way of > doing this, I'd really like to know...! Here's a pretty good implementation: void DeltaMoveWindow(WindowPtr window, short hOffset, short vOffset, Boolean front) { GrafPtr savedPort; /* use to save the current grafport */ Point topLeft; /* use to calculate global top-left */ GetPort(&savedPort); SetPort(window); topLeft.v = window->portRect.top; topLeft.h = window->portRect.left; LocalToGlobal(&topLeft); /* convert to global coordinates */ MoveWindow(window, topLeft.h + hOffset, topLeft.v + vOffset, front); SetPort(savedPort); } I don't think you really need this routine to do what you described, though. Most applications stagger the windows by changing the rectangle they appear in, rather than repeatedly moving the window. Also, this will cause your windows to stagger off the screen, unless you make a separate check. -- Darin Adler, System Software Scapegoat, Apple Computer Internet: darin@Apple.com UUCP: {nsc,sun}!apple!darin