Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!elroy.jpl.nasa.gov!usc!samsung!crackers!m2c!umvlsi!umaecs!amh!djvelleman From: djvelleman@amherst.bitnet Newsgroups: comp.sys.mac.programmer Subject: Re: (R)Drawing to windows Message-ID: <12114.27c4e228@amherst.bitnet> Date: 22 Feb 91 09:19:36 GMT References: <3583.27C35477@blkcat.fidonet.org> Lines: 39 In article <3583.27C35477@blkcat.fidonet.org>, Ken.Knight@f421.n109.z1.fidonet.org (Ken Knight) writes: > cabruen@athena.mit.edu (Charles Alan Bruen) writes [edited] > >>How should I store the information I want drawn in a window. (I know >>how >>to actually do it) IM suggests that you not draw to the screen > directly >>but save the information somehow (it fails to mention). >> >>Problem: In a window a have a plot of a function. I do all the >>calculations as I draw the plot in the window. If I later get an > update >>event for that window, do I have to redo the calculations to redraw > the >>window. This seems like a big waste of effort. >> >>What are the ways in which this is solved in the real world? Could I >>draw to an imaginary Picture and just put that in the window everytime >>I >>get an update? > > If re-plotting the function is fairly fast than tha is a perfectly > reasonable way to go. However, for the fastest results you should use > CopyBits(). The idea is to draw your plot in an offscreen bitmap and > then draw that to the window whenever needed. For info on how to set up Another possibility that's worth mentioning is to save the function values needed for the plot, but not the whole bitmap (which would probably use up much more memory). You could save a table of x and y values, and then when you get an update event, just read the values out of the table and "connect the dots". I think part of the original question, which has not been answered yet, is HOW do you save this info? One convenient way is to use the refCon field of the window record. You can put whatever you want in that field, and the window manager won't mind. In this case, you might put a handle to your table of x and y values. Then when you get an update event for a window, you can look in the window's refCon field to find the table of values and then do the update. -Dan Velleman