Real Window XCMD
Volume Number: 5
Issue Number: 2
Column Tag: HyperChat™
A Real Window XCMD
By Joe Zuffoletto, Cupertino, CA
Note: Source code files accompanying article are located on MacTech CD-ROM or
source code disks.
Window XCMD
Part 1: Windows, XCMD’s, and MultiFinder
Joe has been at Apple a little over a year, where he works in the Software Quality
Assurance department. His group develops automated software test tools. Before
coming to Apple, He earned a BS in EE & CS from Princeton University. He has been
programming the Mac for about 8 months and spends a lot of time experimenting with
HyperCard. This article contains important windowing technology for dealing with gray
regions, contirbuted by Scott Boyd and Greg Marriott.
Of Cards and Windows
For some reason, XCMD’s that put up windows intrigue me. I think it’s because
windows imply event loops, and running an event loop in an XCMD is an interesting
idea because it allows you to temporarily “steal the show” from HyperCard. Also, once
you throw a window on the screen there’s a lot of neat stuff you can put inside it, like
graphics too large for HyperCard’s card window, files generated by other applications,
color pictures, and human interfaces for sophisticated tasks.
In this article I will present an XCMD that displays a document window with
scroll bars. This XCMD is full-featured and very robust -- essentially a
mini-Macintosh application running on top of HyperCard. It is MultiFinder aware,
shows how to scroll bitmapped graphics documents, and also demonstrates how to
support multiple screens on the Mac II. Finally, it demonstrates how to cope with some
human interface issues when it comes to displaying windows on top of HyperCard.
Figure 1a: Before...
My discussion assumes you are somewhat familiar with the issues behind writing
XCMD’s and XFCN’s for HyperCard. In particular, I assume you have a nodding
acquaintance with the glue routines that perform special functions and facilitate
communication between your XCMD and HyperCard. Plenty of introductory articles on
the subject have appeared in MacTutor over the past few months, and Gary Bond has
written an excellent book, XCMD’s for HyperCard (MIS Press, 1988), which gives
you a head start in writing XCMD’s (Like Gary, I refer to XCMD’s and XFCN’s simply as
XCMD’s).
Figure 1b: _After
However, even if you are not writing XCMD’s you might learn a lot of useful stuff
by reading this article. My XCMD uses an event loop much like one you would find in a
normal application, and I show you how to cope effectively with event handling and
cursor tracking under MultiFinder. Also, if you’d like to see a rare example of
scrolling code, that will be coming next month. In short, there’s something here for
just about everyone.
One article will not hold all this material, so I’m splitting it into two parts. This
month I will show you how to put the window up and deal with MultiFinder, multiple
screens, and human interface issues. The window will have scroll bars but they won’t
work. Next month I’ll breathe life into the scroll bars by demonstrating techniques for
scrolling bitmapped graphics documents. As a newcomer to Mac programming I feel
there is a critical shortage of example scrolling code, so I’d like to add some to the pool.
First Stop: The Drawing Board