Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: Drawing direct to a dialog window... Message-ID: <52986@apple.Apple.COM> Date: 17 May 91 03:05:56 GMT References: <1991May15.131300.9898@umiami.ir.miami.edu> <1991May16.170121.7022@oceania.UUCP> Organization: Apple Computer Inc., Cupertino, CA Lines: 46 In article <1991May16.170121.7022@oceania.UUCP> writes: >[...on the subject of dialog windows and userItems...] >I do this all the time. The only drawback (I have found) is those durn >update events. I use a filter proc to handle all the updates. In order to >handle the high volume of dialogs that I use and all the drawing that is >associated with each one, I wrote a function whose primary purpose is to draw >the graphics (lines, etc.) for each dialog box. Inside the filter proc I use, >under the updateEvt event, I call this routine to have the text drawn. It's a >little bit of a kludge, but it works quite well and I only have to use one >filter proc and manage one routine for all the drawing (yes, this routine does >get quite large after a while, but only a small portion of it is executed each >time thru). User Items didn't provide enough functionality for what I wanted >so I went for this method instead. > >Woul someone who is more familiar with User Items want to expand on them? All userItems provide is a hook so that any non-standard drawing (i.e., non text, picture, icon, button) can be handled "automatically" without having to do the kind of special case checking you're doing in your filterProc. All static drawing (lines, boxes, ...) can be handled this way. For instance, to draw boxes and lines, I use something like this: pascal void DrawBox(theDialog, theItem) DialogPtr theDialog; short theItem; { Rect theRect; GetDRect(theDialog, theItem, &theRect); FrameRect(&theRect); }; After it's "installed" with SetDItem(), I don't worry about it anymore. If the bounds grows or shrinks, it doesn't matter. You could even do simple animation this way by having the drawing procedure keep track of its current state instead of a higher-level entity. I've come to the point now where I very rarely use a window, but instead set everything up with dialogs (and userItems for all the weird stuff)... steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen Never hit a man with glasses. stevec@apple.com Hit him with a baseball bat.