home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / scnote / sample.001 / Sample.h < prev    next >
Text File  |  1989-06-01  |  9KB  |  204 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. #                1.03                06/89
  19. #
  20. #    Components:
  21. #                Sample.p            June 1, 1989
  22. #                Sample.c            June 1, 1989
  23. #                Sample.a            June 1, 1989
  24. #                Sample.inc1.a        June 1, 1989
  25. #                SampleMisc.a        June 1, 1989
  26. #                Sample.r            June 1, 1989
  27. #                Sample.h            June 1, 1989
  28. #                PSample.make        June 1, 1989
  29. #                CSample.make        June 1, 1989
  30. #                ASample.make        June 1, 1989
  31. #
  32. #    Sample is an example application that demonstrates how to
  33. #    initialize the commonly used toolbox managers, operate 
  34. #    successfully under MultiFinder, handle desk accessories, 
  35. #    and create, grow, and zoom windows.
  36. #
  37. #    It does not by any means demonstrate all the techniques 
  38. #    you need for a large application. In particular, Sample 
  39. #    does not cover exception handling, multiple windows/documents, 
  40. #    sophisticated memory management, printing, or undo. All of 
  41. #    these are vital parts of a normal full-sized application.
  42. #
  43. #    This application is an example of the form of a Macintosh 
  44. #    application; it is NOT a template. It is NOT intended to be 
  45. #    used as a foundation for the next world-class, best-selling, 
  46. #    600K application. A stick figure drawing of the human body may 
  47. #    be a good example of the form for a painting, but that does not 
  48. #    mean it should be used as the basis for the next Mona Lisa.
  49. #
  50. #    We recommend that you review this program or TESample before 
  51. #    beginning a new application.
  52. ------------------------------------------------------------------------------*/
  53.  
  54. /*    These #defines correspond to values defined in the Pascal source code.
  55.     Sample.c and Sample.r include this file. */
  56.  
  57. /*    Determining an application's minimum size to request from MultiFinder depends
  58.     on many things, each of which can be unique to an application's function,
  59.     the anticipated environment, the developer's attitude of what constitutes
  60.     reasonable functionality and performance, etc. Here is a list of some things to
  61.     consider when determining the minimum size (and preferred size) for your
  62.     application. The list is pretty much in order of importance, but by no means
  63.     complete.
  64.     
  65.     1.    What is the minimum size needed to give almost 100 percent assurance
  66.         that the application won't crash because it ran out of memory? This
  67.         includes not only things that you do have direct control over such as
  68.         checking for NIL handles and pointers, but also things that some
  69.         feel are not so much under their control such as QuickDraw and the
  70.         Segment Loader.
  71.         
  72.     2.    What kind of performance can a user expect from the application when
  73.         it is running in the minimum memory configuration? Performance includes
  74.         not only speed in handling data, but also things like how many documents
  75.         can be opened, etc.
  76.         
  77.     3.    What are the typical sizes of scraps [is a boy dog] that a user might
  78.         wish to work with when lauching or switching to your application? If
  79.         the amount of memory is too small, the scrap may get lost [will have
  80.         to be shot]. This can be quite frustrating to the user.
  81.         
  82.     4.    The previous items have concentrated on topics that tend to cause an
  83.         increase in the minimum size to request from MultiFinder. On the flip
  84.         side, however, should be the consideration of what environments the
  85.         application may be running in. There may be a high probability that
  86.         many users with relatively small memory configurations will want to
  87.         avail themselves of your application. Or, many users might want to use it
  88.         while several other, possibly related/complementary applications are
  89.         running. If that is the case, it would be helpful to have a fairly
  90.         small minimum size.
  91.     
  92.     So, what did we decide on Sample? First, Sample has little risk of
  93.     running out of memory once it starts. Second, performance isn't much
  94.     of an issue since it doesn't do much and multiple windows are not
  95.     allowed. Third, there are no edit operations in Sample itself, so we
  96.     just want to provide enough space for a reasonable scrap to survive
  97.     between desk accessory launches. Lastly, Sample should intrude as little
  98.     as possible, so the effort should be towards making it as small as possible.
  99.     We looked at some heap dumps while the application was running under
  100.     various partition sizes. With a size of 23K, there was approximately
  101.     8-9K free, which is a good 'slop' factor in an application like this
  102.     which doesn't do much, but where we'd still like the scrap to survive
  103.     most of the time. */
  104.  
  105. #define kMinSize    23                /* application's minimum size (in K) */
  106.  
  107. /*    We made the preferred size bigger than the minimum size by 12K, so that
  108.     there would be even more room for the scrap, FKEYs, etc. */
  109.  
  110. #define kPrefSize    35                /* application's preferred size (in K) */
  111.  
  112. #define    rMenuBar    128                /* application's menu bar */
  113. #define    rAboutAlert    128                /* about alert */
  114. #define    rUserAlert    129                /* error user alert */
  115. #define    rWindow        128                /* application's window */
  116. #define rStopRect    128                /* rectangle for Stop light */
  117. #define rGoRect        129                /* rectangle for Go light */
  118.  
  119. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  120.    SysEnvRec we understand. */
  121.  
  122. #define    kSysEnvironsVersion        1
  123.  
  124. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  125.    by MultiFinder. Once we determine that an event is an osEvent, we look at the
  126.    high byte of the message sent to determine which kind it is. To differentiate
  127.    suspend and resume events we check the resumeMask bit. */
  128.  
  129. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  130. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  131. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  132. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  133. #define    kNoEvents                0        /* no events mask */
  134.  
  135. /* The following constants are used to identify menus and their items. The menu IDs
  136.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  137.  
  138. #define    mApple                    128        /* Apple menu */
  139. #define    iAbout                    1
  140.  
  141. #define    mFile                    129        /* File menu */
  142. #define    iNew                    1
  143. #define    iClose                    4
  144. #define    iQuit                    12
  145.  
  146. #define    mEdit                    130        /* Edit menu */
  147. #define    iUndo                    1
  148. #define    iCut                    3
  149. #define    iCopy                    4
  150. #define    iPaste                    5
  151. #define    iClear                    6
  152.  
  153. #define    mLight                    131        /* Light menu */
  154. #define    iStop                    1
  155. #define    iGo                        2
  156.  
  157. /*    1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */
  158.  
  159. #define kDITop                    0x0050
  160. #define kDILeft                    0x0070
  161.  
  162. /*    1.01 - kMinHeap - This is the minimum result from the following
  163.     equation:
  164.         
  165.         ORD(GetApplLimit) - ORD(ApplicZone)
  166.         
  167.     for the application to run. It will insure that enough memory will
  168.     be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  169.     application, and still give the application some 'breathing room'.
  170.     To derive this number, we ran under a MultiFinder partition that was
  171.     our requested minimum size, as given in the 'SIZE' resource. */
  172.      
  173. #define kMinHeap                21 * 1024
  174.     
  175. /*    1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called
  176.     at initialization time, for the application to run. This number acts
  177.     as a double-check to insure that there really is enough memory for the
  178.     application to run, including what has been taken up already by
  179.     pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  180.      
  181. #define kMinSpace                8 * 1024
  182.  
  183. /* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  184.  
  185. #define kExtremeNeg                -32768
  186. #define kExtremePos                32767 - 1 /* required to address an old region bug */
  187.  
  188. /* these #defines are used to set enable/disable flags of a menu */
  189.  
  190. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  191. #define NoItems        0b0000000000000000000000000000000
  192. #define MenuItem1    0b0000000000000000000000000000001
  193. #define MenuItem2    0b0000000000000000000000000000010
  194. #define MenuItem3    0b0000000000000000000000000000100
  195. #define MenuItem4    0b0000000000000000000000000001000
  196. #define MenuItem5    0b0000000000000000000000000010000
  197. #define MenuItem6    0b0000000000000000000000000100000
  198. #define MenuItem7    0b0000000000000000000000001000000
  199. #define MenuItem8    0b0000000000000000000000010000000
  200. #define MenuItem9    0b0000000000000000000000100000000
  201. #define MenuItem10    0b0000000000000000000001000000000
  202. #define MenuItem11    0b0000000000000000000010000000000
  203. #define MenuItem12    0b0000000000000000000100000000000
  204.