Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!stanford.edu!agate!dog.ee.lbl.gov!ux1.lbl.gov!osborn From: osborn@ux1.lbl.gov (James R Osborn) Newsgroups: comp.sys.mac.programmer Subject: Re: Drawing direct to a dialog window... Message-ID: <13295@dog.ee.lbl.gov> Date: 16 May 91 18:58:03 GMT References: <1991May15.131300.9898@umiami.ir.miami.edu> <1991May16.170121.7022@oceania.UUCP> Reply-To: osborn@ux1.lbl.gov (James R Osborn) Organization: Lawrence Berkeley Laboratory Lines: 55 X-Local-Date: Thu, 16 May 91 11:58:03 PDT I have gotten some flack for liking the Dialog Manager and more specifically liking to abuse it! I find that it is much easier to install a userItem to do updating for specific drawing tasks than using a filter procedure and doing the updating myself. I like this because usually you don't need to write a filter proc. So why add one just to do updating in a dialog when a mechanism (the userItem) is provided for you? Another nice thing is that you can reuse the same userItem procedure for a series of different items. Just use a switch inside the draw procedure to select which item to draw. And you can use the same draw procedure to draw the same item all over your dialog. You just set the rectangle different for each item, then in your draw procedure, you retrieve the item rectangle for the item you are drawing (using GetDItem). One other interesting thing. If you use a dialog (instead of a window) that has userItem(s) installed to do your updating, then your window will get updated *BEHIND* a modal dialog that you put up. Try this: 1) go to the finder 2) make sure a folder or disk window is open 3) go to the File menu and choose Page Setup... 4) You get a modal dialog in front of the Finder's windows 5) Now activate your favorite screen saver so that the entire screen goes black or whatever causing the screen to need updating You will notice that the modal dialog will update since it's internal event loop is in control. The Finder's windows (which presumably are not dialog windows) do not get updated until you Cancel/OK out of the modal dialog. This is annoying. For example when printing a long document in the foreground. A modal print dialog comes up and tells you the status. If your screen saver kicks in, then when the screen is redrawn, any documents you have open won't update until you finish printing. If a modeless dialog was used for the document window with userItems to cause text updating, then the documents would be updated properly by the dialog manager. I think this is real neat. It keeps your screen looking good after a screen saver has erased everything. Unfortunately, I think using the dialog manager to do all event processing for an application's documents is considered dialog manager abuse (by the powers that be). Sorry for all the hot air :^o -- james |-----------------------------------------------------------------------| | James R. Osborn | It just goes to show you it's always | | Lawrence Berkeley Laboratory | something. Either it's incorrect tech | | osborn@ux1.lbl.gov | notes or your mac is smoking. It's | | (415) 548-8464 | always something... | |-----------------------------------------------------------------------|