home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Sprocket.h
-
- Contains: Prototypes for the “guts” of a Macintosh application.
-
- Written by: Dave Falkenburg
-
- Copyright: © 1993-1995 by Dave Falkenburg, all rights reserved.
-
- Change History (most recent first):
-
- <12> 1/24/95 DRF Reincarnate HandleMenu as HandleMenuSelection. Also added even
- more predefined command constants.
- <11> 1/20/95 DRF Added cPreferences command constant.
- <10> 1/3/95 DRF Added Nitin’s cooler Drag Manager utilities.
- <9> 1/3/95 DRF Complete overhaul of menu handling: we now have a menubar class,
- HandleMenu has been replaced with HandleMenuCommand. Exported
- StandardDialogFilterProc and renamed dialog filter UPPs.
- StandardCloseDocument is now a method of TDocument. Also added a
- global for the splash screen.
- <8> 12/6/94 DRF Add “sprocket credits” box resource ID.
- <7> 11/23/94 DRF Add ToggleCheckBox, a nice little dialog item utility.
- <6> 11/12/94 DRF AppConditionals.h is now BuildConditionals.h. Also revised some
- QuickDrawGX stuff.
- <5> 11/8/94 DRF Add prototype for DragDestinationIsTheTrash.
- <4> 9/27/94 DRF Changed filename to Sprocket.h. Also made scrap coercion
- routines more explicit.
- <3> 9/9/94 DRF Reordered headers and removed redundant #includes.
- <2> 9/4/94 DRF Added scroll bar constants.
- */
-
- #ifndef _SPROCKET_
- #define _SPROCKET_
-
- #ifndef __CONDITIONALMACROS__
- #include <ConditionalMacros.h>
- #endif
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __STANDARDFILE__
- #include <StandardFile.h> // for ModalFilterYDUPP
- #endif
-
- #ifndef __OCESTANDARDMAIL__
- #include <OCEStandardMail.h>
- #endif
-
- #ifndef __DRAG__
- #include <Drag.h>
- #endif
-
- //#include "Preferences.h"
- #include "MenuBar.h"
- #include "Window.h"
- #include "SplashWindow.h"
-
- #if qUseQuickDrawGX
- #include <GXTypes.h>
- #endif
-
- // useful macros
-
- #if qDebug
- #define DebugMessage(x) DebugStr(x)
- #else
- #define DebugMessage(x)
- #endif
-
- // Resource IDs
-
- #define kErrorAlertID 128
- #define kStandardCloseAlertID 129
- #define kStandardCloseWithNewPubsAlertID 130
-
- #define kCoreErrorStrings 128
- #define kUnsupportedSystemSoftware 1
- #define kNeedsThreadManager 2
- #define kNeedsQuickdrawGX 3
-
- #define kStandardCloseStrings 129
- #define kQuittingStr 1
- #define kClosingStr 2
-
- #define kPreferencesFileStrings 130
- #define kPreferencesFileName 1
-
- #define kSplashPictureID 128
-
- #define kCreditsBox 131
-
- #if qUseQuickDrawGX
- #define kUseGraphicsSizeResource 0
- #define kAllowGXToExtendGraphicsHeap ((gxClientAttribute) 0)
- #endif
-
- // Useful constants
-
- enum
- {
- kScrollbarWidth = 16, // width of a standard Macintosh scrollbar
- kScrollbarTweak = 2 // left edge = rightedge - kScrollbarWidth + kScrollbarTweak
- };
-
- // Well known command IDs
-
- enum
- {
- cAbout = 100,
-
- cNew = 200,
- cOpen = 201,
- cClose = 202,
- cSave = 203,
- cSaveAs = 204,
- cRevert = 205,
- cPageSetup = 206,
- cCustomPageSetup = 207,
- cPrint = 208,
- cPrintOne = 209,
- cPreferences = 210,
- cQuit = 299,
-
- cUndo = 300,
- cCut = 301,
- cCopy = 302,
- cPaste = 303,
- cClear = 304,
- cSelectAll = 305,
- cNewPublisher = 306,
- cSubscribeTo = 307,
- cPublishingOptions = 308,
- cShowClipboard = 309
- };
-
- // Useful functions provided by Sprocket:
-
- void HandleEvent(EventRecord *anEvent);
-
- short StandardAlert( short alertID,
- short defaultItem = ok,
- short cancelItem = 0,
- ModalFilterUPP customFilterProc = nil);
-
- void ErrorAlert(short stringList,short whichString);
- void FatalErrorAlert(short stringList,short whichString);
-
- extern ModalFilterUPP StandardDialogFilterUPP;
- extern ModalFilterYDUPP StandardDialogFilterYDUPP;
-
- extern pascal Boolean StandardDialogFilterProc(DialogRef theDialog, EventRecord* anEvent, short* itemHit);
- extern void PseudoClickInDialogItem(DialogRef theDialog, short itemToClick);
- extern Boolean ToggleCheckBox(DialogRef theDialog, short theCheckBox);
- extern void SetDialogFontAndSize ( DialogRef theDialog, short fontNum, short fontSize );
-
- // This is because it's missing in the 2.1 headers
- // I don't know if it is on purpose or not....
- #ifdef __cplusplus
- inline TEHandle GetDialogTextEdit(DialogRef dialog) { return (*(TEHandle *) (((UInt8 *) dialog) + 160)); }
- #else
- #define GetDialogTextEdit(dialog) (*(TEHandle *) (((UInt8 *) dialog) + 160))
- #endif
-
- short OpenPreferencesResFile();
-
- // Drag Manager utilities
-
- void MakeDragOutlineRegion(RgnHandle theRgn);
- OSErr GetDropDirectory(DragReference theDrag, FSSpecPtr dirSpec);
- Boolean DragLandedInTrash(DragReference theDrag);
-
-
- // AOCE “FrontWindow”-equivalent routine for the Standard Mail package
- extern FrontWindowUPP FrontWindowProcForAOCEUPP;
-
- // Globals
-
- extern Boolean gDone;
- extern TMenuBar * gMenuBar;
- extern TSplashWindow * gSplashWindow;
-
- extern Boolean gHasColorQuickdraw;
- extern Boolean gHasThreadManager;
- extern Boolean gHasDragManager;
- extern Boolean gHasAOCE;
- extern Boolean gHasDisplayManager;
-
- #if qInlineInputAware
- extern Boolean gHasTextServices;
- extern Boolean gHasTSMTE;
- #endif
-
- #if qUseQuickDrawGX
- extern Boolean gHasQuickDrawGX;
- extern long gQuickDrawGXVersion;
- extern long gQuickDrawGXPrintingVersion;
- extern gxGraphicsClient gQuickDrawGXClient;
- #endif
-
- extern GrafPtr gWindowManagerPort;
- extern Rect gDeskRectangle;
- extern RgnHandle gMouseRegion;
-
- extern short gPreferencesRsrcRefNum;
-
-
- /////////////////////////////////////////////////////////////////
- //
- // Routines that the application MUST supply:
-
-
- // Intialization & tear down:
-
- extern OSErr SetupApplication();
- extern void TearDownApplication();
-
-
- // Scrap coercion hooks:
-
- extern void WriteLocalClipboardToScrap();
- extern void ReadLocalClipboardFromScrap();
-
-
- // Document handling routines:
-
- extern OSErr CreateNewDocument();
- extern OSErr OpenDocument(LetterDescriptor * theDocument, void *);
- extern OSErr PrintDocument(LetterDescriptor * theDocument, void *);
- extern Boolean QuitApplication();
-
-
- // Menu Handling
-
- extern void HandleMenuCommand(MenuCommandID theCommand);
- extern void HandleMenuSelection(MenuID theMenu,MenuItemID theItem);
-
- #endif