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

  1. {-------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MacApp Color QuickDraw Fractal Printing Sample Application
  6. #
  7. #    FracApp300
  8. #
  9. #    MFracApp300.p    -    Pascal 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.  All rights reserved.
  48.     February 1, 1988.
  49.     Written by Bo3b Johnson of Developer Technical Support. }
  50.  
  51. PROGRAM FracApp;
  52.  
  53. USES
  54.     {$LOAD MacIntf.LOAD}
  55.         MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
  56.     {$LOAD UMacApp.LOAD}
  57.         UObject, UList, UMacApp,
  58.     {$LOAD UBobLips.LOAD}
  59.         PaletteMgr, UPrinting,
  60.     {$LOAD}
  61.     MacPrint,
  62.     UFracApp300;
  63.  
  64.  
  65.  
  66. VAR
  67.     {The application object:}
  68.     gFracAppApplication:   TFracAppApplication;
  69.     error:    Integer;
  70.  
  71.  
  72. FUNCTION ForceEnvirons(minimumSystemVersion: INTEGER;
  73.                               minimumProcessor: INTEGER; needsFPU: BOOLEAN;
  74.                               needsColorQD: BOOLEAN;
  75.                               minimumATDrvrVersNum: INTEGER): BOOLEAN;
  76.  
  77.     VAR
  78.         error: OSErr;
  79.         theWorld: SysEnvRec;
  80.  
  81.     BEGIN
  82.         error := SysEnvirons(1,theWorld);
  83.         WITH theWorld DO
  84.             ForceEnvirons := (systemVersion >= minimumSystemVersion) AND
  85.                                   (processor >= minimumProcessor) AND (hasFPU >=
  86.                                   needsFPU) AND (hasColorQD >= needsColorQD) AND
  87.                                   (atDrvrVersNum >= minimumATDrvrVersNum);
  88.     END;
  89.  
  90.  
  91. BEGIN
  92.     {Initialize the Toolbox, making 8 calls to MoreMasters:}
  93.     InitToolbox(8);
  94.  
  95.         { The first thing we have to do is ensure that we can run in this environment.
  96.             We must do a ForceEnvirons to avoid crashing needlessly on machines where
  97.             we have no color or 881.  The minimum system is 4.2 since we need the more
  98.             robust printing stuff.  We dont use 020 code, but we require an FPU.  We
  99.             dont require colorQD.  If we dont have the stuff we need, we will alert and
  100.             leave.  }
  101.      IF NOT ForceEnvirons($0420, envDontCare, TRUE, TRUE, envDontCare) THEN
  102.         Failure (kWrongMachine, 0);
  103.  
  104.     {Initialize the UPrinting unit:}
  105.     InitPrinting;
  106.  
  107.     {Allocate a new TFracAppApplication object:}
  108.     New(gFracAppApplication);
  109.  
  110.     {Initialize that new object:}
  111.     gFracAppApplication.IFracAppApplication(kFileType);
  112.  
  113.     {Run the application.  When it's done, exit.}
  114.     gFracAppApplication.Run;
  115. END.
  116.