home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Examples / DrawShapes / DrawShapes.r < prev    next >
Encoding:
Text File  |  1990-10-25  |  11.4 KB  |  387 lines  |  [TEXT/MPS ]

  1. /* Copyright © 1986-1990 Apple Computer, Inc.  All rights reserved. */
  2.  
  3. /* • Auto-Include the requirements for this source */
  4. #ifndef __TYPES.R__
  5. #include "Types.r"
  6. #endif
  7.  
  8. #ifndef __MacAppTypes__
  9. #include "MacAppTypes.r"
  10. #endif
  11.  
  12. #if qTemplateViews
  13. #ifndef __ViewTypes__
  14. #include "ViewTypes.r"
  15. #endif
  16. #endif
  17.  
  18. #if qDebug
  19. include "Debug.rsrc";
  20. #endif
  21. include "MacApp.rsrc";
  22. include "Printing.rsrc";
  23.  
  24. include $$Shell("ObjApp")"DrawShapes" 'CODE';
  25.  
  26. /* Resource ids */
  27. #define kShapeWindowRSRCID        1005            /* The main document window */
  28. #define kShapeViewRSRCID        1006            /* the shape view resource */
  29. #define kColorMenuBar             131            /* Menu bar for a color system */
  30. #define kNonColorMenuBar         132            /* Menu bar for a black & white system */
  31. #define kRainbowArrow             140
  32. #define kPickerPrompt             256            /* 'STR ' resource for Color Picker */
  33. #define mGoodies                   4            /* the goodies menu */
  34. #define mColor                       6            /* The Color menu resource id */
  35. #define mMoreDebug                   7            /* Menu number for the 'More Debug' menu */
  36.  
  37. /* Command numbers */
  38. #define cWhite                    1000            /* The five shades in the 'Shades' menu */
  39. #define cLtGray                 1001
  40. #define cGray                    1002
  41. #define cDkGray                 1003
  42. #define cBlack                    1004
  43. #define cPickColor                1005            /* Command to bring up Color Picker */
  44.  
  45. #define cNewShape                1010            /* Command to draw a new shape */
  46. #define cMoveShape                1011            /* Command to move one or more shapes */
  47. #define cChangeShade            1012            /* Buzz command for "Undo Shade Change" */
  48. #define cChangeColor            1013            /* Buzz command for "Undo Color Change" */
  49.  
  50. #define cPasteReplacesSelection     118            /* Three commands in the 'More Debug' menu */
  51. #define cRecalcExtent             119
  52. #define cConstrainDrags          120
  53. #define cBetterFeedback             121
  54.  
  55. /* view constants */
  56. #define kMaxCoord                30000            /* largest possible QuickDraw view coordinate
  57.                                                 (QuickDraw maximum minus slop for size of screen) */
  58. #define kPaletteWidth                41            /* Width of the palette */
  59.  
  60. resource 'DITL' (phAboutApp, purgeable) {
  61.      {
  62. /* [ 1] */    {160, 182, 180, 262},
  63.             Button {
  64.                 enabled,
  65.                 "OK"
  66.             };
  67. /* [ 2] */    {10, 75, 150, 320},
  68.             StaticText {
  69.                 disabled,
  70.                     "This sample program demonstrates many features of MacApp.\n\n"
  71.                     "This program was written with MacApp® © 1985-1990 Apple Computer, Inc."
  72.             };
  73. /* [ 3] */    {10, 20, 42, 52},
  74.             Icon {
  75.                 disabled,
  76.                 1
  77.             }
  78.     }
  79. };
  80.  
  81. include "Defaults.rsrc"  'ALRT' (phAboutApp);    // Grab the default about box
  82.  
  83. #if qTemplateViews
  84.  
  85. // This guy is used with template views (this is the recommended approach)
  86. resource 'view' (kShapeWindowRSRCID, purgeable) { {
  87.     root, 'WIND', { 50, 40 }, { 200, 396 }, sizeVariable, sizeVariable, shown, enabled,
  88.     Window {
  89.         "",
  90.             zoomDocProc, goAwayBox, resizable, modeless, ignoreFirstClick, freeOnClosing,
  91.             disposeOnFree, closesDocument, openWithDocument, dontAdaptToScreen, stagger,
  92.             forceOnScreen, dontCenter, 'SHAP', "<<<>>>" };
  93.  
  94.     'WIND', 'PLTT', { 0, 0 }, { 0, kPaletteWidth }, sizeSuperView, sizeFixed, shown, enabled,
  95.     view { "TPalette" };
  96.  
  97.     'WIND', 'SCLR',    { 0, kPaletteWidth }, { 200-kSBarSizeMinus1, 396-kSBarSizeMinus1-kPaletteWidth },
  98.     sizeRelSuperView, sizeRelSuperView, shown, enabled,
  99.     Scroller {
  100.         "",
  101.             vertScrollBar, horzScrollBar, 0, 0, 16, 16,
  102.             noVertConstrain, noHorzConstrain, { 0, 0, 0, 0 } };
  103.  
  104.     'SCLR', IncludeViewsAt { kShapeViewRSRCID, { 0, 0 } };
  105. } };
  106.  
  107. resource 'view' (kShapeViewRSRCID, purgeable) { {
  108.     root, 'SHAP', { 0, 0 }, { kMaxCoord, kMaxCoord }, sizeFillPages, sizeFillPages, shown, enabled,
  109.     view { "TShapeView" };
  110. } };
  111.  
  112. #else
  113.  
  114. // This guy is used when the template stuff isn't (but…template views are recommended, see above)
  115. resource 'WIND' (kShapeWindowRSRCID, purgeable) {
  116.     {50, 40, 250, 436},
  117.     zoomDocProc,
  118.     invisible,
  119.     goAway,
  120.     0x0,
  121.     ""
  122. };
  123.  
  124. #endif
  125.  
  126. resource 'SIZE' (-1) {
  127.     saveScreen,
  128.     acceptSuspendResumeEvents,
  129.     enableOptionSwitch,
  130.     canBackground,
  131.     MultiFinderAware,
  132.     backgroundAndForeground,
  133.     dontGetFrontClicks,
  134.     ignoreChildDiedEvents,
  135.     is32BitCompatible,
  136.     reserved,
  137.     reserved,
  138.     reserved,
  139.     reserved,
  140.     reserved,
  141.     reserved,
  142.     reserved,
  143. #if qDebug
  144.     468 * 1024,
  145.     330 * 1024
  146. #else
  147.     230 * 1024,
  148.     160 * 1024
  149. #endif
  150. };
  151.  
  152. /*    Quitting and saving files is the most memory intensive part of this program.
  153.     In addition to the resident segments, these segments are needed. */
  154.  
  155. resource 'seg!' (256, purgeable) {
  156.     {
  157.         "GTerminate";
  158.         "GWriteFile";
  159.         "GClipboard";
  160.         "GDoCommand";
  161.         "GClose";
  162.         "GNonRes";
  163.         "GSelCommand";
  164.         "GFile";
  165.     }
  166. };
  167.  
  168. resource 'STR ' (kPickerPrompt) {
  169.     "Pick a color, any color…"
  170. };
  171.  
  172. include "Defaults.rsrc" 'cmnu' (mApple);        // Grab the default Apple/File menus
  173. include "Defaults.rsrc" 'cmnu' (mFile);
  174.  
  175. resource 'cmnu' (mEdit) {
  176.     mEdit,
  177.     textMenuProc,
  178.     0x7FFFFF7D,
  179.     enabled,
  180.     "Edit",
  181.      {    /* array: 9 elements */
  182. /* [1] */ "Undo",            noIcon, "Z",    noMark, plain, cUndo;
  183. /* [2] */ "-",                noIcon, noKey,    noMark, plain, nocommand;
  184. /* [3] */ "Cut",            noIcon, "X",    noMark, plain, cCut;
  185. /* [4] */ "Copy",            noIcon, "C",    noMark, plain, cCopy;
  186. /* [5] */ "Paste",            noIcon, "V",    noMark, plain, cPaste;
  187. /* [6] */ "Clear",            noIcon, noKey,    noMark, plain, cClear;
  188. /* [7] */ "Select All",        noIcon, "A",    noMark, plain, cSelectAll;
  189. /* [8] */ "-",                noIcon, noKey,    noMark, plain, nocommand;
  190. /* [9] */ "Show Clipboard",    noIcon, noKey,    noMark, plain, cShowClipboard
  191.     }
  192. };
  193.  
  194. resource 'cmnu' (mGoodies) {
  195.     mGoodies,
  196.     textMenuProc,
  197.     0x7FFFFF37,
  198.     enabled,
  199.     "Goodies",
  200.     {
  201. /* [1] */ "Show Page Breaks",
  202.                                 noIcon, noKey, noMark, plain, cShowBreaks;
  203. /* [2] */ "-",                    noIcon, noKey,    noMark, plain, nocommand;
  204. /* [3] */ "Better feedback desired",
  205.                                 noIcon, noKey, noMark, plain, cBetterFeedback
  206.     }
  207. };
  208.  
  209. resource 'cmnu' (5) {
  210.     5,
  211.     textMenuProc,
  212.     allEnabled,
  213.     enabled,
  214.     "Shades",
  215.      {    /* array: 5 elements */
  216. /* [1] */    "White",        noIcon, noKey, noMark, plain, cWhite;
  217. /* [2] */    "25% Shading",    noIcon, noKey, noMark, plain, cLtGray;
  218. /* [3] */    "50% Shading",    noIcon, noKey, noMark, plain, cGray;
  219. /* [4] */    "75% Shading",    noIcon, noKey, noMark, plain, cDkGray;
  220. /* [5] */    "100% Shading",    noIcon, noKey, noMark, plain, cBlack
  221.     }
  222. };
  223.  
  224. resource 'cmnu' (mColor) {
  225.     mColor,
  226.     textMenuProc,
  227.     allEnabled,
  228.     enabled,
  229.     "Colors",
  230.     {    /* array: 9 elements */
  231. /* [1] */    "Green",            noIcon, noKey, noMark, plain, noCommand;
  232. /* [2] */    "Yellow",            noIcon, noKey, noMark, plain, noCommand;
  233. /* [3] */    "Orange",            noIcon, noKey, noMark, plain, noCommand;
  234. /* [4] */    "Red",                noIcon, noKey, noMark, plain, noCommand;
  235. /* [5] */    "Purple",            noIcon, noKey, noMark, plain, noCommand;
  236. /* [6] */    "Blue",                noIcon, noKey, noMark, plain, noCommand;
  237. /* [7] */    "Black",            noIcon, noKey, noMark, plain, noCommand;
  238. /* [8] */    "-",                noIcon, noKey, noMark, plain, noCommand;
  239. /* [9] */    "Pick a Color…",    noIcon, noKey, noMark, plain, cPickColor
  240.     }
  241. };
  242.  
  243. resource 'cmnu' (mMoreDebug) {
  244.     mMoreDebug,
  245.     textMenuProc,
  246.     allEnabled,
  247.     enabled,
  248.     "More Debug",
  249.      {    /* array: 3 elements */
  250. /* [1] */ "Paste Replaces Selection",
  251.                                 noIcon, noKey, noMark, plain, cPasteReplacesSelection;
  252. /* [2] */ "Recompute view extent",
  253.                                 noIcon, noKey, noMark, plain, cRecalcExtent;
  254. /* [3] */ "Constrain dragging to view borders",
  255.                                 noIcon, noKey, noMark, plain, cConstrainDrags
  256.     }
  257. };
  258.  
  259. resource 'mctb' (mColor) {
  260.     {
  261.     /* Green */
  262.     mColor, 1,
  263.         {
  264.         0x0000, 0xDB00, 0x0000;            /* Mark color */
  265.         0x0000, 0xDB00, 0x0000;            /* Name color */
  266.         0x0000, 0xDB00, 0x0000;            /* Command Key color */
  267.         0xFFFF, 0xFFFF, 0xFFFF            /* Background color */
  268.         };
  269.     /* Yellow */
  270.     mColor, 2,
  271.         {
  272.         0xFFFF, 0xDB00, 0x0000;            /* Mark color */
  273.         0xFFFF, 0xDB00, 0x0000;            /* Name color */
  274.         0xFFFF, 0xDB00, 0x0000;            /* Command Key color */
  275.         0xFFFF, 0xFFFF, 0xFFFF            /* Background color */
  276.         };
  277.     /* Orange */
  278.     mColor, 3,
  279.         {
  280.         0xFFFF, 0x4700, 0x0000;            /* Mark color */
  281.         0xFFFF, 0x4700, 0x0000;            /* Name color */
  282.         0xFFFF, 0x4700, 0x0000;            /* Command Key color */
  283.         0xFFFF, 0xFFFF, 0xFFFF            /* Background color */
  284.         };
  285.     /* Red */
  286.     mColor, 4,
  287.         {
  288.         0xDB00, 0x0000, 0x0000;            /* Mark color */
  289.         0xDB00, 0x0000, 0x0000;            /* Name color */
  290.         0xDB00, 0x0000, 0x0000;            /* Command Key color */
  291.         0xFFFF, 0xFFFF, 0xFFFF            /* Background color */
  292.         };
  293.     /* Purple */
  294.     mColor, 5,
  295.         {
  296.         0x9200, 0x0000, 0xB000;            /* Mark color */
  297.         0x9200, 0x0000, 0xB000;            /* Name color */
  298.         0x9200, 0x0000, 0xB000;            /* Command Key color */
  299.         0xFFFF, 0xFFFF, 0xFFFF            /* Background color */
  300.         };
  301.     /* Blue */
  302.     mColor, 6,
  303.         {
  304.         0x0000, 0x0000, 0xFFFF;            /* Mark color */
  305.         0x0000, 0x0000, 0xFFFF;            /* Name color */
  306.         0x0000, 0x0000, 0xFFFF;            /* Command Key color */
  307.         0xFFFF, 0xFFFF, 0xFFFF            /* Background color */
  308.         };
  309.     /* Black */
  310.     mColor, 7,
  311.         {
  312.         0x0000, 0x0000, 0x0000;            /* Mark color */
  313.         0x0000, 0x0000, 0x0000;            /* Name color */
  314.         0x0000, 0x0000, 0x0000;            /* Command Key color */
  315.         0xFFFF, 0xFFFF, 0xFFFF            /* Background color */
  316.         }
  317.     }
  318. };
  319.  
  320. resource 'cmnu' (mBuzzwords) {
  321.     mBuzzwords,
  322.     textMenuProc,
  323.     allEnabled,
  324.     enabled,
  325.     "Buzzwords",
  326.      {    /* array: 5 elements */
  327. /* [1] */    "Drawing",                noIcon, noKey, noMark, plain, cNewShape;
  328. /* [2] */    "Move",                    noIcon, noKey, noMark, plain, cMoveShape;
  329. /* [3] */    "Page Setup Change",    noIcon, noKey, noMark, plain, cChangePrinterStyle;
  330. /* [4] */    "Shade Change",            noIcon, noKey, noMark, plain, cChangeShade;
  331. /* [5] */    "Color Change",            noIcon, noKey, noMark, plain, cChangeColor
  332.     }
  333. };
  334.  
  335. /* Menu bar for a color system */
  336. resource 'MBAR' (kColorMenuBar) {
  337.     {mApple; mFile; mEdit; 5; mColor; mGoodies}
  338. };
  339.  
  340. /* Menu bar for a non-color system */
  341. resource 'MBAR' (kNonColorMenuBar) {
  342.     {mApple; mFile; mEdit; 5; mGoodies}
  343. };
  344.  
  345. resource 'MBAR' (kMBarNotDisplayed) {
  346.     {mMoreDebug}
  347. };
  348.  
  349. /* The color "rainbow" arrow cursor */
  350. data 'crsr' (kRainbowArrow, "Rainbow Arrow") {
  351.     $"8001 0000 0062 0000 0096 0000 0000 0000"        /* Ä....b...ñ...... */
  352.     $"0000 0000 0000 4000 6000 7000 7800 7C00"        /* ......@.`.p.x.|. */
  353.     $"7E00 7F00 7F80 7C00 6C00 4600 0600 0300"        /* ~....Ä|.l.F..... */
  354.     $"0100 0000 C000 E000 F000 F800 FC00 FE00"        /* ....¿........... */
  355.     $"FF00 FF80 FFC0 FFE0 FE00 EF00 CF00 8780"        /* ...Ä.¿......œ.áÄ */
  356.     $"0780 0380 0001 0001 0000 0000 0000 0000"        /* .Ä.Ä............ */
  357.     $"0000 0000 0000 8008 0000 0000 0010 0010"        /* ......Ä......... */
  358.     $"0000 0000 0000 0000 0048 0000 0048 0000"        /* .........H...H.. */
  359.     $"0000 0004 0000 0000 0000 0000 0000 0116"        /* ................ */
  360.     $"0000 0000 0000 0000 0000 0000 0000 0100"        /* ................ */
  361.     $"0000 0000 0000 0110 0000 0000 0000 0121"        /* ...............! */
  362.     $"0000 0000 0000 0222 2000 0000 0000 0233"        /* ......." ......3 */
  363.     $"3200 0000 0000 0333 3330 0000 0000 0344"        /* 2......330.....D */
  364.     $"4445 0000 0000 0444 4445 5000 0000 0444"        /* DE.....DDEP....D */
  365.     $"5500 0000 0000 0550 6600 0000 0000 0500"        /* U......Pf....... */
  366.     $"0660 0000 0000 0000 0660 0000 0000 0000"        /* .`.......`...... */
  367.     $"0066 0000 0000 0000 0066 0000 0000 0000"        /* .f.......f...... */
  368.     $"0000 0000 0000 0000 0000 0000 0006 0000"        /* ................ */
  369.     $"FFFF FFFF FFFF 0001 0000 DB00 0000 0002"        /* ................ */
  370.     $"FFFF DB00 0000 0003 FFFF 4F00 0000 0004"        /* ..........O..... */
  371.     $"DB00 0000 0000 0005 9200 0000 B000 0006"        /* ........í...∞... */
  372.     $"0000 0000 FFFF"                                 /* ...... */
  373. };
  374.  
  375.  
  376. include "Defaults.rsrc"  'STR#' (kDefaultCredits);        // Grab the default credits
  377.  
  378. // Get the default MacApp® application icon and necessary bundling rsrcs
  379. include "Defaults.rsrc"  'MApp' (0);
  380. include "Defaults.rsrc"  'FREF' (128);
  381. include "Defaults.rsrc"  'BNDL' (128);
  382. include "Defaults.rsrc"  'ICN#' (128);
  383.  
  384. // Get the default Version resources
  385. include "Defaults.rsrc"  'vers' (1);        // Application or file specific
  386. include "Defaults.rsrc"  'vers' (2);        // Overall package
  387.