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