2 * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4 * Copyright 2010, Haiku. All rights reserved.
5 * Distributed under the terms of the MIT License.
12 #include "GPCapabilities.h"
14 #include "GPBinding.h"
16 #include "PrinterData.h"
19 GPCapabilities::GPCapabilities(const PrinterData
* printer_data
)
21 PrinterCap(printer_data
)
23 InitCapabilitiesFromGutenprint();
27 GPCapabilities::~GPCapabilities()
32 GPCapabilities::CountCap(CapID category
) const
34 const GPArray
<struct BaseCap
>* capabilities
;
38 return fPageSizes
.Size();
40 return fInputSlots
.Size();
42 return fResolutions
.Size();
44 return fPrintingModes
.Size();
45 case kDriverSpecificCapabilities
:
46 return fDriverSpecificCategories
.Size();
49 capabilities
= DriverSpecificCapabilities(category
);
50 if (capabilities
== NULL
)
52 return capabilities
->Size();
58 GPCapabilities::GetCaps(CapID category
) const
60 typedef const BaseCap
** ArrayType
;
61 const GPArray
<struct BaseCap
>* capabilities
;
65 return (ArrayType
)fPageSizes
.Array();
67 return (ArrayType
)fInputSlots
.Array();
69 return (ArrayType
)fResolutions
.Array();
71 return (ArrayType
)fPrintingModes
.Array();
72 case kDriverSpecificCapabilities
:
73 return (ArrayType
)fDriverSpecificCategories
.Array();
76 capabilities
= DriverSpecificCapabilities(category
);
77 if (capabilities
== NULL
)
79 return (ArrayType
)capabilities
->Array();
85 GPCapabilities::Supports(CapID category
) const
95 return CountCap(category
) > 0;
100 GPCapabilities::InitCapabilitiesFromGutenprint()
102 const GPData
* data
= dynamic_cast<const GPData
*>(GetPrinterData());
103 ASSERT(data
!= NULL
);
104 // capabilities are available only after printer model
106 if (data
->fGutenprintDriverName
== "")
111 binding
.GetCapabilities(data
->fGutenprintDriverName
.String(), this);
115 const GPArray
<struct BaseCap
>*
116 GPCapabilities::DriverSpecificCapabilities(int32 category
) const
118 DriverSpecificCapabilitiesType::const_iterator it
=
119 fDriverSpecificCapabilities
.find(category
);
120 if (it
== fDriverSpecificCapabilities
.end())