1 /* 2 * Copyright 2001-2007, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Philippe Houdoin 7 * Simon Gauvin 8 * Michael Pfeiffer 9 * Dr. Hartmut Reh 10 */ 11 12 #ifndef PRINTERDRIVER_H 13 #define PRINTERDRIVER_H 14 15 #include <AppKit.h> 16 #include <InterfaceKit.h> 17 #include "InterfaceUtils.h" 18 19 class BNode; 20 21 #ifndef ROUND_UP 22 #define ROUND_UP(x, y) (((x) + (y) - 1) & ~((y) - 1)) 23 #endif 24 25 #define MAX_INT32 ((int32)0x7fffffffL) 26 27 /* copied from PDFlib.h: */ 28 #define a0_width (float) 2380.0 29 #define a0_height (float) 3368.0 30 #define a1_width (float) 1684.0 31 #define a1_height (float) 2380.0 32 #define a2_width (float) 1190.0 33 #define a2_height (float) 1684.0 34 #define a3_width (float) 842.0 35 #define a3_height (float) 1190.0 36 #define a4_width (float) 595.0 37 #define a4_height (float) 842.0 38 #define a5_width (float) 421.0 39 #define a5_height (float) 595.0 40 #define a6_width (float) 297.0 41 #define a6_height (float) 421.0 42 #define b5_width (float) 501.0 43 #define b5_height (float) 709.0 44 #define letter_width (float) 612.0 45 #define letter_height (float) 792.0 46 #define legal_width (float) 612.0 47 #define legal_height (float) 1008.0 48 #define ledger_width (float) 1224.0 49 #define ledger_height (float) 792.0 50 #define p11x17_width (float) 792.0 51 #define p11x17_height (float) 1224.0 52 53 54 /** 55 * Class PrinterDriver 56 */ 57 class PrinterDriver 58 { 59 public: 60 // constructors / destructor 61 PrinterDriver(BNode* printerNode); 62 virtual ~PrinterDriver(); 63 64 void StopPrinting(); 65 66 virtual status_t PrintJob(BFile *jobFile, BMessage *jobMsg); 67 virtual status_t BeginJob(); 68 virtual status_t PrintPage(int32 pageNumber, int32 pageCount); 69 virtual status_t EndJob(); 70 71 // configuration window getters 72 virtual BlockingWindow* NewPrinterSetupWindow(char* printerName); 73 virtual BlockingWindow* NewPageSetupWindow(BMessage *setupMsg, const char *printerName); 74 virtual BlockingWindow* NewJobSetupWindow(BMessage *setupMsg, const char *printerName); 75 76 // configuration default methods 77 virtual status_t PrinterSetup(char *printerName); 78 virtual status_t PageSetup(BMessage *msg, const char *printerName = NULL); 79 virtual status_t JobSetup(BMessage *msg, const char *printerName = NULL); 80 virtual BMessage* GetDefaultSettings(); 81 82 // accessors 83 inline BFile *JobFile() { return fJobFile; } 84 inline BNode *PrinterNode() { return fPrinterNode; } 85 inline BMessage *JobMsg() { return fJobMsg; } 86 inline int32 Pass() const { return fPass; } 87 88 // publics status code 89 typedef enum { 90 PORTRAIT_ORIENTATION, 91 LANDSCAPE_ORIENTATION 92 } Orientation; 93 94 95 private: 96 status_t Go(BlockingWindow* w); 97 98 BFile *fJobFile; 99 BNode *fPrinterNode; 100 BMessage *fJobMsg; 101 102 volatile Orientation fOrientation; 103 104 bool fPrinting; 105 int32 fPass; 106 }; 107 108 #endif // #ifndef PRINTERDRIVER_H 109 110