On Sun, March 19, 2006 5:50 pm, Mark O'Neill wrote: > Thanks for your help. I kinda had a feeling it'd > be better to do it with a single canvas, but for > the uninitiated, may I ask what you mean > by "with the pages represented by objects > of a another class".
I have done this with a "print preview" feature I use in some of my projects. It's basically a window with a large canvas on it. Separately, I have created a simple data structure that consists of a "page" class. I put these into an array with as many as I need for each page of the document. Inside the "page" class I have properties that represent lines of text. In my case, this is a bit complicated since mine handles styled text and must compute string widths of various fonts and sizes, etc. Because of that, my page count is dynamic -- I don't know until print time how many pages I'll need, so I build the page structure during the preview as I calculate word wraps and such. In a simpler case (depending on what you are wanting to draw), you could have a paragraph string that represents a chunk of text, or graphic objects, etc. To "draw" your pages in the canvas, just create a "drawPage(x)" routine where x is an integer representing the page number. Within that routine, you grab the appropriate "page" subclass and go through each element in it and draw it (if it's text, use drawstring, if it's a picture, use drawPicture, etc.). In my case, I cache these pages into a series of picture objects to speed previewing (my preview feature lets users quickly scroll through the previewed pages). To print to a printer, I just "draw" the pages to a printer's graphic object instead of the canvas'. With more knowledge about what specifically your pages are containing I could help you more, but the above rough sketch should get you going with a data structure. -- Marc -- Marc Zeedar Publisher REALbasic Developer Magazine http://www.rbdeveloper.com _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
