home *** CD-ROM | disk | FTP | other *** search
- /*
- File: main.h
-
- Contains: This file is a shell that can be used to build QuickDraw GX applications.
- It contains all of the required calls to use the GX routines and QuickDraw
- together. It can put up one or more windows and also supports printing.
-
- The application is expected to supply the following functions which are
- called by the shell:
- void DoSetup(void);
- void DoDraw(WindowPtr);
- OSErr DoNew(void);
- void DoClose(WindowPtr);
- void DoIdle(WindowPtr);
- void DoTeardown(void);
- void DoClick(WindowPtr, Point);
-
- Written by: Developer Technical Support
-
- Copyright: © 1992-1997 by Apple Computer, Inc., all rights reserved.
-
- Writers:
-
- (DMH) Dave Hersey
- (IK) Ingrid Kelly
-
- Change History (most recent first):
-
- <2> 6/1/97 IK Modified printing routines for GXGraphics 1.1.6.
- <1> 9/1/92 DMH First created.
- */
-
- #include <GXPrinting.h>
-
- #include "PrintingLibrary.h"
-
- /* ---------------------------------------------------------------------------
- Global variables
- --------------------------------------------------------------------------- */
-
- /* The following are expected to be initialized by the shell: */
-
- /* main.c: */
-
- extern short gAppResRefNum;
- extern Boolean gQuitting;
- extern long gSleep;
-
- /* The following are expected to be initialized by your code: */
-
- extern long gGraphicsHeapSize;
-
- extern GXPrintingEventUPP gGXPrintingEventUPP;
- extern GXFormatDialogUPP gGXFormatDialogUPP;
-
- /* ---------------------------------------------------------------------------
- Constants
- --------------------------------------------------------------------------- */
-
- enum {
- rDocumentWINDID = 128,
- rAboutBoxALRTID = 128,
- rNoQuickDrawGXALRTID = 129,
- rFormatPanelDITLID = 130
- };
-
- enum {
- rMenuBar = 128
- };
-
- enum {
- mApple = 128,
- iAbout = 1,
- mFile = 129,
- iNew = 1,
- iOpen = 2,
- iClose = 3,
- iSave = 4,
- iPageSetup = 6,
- iCustomPageSetup = 7,
- iPrint = 8,
- iPrintOneCopy = 9,
- iQuit = 11,
- mEdit = 130,
- iUndo = 1,
- iCut = 3,
- iCopy = 4,
- iPaste = 5,
- iClear = 6,
- mDocument = 131,
- iInsertPage = 1,
- iDeletePage = 2,
- iNextPage = 4,
- iPrevPage = 5
- };
-
- /* ---------------------------------------------------------------------------
- Type definitions
- --------------------------------------------------------------------------- */
-
- /* This is the structure we use to hold our private data for each page of a document. */
-
- typedef struct T_Page {
- gxprFormatHdl gxprFormat;
- gxShape shape; /* QuickDraw GX page shape (contents) */
- } T_Page, *TP_Page, **TH_Page;
-
- /* This is the structure we use to hold our private data for each document.
- We store a handle to one of these beasties in each window's refCon field.
- */
- typedef struct T_Document {
- WindowPtr window;
- gxViewPort viewport;
- gxprJobHdl gxprJob;
- short page; /* Page displayed in the window. */
- short pageCount; /* Number of pages (one based). */
- TH_Page pageArray[]; /* Array of page data structures (zero based). */
- } T_Document, *TP_Document, **TH_Document;
-
- /* Type tag for the custom collection item of the application. */
-
- #define kCustomCollectionType 'GXSh'
-
- /* Type definition of the custom collection item for the application; this format must
- match that of the 'xdtl' resource.
- */
- typedef struct
- {
- Boolean one;
- Boolean two;
- char three;
- } T_CustomCollection, *TP_CustomCollection, **TH_CustomCollection;
-
- /* ---------------------------------------------------------------------------
- Function prototypes
- --------------------------------------------------------------------------- */
-
- /* main.c: */
-
- extern void main(void);
- extern void InitToolbox(void);
- extern Boolean InitializeGXEnvironment(void);
- extern void TerminateGXEnvironment(void);
- extern void SetGXDebuggingWorld(Boolean debuggingInitInstalled);
- extern OSErr GXPrintingEventOverride(EventRecord *event, Boolean filterEvent);
- extern OSErr GXFormatDialogOverride(gxFormat format, StringPtr title, gxDialogResult *result);
-
- /* menus & windows.c: */
-
- extern void DoSetup(void);
- extern void DoDraw(WindowPtr window);
- extern OSErr InitDocument(WindowPtr window);
- extern OSErr DoNew(void);
- extern void DoClose(WindowPtr window);
- extern void DoIdle(WindowPtr window);
- extern void DoTeardown(void);
- extern void DoClick(WindowPtr window, Point p);
- extern void DoEvent(EventRecord *theEvent);
- extern void DoMenuCommand(long menuResult);
- extern void DoMouseDown(EventRecord *event);
- extern void EventLoop(void);
-
- extern TH_Document GetDocument(WindowPtr window);
- extern void SetDocument(WindowPtr window, TH_Document document);
- extern gxViewPort GetDocumentViewPort(TH_Document document);
- extern void SetDocumentViewPort(TH_Document document, gxViewPort viewport);
- extern gxprJobHdl GetDocumentJob(TH_Document document);
- extern void SetDocumentJob(TH_Document document, gxprJobHdl gxprJob);
- extern TH_Page GetDocumentPage(TH_Document document, short whichPg);
- extern void SetDocumentPage(TH_Document document, short whichPg, TH_Page page);
- extern gxprFormatHdl GetPageFormat(TH_Document document, short whichPg);
- extern void SetPageFormat(TH_Document document, short whichPg, gxprFormatHdl gxprFormat);
- extern gxShape GetPageShape(TH_Document document, short whichPg);
- extern void SetPageShape(TH_Document document, short whichPg, gxShape shape);
-
- /* printing.c: */
-
- extern OSErr DoPageFormat(WindowPtr window, gxDialogResult *result);
- extern OSErr DoCustomPageFormat(WindowPtr window, gxDialogResult *result);
- extern OSErr DoPrint(WindowPtr window);
- extern OSErr DoPrintOneCopy(WindowPtr window);
- extern OSErr DoPrintLoop(WindowPtr window);
-