home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / what's new / technical documentation / macintosh technotes and q&as / technotes / tn / samplecode.sit.hqx / Sample Code / main.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-22  |  5.6 KB  |  183 lines

  1. /*
  2.     File:        main.h
  3.  
  4.     Contains:    This file is a shell that can be used to build QuickDraw GX applications.
  5.                 It contains all of the required calls to use the GX routines and QuickDraw
  6.                 together. It can put up one or more windows and also supports printing.
  7.  
  8.                 The application is expected to supply the following functions which are
  9.                 called by the shell:
  10.                     void  DoSetup(void);
  11.                     void  DoDraw(WindowPtr);
  12.                     OSErr DoNew(void);
  13.                     void  DoClose(WindowPtr);
  14.                     void  DoIdle(WindowPtr);
  15.                     void  DoTeardown(void);
  16.                     void  DoClick(WindowPtr, Point);
  17.  
  18.     Written by:    Developer Technical Support
  19.  
  20.     Copyright:    © 1992-1997 by Apple Computer, Inc., all rights reserved.
  21.  
  22.     Writers:
  23.  
  24.         (DMH)    Dave Hersey
  25.         (IK)    Ingrid Kelly
  26.  
  27.     Change History (most recent first):
  28.  
  29.          <2>      6/1/97    IK        Modified printing routines for GXGraphics 1.1.6.
  30.          <1>      9/1/92    DMH        First created.
  31. */
  32.  
  33. #include <GXPrinting.h>
  34.  
  35. #include "PrintingLibrary.h"
  36.  
  37. /* ---------------------------------------------------------------------------
  38.     Global variables 
  39.   --------------------------------------------------------------------------- */
  40.  
  41. /*    The following are expected to be initialized by the shell: */
  42.  
  43. /*    main.c: */
  44.  
  45. extern short                 gAppResRefNum;
  46. extern Boolean                gQuitting;
  47. extern long                    gSleep;
  48.  
  49. /*    The following are expected to be initialized by your code: */
  50.  
  51. extern long                    gGraphicsHeapSize;
  52.  
  53. extern GXPrintingEventUPP    gGXPrintingEventUPP;
  54. extern GXFormatDialogUPP    gGXFormatDialogUPP;
  55.  
  56. /* ---------------------------------------------------------------------------
  57.     Constants 
  58.   --------------------------------------------------------------------------- */
  59.  
  60. enum {
  61.     rDocumentWINDID            = 128,
  62.     rAboutBoxALRTID            = 128,
  63.     rNoQuickDrawGXALRTID    = 129,
  64.     rFormatPanelDITLID        = 130
  65. };
  66.  
  67. enum {
  68.     rMenuBar            = 128
  69. };
  70.  
  71. enum {
  72.     mApple                = 128,
  73.         iAbout                = 1,
  74.     mFile                = 129,
  75.         iNew                = 1,
  76.         iOpen                = 2,
  77.         iClose                = 3,
  78.         iSave                = 4,
  79.         iPageSetup            = 6,
  80.         iCustomPageSetup    = 7,
  81.         iPrint                = 8,
  82.         iPrintOneCopy        = 9,
  83.         iQuit                = 11,
  84.     mEdit                = 130,
  85.         iUndo                = 1,
  86.         iCut                = 3,
  87.         iCopy                = 4,
  88.         iPaste                = 5,
  89.         iClear                = 6,
  90.     mDocument            = 131,
  91.         iInsertPage            = 1,
  92.         iDeletePage            = 2,
  93.         iNextPage            = 4,
  94.         iPrevPage            = 5
  95. };
  96.  
  97. /* ---------------------------------------------------------------------------
  98.     Type definitions 
  99.   --------------------------------------------------------------------------- */
  100.  
  101. /*    This is the structure we use to hold our private data for each page of a document. */
  102.  
  103. typedef struct T_Page {
  104.     gxprFormatHdl    gxprFormat;
  105.     gxShape            shape;                    /* QuickDraw GX page shape (contents) */
  106. }    T_Page, *TP_Page, **TH_Page;
  107.  
  108. /*    This is the structure we use to hold our private data for each document.
  109.     We store a handle to one of these beasties in each window's refCon field.
  110. */
  111. typedef struct T_Document {
  112.     WindowPtr        window;
  113.     gxViewPort        viewport;
  114.     gxprJobHdl        gxprJob;
  115.     short            page;                    /* Page displayed in the window. */
  116.     short            pageCount;                /* Number of pages (one based). */
  117.     TH_Page            pageArray[];            /* Array of page data structures (zero based). */
  118. }    T_Document, *TP_Document, **TH_Document;
  119.  
  120. /*    Type tag for the custom collection item of the application. */
  121.  
  122. #define    kCustomCollectionType    'GXSh'
  123.  
  124. /*    Type definition of the custom collection item for the application; this format must
  125.     match that of the 'xdtl' resource.
  126. */
  127. typedef struct
  128. {
  129.     Boolean            one;
  130.     Boolean            two;
  131.     char            three;
  132. }    T_CustomCollection, *TP_CustomCollection, **TH_CustomCollection;
  133.  
  134. /* ---------------------------------------------------------------------------
  135.     Function prototypes 
  136.   --------------------------------------------------------------------------- */
  137.  
  138. /*    main.c: */
  139.  
  140. extern void                main(void);
  141. extern void             InitToolbox(void);
  142. extern Boolean            InitializeGXEnvironment(void);
  143. extern void                TerminateGXEnvironment(void);
  144. extern void                SetGXDebuggingWorld(Boolean debuggingInitInstalled);
  145. extern OSErr            GXPrintingEventOverride(EventRecord *event, Boolean filterEvent);
  146. extern OSErr            GXFormatDialogOverride(gxFormat format, StringPtr title, gxDialogResult *result);
  147.  
  148. /*    menus & windows.c: */
  149.  
  150. extern void                DoSetup(void);
  151. extern void                DoDraw(WindowPtr window);
  152. extern OSErr            InitDocument(WindowPtr window);
  153. extern OSErr            DoNew(void);
  154. extern void                DoClose(WindowPtr window);
  155. extern void                DoIdle(WindowPtr window);
  156. extern void                DoTeardown(void);
  157. extern void                DoClick(WindowPtr window, Point p);
  158. extern void                DoEvent(EventRecord *theEvent);
  159. extern void                DoMenuCommand(long menuResult);
  160. extern void                DoMouseDown(EventRecord *event);
  161. extern void                EventLoop(void);
  162.  
  163. extern TH_Document        GetDocument(WindowPtr window);
  164. extern void                SetDocument(WindowPtr window, TH_Document document);
  165. extern gxViewPort        GetDocumentViewPort(TH_Document document);
  166. extern void                SetDocumentViewPort(TH_Document document, gxViewPort viewport);
  167. extern gxprJobHdl        GetDocumentJob(TH_Document document);
  168. extern void                SetDocumentJob(TH_Document document, gxprJobHdl gxprJob);
  169. extern TH_Page            GetDocumentPage(TH_Document document, short whichPg);
  170. extern void                SetDocumentPage(TH_Document document, short whichPg, TH_Page page);
  171. extern gxprFormatHdl    GetPageFormat(TH_Document document, short whichPg);
  172. extern void                SetPageFormat(TH_Document document, short whichPg, gxprFormatHdl gxprFormat);
  173. extern gxShape            GetPageShape(TH_Document document, short whichPg);
  174. extern void                SetPageShape(TH_Document document, short whichPg, gxShape shape);
  175.  
  176. /*    printing.c: */
  177.  
  178. extern OSErr            DoPageFormat(WindowPtr window, gxDialogResult *result);
  179. extern OSErr            DoCustomPageFormat(WindowPtr window, gxDialogResult *result);
  180. extern OSErr            DoPrint(WindowPtr window);
  181. extern OSErr            DoPrintOneCopy(WindowPtr window);
  182. extern OSErr            DoPrintLoop(WindowPtr window);
  183.