1 /* 2 * PrinterCap.cpp 3 * Copyright 1999-2000 Y.Takagi. All Rights Reserved. 4 */ 5 6 #include "PrinterCap.h" 7 #include "PrinterData.h" 8 9 BaseCap::BaseCap(const string &label, bool isDefault) 10 : 11 fLabel(label), 12 fIsDefault(isDefault) 13 { 14 } 15 16 17 PaperCap::PaperCap(const string &label, bool isDefault, JobData::Paper paper, 18 const BRect &paperRect, const BRect &physicalRect) 19 : 20 BaseCap(label, isDefault), 21 fPaper(paper), 22 fPaperRect(paperRect), 23 fPhysicalRect(physicalRect) 24 { 25 } 26 27 28 PaperSourceCap::PaperSourceCap(const string &label, bool isDefault, 29 JobData::PaperSource paperSource) 30 : 31 BaseCap(label, isDefault), 32 fPaperSource(paperSource) 33 { 34 } 35 36 37 ResolutionCap::ResolutionCap(const string &label, bool isDefault, 38 int xResolution, int yResolution) 39 : 40 BaseCap(label, isDefault), 41 fXResolution(xResolution), 42 fYResolution(yResolution) 43 { 44 } 45 46 47 OrientationCap::OrientationCap(const string &label, bool isDefault, 48 JobData::Orientation orientation) 49 : 50 BaseCap(label, isDefault), 51 fOrientation(orientation) 52 { 53 } 54 55 56 PrintStyleCap::PrintStyleCap(const string &label, bool isDefault, 57 JobData::PrintStyle printStyle) 58 : 59 BaseCap(label, isDefault), 60 fPrintStyle(printStyle) 61 { 62 } 63 64 65 BindingLocationCap::BindingLocationCap(const string &label, bool isDefault, 66 JobData::BindingLocation bindingLocation) 67 : 68 BaseCap(label, isDefault), 69 fBindingLocation(bindingLocation) 70 { 71 } 72 73 74 ColorCap::ColorCap(const string &label, bool isDefault, JobData::Color color) 75 : 76 BaseCap(label, isDefault), 77 fColor(color) 78 { 79 } 80 81 82 ProtocolClassCap::ProtocolClassCap(const string &label, bool isDefault, 83 int protocolClass, const string &description) 84 : 85 BaseCap(label, isDefault), 86 fProtocolClass(protocolClass), 87 fDescription(description) 88 { 89 } 90 91 92 PrinterCap::PrinterCap(const PrinterData *printer_data) 93 : fPrinterData(printer_data), 94 fPrinterID(kUnknownPrinter) 95 { 96 } 97 98 99 PrinterCap::~PrinterCap() 100 { 101 } 102 103 104 const BaseCap *PrinterCap::getDefaultCap(CapID id) const 105 { 106 int count = countCap(id); 107 if (count > 0) { 108 const BaseCap **base_cap = enumCap(id); 109 while (count--) { 110 if ((*base_cap)->fIsDefault) { 111 return *base_cap; 112 } 113 base_cap++; 114 } 115 } 116 return NULL; 117 } 118 119 120 int 121 PrinterCap::getProtocolClass() const { 122 return fPrinterData->getProtocolClass(); 123 } 124 125 126 const 127 PrinterData *PrinterCap::getPrinterData() const 128 { 129 return fPrinterData; 130 } 131 132 133 int 134 PrinterCap::getPrinterId() const 135 { 136 return fPrinterID; 137 } 138 139 140 void 141 PrinterCap::setPrinterId(int id) 142 { 143 fPrinterID = id; 144 } 145 146