home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / ColorSync SDK / Sample Code / CSDemo 2.1 / ShellSources / win.h < prev   
Encoding:
C/C++ Source or Header  |  1997-06-13  |  7.8 KB  |  243 lines  |  [TEXT/CWIE]

  1.  
  2. #ifndef _WIN_
  3. #define _WIN_
  4.  
  5.  
  6. #ifndef __TYPES__
  7. #include <Types.h>
  8. #endif
  9.  
  10. #ifndef __FILES__
  11. #include <Files.h>
  12. #endif
  13.  
  14. #ifndef __EVENTS__
  15. #include <Events.h>
  16. #endif
  17.  
  18. #ifndef PIGS_SHELL_NOPRINT
  19. #ifndef __PRINTING__
  20. #include <Printing.h>
  21. #endif
  22.  
  23. #ifndef __GXPRINTING__
  24. #include <GXPrinting.h>
  25. #endif
  26. #endif
  27.  
  28.  
  29. /**\
  30. |**| ==============================================================================
  31. |**| PUBLIC DEFINES
  32. |**| ==============================================================================
  33. \**/
  34. #define kDocumentCreator    'ASDF'
  35. #define kWasAlreadyOpen        128
  36.  
  37.  
  38. /**\
  39. |**| ==============================================================================
  40. |**| PUBLIC TYPEDEFS
  41. |**| ==============================================================================
  42. \**/
  43. typedef    struct    _winRecord  winRecord, *winPtr, **winHandle ;
  44.  
  45. /*------------------------------------------------------------------------------*\
  46.     typedefs for the procptrs used by the framework.
  47. \*------------------------------------------------------------------------------*/
  48. typedef    void  (*ActivateProcPtr)    ( winHandle win, Boolean activating ) ;
  49. typedef    void  (*ResumeProcPtr)      ( winHandle win, Boolean resuming ) ;
  50. typedef    void  (*UpdateProcPtr)      ( winHandle win, EventRecord *e) ;
  51. typedef    void  (*ClickProcPtr)       ( winHandle win, EventRecord *e) ;
  52. typedef    void  (*KeyProcPtr)         ( winHandle win, EventRecord *e) ;
  53. typedef    void  (*NullProcPtr)        ( winHandle win, EventRecord *e) ; 
  54. typedef    void  (*MenuProcPtr)        ( winHandle win, long m, Boolean *didit) ;
  55. typedef    void  (*UpdateMenusProcPtr) ( winHandle win ) ;
  56. typedef    void  (*ResizeProcPtr)      ( winHandle win ) ;
  57. typedef    OSErr (*AllocProcPtr)        ( winHandle win ) ; 
  58. typedef    OSErr (*NewProcPtr)         ( winHandle win ) ; 
  59. typedef    OSErr (*OpenProcPtr)        ( winHandle win ) ; 
  60. typedef    void  (*CloseProcPtr)       ( winHandle win ) ; 
  61. typedef    void  (*DisposeProcPtr)        ( winHandle win ) ; 
  62. #ifndef PIGS_SHELL_NOPRINT
  63. typedef    OSErr (*PageCountProcPtr)   ( winHandle win, short *pageCount ) ; 
  64. typedef    OSErr (*PagePrintProcPtr)   ( winHandle win, GrafPtr imagingPort, short pageNum ) ;
  65. #endif
  66. /*------------------------------------------------------------------------------*\
  67.     winRecord structure used by the framework.
  68. \*------------------------------------------------------------------------------*/
  69. struct    _winRecord {
  70. // type & creator of the windows
  71.     OSType                Creator ;            // always 'ASDF' - helps to verify that it is our window
  72.     OSType                Type ;                // this is the type of window (eg 'Pict' 'Abou', etc.)
  73.     OSType                Subtype ;            // this is the type is free for each window type to use
  74.  
  75. // pocedure pointers
  76.     ActivateProcPtr        ActivateProc;
  77.     ResumeProcPtr        ResumeProc;
  78.     UpdateProcPtr        UpdateProc;
  79.     ClickProcPtr        ClickProc;
  80.     KeyProcPtr            KeyProc;
  81.     NullProcPtr            NullProc;
  82.     MenuProcPtr            MenuProc;
  83.     UpdateMenusProcPtr    UpdateMenusProc;
  84.     ResizeProcPtr        ResizeProc;
  85.     AllocProcPtr        AllocProc;
  86.     NewProcPtr            NewProc;
  87.     OpenProcPtr            OpenProc;
  88.     CloseProcPtr        CloseProc;
  89.     DisposeProcPtr        DisposeProc;
  90. #ifndef PIGS_SHELL_NOPRINT
  91.     PageCountProcPtr    PageCountProc;
  92.     PagePrintProcPtr    PagePrintProc;
  93. #endif
  94.  
  95. // basic necessities
  96.     FSSpec                FSSpec ;            // file spec for the win, we don't keep it open
  97.     WindowRef            Window ;            // the graf port/window for the document
  98.     Rect                Rect ;                // the bounds of the document
  99.     Rect                SizeRect ;            // the max/min size of the document
  100.     Boolean                Dirty ;             // true if the file needs to be saved
  101.     
  102. #ifndef PIGS_SHELL_NOPRINT
  103. // print data record (classic & GX)
  104.     THPrint                PrintRec ;            // a print record for the document
  105.     gxJob                GXJob ;                // stores a reference to the win's job format
  106. #endif
  107.  
  108. //content data
  109.     Handle                Data;                // handle to whatever data this document needs
  110.  
  111. } ;
  112.  
  113. typedef struct AllocProcMap
  114. {
  115.     OSType                type ;
  116.     AllocProcPtr        AllocProc ;
  117.     Boolean                printable ;
  118.     Boolean                autoNew ;
  119. } AllocProcMapRec, *AllocProcMapPtr, **AllocProcMapHdl ;
  120.  
  121.  
  122.  
  123. /**\
  124. |**| ==============================================================================
  125. |**| PUBLIC FUNCTION PROTOTYPES
  126. |**| ==============================================================================
  127. \**/
  128. OSErr            NewWinHandle        ( winHandle *win, AllocProcPtr allocProc ) ;
  129. OSErr            DisposeWinHandle    ( winHandle win ) ;
  130.  
  131. winHandle        GetWindowWinHandle    ( WindowRef w ) ;
  132. void            SetWindowWinHandle    ( WindowRef w, winHandle win ) ;
  133.  
  134. winHandle        GetFrontWindowWinHandle ( void ) ;
  135. winHandle        FrontWin            ( void ) ;
  136. winHandle        GetNextWin            ( winHandle win ) ;
  137.  
  138. short            FindWinHandle        ( FSSpec *specPtr,
  139.                                       OSType type,
  140.                                       OSType subtype,
  141.                                       short index,
  142.                                       short count,
  143.                                       winHandle *result ) ;
  144.  
  145. static            Boolean    SameFSSpec    ( FSSpec *fs1, FSSpec *fs2 ) ;
  146.  
  147. OSType        GetWinCreator        ( winHandle win ) ;
  148. void        SetWinCreator        ( winHandle win, OSType creator ) ;
  149.  
  150. OSType        GetWinType            ( winHandle win ) ;
  151. void        SetWinType            ( winHandle win, OSType type ) ;
  152.  
  153. OSType        GetWinSubtype        ( winHandle win ) ;
  154. void        SetWinSubtype        ( winHandle win, OSType type ) ;
  155.  
  156. FSSpec        GetWinFSSpec        ( winHandle win ) ;
  157. void        SetWinFSSpec        ( winHandle win, FSSpec *theFSSpec ) ; 
  158.  
  159. WindowRef    GetWinWindow        ( winHandle win ) ;
  160. void        SetWinWindow        ( winHandle win, WindowRef theWindow ) ;
  161.  
  162. Rect        GetWinRect            ( winHandle win ) ;
  163. void        SetWinRect            ( winHandle win, Rect theRect ) ;
  164.  
  165. Rect        GetWinSizeRect        ( winHandle win ) ;
  166. void        SetWinSizeRect        ( winHandle win, Rect theRect ) ;
  167.  
  168. Boolean        GetWinDirty            ( winHandle win ) ;
  169. void        SetWinDirty            ( winHandle win, Boolean dirty ) ;
  170.  
  171. #ifndef PIGS_SHELL_NOPRINT
  172.  
  173. THPrint        GetWinPrintRec        ( winHandle win ) ;
  174. void        SetWinPrintRec        ( winHandle win, THPrint thePrintRec ) ;
  175.  
  176. gxJob        GetWinGXJob            ( winHandle win ) ;
  177. void        SetWinGXJob            ( winHandle win, gxJob theGXJob ) ;
  178.  
  179. #endif
  180.  
  181. Handle        GetWinData            ( winHandle win ) ;
  182. void        SetWinData            ( winHandle win, Handle h ) ;
  183.  
  184.  
  185. void        CallWinActivateProc    ( winHandle win, Boolean activating ) ;
  186. void        SetWinActivateProc    ( winHandle win, ActivateProcPtr f ) ;
  187.  
  188. void        CallWinResumeProc    ( winHandle win, Boolean resuming ) ;
  189. void        SetWinResumeProc    ( winHandle win, ResumeProcPtr f ) ;
  190.  
  191. void        CallWinUpdateProc    ( winHandle win, EventRecord *e ) ;
  192. void        SetWinUpdateProc    ( winHandle win, UpdateProcPtr f ) ;
  193.  
  194. void        CallWinClickProc    ( winHandle win, EventRecord *e ) ;
  195. void        SetWinClickProc        ( winHandle win, ClickProcPtr f ) ;
  196.  
  197. void        CallWinKeyProc        ( winHandle win, EventRecord *e ) ;
  198. void        SetWinKeyProc        ( winHandle win, KeyProcPtr f ) ;
  199.  
  200. void        CallWinNullProc        ( winHandle win, EventRecord *e ) ;
  201. void        SetWinNullProc        ( winHandle win, NullProcPtr f ) ;
  202.  
  203. void        CallWinMenuProc        ( winHandle win, long m, Boolean *didit ) ;
  204. void        SetWinMenuProc        ( winHandle win, MenuProcPtr f ) ;
  205.  
  206. void        CallWinUpdateMenusProc    ( winHandle win ) ;
  207. void        SetWinUpdateMenusProc    ( winHandle win, UpdateMenusProcPtr f ) ;
  208.  
  209. void        CallWinResizeProc    ( winHandle win ) ;
  210. void        SetWinResizeProc    ( winHandle win, ResizeProcPtr f ) ;
  211.  
  212. OSErr        CallWinAllocProc    ( winHandle win ) ;
  213. void        SetWinAllocProc        ( winHandle win, AllocProcPtr f ) ;
  214.  
  215. OSErr        CallWinNewProc        ( winHandle win ) ;
  216. void        SetWinNewProc        ( winHandle win, NewProcPtr f ) ;
  217.  
  218. OSErr        CallWinOpenProc        ( winHandle win ) ;
  219. void        SetWinOpenProc        ( winHandle win, OpenProcPtr f ) ;
  220.  
  221. void        CallWinCloseProc    ( winHandle win ) ;
  222. void        SetWinCloseProc        ( winHandle win, CloseProcPtr f ) ;
  223.  
  224. void        CallWinDisposeProc    ( winHandle win ) ;
  225. void        SetWinDisposeProc    ( winHandle win, DisposeProcPtr f ) ;
  226.  
  227. #ifndef PIGS_SHELL_NOPRINT
  228.  
  229. OSErr        CallWinPageCountProc    ( winHandle win, short *pageCount ) ;
  230. void        SetWinPageCountProc        ( winHandle win, PageCountProcPtr f ) ;
  231.  
  232. OSErr        CallWinPagePrintProc    ( winHandle win, GrafPtr imagingPort, short pageNum ) ;
  233. void        SetWinPagePrintProc        ( winHandle win, PagePrintProcPtr f ) ;
  234.  
  235. #endif
  236.  
  237. OSErr        CallAllWinNullProcs            ( EventRecord *event ) ;
  238. OSErr        CallAllWinResumeProcs        ( Boolean resuming ) ;
  239. OSErr        CallAllWinUpdateMenusProcs    ( void ) ;
  240. OSErr        CallAllWinMenuProcs            ( long m, Boolean *didit ) ;
  241.  
  242.  
  243. #endif