home *** CD-ROM | disk | FTP | other *** search
/ develop, the CD; issue 1 / Apple_Develop_1989.bin / Compatibility / Sample.r < prev    next >
Text File  |  1989-10-16  |  7KB  |  310 lines

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple Sample Application
  6. #
  7. #    Sample
  8. #
  9. #    Sample.r    -    Rez Source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                08/88
  16. #                1.01                11/88
  17. #                1.02                04/89
  18. #
  19. #    Components:
  20. #                Sample.p            April 1, 1989
  21. #                Sample.c            April 1, 1989
  22. #                Sample.a            April 1, 1989
  23. #                Sample.inc1.a        April 1, 1989
  24. #                SampleMisc.a        April 1, 1989
  25. #                Sample.r            April 1, 1989
  26. #                Sample.h            April 1, 1989
  27. #                PSample.make        April 1, 1989
  28. #                CSample.make        April 1, 1989
  29. #                ASample.make        April 1, 1989
  30. #
  31. #    Sample is an example application that demonstrates how to
  32. #    initialize the commonly used toolbox managers, operate 
  33. #    successfully under MultiFinder, handle desk accessories, 
  34. #    and create, grow, and zoom windows.
  35. #
  36. #    It does not by any means demonstrate all the techniques 
  37. #    you need for a large application. In particular, Sample 
  38. #    does not cover exception handling, multiple windows/documents, 
  39. #    sophisticated memory management, printing, or undo. All of 
  40. #    these are vital parts of a normal full-sized application.
  41. #
  42. #    This application is an example of the form of a Macintosh 
  43. #    application; it is NOT a template. It is NOT intended to be 
  44. #    used as a foundation for the next world-class, best-selling, 
  45. #    600K application. A stick figure drawing of the human body may 
  46. #    be a good example of the form for a painting, but that does not 
  47. #    mean it should be used as the basis for the next Mona Lisa.
  48. #
  49. #    We recommend that you review this program or TESample before 
  50. #    beginning a new application.
  51. ------------------------------------------------------------------------------*/
  52.  
  53.  
  54. #include "Types.r"
  55.  
  56. #include "Sample.h"
  57.  
  58.  
  59. /* this is a definition for a resource which contains only a rectangle */
  60.  
  61. type 'RECT' {
  62.     rect;
  63. };
  64.  
  65.  
  66. /* we use an MBAR resource to conveniently load all the menus */
  67.  
  68. resource 'MBAR' (rMenuBar, preload) {
  69.     { mApple, mFile, mEdit, mLight };    /* four menus */
  70. };
  71.  
  72.  
  73. resource 'MENU' (mApple, preload) {
  74.     mApple, textMenuProc,
  75.     AllItems & ~MenuItem2,    /* Disable dashed line, enable About and DAs */
  76.     enabled, apple,
  77.     {
  78.         "About Sample...",
  79.             noicon, nokey, nomark, plain;
  80.         "-",
  81.             noicon, nokey, nomark, plain
  82.     }
  83. };
  84.  
  85. resource 'MENU' (mFile, preload) {
  86.     mFile, textMenuProc,
  87.     MenuItem12,                /* enable Quit only, program enables others */
  88.     enabled, "File",
  89.     {
  90.         "New",
  91.             noicon, "N", nomark, plain;
  92.         "Open",
  93.             noicon, "O", nomark, plain;
  94.         "-",
  95.             noicon, nokey, nomark, plain;
  96.         "Close",
  97.             noicon, "W", nomark, plain;
  98.         "Save",
  99.             noicon, "S", nomark, plain;
  100.         "Save As...",
  101.             noicon, nokey, nomark, plain;
  102.         "Revert",
  103.             noicon, nokey, nomark, plain;
  104.         "-",
  105.             noicon, nokey, nomark, plain;
  106.         "Page Setup...",
  107.             noicon, nokey, nomark, plain;
  108.         "Print...",
  109.             noicon, nokey, nomark, plain;
  110.         "-",
  111.             noicon, nokey, nomark, plain;
  112.         "Quit",
  113.             noicon, "Q", nomark, plain
  114.     }
  115. };
  116.  
  117. resource 'MENU' (mEdit, preload) {
  118.     mEdit, textMenuProc,
  119.     NoItems,                /* disable everything, program does the enabling */
  120.     enabled, "Edit",
  121.      {
  122.         "Undo",
  123.             noicon, "Z", nomark, plain;
  124.         "-",
  125.             noicon, nokey, nomark, plain;
  126.         "Cut",
  127.             noicon, "X", nomark, plain;
  128.         "Copy",
  129.             noicon, "C", nomark, plain;
  130.         "Paste",
  131.             noicon, "V", nomark, plain;
  132.         "Clear",
  133.             noicon, nokey, nomark, plain
  134.     }
  135. };
  136.  
  137. resource 'MENU' (mLight, preload) {
  138.     mLight, textMenuProc,
  139.     NoItems,                /* disable everything, program does the enabling */
  140.     enabled, "Traffic",
  141.      {
  142.         "Red Light",
  143.             noicon, nokey, nomark, plain;
  144.         "Green Light",
  145.             noicon, nokey, nomark, plain
  146.     }
  147. };
  148.  
  149.  
  150. /* this ALRT and DITL are used as an About screen */
  151.  
  152. resource 'ALRT' (rAboutAlert, purgeable) {
  153.     {40, 20, 160, 290},
  154.     rAboutAlert,
  155.     { /* array: 4 elements */
  156.         /* [1] */
  157.         OK, visible, silent,
  158.         /* [2] */
  159.         OK, visible, silent,
  160.         /* [3] */
  161.         OK, visible, silent,
  162.         /* [4] */
  163.         OK, visible, silent
  164.     }
  165. };
  166.  
  167. resource 'DITL' (rAboutAlert, purgeable) {
  168.     { /* array DITLarray: 5 elements */
  169.         /* [1] */
  170.         {88, 180, 108, 260},
  171.         Button {
  172.             enabled,
  173.             "OK"
  174.         },
  175.         /* [2] */
  176.         {8, 8, 24, 214},
  177.         StaticText {
  178.             disabled,
  179.             "Simple Sample (Traffic Light)"
  180.         },
  181.         /* [3] */
  182.         {32, 8, 48, 237},
  183.         StaticText {
  184.             disabled,
  185.             "Copyright © 1989 Apple Computer"
  186.         },
  187.         /* [4] */
  188.         {56, 8, 72, 136},
  189.         StaticText {
  190.             disabled,
  191.             "Brought to you by:"
  192.         },
  193.         /* [5] */
  194.         {80, 24, 112, 167},
  195.         StaticText {
  196.             disabled,
  197.             "Macintosh Developer †Technical Support"
  198.         }
  199.     }
  200. };
  201.  
  202.  
  203. /* this ALRT and DITL are used as an error screen */
  204.  
  205. resource 'ALRT' (rUserAlert, purgeable) {
  206.     {40, 20, 120, 260},
  207.     rUserAlert,
  208.     { /* array: 4 elements */
  209.         /* [1] */
  210.         OK, visible, silent,
  211.         /* [2] */
  212.         OK, visible, silent,
  213.         /* [3] */
  214.         OK, visible, silent,
  215.         /* [4] */
  216.         OK, visible, silent
  217.     }
  218. };
  219.  
  220.  
  221. resource 'DITL' (rUserAlert, purgeable) {
  222.     { /* array DITLarray: 3 elements */
  223.         /* [1] */
  224.         {50, 150, 70, 230},
  225.         Button {
  226.             enabled,
  227.             "OK"
  228.         },
  229.         /* [2] */
  230.         {10, 60, 30, 230},
  231.         StaticText {
  232.             disabled,
  233.             "Sample - Error occurred!"
  234.         },
  235.         /* [3] */
  236.         {8, 8, 40, 40},
  237.         Icon {
  238.             disabled,
  239.             2
  240.         }
  241.     }
  242. };
  243.  
  244.  
  245. resource 'WIND' (rWindow, preload, purgeable) {
  246.     {60, 40, 290, 160},
  247.     noGrowDocProc, invisible, noGoAway, 0x0, "Traffic"
  248. };
  249.  
  250. resource 'RECT' (rStopRect, preload, purgeable) {
  251.     {10, 10, 110, 110}
  252. };
  253.  
  254. resource 'RECT' (rGoRect, preload, purgeable) {
  255.     {120, 10, 220, 110}
  256. };
  257.  
  258. /* dialog used to display VBL task counter */
  259. resource 'DLOG' (140) {
  260.     {84, 78, 176, 284},
  261.     altDBoxProc,
  262.     visible,
  263.     goAway,
  264.     0x0,
  265.     140,
  266.     "New Dialog"
  267. };
  268.  
  269. /* dialog item list used to display VBL task counter */
  270. resource 'DITL' (140) {
  271.     {    /* array DITLarray: 2 elements */
  272.         /* [1] */
  273.         {10, 10, 45, 180},
  274.         StaticText {
  275.             enabled,
  276.             "Counting...\n(Click Button to Stop)"
  277.         };
  278.         /* [2] */
  279.         {55, 10, 75, 100},
  280.         StaticText {
  281.             enabled,
  282.             ""
  283.         }
  284.     }
  285. };
  286.  
  287. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  288.  
  289. resource 'SIZE' (-1) {
  290.     dontSaveScreen,
  291.     acceptSuspendResumeEvents,
  292.     enableOptionSwitch,
  293.     canBackground,                /* we can background; we don't currently, but our sleep value */
  294.                                 /* guarantees we don't hog the Mac while we are in the background */
  295.     multiFinderAware,            /* this says we do our own activate/deactivate; don't fake us out */
  296.     backgroundAndForeground,    /* this is definitely not a background-only application! */
  297.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  298.     ignoreChildDiedEvents,        /* essentially, I'm not a debugger (sub-launching) */
  299.     not32BitCompatible,            /* this app should not be run in 32-bit address space */
  300.     reserved,
  301.     reserved,
  302.     reserved,
  303.     reserved,
  304.     reserved,
  305.     reserved,
  306.     reserved,
  307.     kPrefSize * 1024,
  308.     kMinSize * 1024    
  309. };
  310.