Mac Pgming Secrets sources

Date: Fri, 7 May 1993 17:27:31 -0500

Attached are the sources to examples from Scott Knaster's and Keith
Rollin's book _Macintosh Programming Secrets_, 2nd edition.

Keith mentioned that he did not know how to send stuff to sumex-aim; so, I
assumed he wanted it here Wink

Anyway, here's what he had to say:

A few days ago, people were asking about the possibility of making the
source code to Macintosh Programming Secrets (2nd Edition) available via
ftp. Among the reasons against this, I cited that I really didn't have
access to an ftp site.

Oddly ( Smile ), this prompted at least three ftp site administrators to send
me mail saying "You can use mine!" So I've sent the source to them.
Already, it's shown up on two of them. Here are the locations:

ftp.apple.com (/dts/mac/sc/mps-disk-v1-0-1.hqx)
mac.archive.umich.edu (I don't see it there, yet)
ftp.gmd.de (/mac/books/mps-examples-1.0.1.hqx)

I don't know how to submit things to sumex-aim, or I'd send it there, too.

In case you're curious as to exactly what the source code is I'm talking
about, I've appended a summary of the book I posted last June.

Scott Knaster and I wish you all the best with this sample code.

----------

The second edition is almost entirely new.

As you may recall, the first edition was split into two parts. The first
part was a historical background and philosophy section. The second part
was a technical section (but, alas, lacking in source code samples). The
two sections were divided by a cartoon showing how the event manager
worked.

In the new edition, the book is still split up into two parts. The first
section is mostly the same, updated to take out anachronisms (like
references to the possibilities of multi-tasking and 32-bit cleanliness)
and add current information (like System 7.0 stuff).

The cartoon has been replaced by famous Apple About boxes. The first is the
unexpurgated MultiFinder 1.0 about box (the official release version had
all the good parts bleeped; we've put them back in for the book). The
second is the text from the circus parade from one of the preliminary 7.0
release CD's.

The second section is where all the new information are.

Chapter 3 shows the application skeleton used for all the samples in the
book. Rather than duplicate the same code that handles initialization,
windows, and menus in each chapter, we show it just once. All the
subsequent chapters tweak the skeleton a little and then get on with the
interesting stuff.

Chapter 4 is on dialogs. It shows how to handle modal, modeless, and
movable-modal dialogs. The sample for the modal dialog is based on an idea
in the first book, where command-key equivalents are assigned to all the
dialogs items. The modeless dialog shows a sample "Find" dialog that uses
the 7.0 popupmenu control. The movable-modal dialog shows how to do a
progress indicator like the Finder's.

Chapter 5 talks about QuickDraw. It starts off a lot like the QuickDraw
chapter of the first edition, but then delves a little more into current
color issues. The second half of the chapter implements an idea put forth
in the first edition, where offscreen buffers are used to save the contents
of background windows when a dialog is displayed, and then used to restore
the contents of those windows when the dialog is dismissed.

Chapter 6 deals more with QuickDraw and shows how to do mouse tracking. The
sample program reads in a MacPaint picture. The user can then use the mouse
to etch out a rectangular selection that does the "marching ants"
animation. The selection can then be clicked on and dragged around.
Offscreen buffers are used for this, too.

Chapter 7 gets into window management. We show how to implement Tile
Windows and Stack Windows menu items, and show how to do a Window menu that
keeps track of all the open windows. The algorithms for tiling and stacking
work across multiple monitors.

Chapter 8 delves into the File Manager. A simple program is shown that
allows the user to select a file (using Standard File), and target
directory (again, using Standard File) and then copies the file to the
destination in small chunks. The reader is encouraged to integrate the copy
routine with the progress indicator shown in Chapter 4.

Chapter 9 develops different kinds of standalone code. The first sample is
a simple INIT that beeps at startup. Then a more realistic INIT is given
that causes a command-key sequence to zoom the frontmost window (I actually
use this INIT in my everyday work). Next, we show how to implement an LDEF
that draws icons and grays out disabled items. Finally, we give the source
code to a windoid WDEF (the kind of window usually associated with floating
windows). Note that we don't actually show how to do floating windows
(bummer).

Chapter 10 is a collection of little routines that aren't large enough to
qualify for chapters of their own. We show how THINK programmers can do
spinning cursors based on MPW's 'acur' resources. We even show how such
animation can be done an interrupt time (even though I personally don't
approve of the practice). We show how applications can check for
Command-Period without calling WaitNextEvent, and how to implement a
password-entry dialog box with the little bullet characters. We also show
how to hide the menubar.

In summary, chapters 1 and 2 are a lot like the first edition. Chapters 4,
5, and 7 are partially based on information and ideas in the first edition.
The remaining chapters (3, 6, 8, 9, and 10) are totally new. If you get the
second edition, keep the first edition handy, because there's a lot of
material we threw away (like a lot of stuff dealing with printing and the
Finder desktop database).

All of the chapters include complete source code (in THINK C) to all of the
interesting stuff we talk about. Two people have complained about our not
including and resource dumps, but all of the resources we use are
straightforward enough that we didn't want to fill up pages and pages with
blocks of data (Like icons. I used to hate that about the old MacTutor -- I
hope the new MacTutor is better). Besides, we used ResEdit exclusively, and
there were no .r files.

--------------------------------------------------------------------------
Keith Rollin --- Phantom Programmer --- Taligent, Inc.
---------------------------------------------------------------------------

Path: /www/exparrot/files.tidbits.com/info-mac/dev/info/mac-prog-secrets-101.hqx

AttachmentSize
File mac-prog-secrets-101.hqx308.96 KB
Architecture: 
File Type: 
License: 
Year: 
Archive: