home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------
- #
- # Apple Macintosh Developer Technical Support
- #
- # MacApp Color QuickDraw Fractal Printing Sample Application
- #
- # FracApp300
- #
- # FracApp300.r - Rez Source
- #
- # Copyright ⌐ 1988 Apple Computer, Inc.
- # All rights reserved.
- #
- # Versions: 1.0 8/88
- #
- # Components: MFracApp300.p August 1, 1988
- # UFracApp300.p August 1, 1988
- # UFracApp300.inc1.p August 1, 1988
- # FracApp300.r August 1, 1988
- # FracApp300.make August 1, 1988
- #
- # The FracApp300 program is a version of the FracApp program that is
- # set up to be as compatible as possible. It uses the PrGeneral call
- # in order to print at high resolution. It demonstrates how to create
- # and save 300 dpi PICT files. It uses an offscreen port to calculate
- # the data, and CopyBits to update the window on the screen. When the
- # documents are written or read, the QuickDraw bottlenecks are used to
- # avoid having a huge memory hit during saving or opening. (800K of RAM
- # not needed, on a 640x480 screen, a big win.) The Palette Manager is
- # used very slightly, only to associate a small palette with only Black
- # and White with each window. This avoids needing the system palette
- # for each window, when no colors are used. Since we are printing to
- # normal printers, we only use B&W in this version.
- # Written in MacApp Object Pascal code.
- # Compatibility rating = 1. (The use of PrGeneral is slightly
- # out of the ordinary, although supported.)
- #
- # The program is a complete Macintosh application written in Object
- # Pascal using MacApp. It supports multiple windows, calculations in the
- # background under MultiFinder, use of the Palette Manager, reading and
- # writing of PICT files using the bottlenecks, and shows how to calculate
- # the Mandelbrot set.
- #
- # There is a resource file that is necessary as well, to define the Menus, Window,
- # Dialog, and Palette resources used in the program.
- -------------------------------------------------------------*/
- /* Copyright 1988 by Bob. */
- /* February 1, 1988 */
- /* Modified May 1, 1988 to become FracApp300 for printing
- and 300 dpi calculation. */
- /* Written by Bo3b Johnson of Developer Technical Support. */
-
- #ifdef Debugging
- include MacAppRFiles"Debug.rsrc";
- #endif
- include MacAppRFiles"MacApp.rsrc";
- include MacAppRFiles"Printing.rsrc";
-
- include "FracApp300" 'CODE';
-
- resource 'WIND' (1001, purgeable) {
- {50, 20, 200, 450},
- zoomDocProc,
- invisible,
- goAway,
- 0x0,
- "<<<>>>"
- };
-
-
- /* Now a palette that is associated with every window automatically when the
- window is opened. The resource ID matches that of the window template.
- This palette is very mellow, just the two colors as the standard
- color palette. */
-
- data 'pltt' (1001, preload, nonpurgeable) {
- $"0001 0000 0000 0000 0000 0000 0000 0000" /* 2 colors in table. */
- $"FFFF FFFF FFFF 0000 0000 0000 0000 0000" /* white as first guy. */
- $"0000 0000 0000 0000 0000 0000 0000 0000" /* black as second */
- };
-
-
- /* we put the latest SIZE template here so we can rez with MPW 2.0 */
-
- type 'SIZE' {
- boolean dontSaveScreen,
- saveScreen;
- boolean ignoreSuspendResumeEvents,
- acceptSuspendResumeEvents;
- boolean enableOptionSwitch,
- disableOptionSwitch;
- boolean cannotBackground,
- canBackground;
- boolean notMultiFinderAware,
- multiFinderAware;
- boolean notOnlyBackground,
- onlyBackground;
- boolean dontGetFrontClicks,
- getFrontClicks;
- unsigned bitstring[9] = 0;
- unsigned longint; /* preferred memory size in bytes */
- unsigned longint; /* minimum memory size in bytes */
- }; /* ignore the warning caused by re-defining SIZE */
-
-
- /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
-
- resource 'SIZE' (-1) {
- saveScreen,
- acceptSuspendResumeEvents,
- disableOptionSwitch,
- canBackground,
- multiFinderAware, /* this says we do our own activate/deactivate; don't fake us out */
- notOnlyBackground, /* this is definitely not a background-only application! */
- dontGetFrontClicks, /* change this is if you want "do first click" behavior like the Finder */
- #ifdef Debugging
- 1780 * 1024,
- 1000 * 1024
- #else
- 1780 * 1024, /* preferred- enough for two documents open. */
- 950 * 1024 /* min- enough for one document open. */
- #endif
- };
-
- resource 'DITL' (201, purgeable) {
- { /* array DITLarray: 3 elements */
- /* [1] */
- {145, 182, 165, 262},
- Button {
- enabled,
- "OK, OK."
- },
- /* [2] */
- {10, 80, 133, 304},
- StaticText {
- disabled,
- "FracApp300, version 1.1 by Bo3b Johnson. Calculates the Mandelbrot "
- "set using direct 68881 code for maximum speed. "
- "Select an area with "
- "the mouse to zoom in. 300 dpi calculations, no color; but you can Print."
- },
- /* [3] */
- {10, 20, 42, 52},
- Icon {
- disabled,
- 201
- }
- }
- };
-
- resource 'ALRT' (201, purgeable) {
- {90, 100, 270, 412},
- 201,
- {
- OK, visible, silent;
- OK, visible, silent;
- OK, visible, silent;
- OK, visible, silent
- }
- };
-
- /* The icon used in the about box. The same as the program ICN#, but ICON instead. */
- resource 'ICON' (201, purgeable) {
- $"0000 0001 0000 0002 0000 0004 0040 0018 0020 0418 001C 03E0 001C 03E0 001F FFE0"
- $"0007 FFE0 0007 FFE0 0007 FF90 0007 FF80 FFFF FF80 FFFF FF80 DFFF FF80 EFFF FF80"
- $"F1FF FF80 F1FF FF80 F1FF FFE0 FE07 FFE0 FE07 C0E0 FE07 8050 FE07 3028 FE01 C810"
- $"FE0E 7F8F FFE2 3007 FFFF 0007 FFFF 8007 FFFF E007 FFFF FFE7 FFFF F01F FFFF F007"
- };
-
- /* For the menus, except the Apple menu, we set the enable flags to zero for
- simplicity. The right pieces will get enabled by the MacApp handlers (DoSetUpMenus
- for whatever object can do it), so we'll start with disabled. */
- resource 'cmnu' (1) {
- 1,
- textMenuProc,
- 0x7FFFFFFD,
- enabled,
- apple,
- { /* array: 2 elements */
- /* [1] */
- "About FracApp╔", noIcon, noKey, noMark, plain, cAboutApp;
- /* [2] */
- "-", noIcon, noKey, noMark, plain, nocommand
- }
- };
-
- resource 'cmnu' (2) {
- 2,
- textMenuProc,
- 0x0,
- enabled,
- "File",
- { /* array: 12 elements */
- /* [1] */
- "New", noIcon, "N", noMark, plain, cNew;
- /* [2] */
- "Open╔", noIcon, "O", noMark, plain, cOpen;
- /* [3] */
- "-", noIcon, noKey, noMark, plain, nocommand;
- /* [4] */
- "Close", noIcon, "W", noMark, plain, cClose;
- /* [5] */
- "Save", noIcon, "S", noMark, plain, cSave;
- /* [6] */
- "Save As╔", noIcon, noKey, noMark, plain, cSaveAs;
- /* [7] */
- "Save a Copy In╔", noIcon, noKey, noMark, plain, cSaveCopy;
- /* [8] */
- "-", noIcon, noKey, noMark, plain, nocommand;
- /* [9] */
- "Print╔", noIcon, "P", noMark, plain, cPrint;
- /* [10] */
- "-", noIcon, noKey, noMark, plain, nocommand;
- /* [11] */
- "Quit", noIcon, "Q", noMark, plain, cQuit
- }
- };
-
- resource 'cmnu' (3) {
- 3,
- textMenuProc,
- 0x0,
- enabled,
- "Edit",
- { /* array: 8 elements */
- /* [1] */
- "Undo", noIcon, "Z", noMark, plain, cUndo;
- /* [2] */
- "-", noIcon, noKey, noMark, plain, nocommand;
- /* [3] */
- "Cut", noIcon, "X", noMark, plain, cCut;
- /* [4] */
- "Copy", noIcon, "C", noMark, plain, cCopy;
- /* [5] */
- "Paste", noIcon, "V", noMark, plain, cPaste;
- /* [6] */
- "Clear", noIcon, noKey, noMark, plain, cClear;
- /* [7] */
- "-", noIcon, noKey, noMark, plain, nocommand;
- /* [8] */
- "Show Clipboard", noIcon, noKey, noMark, plain, cShowClipboard
- }
- };
-
- resource 'cmnu' (4) {
- 4,
- textMenuProc,
- 0x0,
- enabled,
- "Zoomy",
- { /* array: 1 elements */
- /* [1] */
- "New from selection", noIcon, noKey, noMark, plain, 1000
- }
- };
-
- resource 'MBAR' (128) {
- {1; 2; 3; 4}
- };
-
-
- /* Now the pattern that is used for the selection rectangle. */
-
- resource 'PAT ' (128, preload, nonpurgeable) {
- $"FCF9 F3E7 CF9F 3F7E"
- };
-
-
- /* list mapping of our error code to the info string. */
-
- resource 'errs' (1128, purgeable) {
- { whichList, 0, 1100;
- 1000, 1000, 1; /* error code if wrong machine, crash avoidance. */
- 1001, 1001, 2 /* err code for no resolution on printer. */
- }
- };
-
- /* The info strings for our errors. */
-
- resource 'STR#' (1100, purgeable) {
- { /* [1] */ "Color QuickDraw, a 68881 (FPU), and the latest System "
- "are required";
- /* [2] */ "the printer does not support high resolution printing"
- }
- };
-
-
- /* Now all the baggage required for the Icons at the Finder. No real
- program keeps the default Icon. Herein is the BNDL, Arf3, ICN#, FREF
- resources required. The 'Arf3' is the application type. Registered
- of course. */
-
- resource 'ICN#' (128) {
- { /* array: 2 elements */
- /* [1] */
- $"0000 0001 0000 0002 0000 0004 0040 0018 0020 0418 001C 03E0 001C 03E0 001F FFE0"
- $"0007 FFE0 0007 FFE0 0007 FF90 0007 FF80 FFFF FF80 FFFF FF80 DFFF FF80 EFFF FF80"
- $"F1FF FF80 F1FF FF80 F1FF FFE0 FE07 FFE0 FE07 C0E0 FE07 8050 FE07 3028 FE01 C810"
- $"FE0E 7F8F FFE2 3007 FFFF 0007 FFFF 8007 FFFF E007 FFFF FFE7 FFFF F01F FFFF F007",
- /* [2] */
- $"0000 0001 0000 0002 0000 0004 0040 0018 0020 0418 001C 03E0 001C 03E0 001F FFE0"
- $"0007 FFE0 0007 FFE0 0007 FF90 0007 FF80 FFFF FF80 FFFF FF80 FFFF FF80 FFFF FF80"
- $"FFFF FF80 FFFF FF80 FFFF FFE0 FFFF FFE0 FFFF FFE0 FFFF FFF0 FFFF FFF8 FFFF FFF0"
- $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF F01F FFFF F007"
- }
- };
-
- resource 'ICN#' (129) {
- { /* array: 2 elements */
- /* [1] */
- $"0FFF FC00 0C00 0200 0A00 0100 0980 0080 0982 0040 087C 03A0 087C 0390 087F FF90"
- $"087F FE10 087F FE10 089F FE10 081F FE10 081F FFF0 081F FFF0 081F FFF0 081F FFF0"
- $"081F FFF0 081F FFF0 087F FFF0 0870 FFF0 0870 FFF0 0880 FFF0 0900 FFF0 0800 FFF0"
- $"0800 FFF0 0800 FFF0 0800 FFF0 0800 FFF0 0800 FFF0 0800 FFF0 0800 FFF0 0FFF FFF0",
- /* [2] */
- $"0FFF FC00 0FFF FE00 0FFF FF00 0FFF FF80 0FFF FFC0 0FFF FFE0 0FFF FFF0 0FFF FFF0"
- $"0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0"
- $"0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0"
- $"0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0"
- }
- };
-
- resource 'BNDL' (128) {
- 'Arf3',
- 0,
- { /* array TypeArray: 2 elements */
- /* [1] */
- 'ICN#',
- { /* array IDArray: 2 elements */
- /* [1] */
- 0, 128,
- /* [2] */
- 1, 129
- },
- /* [2] */
- 'FREF',
- { /* array IDArray: 2 elements */
- /* [1] */
- 0, 128,
- /* [2] */
- 1, 129
- }
- }
- };
-
- resource 'FREF' (128) {
- 'APPL',
- 0,
- ""
- };
-
- resource 'FREF' (129) {
- 'PICT',
- 1,
- ""
- };
-
-
- type 'Arf3' as 'STR ';
-
- resource 'Arf3' (0) {
- "FracApp 300, version 1.1" /* the ID string as part of Bundle. */
- };
-
-
- /* The mem! resource that MacApp uses to know how much more space we need to
- reserve. We reserve a big old 40K just for fun, so we don't have to narrow
- down the memory useage too closely. This is big enough to cut us slack
- during the big picture playbacks. A little wasteful. We aren't currently
- using the low space reserve, since we don't have many commands to implement.
- Our memory useage comes in big hunks so it is not as useful to watch for
- crossing a low memory barrier. We tend to run out completely or not at
- all. We could check the space is low before allowing the new fractal
- operations, but currently it will fail during the allocation and let
- the user know. Somewhat less friendly, but adequate. The 40K number
- was found heuristically by examing the heap with TMon to see how
- big the code blocks are. */
-
- resource 'mem!' (1000) {
- 40000, /* code reserve size */
- 0, /* low space reserve size */
- 0 /* stack size */
- };
-