WorldViewer
Volume Number: 12
Issue Number: 4
Column Tag: Macapp Adventures
Documentation Viewer Lite 
Help save a tree today!
By Matthew Clark, WorldView Information Technology
Note: Source code files accompanying article are located on MacTech CD-ROM orsource code disks.
This article documents the creation of an ad hoc application using MacApp. Our goal
was simple: build a documentation viewer for our manual, presentation slides,
scripting dictionary, and product screen-shots. A quick survey of the existing viewer
tools had led us to the conclusion: “What? They want how much money? Hey, we don’t
need all those features!” (Of course, this all happened back before Adobe dropped its
per-reader fee for Acrobat from $25 to zero.) So we decided to do it ourselves.
The requirements for this application are straightforward. The screen must
display an exact duplicate of the original printed pages. Access to the pre-formatted
documentation source is denied, but the user can copy and print the displayed pages.
Simple page navigation is needed, but not content-based searching. The last
requirement is the name: we’re working at WorldView, so it is natural to title the
application WorldViewer.
Approach
The first hurdle is to create the on-line documents from a variety of publishing
applications. If a bitmapped picture approach is used, the documentation files will be
huge, printed pages cannot rescale text for maximal printer resolution, and zooming
will show “jaggies”. On the other hand, if a picture ('PICT') file or resource is
used, then the image will scale correctly. An added benefit is that the Mac toolbox
routine DrawPicture substitutes fonts if the original fonts are not present. Our
solution is to use the shareware utility Print2Pict, by Baudouin Raoult. It is placed
into the Extensions Folder and activated by using the Chooser to select it as the
“printer”. When you “print”, Print2Pict records each output page as a 'PICT'
resource in a scrapbook file.
The WorldViewer application itself is based on MacApp 3.3 (actually, it was
originally done with MacApp 3.1, and source code for both versions is provided). As
many Macintosh programmers already know, MacApp is an object-oriented framework
for writing applications. The main advantage is that the developer can leverage tens of
programmer-years of work and have instant support for AppleEvents, the Scrap
Manager, window management, event handling, printing, and other modules required of
almost all Macintosh programs. Our application was written in only a few days and
contains less than a thousand lines of source code.
Figure 1. A sample document in WorldViewer
Human Interface
Figure 1 illustrates the final screen interface. It evolved during development (as so
often happens), but let’s pretend the design was fully completed first.
Separate tools are needed for navigating forward and backward, scrolling the page
within the window, and zooming. The navigation operation should be
context-dependent: the next-page cursor icon is displayed when the cursor is on the