3 * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
6 #ifndef __JOBSETUPDLG_H
7 #define __JOBSETUPDLG_H
12 #include "DialogWindow.h"
16 #include "JSDSlider.h"
17 #include "PrinterCap.h"
33 template<typename T
, typename R
>
38 Range(const char* label
, const char* key
, const R
* range
, BSlider
* slider
);
39 const char* Key() const;
51 template<typename T
, typename R
>
61 template<typename T
, typename R
>
62 Range
<T
, R
>::Range(const char* label
, const char* key
, const R
* range
,
74 template<typename T
, typename R
>
76 Range
<T
, R
>::Key() const
82 template<typename T
, typename R
>
86 return static_cast<T
>(fRange
->Lower() +
87 (fRange
->Upper() - fRange
->Lower()) * fSlider
->Position());
91 template<typename T
, typename R
>
93 Range
<T
, R
>::UpdateLabel()
95 BString label
= fLabel
;
96 label
<< " (" << Value() << ")";
97 fSlider
->SetLabel(label
.String());
101 typedef Range
<int32
, IntRangeCap
> IntRange
;
102 typedef Range
<double, DoubleRangeCap
> DoubleRange
;
104 class JobSetupView
: public BView
{
106 JobSetupView(JobData
* jobData
, PrinterData
* printerData
,
107 const PrinterCap
* printerCap
);
108 virtual void AttachedToWindow();
109 virtual void MessageReceived(BMessage
* message
);
110 bool UpdateJobData();
113 void UpdateButtonEnabledState();
114 bool IsHalftoneConfigurationNeeded();
115 void CreateHalftoneConfigurationUI();
116 void AddDriverSpecificSettings(BGridLayout
* gridLayout
, int row
);
117 void AddPopUpMenu(const DriverSpecificCap
* capability
,
118 BGridLayout
* gridLayout
, int& row
);
119 void AddCheckBox(const DriverSpecificCap
* capability
,
120 BGridLayout
* gridLayout
, int& row
);
121 void AddIntSlider(const DriverSpecificCap
* capability
,
122 BGridLayout
* gridLayout
, int& row
);
123 void AddDoubleSlider(const DriverSpecificCap
* capability
,
124 BGridLayout
* gridLayout
, int& row
);
125 string
GetDriverSpecificValue(PrinterCap::CapID category
,
127 template<typename Predicate
>
128 void FillCapabilityMenu(BPopUpMenu
* menu
, uint32 message
,
129 const BaseCap
** capabilities
, int count
,
130 Predicate
& predicate
);
131 void FillCapabilityMenu(BPopUpMenu
* menu
, uint32 message
,
132 PrinterCap::CapID category
, int id
);
133 void FillCapabilityMenu(BPopUpMenu
* menu
, uint32 message
,
134 const BaseCap
** capabilities
, int count
, int id
);
135 int GetID(const BaseCap
** capabilities
, int count
,
136 const char* label
, int defaultValue
);
137 BRadioButton
* CreatePageSelectionItem(const char* name
,
139 JobData::PageSelection pageSelection
);
140 void AllowOnlyDigits(BTextView
* textView
, int maxDigits
);
141 void UpdateHalftonePreview();
142 void UpdateIntSlider(BMessage
* message
);
143 void UpdateDoubleSlider(BMessage
* message
);
145 JobData::Color
Color();
146 Halftone::DitherType
DitherType();
149 JobData::PaperSource
PaperSource();
152 BTextControl
* fCopies
;
153 BTextControl
* fFromPage
;
154 BTextControl
* fToPage
;
156 PrinterData
* fPrinterData
;
157 const PrinterCap
* fPrinterCap
;
158 BPopUpMenu
* fColorType
;
159 BPopUpMenu
* fDitherType
;
160 BMenuField
* fDitherMenuField
;
162 JSDSlider
* fInkDensity
;
163 HalftoneView
* fHalftone
;
169 BPopUpMenu
* fPaperFeed
;
172 BRadioButton
* fAllPages
;
173 BRadioButton
* fOddNumberedPages
;
174 BRadioButton
* fEvenNumberedPages
;
175 std::map
<PrinterCap::CapID
, BPopUpMenu
*> fDriverSpecificPopUpMenus
;
176 std::map
<string
, BCheckBox
*> fDriverSpecificCheckBoxes
;
177 std::map
<PrinterCap::CapID
, IntRange
> fDriverSpecificIntSliders
;
178 std::map
<PrinterCap::CapID
, DoubleRange
> fDriverSpecificDoubleSliders
;
182 class JobSetupDlg
: public DialogWindow
{
184 JobSetupDlg(JobData
* jobData
, PrinterData
* printerData
,
185 const PrinterCap
* printerCap
);
186 virtual void MessageReceived(BMessage
* message
);
189 JobSetupView
* fJobSetup
;
192 #endif /* __JOBSETUPDLG_H */