home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / macintosh-c / macc-carbon-demos-nonbinhex.sit / macc-carbon-demos-nonbinhex / chap15-demo / CarbonPrinting.h < prev    next >
Text File  |  2001-06-25  |  4KB  |  112 lines

  1. // *******************************************************************************************
  2. // CarbonPrinting.h                                                        CLASSIC EVENT MODEL
  3. // *******************************************************************************************
  4. // 
  5. // This program:
  6. //
  7. // •    Demonstrates printing using the Carbon Printing Manager session functions. 
  8. //
  9. // •    Opens two windows. The first window is a document window in which is displayed the
  10. //        document to be printed.  The second window displays some printing-related information
  11. //        obtained from PMPageFormat and PMPrintSettings objects.
  12. //
  13. // •    Customises the Pring dialog by adding a pop-up menu button, three radio buttons, a 
  14. //        checkbox, and a group box. 
  15. //
  16. // •    Allows the user to print a document containing a picture and text, with the text
  17. //        being printed in the font and font size, and with the fractional widths setting, 
  18. //        specified using the items added to the Print dialog.
  19. //
  20. // The customising of the Print dialog uses the AppendDITL method.  Accordingly, on Mac OS X,
  21. // the dialogs are application-modal and are not displayed as window-modal sheet dialogs.
  22. //
  23. // The program utilises the following resources:
  24. //
  25. // •    A 'plst' resource.
  26. //
  27. // •    'MBAR' resource and associated 'MENU' resources (preload, non-purgeable).
  28. //
  29. // •    Two 'WIND' resources (purgeable).
  30. //
  31. // •    A 'TEXT' resource (purgeable) used for printing.
  32. //
  33. // •    A 'PICT' resource (non-purgeable) used for printing.
  34. //
  35. // •    'CNTL' resources (purgeable) for controls added to the Print dialog box.
  36. //
  37. // •    A 'DITL' resource (purgeable) specifying the items to be appended to the Print dialog
  38. //        box.
  39. //
  40. // •    A 'MENU' resource (preload, non-purgeable) for the pop-up menu button.
  41. //
  42. // •    A 'SIZE' resource with the acceptSuspendResumeEvents, canBackground, 
  43. //        doesActivateOnFGSwitch, and isHighLevelEventAware flags set.
  44. //
  45. // *******************************************************************************************
  46.  
  47. // ………………………………………………………………………………………………………………………………………………………………………………………………………………………… includes
  48.  
  49. #include <Carbon.h>
  50.  
  51. // …………………………………………………………………………………………………………………………………………………………………………………………………………………………… defines
  52.  
  53. #define rMenubar                                128
  54. #define mAppleApplication                128
  55. #define  iAbout                                    1
  56. #define mFile                                        129
  57. #define  iPageSetup                            9
  58. #define  iPrint                                    10
  59. #define  iQuit                                    12
  60. #define mFont                                        131
  61. #define rDocWindow                            128
  62. #define rInfoWindow                            129
  63. #define rText                                        128
  64. #define rPicture                                128
  65. #define rPrintDialogAppendDITL    128
  66. #define  iPopupButton                        1
  67. #define  iRadioButton10pt                2
  68. #define  iRadioButton12pt                3
  69. #define  iRadioButton14pt                4
  70. #define  iCheckboxFracWidths        5
  71. #define kMargin                                    90
  72. #define MAX_UINT32                            0xFFFFFFFF
  73. #define MIN(a,b)                                 ((a) < (b) ? (a) : (b))
  74.  
  75. // ………………………………………………………………………………………………………………………………………………………………………………………………………………………… typedefs
  76.  
  77. typedef struct
  78. {
  79.     PMPrintSession    printSession;
  80.     PMPageFormat        pageFormat;
  81.     PMPrintSettings    printSettings;
  82.     TEHandle                editTextStrucHdl;
  83.     PicHandle                pictureHdl;
  84. } docStructure, *docStructurePtr, **docStructureHdl;
  85.  
  86. // …………………………………………………………………………………………………………………………………………………………………………………………… function prototypes
  87.  
  88. void            main                                                    (void);
  89. void            doPreliminaries                                (void);
  90. OSErr            quitAppEventHandler                        (AppleEvent *,AppleEvent *,SInt32);
  91. void            doGetDocument                                    (void);
  92. void            doEvents                                            (EventRecord *);
  93. void            doUpdate                                            (EventRecord *);
  94. void            doUpdateDocumentWindow                (WindowRef);
  95. void            doMenuChoice                                    (SInt32);
  96. OSStatus    doCreateOrValidatePageFormat    (WindowRef);
  97. OSStatus    doPageSetUpDialog                            (WindowRef);
  98. OSStatus    doPrintSettingsDialog                    (WindowRef);
  99. OSStatus    doPrinting                                        (WindowRef);
  100. SInt16        doCalcNumberOfPages                        (WindowRef,Rect);
  101. void            doDrawPage                                        (WindowRef,Rect,SInt16,SInt16);
  102. void            doDrawPrintInfo                                (void);
  103. void            doDrawRectStrings                            (Str255,SInt16,SInt16,Str255,SInt16,SInt16,Str255);
  104. void            doErrorAlert                                    (OSStatus);
  105. void            doConcatPStrings                            (Str255,Str255);
  106.  
  107. void            initialisationFunction                (PMPrintSettings, PMDialog *);
  108. void            itemEvaluationFunction                (DialogPtr,SInt16);
  109. Boolean        eventFilter                                        (DialogPtr,EventRecord *,SInt16 *);
  110.  
  111. // *******************************************************************************************
  112.