home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / macintosh-c / macc-carbon-demos-nonbinhex.sit / macc-carbon-demos-nonbinhex / chap26-demo / MLTETextEditor.h < prev    next >
Text File  |  2001-05-31  |  7KB  |  168 lines

  1. // *******************************************************************************************
  2. // MTLETextEditor.h                                                        CLASSIC EVENT MODEL
  3. // *******************************************************************************************
  4. //
  5. // This program demonstrates the use of the Multilingual Text Engine API to create a basic
  6. // multi-styled text editor.  New documents created by the program are created and saved as
  7. // Textension ('txtn') documents.  Existing 'TEXT' documents and Unicode ('utxt') documents
  8. // are saved in the original format.  In the case of 'TEXT' documents, style information is
  9. // saved in a 'styl' resource. 
  10. //
  11. // The program utilises the following resources:
  12. //
  13. // •    A 'plst' resource.
  14. //
  15. // •    An 'MBAR' resource, and 'MENU' resources for Apple, File, Edit, Size, Style, Colour,
  16. //        and Justification (preload, non-purgeable).  
  17. //
  18. // •    A 'WIND' resource (purgeable) (initially not visible).  
  19. //
  20. // •    A 'STR ' resource (purgeable) containing the "missing application name" string, which is
  21. //        copied to all document files created by the program.
  22. //
  23. // •    'STR#' resources (purgeable) containing error strings, the application's name (for
  24. //        certain Navigation Services functions), and strings for the Edit menu Undo and Redo
  25. //        items.
  26. //
  27. // •    A 'kind' resource (purgeable) describing file types, which is used by Navigation 
  28. //        Services to    build the native file types section of the Show pop-up menu in the Open
  29. //        dialog box.
  30. //
  31. // •    An 'open' resource (purgeable) containing the file type list for the Open dialog box.
  32. //
  33. // •    The 'BNDL' resource (non-purgeable), 'FREF' resources (non-purgeable), signature
  34. //        resource (non-purgeable), and icon family resources (purgeable), required to support the
  35. //        built application.
  36. //
  37. // •    A 'SIZE' resource with the acceptSuspendResumeEvents, canBackground, 
  38. //        doesActivateOnFGSwitch, and isHighLevelEventAware flags set.
  39. //
  40. // *******************************************************************************************
  41.  
  42. // ………………………………………………………………………………………………………………………………………………………………………………………………………………………… includes
  43.  
  44. #include <Carbon.h>
  45.  
  46. // …………………………………………………………………………………………………………………………………………………………………………………………………………………………… defines
  47.  
  48. #define rMenubar                                128
  49. #define mAppleApplication                128
  50. #define  iAbout                                    1
  51. #define mFile                                        129
  52. #define  iNew                                        1
  53. #define  iOpen                                    2
  54. #define  iClose                                    4
  55. #define  iSave                                    5
  56. #define  iSaveAs                                6
  57. #define  iRevert                                7
  58. #define  iPageSetup                            9
  59. #define  iPrint                                    10
  60. #define  iQuit                                    12
  61. #define mEdit                                        130
  62. #define  iUndo                                    1
  63. #define  iRedo                                    2
  64. #define  iCut                                        4
  65. #define  iCopy                                    5
  66. #define  iPaste                                    6
  67. #define  iClear                                    7
  68. #define  iSelectAll                            8
  69. #define mFont                                        131
  70. #define mSize                                        132
  71. #define  iTwelve                                4
  72. #define mStyle                                    133
  73. #define  iPlain                                    1
  74. #define  iBold                                    3
  75. #define  iUnderline                            5
  76. #define mColour                                    134
  77. #define  iBlack                                    4
  78. #define  iColourPicker                    6
  79. #define mJustification                    135
  80. #define  iDefault                                1
  81. #define  iLeft                                    2
  82. #define  iForceFull                            6
  83. #define mWindow                                    136
  84. #define mFirstHierarchical            160
  85.  
  86. #define rNewWindow                            128
  87. #define rAboutDialog                        128
  88. #define rErrorStrings                        128
  89. #define  eInstallHandler                1000
  90. #define  eMaxWindows                        1001
  91. #define  eCantFindFinderProcess    1002
  92. #define rMiscellaneousStrings        129
  93. #define  sApplicationName                1
  94. #define rOpenResource                        128
  95.  
  96. #define kMaxWindows                            8
  97. #define kOpen                                        0
  98. #define kPrint                                    1
  99. #define kFileCreator            'bbJk'
  100. #define MAX_UINT32                            0xFFFFFFFF
  101. #define MIN(a,b)                                 ((a) < (b) ? (a) : (b))
  102. #define topLeft(r)                            (((Point *) &(r))[0])
  103.  
  104. #define kATSUCGContextTag                32767L
  105.  
  106. // …………………………………………………………………………………………………………………………………………………………………………………………… function prototypes
  107.  
  108. void            main                                                    (void);
  109. void            doPreliminaries                                (void);
  110. void            doInitialiseMTLE                            (void);
  111. void            doInstallAEHandlers                        (void);
  112. void            eventLoop                                            (void);
  113. UInt32        doGetSleepTime                                (void);
  114. void            doIdle                                                (void);
  115. void            doEvents                                            (EventRecord *);
  116. void            doMouseDown                                        (EventRecord *);
  117. void            doBringFinderToFront                    (void);
  118. OSStatus    doFindProcess                                    (OSType,OSType,ProcessSerialNumber *);
  119. void            doActivate                                        (EventRecord *);
  120. void            doUpdate                                            (EventRecord *);
  121. Boolean        isApplicationWindow                        (WindowRef,TXNObject *);
  122. void            doAboutDialog                                    (void);
  123. void            doSynchroniseFiles                        (void);
  124. OSStatus    openAppEventHandler                        (AppleEvent *,AppleEvent *,SInt32);
  125. OSStatus    reopenAppEventHandler                    (AppleEvent *,AppleEvent *,SInt32);
  126. OSStatus    openAndPrintDocsEventHandler    (AppleEvent *,AppleEvent *,SInt32);
  127. OSStatus    quitAppEventHandler                        (AppleEvent *,AppleEvent *,SInt32);
  128. OSStatus    doHasGotRequiredParams                (AppleEvent *);
  129. void            doErrorAlert                                    (SInt16);
  130. void            doCopyPString                                    (Str255,Str255);
  131. void            doConcatPStrings                            (Str255,Str255);
  132.  
  133. void            doEnableDisableMenus                    (Boolean);
  134. void            doAdjustAndPrepareMenus                (void);
  135. void            doAdjustFileMenu                            (MenuRef,WindowRef);
  136. void            doAdjustEditMenu                            (MenuRef,WindowRef);
  137. void            doPrepareFontMenu                            (WindowRef);
  138. void            doPrepareSizeMenu                            (MenuRef,WindowRef);
  139. void            doPrepareStyleMenu                        (MenuRef,WindowRef);
  140. void            doPrepareColourMenu                        (MenuRef,WindowRef);
  141. Boolean        isEqualRGB                                        (RGBColor *,RGBColor *);
  142. void            doPrepareJustificationMenu        (MenuRef,WindowRef);
  143. void            doMenuChoice                                    (SInt32);
  144. void            doFileMenuChoice                            (MenuItemIndex,WindowRef);
  145. void            doEditMenuChoice                            (MenuItemIndex,WindowRef);
  146. void            doFontMenuChoice                            (MenuID,MenuItemIndex,WindowRef);
  147. void            doSizeMenuChoice                            (MenuItemIndex,WindowRef);
  148. void            doStyleMenuChoice                            (MenuItemIndex,WindowRef);
  149. void            doColourMenuChoice                        (MenuItemIndex,WindowRef);
  150. void            doJustificationMenuChoice            (MenuItemIndex,WindowRef);
  151.  
  152. OSStatus    doNewCommand                                    (void);
  153. OSStatus    doOpenCommand                                    (void);
  154. OSStatus    doCloseCommand                                (NavAskSaveChangesAction);
  155. OSStatus    doSaveCommand                                    (void);
  156. OSStatus    doSaveAsCommand                                (void);
  157. OSStatus    doRevertCommand                                (void);
  158. OSStatus    doQuitCommand                                    (NavAskSaveChangesAction);
  159. OSStatus    doNewDocWindow                                (WindowRef *,FSSpec *,TXNFileType);
  160. OSStatus    doOpenFile                                        (FSSpec,OSType);
  161. void            doCloseWindow                                    (WindowRef,TXNObject);
  162. OSStatus    doWriteFile                                        (WindowRef,Boolean);
  163. OSStatus    doCopyResources                                (FSSpec,TXNFileType,Boolean);
  164. OSStatus    doCopyAResource                                (ResType,SInt16,SInt16,SInt16);
  165. void            navEventFunction                            (NavEventCallbackMessage,NavCBRecPtr,
  166.                                                                                  NavCallBackUserData);
  167.  
  168. // *******************************************************************************************