home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / scnote / fapp300.009 / FracApp300.r < prev    next >
Encoding:
Text File  |  1988-08-17  |  11.1 KB  |  384 lines

  1. /*-------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MacApp Color QuickDraw Fractal Printing Sample Application
  6. #
  7. #    FracApp300
  8. #
  9. #    FracApp300.r    -    Rez Source
  10. #
  11. #    Copyright ⌐ 1988 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    1.0                    8/88
  15. #
  16. #    Components:    MFracApp300.p        August 1, 1988
  17. #                UFracApp300.p        August 1, 1988
  18. #                UFracApp300.inc1.p    August 1, 1988
  19. #                FracApp300.r        August 1, 1988
  20. #                FracApp300.make        August 1, 1988
  21. #
  22. #    The FracApp300 program is a version of the FracApp program that is
  23. #    set up to be as compatible as possible.  It uses the PrGeneral call
  24. #    in order to print at high resolution.  It demonstrates how to create
  25. #    and save 300 dpi PICT files.  It uses an offscreen port to calculate
  26. #    the data, and CopyBits to update the window on the screen.  When the
  27. #    documents are written or read, the QuickDraw bottlenecks are used to
  28. #    avoid having a huge memory hit during saving or opening. (800K of RAM
  29. #    not needed, on a 640x480 screen, a big win.)  The Palette Manager is
  30. #    used very slightly, only to associate a small palette with only Black
  31. #    and White with each window.  This avoids needing the system palette
  32. #    for each window, when no colors are used.  Since we are printing to
  33. #    normal printers, we only use B&W in this version.
  34. #            Written in MacApp Object Pascal code.
  35. #            Compatibility rating = 1.  (The use of PrGeneral is slightly 
  36. #                out of the ordinary, although supported.)
  37. #
  38. #    The program is a complete Macintosh application written in Object 
  39. #    Pascal using MacApp.  It supports multiple windows, calculations in the
  40. #    background under MultiFinder, use of the Palette Manager, reading and
  41. #    writing of PICT files using the bottlenecks, and shows how to calculate
  42. #    the Mandelbrot set.
  43. #
  44. #    There is a resource file that is necessary as well, to define the Menus, Window,
  45. #    Dialog, and Palette resources used in the program.  
  46. -------------------------------------------------------------*/
  47. /* Copyright 1988 by Bob. */
  48. /* February 1, 1988 */
  49. /* Modified May 1, 1988 to become FracApp300 for printing
  50.         and 300 dpi calculation. */
  51. /*    Written by Bo3b Johnson of Developer Technical Support. */
  52.  
  53. #ifdef Debugging
  54. include MacAppRFiles"Debug.rsrc";
  55. #endif
  56. include MacAppRFiles"MacApp.rsrc";
  57. include MacAppRFiles"Printing.rsrc";
  58.  
  59. include "FracApp300" 'CODE';
  60.  
  61. resource 'WIND' (1001, purgeable) {
  62.     {50, 20, 200, 450},
  63.     zoomDocProc,
  64.     invisible,
  65.     goAway,
  66.     0x0,
  67.     "<<<>>>"
  68. };
  69.  
  70.  
  71. /* Now a palette that is associated with every window automatically when the
  72.     window is opened.  The resource ID matches that of the window template.
  73.     This palette is very mellow, just the two colors as the standard
  74.     color palette.  */
  75.  
  76. data 'pltt' (1001, preload, nonpurgeable) {
  77.     $"0001 0000 0000 0000 0000 0000 0000 0000"    /* 2 colors in table. */
  78.     $"FFFF FFFF FFFF 0000 0000 0000 0000 0000"    /* white as first guy. */
  79.     $"0000 0000 0000 0000 0000 0000 0000 0000"    /* black as second */
  80. };
  81.  
  82.  
  83. /* we put the latest SIZE template here so we can rez with MPW 2.0 */
  84.  
  85. type 'SIZE' {
  86.         boolean        dontSaveScreen,
  87.                     saveScreen;
  88.         boolean     ignoreSuspendResumeEvents,
  89.                     acceptSuspendResumeEvents;
  90.         boolean        enableOptionSwitch,
  91.                     disableOptionSwitch;
  92.         boolean        cannotBackground,
  93.                     canBackground;
  94.         boolean        notMultiFinderAware,
  95.                     multiFinderAware;
  96.         boolean        notOnlyBackground,
  97.                     onlyBackground;
  98.         boolean        dontGetFrontClicks,
  99.                     getFrontClicks;
  100.         unsigned bitstring[9] = 0;
  101.         unsigned longint;    /* preferred memory size in bytes */
  102.         unsigned longint;    /* minimum memory size in bytes */
  103. };    /* ignore the warning caused by re-defining SIZE */
  104.  
  105.  
  106. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  107.  
  108. resource 'SIZE' (-1) {
  109.     saveScreen,
  110.     acceptSuspendResumeEvents,
  111.     disableOptionSwitch,
  112.     canBackground,
  113.     multiFinderAware,    /* this says we do our own activate/deactivate; don't fake us out */
  114.     notOnlyBackground,    /* this is definitely not a background-only application! */
  115.     dontGetFrontClicks,    /* change this is if you want "do first click" behavior like the Finder */
  116. #ifdef Debugging
  117.     1780 * 1024,
  118.     1000 * 1024
  119. #else
  120.     1780 * 1024,        /* preferred- enough for two documents open. */
  121.     950 * 1024            /* min- enough for one document open. */
  122. #endif
  123. };
  124.  
  125. resource 'DITL' (201, purgeable) {
  126.     {    /* array DITLarray: 3 elements */
  127.         /* [1] */
  128.         {145, 182, 165, 262},
  129.         Button {
  130.             enabled,
  131.             "OK, OK."
  132.         },
  133.         /* [2] */
  134.         {10, 80, 133, 304},
  135.         StaticText {
  136.             disabled,
  137.             "FracApp300, version 1.1 by Bo3b Johnson.  Calculates the Mandelbrot "
  138.             "set using direct 68881 code for maximum speed. "
  139.             "Select an area with "
  140.             "the mouse to zoom in.  300 dpi calculations, no color; but you can Print."
  141.         },
  142.         /* [3] */
  143.         {10, 20, 42, 52},
  144.         Icon {
  145.             disabled,
  146.             201
  147.         }
  148.     }
  149. };
  150.  
  151. resource 'ALRT' (201, purgeable) {
  152.     {90, 100, 270, 412},
  153.     201,
  154.     {
  155.         OK, visible, silent;
  156.         OK, visible, silent;
  157.         OK, visible, silent;
  158.         OK, visible, silent
  159.     }
  160. };
  161.  
  162. /* The icon used in the about box.  The same as the program ICN#, but ICON instead. */
  163. resource 'ICON' (201, purgeable) {
  164.         $"0000 0001 0000 0002 0000 0004 0040 0018 0020 0418 001C 03E0 001C 03E0 001F FFE0"
  165.         $"0007 FFE0 0007 FFE0 0007 FF90 0007 FF80 FFFF FF80 FFFF FF80 DFFF FF80 EFFF FF80"
  166.         $"F1FF FF80 F1FF FF80 F1FF FFE0 FE07 FFE0 FE07 C0E0 FE07 8050 FE07 3028 FE01 C810"
  167.         $"FE0E 7F8F FFE2 3007 FFFF 0007 FFFF 8007 FFFF E007 FFFF FFE7 FFFF F01F FFFF F007"
  168. };
  169.  
  170. /* For the menus, except the Apple menu, we set the enable flags to zero for
  171.     simplicity.   The right pieces will get enabled by the MacApp handlers (DoSetUpMenus
  172.     for whatever object can do it), so we'll start with disabled. */
  173. resource 'cmnu' (1) {
  174.     1,
  175.     textMenuProc,
  176.     0x7FFFFFFD,
  177.     enabled,
  178.     apple,
  179.      {    /* array: 2 elements */
  180.         /* [1] */
  181.         "About FracApp╔", noIcon, noKey, noMark, plain, cAboutApp;
  182.         /* [2] */
  183.         "-", noIcon, noKey, noMark, plain, nocommand
  184.     }
  185. };
  186.  
  187. resource 'cmnu' (2) {
  188.     2,
  189.     textMenuProc,
  190.     0x0,
  191.     enabled,
  192.     "File",
  193.      {    /* array: 12 elements */
  194.         /* [1] */
  195.         "New", noIcon, "N", noMark, plain, cNew;
  196.         /* [2] */
  197.         "Open╔", noIcon, "O", noMark, plain, cOpen;
  198.         /* [3] */
  199.         "-", noIcon, noKey, noMark, plain, nocommand;
  200.         /* [4] */
  201.         "Close", noIcon, "W", noMark, plain, cClose;
  202.         /* [5] */
  203.         "Save", noIcon, "S", noMark, plain, cSave;
  204.         /* [6] */
  205.         "Save As╔", noIcon, noKey, noMark, plain, cSaveAs;
  206.         /* [7] */
  207.         "Save a Copy In╔", noIcon, noKey, noMark, plain, cSaveCopy;
  208.         /* [8] */
  209.         "-", noIcon, noKey, noMark, plain, nocommand;
  210.         /* [9] */
  211.         "Print╔", noIcon, "P", noMark, plain, cPrint;
  212.         /* [10] */
  213.         "-", noIcon, noKey, noMark, plain, nocommand;
  214.         /* [11] */
  215.         "Quit", noIcon, "Q", noMark, plain, cQuit
  216.     }
  217. };
  218.  
  219. resource 'cmnu' (3) {
  220.     3,
  221.     textMenuProc,
  222.     0x0,
  223.     enabled,
  224.     "Edit",
  225.      {    /* array: 8 elements */
  226.         /* [1] */
  227.         "Undo", noIcon, "Z", noMark, plain, cUndo;
  228.         /* [2] */
  229.         "-", noIcon, noKey, noMark, plain, nocommand;
  230.         /* [3] */
  231.         "Cut", noIcon, "X", noMark, plain, cCut;
  232.         /* [4] */
  233.         "Copy", noIcon, "C", noMark, plain, cCopy;
  234.         /* [5] */
  235.         "Paste", noIcon, "V", noMark, plain, cPaste;
  236.         /* [6] */
  237.         "Clear", noIcon, noKey, noMark, plain, cClear;
  238.         /* [7] */
  239.         "-", noIcon, noKey, noMark, plain, nocommand;
  240.         /* [8] */
  241.         "Show Clipboard", noIcon, noKey, noMark, plain, cShowClipboard
  242.     }
  243. };
  244.  
  245. resource 'cmnu' (4) {
  246.     4,
  247.     textMenuProc,
  248.     0x0,
  249.     enabled,
  250.     "Zoomy",
  251.      {    /* array: 1 elements */
  252.         /* [1] */
  253.         "New from selection", noIcon, noKey, noMark, plain, 1000
  254.     }
  255. };
  256.  
  257. resource 'MBAR' (128) {
  258.     {1; 2; 3; 4}
  259. };
  260.  
  261.  
  262. /* Now the pattern that is used for the selection rectangle. */
  263.  
  264. resource 'PAT ' (128, preload, nonpurgeable) {
  265.     $"FCF9 F3E7 CF9F 3F7E"
  266. };
  267.  
  268.  
  269. /* list mapping of our error code to the info string. */
  270.  
  271. resource 'errs' (1128, purgeable) {
  272.     {    whichList, 0, 1100;
  273.         1000, 1000, 1;                /* error code if wrong machine, crash avoidance. */
  274.         1001, 1001, 2                /* err code for no resolution on printer. */
  275.     }
  276. };
  277.  
  278. /* The info strings for our errors.  */
  279.  
  280. resource 'STR#' (1100, purgeable) {
  281.     {    /* [1] */    "Color QuickDraw, a 68881 (FPU), and the latest System "
  282.                         "are required";
  283.         /* [2] */    "the printer does not support high resolution printing"
  284.     }
  285. };
  286.  
  287.  
  288.     /* Now all the baggage required for the Icons at the Finder.  No real
  289.         program keeps the default Icon.  Herein is the BNDL, Arf3, ICN#, FREF
  290.         resources required. The 'Arf3' is the application type.  Registered
  291.         of course. */
  292.  
  293. resource 'ICN#' (128) {
  294.     {    /* array: 2 elements */
  295.         /* [1] */
  296.         $"0000 0001 0000 0002 0000 0004 0040 0018 0020 0418 001C 03E0 001C 03E0 001F FFE0"
  297.         $"0007 FFE0 0007 FFE0 0007 FF90 0007 FF80 FFFF FF80 FFFF FF80 DFFF FF80 EFFF FF80"
  298.         $"F1FF FF80 F1FF FF80 F1FF FFE0 FE07 FFE0 FE07 C0E0 FE07 8050 FE07 3028 FE01 C810"
  299.         $"FE0E 7F8F FFE2 3007 FFFF 0007 FFFF 8007 FFFF E007 FFFF FFE7 FFFF F01F FFFF F007",
  300.         /* [2] */
  301.         $"0000 0001 0000 0002 0000 0004 0040 0018 0020 0418 001C 03E0 001C 03E0 001F FFE0"
  302.         $"0007 FFE0 0007 FFE0 0007 FF90 0007 FF80 FFFF FF80 FFFF FF80 FFFF FF80 FFFF FF80"
  303.         $"FFFF FF80 FFFF FF80 FFFF FFE0 FFFF FFE0 FFFF FFE0 FFFF FFF0 FFFF FFF8 FFFF FFF0"
  304.         $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF F01F FFFF F007"
  305.     }
  306. };
  307.  
  308. resource 'ICN#' (129) {
  309.     {    /* array: 2 elements */
  310.         /* [1] */
  311.         $"0FFF FC00 0C00 0200 0A00 0100 0980 0080 0982 0040 087C 03A0 087C 0390 087F FF90"
  312.         $"087F FE10 087F FE10 089F FE10 081F FE10 081F FFF0 081F FFF0 081F FFF0 081F FFF0"
  313.         $"081F FFF0 081F FFF0 087F FFF0 0870 FFF0 0870 FFF0 0880 FFF0 0900 FFF0 0800 FFF0"
  314.         $"0800 FFF0 0800 FFF0 0800 FFF0 0800 FFF0 0800 FFF0 0800 FFF0 0800 FFF0 0FFF FFF0",
  315.         /* [2] */
  316.         $"0FFF FC00 0FFF FE00 0FFF FF00 0FFF FF80 0FFF FFC0 0FFF FFE0 0FFF FFF0 0FFF FFF0"
  317.         $"0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0"
  318.         $"0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0"
  319.         $"0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0 0FFF FFF0"
  320.     }
  321. };
  322.  
  323. resource 'BNDL' (128) {
  324.     'Arf3',
  325.     0,
  326.     {    /* array TypeArray: 2 elements */
  327.         /* [1] */
  328.         'ICN#',
  329.         {    /* array IDArray: 2 elements */
  330.             /* [1] */
  331.             0, 128,
  332.             /* [2] */
  333.             1, 129
  334.         },
  335.         /* [2] */
  336.         'FREF',
  337.         {    /* array IDArray: 2 elements */
  338.             /* [1] */
  339.             0, 128,
  340.             /* [2] */
  341.             1, 129
  342.         }
  343.     }
  344. };
  345.  
  346. resource 'FREF' (128) {
  347.     'APPL',
  348.     0,
  349.     ""
  350. };
  351.  
  352. resource 'FREF' (129) {
  353.     'PICT',
  354.     1,
  355.     ""
  356. };
  357.  
  358.  
  359. type 'Arf3' as 'STR ';
  360.  
  361. resource  'Arf3' (0) {
  362.     "FracApp 300, version 1.1"        /* the ID string as part of Bundle. */
  363. };
  364.  
  365.  
  366. /* The mem! resource that MacApp uses to know how much more space we need to
  367.    reserve.  We reserve a big old 40K just for fun, so we don't have to narrow
  368.    down the memory useage too closely.  This is big enough to cut us slack
  369.    during the big picture playbacks.  A little wasteful.  We aren't currently
  370.    using the low space reserve, since we don't have many commands to implement.
  371.    Our memory useage comes in big hunks so it is not as useful to watch for
  372.    crossing a low memory barrier.  We tend to run out completely or not at
  373.    all. We could check the space is low before allowing the new fractal
  374.    operations, but currently it will fail during the allocation and let
  375.    the user know.  Somewhat less friendly, but adequate.   The 40K number
  376.    was found heuristically by examing the heap with TMon to see how
  377.    big the code blocks are.  */
  378.  
  379. resource 'mem!' (1000) {
  380.         40000,        /* code reserve size */
  381.         0,            /* low space reserve size */
  382.         0            /* stack size */
  383. };
  384.