home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / scnote / tesample.002 / TESample.h < prev    next >
Text File  |  1989-06-01  |  10KB  |  248 lines

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware TextEdit Sample Application
  6. #
  7. #    TESample
  8. #
  9. #    TESample.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. #                TESample.p            June 1, 1989
  22. #                TESample.c            June 1, 1989
  23. #                TESampleGlue.a        June 1, 1989    -MPW only-
  24. #                TESample.r            June 1, 1989
  25. #                TESample.h            June 1, 1989
  26. #                PTESample.make        June 1, 1989    -MPW only-
  27. #                CTESample.make        June 1, 1989    -MPW only-
  28. #                TESampleGlue.s        June 1, 1989    -A/UX only-
  29. #                TESampleAUX.r        June 1, 1989    -A/UX only-
  30. #                Makefile            June 1, 1989    -A/UX only-
  31. #
  32. #    TESample is an example application that demonstrates how 
  33. #    to initialize the commonly used toolbox managers, operate 
  34. #    successfully under MultiFinder, handle desk accessories and 
  35. #    create, grow, and zoom windows. The fundamental TextEdit 
  36. #    toolbox calls and TextEdit autoscroll are demonstrated. It 
  37. #    also shows how to create and maintain scrollbar controls.
  38. #
  39. #    It does not by any means demonstrate all the techniques you 
  40. #    need for a large application. In particular, Sample does not 
  41. #    cover exception handling, multiple windows/documents, 
  42. #    sophisticated memory management, printing, or undo. All of 
  43. #    these are vital parts of a normal full-sized application.
  44. #
  45. #    This application is an example of the form of a Macintosh 
  46. #    application; it is NOT a template. It is NOT intended to be 
  47. #    used as a foundation for the next world-class, best-selling, 
  48. #    600K application. A stick figure drawing of the human body may 
  49. #    be a good example of the form for a painting, but that does not 
  50. #    mean it should be used as the basis for the next Mona Lisa.
  51. #
  52. #    We recommend that you review this program or Sample before 
  53. #    beginning a new application. Sample is a simple app. which doesn╒t 
  54. #    use TextEdit or the Control Manager.
  55. #
  56. ------------------------------------------------------------------------------*/
  57.  
  58. /*    These #defines correspond to values in the Pascal source code.
  59.     TESample.c and TESample.r include this file. */
  60.  
  61. /*    Determining an application's minimum size to request from MultiFinder depends
  62.     on many things, each of which can be unique to an application's function,
  63.     the anticipated environment, the developer's attitude of what constitutes
  64.     reasonable functionality and performance, etc. Here is a list of some things to
  65.     consider when determining the minimum size (and preferred size) for your
  66.     application. The list is pretty much in order of importance, but by no means
  67.     complete.
  68.     
  69.     1.    What is the minimum size needed to give almost 100 percent assurance
  70.         that the application won't crash because it ran out of memory? This
  71.         includes not only things that you do have direct control over such as
  72.         checking for NIL handles and pointers, but also things that some
  73.         feel are not so much under their control such as QuickDraw and the
  74.         Segment Loader.
  75.         
  76.     2.    What kind of performance can a user expect from the application when
  77.         it is running in the minimum memory configuration? Performance includes
  78.         not only speed in handling data, but also things like how many documents
  79.         can be opened, etc.
  80.         
  81.     3.    What are the typical sizes of scraps is [a boy dog] that a user might
  82.         wish to work with when lauching or switching to your application? If
  83.         the amount of memory is too small, the scrap may get lost [will have
  84.         to be shot]. This can be quite frustrating to the user.
  85.         
  86.     4.    The previous items have concentrated on topics that tend to cause an
  87.         increase in the minimum size to request from MultiFinder. On the flip
  88.         side, however, should be the consideration of what environments the
  89.         application may be running in. There may be a high probability that
  90.         many users with relatively small memory configurations will want to
  91.         avail themselves of your application. Or, many users might want to use it
  92.         while several other, possibly related/complementary applications are
  93.         running. If that is the case, it would be helpful to have a fairly
  94.         small minimum size.
  95.     
  96.     What we did for TESample:
  97.     
  98.         We determined the smallest heap size that TESample could have and still
  99.         run (22K). For the preferred size we added enough space to permit:
  100.             a. a maximum size TextEdit text handle (32000 characters)
  101.             b. a maximum usable TextEdit scrap (32000 characters)
  102.             b. a maximum scrap as a result of Copy (32000 characters)
  103.             d. a little performance cushion (see 2, above) (10K)
  104.         Result: 122K for preferred size
  105.         
  106.         For the minimum size we took the 22K and then scaled down our requirements
  107.         for a,b, and c above. We thought that providing 16K more would be lean
  108.         and mean (see 4, above).
  109.         Result: 38K for minimum size
  110. */
  111.  
  112. #define kPrefSize                122
  113. #define kMinSize                38
  114.     
  115. /* The following constants are used to identify menus and their items. The menu IDs
  116.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  117. #define    mApple                    128        /* Apple menu */
  118. #define    iAbout                    1
  119.  
  120. #define    mFile                    129        /* File menu */
  121. #define    iNew                    1
  122. #define    iClose                    4
  123. #define    iQuit                    12
  124.  
  125. #define    mEdit                    130        /* Edit menu */
  126. #define    iUndo                    1
  127. #define    iCut                    3
  128. #define    iCopy                    4
  129. #define    iPaste                    5
  130. #define    iClear                    6
  131.  
  132. /*    1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */
  133.  
  134. #define kDITop                    0x0050
  135. #define kDILeft                    0x0070
  136.  
  137. /* 1.01 - changed constants to begin with 'k' for consistency, except for resource IDs */
  138. /*    kTextMargin is the number of pixels we leave blank at the edge of the window. */
  139. #define kTextMargin                2
  140.  
  141. /* kMaxOpenDocuments is used to determine whether a new document can be opened
  142.    or created. We keep track of the number of open documents, and disable the
  143.    menu items that create a new document when the maximum is reached. If the
  144.    number of documents falls below the maximum, the items are enabled again. */
  145. #define    kMaxOpenDocuments        1
  146.     
  147. /*    kMaxDocWidth is an arbitrary number used to specify the width of the TERec's
  148.     destination rectangle so that word wrap and horizontal scrolling can be
  149.     demonstrated. */
  150. #define    kMaxDocWidth            576
  151.     
  152. /* kMinDocDim is used to limit the minimum dimension of a window when GrowWindow
  153.     is called. */
  154. #define    kMinDocDim                64
  155.  
  156. /*    kControlInvisible is used to 'turn off' controls (i.e., cause the control not
  157.     to be redrawn as a result of some Control Manager call such as SetCtlValue)
  158.     by being put into the contrlVis field of the record. kControlVisible is used
  159.     the same way to 'turn on' the control. */
  160. #define kControlInvisible        0
  161. #define kControlVisible            0xFF
  162.  
  163. /*    kScrollbarAdjust and kScrollbarWidth are used in calculating
  164.     values for control positioning and sizing. */
  165. #define kScrollbarWidth            16
  166. #define kScrollbarAdjust        (kScrollbarWidth - 1)
  167.  
  168. /*    kScrollTweek compensates for off-by-one requirements of the scrollbars
  169.  to have borders coincide with the growbox. */
  170. #define kScrollTweek            2
  171.     
  172. /*    kCrChar is used to match with a carriage return when calculating the
  173.     number of lines in the TextEdit record. kDelChar is used to check for
  174.     delete in keyDowns. */
  175. #define kCrChar                    13
  176. #define kDelChar                8
  177.     
  178. /*    kButtonScroll is how many pixels to scroll horizontally when the button part
  179.     of the horizontal scrollbar is pressed. */
  180. #define kButtonScroll            4
  181.     
  182. /*    kMaxTELength is an arbitrary number used to limit the length of text in the TERec
  183.     so that various errors won't occur from too many characters in the text. */
  184. #define    kMaxTELength            32000
  185.  
  186. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  187.    SysEnvRec we understand. */
  188. #define    kSysEnvironsVersion        1
  189.  
  190. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  191.    by MultiFinder. Once we determine that an event is an OSEvent, we look at the
  192.    high byte of the message sent to determine which kind it is. To differentiate
  193.    suspend and resume events we check the resumeMask bit. */
  194. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  195. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  196. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  197. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  198. #define    kNoEvents                0        /* no events mask */
  199.  
  200. /* 1.01 - kMinHeap - This is the minimum result from the following
  201.      equation:
  202.             
  203.             ORD(GetApplLimit) - ORD(ApplicZone)
  204.             
  205.      for the application to run. It will insure that enough memory will
  206.      be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  207.      application, and still give the application some 'breathing room'.
  208.      To derive this number, we ran under a MultiFinder partition that was
  209.      our requested minimum size, as given in the 'SIZE' resource. */
  210.      
  211. #define    kMinHeap                 (29 * 1024)
  212.     
  213. /* 1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called
  214.      at initialization time, for the application to run. This number acts
  215.      as a double-check to insure that there really is enough memory for the
  216.      application to run, including what has been taken up already by
  217.      pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  218.      
  219. #define    kMinSpace                (20 * 1024)
  220.  
  221. /*    kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  222. #define kExtremeNeg                -32768
  223. #define kExtremePos                (32767 - 1)    /* required to address an old region bug */
  224.     
  225. /* kTESlop provides some extra security when pre-flighting edit commands. */
  226. #define    kTESlop                    1024
  227.  
  228. /* The following are indicies into STR# resources. */
  229. #define    eWrongMachine            1
  230. #define    eSmallSize                2
  231. #define    eNoMemory                3
  232. #define    eNoSpaceCut                4
  233. #define    eNoCut                    5
  234. #define    eNoCopy                    6
  235. #define    eExceedPaste            7
  236. #define    eNoSpacePaste            8
  237. #define    eNoWindow                9
  238. #define    eExceedChar                10
  239. #define    eNoPaste                11
  240.  
  241. #define    rMenuBar    128                /* application's menu bar */
  242. #define    rAboutAlert    128                /* about alert */
  243. #define    rUserAlert    129                /* user error alert */
  244. #define    rDocWindow    128                /* application's window */
  245. #define    rVScroll    128                /* vertical scrollbar control */
  246. #define    rHScroll    129                /* horizontal scrollbar control */
  247. #define    kErrStrings    128                /* error string list */
  248.