home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / technical documentation / develop / develop issue 26 / develop issue 26 code / truffles - display mgr. / sprocket / interfaces / sprocket.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-09  |  6.2 KB  |  247 lines

  1. /*
  2.     File:        Sprocket.h
  3.  
  4.     Contains:    Prototypes for the “guts” of a Macintosh application.
  5.  
  6.     Written by: Dave Falkenburg
  7.  
  8.     Copyright:    © 1993-1995 by Dave Falkenburg, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.      
  12.         <12>     1/24/95    DRF        Reincarnate HandleMenu as HandleMenuSelection. Also added even
  13.                                     more predefined command constants.
  14.         <11>     1/20/95    DRF        Added cPreferences command constant.
  15.         <10>      1/3/95    DRF        Added Nitin’s cooler Drag Manager utilities.
  16.          <9>      1/3/95    DRF        Complete overhaul of menu handling: we now have a menubar class,
  17.                                     HandleMenu has been replaced with HandleMenuCommand. Exported
  18.                                     StandardDialogFilterProc and renamed dialog filter UPPs.
  19.                                     StandardCloseDocument is now a method of TDocument. Also added a
  20.                                     global for the splash screen.
  21.          <8>     12/6/94    DRF        Add  “sprocket credits” box resource ID.
  22.          <7>    11/23/94    DRF        Add ToggleCheckBox, a nice little dialog item utility.
  23.          <6>    11/12/94    DRF        AppConditionals.h is now BuildConditionals.h.  Also revised some
  24.                                     QuickDrawGX stuff.
  25.          <5>     11/8/94    DRF        Add prototype for DragDestinationIsTheTrash.
  26.          <4>     9/27/94    DRF        Changed filename to Sprocket.h. Also made scrap coercion
  27.                                      routines more explicit.
  28.          <3>      9/9/94    DRF        Reordered headers and removed redundant #includes.
  29.          <2>      9/4/94    DRF        Added scroll bar constants.
  30.  */
  31.  
  32. #ifndef        _SPROCKET_
  33. #define        _SPROCKET_
  34.  
  35. #ifndef        __CONDITIONALMACROS__
  36. #include    <ConditionalMacros.h>
  37. #endif
  38.  
  39. #ifndef        __TYPES__
  40. #include    <Types.h>
  41. #endif
  42.  
  43. #ifndef        __WINDOWS__
  44. #include    <Windows.h>
  45. #endif
  46.  
  47. #ifndef        __DIALOGS__
  48. #include    <Dialogs.h>
  49. #endif
  50.  
  51. #ifndef        __STANDARDFILE__
  52. #include    <StandardFile.h>    //    for ModalFilterYDUPP
  53. #endif
  54.  
  55. #ifndef        __OCESTANDARDMAIL__
  56. #include    <OCEStandardMail.h>
  57. #endif
  58.  
  59. #ifndef        __DRAG__
  60. #include    <Drag.h>
  61. #endif
  62.  
  63. //#include    "Preferences.h"
  64. #include    "MenuBar.h"
  65. #include    "Window.h"
  66. #include    "SplashWindow.h"
  67.  
  68. #if    qUseQuickDrawGX
  69. #include    <GXTypes.h>
  70. #endif
  71.  
  72. //    useful macros
  73.  
  74. #if    qDebug
  75. #define    DebugMessage(x)    DebugStr(x)
  76. #else
  77. #define    DebugMessage(x)
  78. #endif
  79.  
  80. //    Resource IDs
  81.  
  82. #define    kErrorAlertID                        128
  83. #define    kStandardCloseAlertID                129
  84. #define    kStandardCloseWithNewPubsAlertID    130
  85.  
  86. #define    kCoreErrorStrings                    128
  87. #define    kUnsupportedSystemSoftware            1
  88. #define    kNeedsThreadManager                    2
  89. #define    kNeedsQuickdrawGX                    3
  90.  
  91. #define    kStandardCloseStrings                129
  92. #define    kQuittingStr                        1
  93. #define    kClosingStr                            2
  94.  
  95. #define    kPreferencesFileStrings                130
  96. #define    kPreferencesFileName                1
  97.  
  98. #define    kSplashPictureID                    128
  99.  
  100. #define    kCreditsBox                            131
  101.  
  102. #if        qUseQuickDrawGX
  103. #define    kUseGraphicsSizeResource        0
  104. #define    kAllowGXToExtendGraphicsHeap    ((gxClientAttribute) 0)
  105. #endif
  106.  
  107. //    Useful constants
  108.     
  109. enum
  110.     {
  111.     kScrollbarWidth = 16,    //    width of a standard Macintosh scrollbar
  112.     kScrollbarTweak = 2        //    left edge = rightedge - kScrollbarWidth + kScrollbarTweak
  113.     };
  114.  
  115. //    Well known command IDs
  116.  
  117. enum
  118.     {
  119.     cAbout                = 100,
  120.     
  121.     cNew                = 200,
  122.     cOpen                = 201,
  123.     cClose                = 202,
  124.     cSave                = 203,
  125.     cSaveAs                = 204,
  126.     cRevert                = 205,
  127.     cPageSetup            = 206,
  128.     cCustomPageSetup    = 207,
  129.     cPrint                = 208,
  130.     cPrintOne            = 209,
  131.     cPreferences        = 210,
  132.     cQuit                = 299,
  133.     
  134.     cUndo                = 300,
  135.     cCut                = 301,
  136.     cCopy                = 302,
  137.     cPaste                = 303,
  138.     cClear                = 304,
  139.     cSelectAll            = 305,
  140.     cNewPublisher        = 306,
  141.     cSubscribeTo        = 307,
  142.     cPublishingOptions    = 308,
  143.     cShowClipboard        = 309
  144.     };
  145.  
  146. //    Useful functions provided by Sprocket:
  147.  
  148. void                    HandleEvent(EventRecord *anEvent);
  149.  
  150. short                    StandardAlert(    short alertID,
  151.                                         short defaultItem                = ok,
  152.                                         short cancelItem                = 0,
  153.                                         ModalFilterUPP customFilterProc    = nil);
  154.  
  155. void                    ErrorAlert(short stringList,short whichString);
  156. void                    FatalErrorAlert(short stringList,short whichString);
  157.  
  158. extern ModalFilterUPP    StandardDialogFilterUPP;
  159. extern ModalFilterYDUPP    StandardDialogFilterYDUPP;
  160.  
  161. extern pascal Boolean    StandardDialogFilterProc(DialogRef theDialog, EventRecord* anEvent, short* itemHit);
  162. extern void                PseudoClickInDialogItem(DialogRef theDialog, short itemToClick);
  163. extern Boolean            ToggleCheckBox(DialogRef theDialog, short theCheckBox);
  164. extern void             SetDialogFontAndSize ( DialogRef theDialog, short fontNum, short fontSize );
  165.  
  166. //    This is because it's missing in the 2.1 headers
  167. //    I don't know if it is on purpose or not....
  168. #ifdef __cplusplus
  169. inline TEHandle     GetDialogTextEdit(DialogRef dialog)        { return (*(TEHandle *) (((UInt8 *) dialog) + 160)); }
  170. #else
  171. #define GetDialogTextEdit(dialog)    (*(TEHandle *) (((UInt8 *) dialog) + 160))
  172. #endif
  173.  
  174. short                    OpenPreferencesResFile();
  175.  
  176. //    Drag Manager utilities
  177.  
  178. void                    MakeDragOutlineRegion(RgnHandle theRgn);
  179. OSErr                    GetDropDirectory(DragReference theDrag, FSSpecPtr dirSpec);
  180. Boolean                    DragLandedInTrash(DragReference theDrag);
  181.  
  182.  
  183. //    AOCE “FrontWindow”-equivalent routine for the Standard Mail package
  184. extern FrontWindowUPP    FrontWindowProcForAOCEUPP;
  185.  
  186. //    Globals
  187.  
  188. extern    Boolean                gDone;
  189. extern    TMenuBar *            gMenuBar;
  190. extern    TSplashWindow *        gSplashWindow;
  191.  
  192. extern    Boolean                gHasColorQuickdraw;
  193. extern    Boolean                gHasThreadManager;
  194. extern    Boolean                gHasDragManager;
  195. extern    Boolean                gHasAOCE;
  196. extern    Boolean                gHasDisplayManager;
  197.  
  198. #if    qInlineInputAware
  199. extern    Boolean                gHasTextServices;
  200. extern    Boolean                gHasTSMTE;
  201. #endif
  202.  
  203. #if    qUseQuickDrawGX
  204. extern    Boolean                gHasQuickDrawGX;
  205. extern    long                gQuickDrawGXVersion;
  206. extern    long                gQuickDrawGXPrintingVersion;
  207. extern    gxGraphicsClient    gQuickDrawGXClient;
  208. #endif
  209.  
  210. extern    GrafPtr                gWindowManagerPort;
  211. extern    Rect                gDeskRectangle;
  212. extern    RgnHandle            gMouseRegion;
  213.  
  214. extern    short                gPreferencesRsrcRefNum;
  215.  
  216.  
  217. /////////////////////////////////////////////////////////////////
  218. //
  219. //    Routines that the application MUST supply:
  220.  
  221.  
  222. //    Intialization & tear down:
  223.  
  224. extern    OSErr    SetupApplication();
  225. extern    void    TearDownApplication();
  226.  
  227.  
  228. //    Scrap coercion hooks:
  229.  
  230. extern    void    WriteLocalClipboardToScrap();
  231. extern    void    ReadLocalClipboardFromScrap();
  232.  
  233.  
  234. //    Document handling routines:
  235.  
  236. extern    OSErr    CreateNewDocument();
  237. extern    OSErr    OpenDocument(LetterDescriptor * theDocument, void *);
  238. extern    OSErr    PrintDocument(LetterDescriptor * theDocument, void *);
  239. extern    Boolean    QuitApplication();
  240.  
  241.  
  242. //    Menu Handling
  243.  
  244. extern    void    HandleMenuCommand(MenuCommandID theCommand);
  245. extern    void    HandleMenuSelection(MenuID theMenu,MenuItemID theItem);
  246.  
  247. #endif