home *** CD-ROM | disk | FTP | other *** search
/ develop, the CD; issue 1 / Apple_Develop_1989.bin / Compatibility / Sample.h < prev    next >
Text File  |  1989-04-01  |  9KB  |  203 lines

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple Sample Application
  6. #
  7. #    Sample
  8. #
  9. #    Sample.h    -    Rez and C Include 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. /*    These #defines correspond to values defined in the Pascal source code.
  54.     Sample.c and Sample.r include this file. */
  55.  
  56. /*    Determining an application's minimum size to request from MultiFinder depends
  57.     on many things, each of which can be unique to an application's function,
  58.     the anticipated environment, the developer's attitude of what constitutes
  59.     reasonable functionality and performance, etc. Here is a list of some things to
  60.     consider when determining the minimum size (and preferred size) for your
  61.     application. The list is pretty much in order of importance, but by no means
  62.     complete.
  63.     
  64.     1.    What is the minimum size needed to give almost 100 percent assurance
  65.         that the application won't crash because it ran out of memory? This
  66.         includes not only things that you do have direct control over such as
  67.         checking for NIL handles and pointers, but also things that some
  68.         feel are not so much under their control such as QuickDraw and the
  69.         Segment Loader.
  70.         
  71.     2.    What kind of performance can a user expect from the application when
  72.         it is running in the minimum memory configuration? Performance includes
  73.         not only speed in handling data, but also things like how many documents
  74.         can be opened, etc.
  75.         
  76.     3.    What are the typical sizes of scraps [is a boy dog] that a user might
  77.         wish to work with when lauching or switching to your application? If
  78.         the amount of memory is too small, the scrap may get lost [will have
  79.         to be shot]. This can be quite frustrating to the user.
  80.         
  81.     4.    The previous items have concentrated on topics that tend to cause an
  82.         increase in the minimum size to request from MultiFinder. On the flip
  83.         side, however, should be the consideration of what environments the
  84.         application may be running in. There may be a high probability that
  85.         many users with relatively small memory configurations will want to
  86.         avail themselves of your application. Or, many users might want to use it
  87.         while several other, possibly related/complementary applications are
  88.         running. If that is the case, it would be helpful to have a fairly
  89.         small minimum size.
  90.     
  91.     So, what did we decide on Sample? First, Sample has little risk of
  92.     running out of memory once it starts. Second, performance isn't much
  93.     of an issue since it doesn't do much and multiple windows are not
  94.     allowed. Third, there are no edit operations in Sample itself, so we
  95.     just want to provide enough space for a reasonable scrap to survive
  96.     between desk accessory launches. Lastly, Sample should intrude as little
  97.     as possible, so the effort should be towards making it as small as possible.
  98.     We looked at some heap dumps while the application was running under
  99.     various partition sizes. With a size of 23K, there was approximately
  100.     8-9K free, which is a good 'slop' factor in an application like this
  101.     which doesn't do much, but where we'd still like the scrap to survive
  102.     most of the time. */
  103.  
  104. #define kMinSize    23                /* application's minimum size (in K) */
  105.  
  106. /*    We made the preferred size bigger than the minimum size by 12K, so that
  107.     there would be even more room for the scrap, FKEYs, etc. */
  108.  
  109. #define kPrefSize    35                /* application's preferred size (in K) */
  110.  
  111. #define    rMenuBar    128                /* application's menu bar */
  112. #define    rAboutAlert    128                /* about alert */
  113. #define    rUserAlert    129                /* error user alert */
  114. #define    rWindow        128                /* application's window */
  115. #define rStopRect    128                /* rectangle for Stop light */
  116. #define rGoRect        129                /* rectangle for Go light */
  117.  
  118. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  119.    SysEnvRec we understand. */
  120.  
  121. #define    kSysEnvironsVersion        1
  122.  
  123. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  124.    by MultiFinder. Once we determine that an event is an osEvent, we look at the
  125.    high byte of the message sent to determine which kind it is. To differentiate
  126.    suspend and resume events we check the resumeMask bit. */
  127.  
  128. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  129. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  130. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  131. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  132. #define    kNoEvents                0        /* no events mask */
  133.  
  134. /* The following constants are used to identify menus and their items. The menu IDs
  135.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  136.  
  137. #define    mApple                    128        /* Apple menu */
  138. #define    iAbout                    1
  139.  
  140. #define    mFile                    129        /* File menu */
  141. #define    iNew                    1
  142. #define    iClose                    4
  143. #define    iQuit                    12
  144.  
  145. #define    mEdit                    130        /* Edit menu */
  146. #define    iUndo                    1
  147. #define    iCut                    3
  148. #define    iCopy                    4
  149. #define    iPaste                    5
  150. #define    iClear                    6
  151.  
  152. #define    mLight                    131        /* Light menu */
  153. #define    iStop                    1
  154. #define    iGo                        2
  155.  
  156. /*    1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */
  157.  
  158. #define kDITop                    0x0050
  159. #define kDILeft                    0x0070
  160.  
  161. /*    1.01 - kMinHeap - This is the minimum result from the following
  162.     equation:
  163.         
  164.         ORD(GetApplLimit) - ORD(ApplicZone)
  165.         
  166.     for the application to run. It will insure that enough memory will
  167.     be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  168.     application, and still give the application some 'breathing room'.
  169.     To derive this number, we ran under a MultiFinder partition that was
  170.     our requested minimum size, as given in the 'SIZE' resource. */
  171.      
  172. #define kMinHeap                21 * 1024
  173.     
  174. /*    1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called
  175.     at initialization time, for the application to run. This number acts
  176.     as a double-check to insure that there really is enough memory for the
  177.     application to run, including what has been taken up already by
  178.     pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  179.      
  180. #define kMinSpace                8 * 1024
  181.  
  182. /* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  183.  
  184. #define kExtremeNeg                -32768
  185. #define kExtremePos                32767 - 1 /* required to address an old region bug */
  186.  
  187. /* these #defines are used to set enable/disable flags of a menu */
  188.  
  189. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  190. #define NoItems        0b0000000000000000000000000000000
  191. #define MenuItem1    0b0000000000000000000000000000001
  192. #define MenuItem2    0b0000000000000000000000000000010
  193. #define MenuItem3    0b0000000000000000000000000000100
  194. #define MenuItem4    0b0000000000