1*12fd6cc2SKarsten Heimrich /* 2*12fd6cc2SKarsten Heimrich * JobSetupDlg.cpp 3*12fd6cc2SKarsten Heimrich * Copyright 1999-2000 Y.Takagi. All Rights Reserved. 4*12fd6cc2SKarsten Heimrich */ 5*12fd6cc2SKarsten Heimrich 6*12fd6cc2SKarsten Heimrich #include <cstdio> 7*12fd6cc2SKarsten Heimrich #include <cstring> 8*12fd6cc2SKarsten Heimrich #include <cstdlib> 9*12fd6cc2SKarsten Heimrich #include <string> 10*12fd6cc2SKarsten Heimrich #include <fcntl.h> 11*12fd6cc2SKarsten Heimrich #include <unistd.h> 12*12fd6cc2SKarsten Heimrich #include <sys/stat.h> 13*12fd6cc2SKarsten Heimrich #include <math.h> 14*12fd6cc2SKarsten Heimrich 15*12fd6cc2SKarsten Heimrich #include <Alert.h> 16*12fd6cc2SKarsten Heimrich #include <Bitmap.h> 17*12fd6cc2SKarsten Heimrich #include <Box.h> 18*12fd6cc2SKarsten Heimrich #include <Button.h> 19*12fd6cc2SKarsten Heimrich #include <CheckBox.h> 20*12fd6cc2SKarsten Heimrich #include <Looper.h> 21*12fd6cc2SKarsten Heimrich #include <MessageFilter.h> 22*12fd6cc2SKarsten Heimrich #include <MenuField.h> 23*12fd6cc2SKarsten Heimrich #include <MenuItem.h> 24*12fd6cc2SKarsten Heimrich #include <Message.h> 25*12fd6cc2SKarsten Heimrich #include <Point.h> 26*12fd6cc2SKarsten Heimrich #include <PopUpMenu.h> 27*12fd6cc2SKarsten Heimrich #include <PrintJob.h> 28*12fd6cc2SKarsten Heimrich #include <RadioButton.h> 29*12fd6cc2SKarsten Heimrich #include <Rect.h> 30*12fd6cc2SKarsten Heimrich #include <Slider.h> 31*12fd6cc2SKarsten Heimrich #include <String.h> 32*12fd6cc2SKarsten Heimrich #include <TextControl.h> 33*12fd6cc2SKarsten Heimrich #include <TextView.h> 34*12fd6cc2SKarsten Heimrich #include <View.h> 35*12fd6cc2SKarsten Heimrich 36*12fd6cc2SKarsten Heimrich #include "HalftoneView.h" 37*12fd6cc2SKarsten Heimrich #include "JobSetupDlg.h" 38*12fd6cc2SKarsten Heimrich #include "JobData.h" 39*12fd6cc2SKarsten Heimrich #include "JSDSlider.h" 40*12fd6cc2SKarsten Heimrich #include "PagesView.h" 41*12fd6cc2SKarsten Heimrich #include "PrinterData.h" 42*12fd6cc2SKarsten Heimrich #include "PrinterCap.h" 43*12fd6cc2SKarsten Heimrich #include "DbgMsg.h" 44*12fd6cc2SKarsten Heimrich 45*12fd6cc2SKarsten Heimrich #if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE)) 46*12fd6cc2SKarsten Heimrich using namespace std; 47*12fd6cc2SKarsten Heimrich #else 48*12fd6cc2SKarsten Heimrich #define std 49*12fd6cc2SKarsten Heimrich #endif 50*12fd6cc2SKarsten Heimrich 51*12fd6cc2SKarsten Heimrich //#define PRINT_COPIES 100 52*12fd6cc2SKarsten Heimrich 53*12fd6cc2SKarsten Heimrich #define QUALITY_H 10 54*12fd6cc2SKarsten Heimrich #define QUALITY_V 10 55*12fd6cc2SKarsten Heimrich #define QUALITY_WIDTH 180 56*12fd6cc2SKarsten Heimrich 57*12fd6cc2SKarsten Heimrich #define BPP_H 10 58*12fd6cc2SKarsten Heimrich #define BPP_V 15 59*12fd6cc2SKarsten Heimrich #define BPP_WIDTH 120 60*12fd6cc2SKarsten Heimrich #define BPP_HEIGHT 16 61*12fd6cc2SKarsten Heimrich 62*12fd6cc2SKarsten Heimrich #define DITHER_H BPP_H 63*12fd6cc2SKarsten Heimrich #define DITHER_V BPP_V + BPP_HEIGHT + 10 64*12fd6cc2SKarsten Heimrich #define DITHER_WIDTH BPP_WIDTH 65*12fd6cc2SKarsten Heimrich #define DITHER_HEIGHT BPP_HEIGHT 66*12fd6cc2SKarsten Heimrich 67*12fd6cc2SKarsten Heimrich #define GAMMA_H BPP_H 68*12fd6cc2SKarsten Heimrich #define GAMMA_V DITHER_V + DITHER_HEIGHT + 10 69*12fd6cc2SKarsten Heimrich #define GAMMA_WIDTH QUALITY_WIDTH - 20 70*12fd6cc2SKarsten Heimrich #define GAMMA_HEIGHT 55 // BPP_HEIGHT 71*12fd6cc2SKarsten Heimrich 72*12fd6cc2SKarsten Heimrich #define INK_DENSITY_H BPP_H 73*12fd6cc2SKarsten Heimrich #define INK_DENSITY_V GAMMA_V + GAMMA_HEIGHT + 5 74*12fd6cc2SKarsten Heimrich #define INK_DENSITY_WIDTH GAMMA_WIDTH 75*12fd6cc2SKarsten Heimrich #define INK_DENSITY_HEIGHT 55 // BPP_HEIGHT 76*12fd6cc2SKarsten Heimrich 77*12fd6cc2SKarsten Heimrich #define HALFTONE_H INK_DENSITY_H 78*12fd6cc2SKarsten Heimrich #define HALFTONE_V INK_DENSITY_V + INK_DENSITY_HEIGHT + 5 79*12fd6cc2SKarsten Heimrich #define HALFTONE_WIDTH 160 80*12fd6cc2SKarsten Heimrich #define HALFTONE_HEIGHT 4*11 81*12fd6cc2SKarsten Heimrich 82*12fd6cc2SKarsten Heimrich #define QUALITY_HEIGHT HALFTONE_V + HALFTONE_HEIGHT + 5 83*12fd6cc2SKarsten Heimrich 84*12fd6cc2SKarsten Heimrich #define PAGERABGE_H QUALITY_H 85*12fd6cc2SKarsten Heimrich #define PAGERABGE_V QUALITY_V + QUALITY_HEIGHT + 5 86*12fd6cc2SKarsten Heimrich #define PAGERABGE_WIDTH QUALITY_WIDTH 87*12fd6cc2SKarsten Heimrich #define PAGERABGE_HEIGHT 70 88*12fd6cc2SKarsten Heimrich 89*12fd6cc2SKarsten Heimrich #define ALL_H 10 90*12fd6cc2SKarsten Heimrich #define ALL_V 20 91*12fd6cc2SKarsten Heimrich #define ALL_WIDTH 36 92*12fd6cc2SKarsten Heimrich #define ALL_HEIGHT 16 93*12fd6cc2SKarsten Heimrich 94*12fd6cc2SKarsten Heimrich #define SELECTION_H ALL_H 95*12fd6cc2SKarsten Heimrich #define SELECTION_V ALL_V + ALL_HEIGHT + 4 96*12fd6cc2SKarsten Heimrich #define SELECTION_WIDTH 16 97*12fd6cc2SKarsten Heimrich #define SELECTION_HEIGHT 16 98*12fd6cc2SKarsten Heimrich 99*12fd6cc2SKarsten Heimrich #define FROM_H (SELECTION_H + SELECTION_WIDTH + 1) 100*12fd6cc2SKarsten Heimrich #define FROM_V ALL_V + 19 101*12fd6cc2SKarsten Heimrich #define FROM_WIDTH 73 102*12fd6cc2SKarsten Heimrich #define FROM_HEIGHT 16 103*12fd6cc2SKarsten Heimrich 104*12fd6cc2SKarsten Heimrich #define TO_H (FROM_H + FROM_WIDTH + 7) 105*12fd6cc2SKarsten Heimrich #define TO_V FROM_V 106*12fd6cc2SKarsten Heimrich #define TO_WIDTH 59 107*12fd6cc2SKarsten Heimrich #define TO_HEIGHT FROM_HEIGHT 108*12fd6cc2SKarsten Heimrich 109*12fd6cc2SKarsten Heimrich #define PRINT_WIDTH 365 110*12fd6cc2SKarsten Heimrich #define PRINT_HEIGHT QUALITY_HEIGHT + PAGERABGE_HEIGHT + 60 111*12fd6cc2SKarsten Heimrich 112*12fd6cc2SKarsten Heimrich #define PAPERFEED_H QUALITY_H + QUALITY_WIDTH + 10 113*12fd6cc2SKarsten Heimrich #define PAPERFEED_V QUALITY_V + 5 114*12fd6cc2SKarsten Heimrich #define PAPERFEED_WIDTH 160 115*12fd6cc2SKarsten Heimrich #define PAPERFEED_HEIGHT 16 116*12fd6cc2SKarsten Heimrich 117*12fd6cc2SKarsten Heimrich #define NUP_H PAPERFEED_H 118*12fd6cc2SKarsten Heimrich #define NUP_V PAPERFEED_V + PAPERFEED_HEIGHT + 7 119*12fd6cc2SKarsten Heimrich #define NUP_WIDTH PAPERFEED_WIDTH 120*12fd6cc2SKarsten Heimrich #define NUP_HEIGHT 16 121*12fd6cc2SKarsten Heimrich #define MENU_HEIGHT 16 122*12fd6cc2SKarsten Heimrich 123*12fd6cc2SKarsten Heimrich #define COPIES_H PAPERFEED_H 124*12fd6cc2SKarsten Heimrich #define COPIES_V NUP_V + NUP_HEIGHT + 10 125*12fd6cc2SKarsten Heimrich #define COPIES_WIDTH 140 126*12fd6cc2SKarsten Heimrich #define COPIES_HEIGHT 16 127*12fd6cc2SKarsten Heimrich 128*12fd6cc2SKarsten Heimrich #define DUPLEX_H PAPERFEED_H 129*12fd6cc2SKarsten Heimrich #define DUPLEX_V COPIES_V + COPIES_HEIGHT + 7 130*12fd6cc2SKarsten Heimrich #define DUPLEX_WIDTH PAPERFEED_WIDTH 131*12fd6cc2SKarsten Heimrich #define DUPLEX_HEIGHT 16 132*12fd6cc2SKarsten Heimrich 133*12fd6cc2SKarsten Heimrich #define COLLATE_H PAPERFEED_H 134*12fd6cc2SKarsten Heimrich #define COLLATE_V DUPLEX_V + DUPLEX_HEIGHT + 5 135*12fd6cc2SKarsten Heimrich #define COLLATE_WIDTH PAPERFEED_WIDTH 136*12fd6cc2SKarsten Heimrich #define COLLATE_HEIGHT 16 137*12fd6cc2SKarsten Heimrich 138*12fd6cc2SKarsten Heimrich #define REVERSE_H PAPERFEED_H 139*12fd6cc2SKarsten Heimrich #define REVERSE_V COLLATE_V + COLLATE_HEIGHT + 5 140*12fd6cc2SKarsten Heimrich #define REVERSE_WIDTH PAPERFEED_WIDTH 141*12fd6cc2SKarsten Heimrich #define REVERSE_HEIGHT 16 142*12fd6cc2SKarsten Heimrich 143*12fd6cc2SKarsten Heimrich #define PAGES_H PAPERFEED_H 144*12fd6cc2SKarsten Heimrich #define PAGES_V REVERSE_V + REVERSE_HEIGHT + 5 145*12fd6cc2SKarsten Heimrich #define PAGES_WIDTH PAPERFEED_WIDTH 146*12fd6cc2SKarsten Heimrich #define PAGES_HEIGHT 40 147*12fd6cc2SKarsten Heimrich 148*12fd6cc2SKarsten Heimrich #define PAGE_SELECTION_H PAPERFEED_H 149*12fd6cc2SKarsten Heimrich #define PAGE_SELECTION_V PAGES_V + PAGES_HEIGHT + 5 150*12fd6cc2SKarsten Heimrich #define PAGE_SELECTION_WIDTH PAPERFEED_WIDTH 151*12fd6cc2SKarsten Heimrich #define PAGE_SELECTION_HEIGHT 3 * 16 + 30 152*12fd6cc2SKarsten Heimrich 153*12fd6cc2SKarsten Heimrich #define PS_ALL_PAGES_H 10 154*12fd6cc2SKarsten Heimrich #define PS_ALL_PAGES_V 20 155*12fd6cc2SKarsten Heimrich #define PS_ALL_PAGES_WIDTH PAGE_SELECTION_WIDTH - 20 156*12fd6cc2SKarsten Heimrich #define PS_ALL_PAGES_HEIGHT 16 157*12fd6cc2SKarsten Heimrich 158*12fd6cc2SKarsten Heimrich #define PS_ODD_PAGES_H PS_ALL_PAGES_H 159*12fd6cc2SKarsten Heimrich #define PS_ODD_PAGES_V PS_ALL_PAGES_V + PS_ALL_PAGES_HEIGHT 160*12fd6cc2SKarsten Heimrich #define PS_ODD_PAGES_WIDTH PS_ALL_PAGES_WIDTH 161*12fd6cc2SKarsten Heimrich #define PS_ODD_PAGES_HEIGHT PS_ALL_PAGES_HEIGHT 162*12fd6cc2SKarsten Heimrich 163*12fd6cc2SKarsten Heimrich #define PS_EVEN_PAGES_H PS_ALL_PAGES_H 164*12fd6cc2SKarsten Heimrich #define PS_EVEN_PAGES_V PS_ODD_PAGES_V + PS_ODD_PAGES_HEIGHT 165*12fd6cc2SKarsten Heimrich #define PS_EVEN_PAGES_WIDTH PS_ALL_PAGES_WIDTH 166*12fd6cc2SKarsten Heimrich #define PS_EVEN_PAGES_HEIGHT PS_ALL_PAGES_HEIGHT 167*12fd6cc2SKarsten Heimrich 168*12fd6cc2SKarsten Heimrich #define PRINT_BUTTON_WIDTH 70 169*12fd6cc2SKarsten Heimrich #define PRINT_BUTTON_HEIGHT 20 170*12fd6cc2SKarsten Heimrich 171*12fd6cc2SKarsten Heimrich #define PRINT_LINE_V (PRINT_HEIGHT - PRINT_BUTTON_HEIGHT - 23) 172*12fd6cc2SKarsten Heimrich 173*12fd6cc2SKarsten Heimrich #define PRINT_OK_BUTTON_H (PRINT_WIDTH - PRINT_BUTTON_WIDTH - 10) 174*12fd6cc2SKarsten Heimrich #define PRINT_OK_BUTTON_V (PRINT_HEIGHT - PRINT_BUTTON_HEIGHT - 11) 175*12fd6cc2SKarsten Heimrich 176*12fd6cc2SKarsten Heimrich #define PREVIEW_H (PRINT_OK_BUTTON_H - PRINT_BUTTON_WIDTH - 12) 177*12fd6cc2SKarsten Heimrich #define PREVIEW_V (PRINT_OK_BUTTON_V) 178*12fd6cc2SKarsten Heimrich 179*12fd6cc2SKarsten Heimrich #define PRINT_CANCEL_BUTTON_H (PREVIEW_H - PRINT_BUTTON_WIDTH - 12) 180*12fd6cc2SKarsten Heimrich #define PRINT_CANCEL_BUTTON_V PRINT_OK_BUTTON_V 181*12fd6cc2SKarsten Heimrich 182*12fd6cc2SKarsten Heimrich const BRect quality_rect( 183*12fd6cc2SKarsten Heimrich QUALITY_H, 184*12fd6cc2SKarsten Heimrich QUALITY_V, 185*12fd6cc2SKarsten Heimrich QUALITY_H + QUALITY_WIDTH, 186*12fd6cc2SKarsten Heimrich QUALITY_V + QUALITY_HEIGHT); 187*12fd6cc2SKarsten Heimrich 188*12fd6cc2SKarsten Heimrich BRect bpp_rect( 189*12fd6cc2SKarsten Heimrich BPP_H, 190*12fd6cc2SKarsten Heimrich BPP_V, 191*12fd6cc2SKarsten Heimrich BPP_H + BPP_WIDTH, 192*12fd6cc2SKarsten Heimrich BPP_V + BPP_HEIGHT); 193*12fd6cc2SKarsten Heimrich 194*12fd6cc2SKarsten Heimrich BRect dither_rect( 195*12fd6cc2SKarsten Heimrich DITHER_H, 196*12fd6cc2SKarsten Heimrich DITHER_V, 197*12fd6cc2SKarsten Heimrich DITHER_H + DITHER_WIDTH, 198*12fd6cc2SKarsten Heimrich DITHER_V + DITHER_HEIGHT); 199*12fd6cc2SKarsten Heimrich 200*12fd6cc2SKarsten Heimrich const BRect ink_density_rect( 201*12fd6cc2SKarsten Heimrich INK_DENSITY_H, 202*12fd6cc2SKarsten Heimrich INK_DENSITY_V, 203*12fd6cc2SKarsten Heimrich INK_DENSITY_H + INK_DENSITY_WIDTH, 204*12fd6cc2SKarsten Heimrich INK_DENSITY_V + INK_DENSITY_HEIGHT); 205*12fd6cc2SKarsten Heimrich 206*12fd6cc2SKarsten Heimrich const BRect halftone_rect( 207*12fd6cc2SKarsten Heimrich HALFTONE_H, 208*12fd6cc2SKarsten Heimrich HALFTONE_V, 209*12fd6cc2SKarsten Heimrich HALFTONE_H + HALFTONE_WIDTH, 210*12fd6cc2SKarsten Heimrich HALFTONE_V + HALFTONE_HEIGHT); 211*12fd6cc2SKarsten Heimrich 212*12fd6cc2SKarsten Heimrich const BRect gamma_rect( 213*12fd6cc2SKarsten Heimrich GAMMA_H, 214*12fd6cc2SKarsten Heimrich GAMMA_V, 215*12fd6cc2SKarsten Heimrich GAMMA_H + GAMMA_WIDTH, 216*12fd6cc2SKarsten Heimrich GAMMA_V + GAMMA_HEIGHT); 217*12fd6cc2SKarsten Heimrich 218*12fd6cc2SKarsten Heimrich const BRect pagerange_rect( 219*12fd6cc2SKarsten Heimrich PAGERABGE_H, 220*12fd6cc2SKarsten Heimrich PAGERABGE_V, 221*12fd6cc2SKarsten Heimrich PAGERABGE_H + PAGERABGE_WIDTH, 222*12fd6cc2SKarsten Heimrich PAGERABGE_V + PAGERABGE_HEIGHT); 223*12fd6cc2SKarsten Heimrich 224*12fd6cc2SKarsten Heimrich const BRect all_button_rect( 225*12fd6cc2SKarsten Heimrich ALL_H, 226*12fd6cc2SKarsten Heimrich ALL_V, 227*12fd6cc2SKarsten Heimrich ALL_H + ALL_WIDTH, 228*12fd6cc2SKarsten Heimrich ALL_V + ALL_HEIGHT); 229*12fd6cc2SKarsten Heimrich 230*12fd6cc2SKarsten Heimrich const BRect selection_rect( 231*12fd6cc2SKarsten Heimrich SELECTION_H, 232*12fd6cc2SKarsten Heimrich SELECTION_V, 233*12fd6cc2SKarsten Heimrich SELECTION_H + SELECTION_WIDTH, 234*12fd6cc2SKarsten Heimrich SELECTION_V + SELECTION_HEIGHT); 235*12fd6cc2SKarsten Heimrich 236*12fd6cc2SKarsten Heimrich const BRect from_rect( 237*12fd6cc2SKarsten Heimrich FROM_H, 238*12fd6cc2SKarsten Heimrich FROM_V, 239*12fd6cc2SKarsten Heimrich FROM_H + FROM_WIDTH, 240*12fd6cc2SKarsten Heimrich FROM_V + FROM_HEIGHT); 241*12fd6cc2SKarsten Heimrich 242*12fd6cc2SKarsten Heimrich const BRect to_rect( 243*12fd6cc2SKarsten Heimrich TO_H, 244*12fd6cc2SKarsten Heimrich TO_V, 245*12fd6cc2SKarsten Heimrich TO_H + TO_WIDTH, 246*12fd6cc2SKarsten Heimrich TO_V + TO_HEIGHT); 247*12fd6cc2SKarsten Heimrich 248*12fd6cc2SKarsten Heimrich const BRect paperfeed_rect( 249*12fd6cc2SKarsten Heimrich PAPERFEED_H, 250*12fd6cc2SKarsten Heimrich PAPERFEED_V, 251*12fd6cc2SKarsten Heimrich PAPERFEED_H + PAPERFEED_WIDTH, 252*12fd6cc2SKarsten Heimrich PAPERFEED_V + PAPERFEED_HEIGHT); 253*12fd6cc2SKarsten Heimrich 254*12fd6cc2SKarsten Heimrich BRect nup_rect( 255*12fd6cc2SKarsten Heimrich NUP_H, 256*12fd6cc2SKarsten Heimrich NUP_V, 257*12fd6cc2SKarsten Heimrich NUP_H + NUP_WIDTH, 258*12fd6cc2SKarsten Heimrich NUP_V + NUP_HEIGHT); 259*12fd6cc2SKarsten Heimrich 260*12fd6cc2SKarsten Heimrich const BRect copies_rect( 261*12fd6cc2SKarsten Heimrich COPIES_H, 262*12fd6cc2SKarsten Heimrich COPIES_V, 263*12fd6cc2SKarsten Heimrich COPIES_H + COPIES_WIDTH, 264*12fd6cc2SKarsten Heimrich COPIES_V + COPIES_HEIGHT); 265*12fd6cc2SKarsten Heimrich 266*12fd6cc2SKarsten Heimrich const BRect duplex_rect( 267*12fd6cc2SKarsten Heimrich DUPLEX_H, 268*12fd6cc2SKarsten Heimrich DUPLEX_V, 269*12fd6cc2SKarsten Heimrich DUPLEX_H + DUPLEX_WIDTH, 270*12fd6cc2SKarsten Heimrich DUPLEX_V + DUPLEX_HEIGHT); 271*12fd6cc2SKarsten Heimrich 272*12fd6cc2SKarsten Heimrich const BRect collate_rect( 273*12fd6cc2SKarsten Heimrich COLLATE_H, 274*12fd6cc2SKarsten Heimrich COLLATE_V, 275*12fd6cc2SKarsten Heimrich COLLATE_H + COLLATE_WIDTH, 276*12fd6cc2SKarsten Heimrich COLLATE_V + COLLATE_HEIGHT); 277*12fd6cc2SKarsten Heimrich 278*12fd6cc2SKarsten Heimrich const BRect reverse_rect( 279*12fd6cc2SKarsten Heimrich REVERSE_H, 280*12fd6cc2SKarsten Heimrich REVERSE_V, 281*12fd6cc2SKarsten Heimrich REVERSE_H + REVERSE_WIDTH, 282*12fd6cc2SKarsten Heimrich REVERSE_V + REVERSE_HEIGHT); 283*12fd6cc2SKarsten Heimrich 284*12fd6cc2SKarsten Heimrich const BRect pages_rect( 285*12fd6cc2SKarsten Heimrich PAGES_H, 286*12fd6cc2SKarsten Heimrich PAGES_V, 287*12fd6cc2SKarsten Heimrich PAGES_H + PAGES_WIDTH, 288*12fd6cc2SKarsten Heimrich PAGES_V + PAGES_HEIGHT); 289*12fd6cc2SKarsten Heimrich 290*12fd6cc2SKarsten Heimrich const BRect page_selection_rect( 291*12fd6cc2SKarsten Heimrich PAGE_SELECTION_H, 292*12fd6cc2SKarsten Heimrich PAGE_SELECTION_V, 293*12fd6cc2SKarsten Heimrich PAGE_SELECTION_H + PAGE_SELECTION_WIDTH, 294*12fd6cc2SKarsten Heimrich PAGE_SELECTION_V + PAGE_SELECTION_HEIGHT); 295*12fd6cc2SKarsten Heimrich 296*12fd6cc2SKarsten Heimrich const BRect page_selection_all_pages_rect( 297*12fd6cc2SKarsten Heimrich PS_ALL_PAGES_H, 298*12fd6cc2SKarsten Heimrich PS_ALL_PAGES_V, 299*12fd6cc2SKarsten Heimrich PS_ALL_PAGES_H + PS_ALL_PAGES_WIDTH, 300*12fd6cc2SKarsten Heimrich PS_ALL_PAGES_V + PS_ALL_PAGES_HEIGHT); 301*12fd6cc2SKarsten Heimrich 302*12fd6cc2SKarsten Heimrich const BRect page_selection_odd_pages_rect( 303*12fd6cc2SKarsten Heimrich PS_ODD_PAGES_H, 304*12fd6cc2SKarsten Heimrich PS_ODD_PAGES_V, 305*12fd6cc2SKarsten Heimrich PS_ODD_PAGES_H + PS_ODD_PAGES_WIDTH, 306*12fd6cc2SKarsten Heimrich PS_ODD_PAGES_V + PS_ODD_PAGES_HEIGHT); 307*12fd6cc2SKarsten Heimrich 308*12fd6cc2SKarsten Heimrich const BRect page_selection_even_pages_rect( 309*12fd6cc2SKarsten Heimrich PS_EVEN_PAGES_H, 310*12fd6cc2SKarsten Heimrich PS_EVEN_PAGES_V, 311*12fd6cc2SKarsten Heimrich PS_EVEN_PAGES_H + PS_EVEN_PAGES_WIDTH, 312*12fd6cc2SKarsten Heimrich PS_EVEN_PAGES_V + PS_EVEN_PAGES_HEIGHT); 313*12fd6cc2SKarsten Heimrich 314*12fd6cc2SKarsten Heimrich const BRect ok_rect( 315*12fd6cc2SKarsten Heimrich PRINT_OK_BUTTON_H, 316*12fd6cc2SKarsten Heimrich PRINT_OK_BUTTON_V, 317*12fd6cc2SKarsten Heimrich PRINT_OK_BUTTON_H + PRINT_BUTTON_WIDTH, 318*12fd6cc2SKarsten Heimrich PRINT_OK_BUTTON_V + PRINT_BUTTON_HEIGHT); 319*12fd6cc2SKarsten Heimrich 320*12fd6cc2SKarsten Heimrich const BRect cancel_rect( 321*12fd6cc2SKarsten Heimrich PRINT_CANCEL_BUTTON_H, 322*12fd6cc2SKarsten Heimrich PRINT_CANCEL_BUTTON_V, 323*12fd6cc2SKarsten Heimrich PRINT_CANCEL_BUTTON_H + PRINT_BUTTON_WIDTH, 324*12fd6cc2SKarsten Heimrich PRINT_CANCEL_BUTTON_V + PRINT_BUTTON_HEIGHT); 325*12fd6cc2SKarsten Heimrich 326*12fd6cc2SKarsten Heimrich const BRect preview_rect( 327*12fd6cc2SKarsten Heimrich PREVIEW_H, 328*12fd6cc2SKarsten Heimrich PREVIEW_V, 329*12fd6cc2SKarsten Heimrich PREVIEW_H + PRINT_BUTTON_WIDTH, 330*12fd6cc2SKarsten Heimrich PREVIEW_V + PRINT_BUTTON_HEIGHT); 331*12fd6cc2SKarsten Heimrich 332*12fd6cc2SKarsten Heimrich 333*12fd6cc2SKarsten Heimrich 334*12fd6cc2SKarsten Heimrich struct SurfaceCap : public BaseCap { 335*12fd6cc2SKarsten Heimrich color_space surface_type; 336*12fd6cc2SKarsten Heimrich SurfaceCap(const string &s, bool d, color_space cs) : BaseCap(s, d), surface_type(cs) {} 337*12fd6cc2SKarsten Heimrich }; 338*12fd6cc2SKarsten Heimrich 339*12fd6cc2SKarsten Heimrich struct NupCap : public BaseCap { 340*12fd6cc2SKarsten Heimrich int nup; 341*12fd6cc2SKarsten Heimrich NupCap(const string &s, bool d, int n) : BaseCap(s, d), nup(n) {} 342*12fd6cc2SKarsten Heimrich }; 343*12fd6cc2SKarsten Heimrich 344*12fd6cc2SKarsten Heimrich struct DitherCap : public BaseCap { 345*12fd6cc2SKarsten Heimrich Halftone::DitherType dither_type; 346*12fd6cc2SKarsten Heimrich DitherCap(const string &s, bool d, Halftone::DitherType type) : BaseCap(s, d), dither_type(type) {} 347*12fd6cc2SKarsten Heimrich }; 348*12fd6cc2SKarsten Heimrich 349*12fd6cc2SKarsten Heimrich static const SurfaceCap gRGB32("RGB32", false, B_RGB32); 350*12fd6cc2SKarsten Heimrich static const SurfaceCap gCMAP8("CMAP8", true, B_CMAP8); 351*12fd6cc2SKarsten Heimrich static const SurfaceCap gGray8("GRAY8", false, B_GRAY8); 352*12fd6cc2SKarsten Heimrich static const SurfaceCap gGray1("GRAY1", false, B_GRAY1); 353*12fd6cc2SKarsten Heimrich 354*12fd6cc2SKarsten Heimrich static const NupCap gNup1("1", true, 1); 355*12fd6cc2SKarsten Heimrich static const NupCap gNup2("2", false, 2); 356*12fd6cc2SKarsten Heimrich static const NupCap gNup4("4", false, 4); 357*12fd6cc2SKarsten Heimrich static const NupCap gNup8("8", false, 8); 358*12fd6cc2SKarsten Heimrich static const NupCap gNup9("9", false, 9); 359*12fd6cc2SKarsten Heimrich static const NupCap gNup16("16", false, 16); 360*12fd6cc2SKarsten Heimrich static const NupCap gNup25("25", false, 25); 361*12fd6cc2SKarsten Heimrich static const NupCap gNup32("32", false, 32); 362*12fd6cc2SKarsten Heimrich static const NupCap gNup36("36", false, 36); 363*12fd6cc2SKarsten Heimrich 364*12fd6cc2SKarsten Heimrich static const DitherCap gDitherType1("Crosshatch", false, Halftone::kType1); 365*12fd6cc2SKarsten Heimrich static const DitherCap gDitherType2("Grid", false, Halftone::kType2); 366*12fd6cc2SKarsten Heimrich static const DitherCap gDitherType3("Stipple", false, Halftone::kType3); 367*12fd6cc2SKarsten Heimrich static const DitherCap gDitherFloydSteinberg("Floyd-Steinberg", false, Halftone::kTypeFloydSteinberg); 368*12fd6cc2SKarsten Heimrich 369*12fd6cc2SKarsten Heimrich const SurfaceCap *gSurfaces[] = { 370*12fd6cc2SKarsten Heimrich &gRGB32, 371*12fd6cc2SKarsten Heimrich &gCMAP8, 372*12fd6cc2SKarsten Heimrich &gGray8, 373*12fd6cc2SKarsten Heimrich &gGray1 374*12fd6cc2SKarsten Heimrich }; 375*12fd6cc2SKarsten Heimrich 376*12fd6cc2SKarsten Heimrich const NupCap *gNups[] = { 377*12fd6cc2SKarsten Heimrich &gNup1, 378*12fd6cc2SKarsten Heimrich &gNup2, 379*12fd6cc2SKarsten Heimrich &gNup4, 380*12fd6cc2SKarsten Heimrich &gNup8, 381*12fd6cc2SKarsten Heimrich &gNup9, 382*12fd6cc2SKarsten Heimrich &gNup16, 383*12fd6cc2SKarsten Heimrich &gNup25, 384*12fd6cc2SKarsten Heimrich &gNup32, 385*12fd6cc2SKarsten Heimrich &gNup36 386*12fd6cc2SKarsten Heimrich }; 387*12fd6cc2SKarsten Heimrich 388*12fd6cc2SKarsten Heimrich const DitherCap *gDitherTypes[] = { 389*12fd6cc2SKarsten Heimrich &gDitherType1, 390*12fd6cc2SKarsten Heimrich &gDitherType2, 391*12fd6cc2SKarsten Heimrich &gDitherType3, 392*12fd6cc2SKarsten Heimrich &gDitherFloydSteinberg 393*12fd6cc2SKarsten Heimrich }; 394*12fd6cc2SKarsten Heimrich 395*12fd6cc2SKarsten Heimrich enum { 396*12fd6cc2SKarsten Heimrich kMsgRangeAll = 'JSdl', 397*12fd6cc2SKarsten Heimrich kMsgRangeSelection, 398*12fd6cc2SKarsten Heimrich kMsgPreview, 399*12fd6cc2SKarsten Heimrich kMsgCancel, 400*12fd6cc2SKarsten Heimrich kMsgOK, 401*12fd6cc2SKarsten Heimrich kMsgQuality, 402*12fd6cc2SKarsten Heimrich kMsgCollateChanged, 403*12fd6cc2SKarsten Heimrich kMsgReverseChanged, 404*12fd6cc2SKarsten Heimrich kMsgDuplexChanged, 405*12fd6cc2SKarsten Heimrich }; 406*12fd6cc2SKarsten Heimrich 407*12fd6cc2SKarsten Heimrich JobSetupView::JobSetupView(BRect frame, JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap) 408*12fd6cc2SKarsten Heimrich : BView(frame, "", B_FOLLOW_ALL, B_WILL_DRAW), fJobData(job_data), fPrinterData(printer_data), fPrinterCap(printer_cap) 409*12fd6cc2SKarsten Heimrich { 410*12fd6cc2SKarsten Heimrich SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 411*12fd6cc2SKarsten Heimrich } 412*12fd6cc2SKarsten Heimrich 413*12fd6cc2SKarsten Heimrich BRadioButton* 414*12fd6cc2SKarsten Heimrich JobSetupView::AddPageSelectionItem(BView* parent, BRect rect, const char* name, const char* label, 415*12fd6cc2SKarsten Heimrich JobData::PageSelection pageSelection) 416*12fd6cc2SKarsten Heimrich { 417*12fd6cc2SKarsten Heimrich BRadioButton* button = new BRadioButton(rect, name, label, NULL); 418*12fd6cc2SKarsten Heimrich if (fJobData->getPageSelection() == pageSelection) { 419*12fd6cc2SKarsten Heimrich button->SetValue(B_CONTROL_ON); 420*12fd6cc2SKarsten Heimrich } 421*12fd6cc2SKarsten Heimrich parent->AddChild(button); 422*12fd6cc2SKarsten Heimrich return button; 423*12fd6cc2SKarsten Heimrich } 424*12fd6cc2SKarsten Heimrich 425*12fd6cc2SKarsten Heimrich void 426*12fd6cc2SKarsten Heimrich JobSetupView::AllowOnlyDigits(BTextView* textView, int maxDigits) 427*12fd6cc2SKarsten Heimrich { 428*12fd6cc2SKarsten Heimrich int num; 429*12fd6cc2SKarsten Heimrich for (num = 0; num <= 255; num++) { 430*12fd6cc2SKarsten Heimrich textView->DisallowChar(num); 431*12fd6cc2SKarsten Heimrich } 432*12fd6cc2SKarsten Heimrich for (num = 0; num <= 9; num++) { 433*12fd6cc2SKarsten Heimrich textView->AllowChar('0' + num); 434*12fd6cc2SKarsten Heimrich } 435*12fd6cc2SKarsten Heimrich textView->SetMaxBytes(maxDigits); 436*12fd6cc2SKarsten Heimrich } 437*12fd6cc2SKarsten Heimrich 438*12fd6cc2SKarsten Heimrich void 439*12fd6cc2SKarsten Heimrich JobSetupView::AttachedToWindow() 440*12fd6cc2SKarsten Heimrich { 441*12fd6cc2SKarsten Heimrich BBox *box; 442*12fd6cc2SKarsten Heimrich BMenuItem *item = NULL; 443*12fd6cc2SKarsten Heimrich BMenuField *menufield; 444*12fd6cc2SKarsten Heimrich BButton *button; 445*12fd6cc2SKarsten Heimrich float width; 446*12fd6cc2SKarsten Heimrich bool marked; 447*12fd6cc2SKarsten Heimrich int count; 448*12fd6cc2SKarsten Heimrich 449*12fd6cc2SKarsten Heimrich /* quality */ 450*12fd6cc2SKarsten Heimrich 451*12fd6cc2SKarsten Heimrich box = new BBox(quality_rect); 452*12fd6cc2SKarsten Heimrich AddChild(box); 453*12fd6cc2SKarsten Heimrich box->SetLabel("Quality"); 454*12fd6cc2SKarsten Heimrich 455*12fd6cc2SKarsten Heimrich /* 456*12fd6cc2SKarsten Heimrich // always B_RGB32 457*12fd6cc2SKarsten Heimrich fSurfaceType = new BPopUpMenu(""); 458*12fd6cc2SKarsten Heimrich fSurfaceType->SetRadioMode(true); 459*12fd6cc2SKarsten Heimrich 460*12fd6cc2SKarsten Heimrich count = sizeof(gSurfaces) / sizeof(gSurfaces[0]); 461*12fd6cc2SKarsten Heimrich const SurfaceCap **surface_cap = gSurfaces; 462*12fd6cc2SKarsten Heimrich uint32 support_flags; 463*12fd6cc2SKarsten Heimrich while (count--) { 464*12fd6cc2SKarsten Heimrich if (bitmaps_support_space((*surface_cap)->surface_type, &support_flags)) { 465*12fd6cc2SKarsten Heimrich item = new BMenuItem((*surface_cap)->label.c_str(), NULL); 466*12fd6cc2SKarsten Heimrich fSurfaceType->AddItem(item); 467*12fd6cc2SKarsten Heimrich if ((*surface_cap)->surface_type == fJobData->getSurfaceType()) { 468*12fd6cc2SKarsten Heimrich item->SetMarked(true); 469*12fd6cc2SKarsten Heimrich marked = true; 470*12fd6cc2SKarsten Heimrich } 471*12fd6cc2SKarsten Heimrich } 472*12fd6cc2SKarsten Heimrich surface_cap++; 473*12fd6cc2SKarsten Heimrich } 474*12fd6cc2SKarsten Heimrich menufield = new BMenuField(bpp_rect, "", "Surface Type", fSurfaceType); 475*12fd6cc2SKarsten Heimrich box->AddChild(menufield); 476*12fd6cc2SKarsten Heimrich width = StringWidth("Color") + 10; 477*12fd6cc2SKarsten Heimrich menufield->SetDivider(width); 478*12fd6cc2SKarsten Heimrich */ 479*12fd6cc2SKarsten Heimrich 480*12fd6cc2SKarsten Heimrich /* color */ 481*12fd6cc2SKarsten Heimrich marked = false; 482*12fd6cc2SKarsten Heimrich fColorType = new BPopUpMenu(""); 483*12fd6cc2SKarsten Heimrich fColorType->SetRadioMode(true); 484*12fd6cc2SKarsten Heimrich 485*12fd6cc2SKarsten Heimrich count = fPrinterCap->countCap(PrinterCap::kColor); 486*12fd6cc2SKarsten Heimrich const ColorCap **color_cap = (const ColorCap **)fPrinterCap->enumCap(PrinterCap::kColor); 487*12fd6cc2SKarsten Heimrich while (count--) { 488*12fd6cc2SKarsten Heimrich item = new BMenuItem((*color_cap)->label.c_str(), new BMessage(kMsgQuality)); 489*12fd6cc2SKarsten Heimrich fColorType->AddItem(item); 490*12fd6cc2SKarsten Heimrich if ((*color_cap)->color == fJobData->getColor()) { 491*12fd6cc2SKarsten Heimrich item->SetMarked(true); 492*12fd6cc2SKarsten Heimrich marked = true; 493*12fd6cc2SKarsten Heimrich } 494*12fd6cc2SKarsten Heimrich color_cap++; 495*12fd6cc2SKarsten Heimrich } 496*12fd6cc2SKarsten Heimrich if (!marked && item) 497*12fd6cc2SKarsten Heimrich item->SetMarked(true); 498*12fd6cc2SKarsten Heimrich bpp_rect.right = bpp_rect.left + StringWidth("Color:") + fColorType->MaxContentWidth() + 10; 499*12fd6cc2SKarsten Heimrich menufield = new BMenuField(bpp_rect, "color", "Color:", fColorType); 500*12fd6cc2SKarsten Heimrich 501*12fd6cc2SKarsten Heimrich box->AddChild(menufield); 502*12fd6cc2SKarsten Heimrich width = StringWidth("Color:") + 10; 503*12fd6cc2SKarsten Heimrich menufield->SetDivider(width); 504*12fd6cc2SKarsten Heimrich fColorType->SetTargetForItems(this); 505*12fd6cc2SKarsten Heimrich 506*12fd6cc2SKarsten Heimrich /* dither type */ 507*12fd6cc2SKarsten Heimrich marked = false; 508*12fd6cc2SKarsten Heimrich fDitherType = new BPopUpMenu(""); 509*12fd6cc2SKarsten Heimrich fDitherType->SetRadioMode(true); 510*12fd6cc2SKarsten Heimrich 511*12fd6cc2SKarsten Heimrich count = sizeof(gDitherTypes) / sizeof(gDitherTypes[0]); 512*12fd6cc2SKarsten Heimrich const DitherCap **dither_cap = gDitherTypes; 513*12fd6cc2SKarsten Heimrich while (count--) { 514*12fd6cc2SKarsten Heimrich item = new BMenuItem((*dither_cap)->label.c_str(), new BMessage(kMsgQuality)); 515*12fd6cc2SKarsten Heimrich fDitherType->AddItem(item); 516*12fd6cc2SKarsten Heimrich if ((*dither_cap)->dither_type == fJobData->getDitherType()) { 517*12fd6cc2SKarsten Heimrich item->SetMarked(true); 518*12fd6cc2SKarsten Heimrich marked = true; 519*12fd6cc2SKarsten Heimrich } 520*12fd6cc2SKarsten Heimrich dither_cap++; 521*12fd6cc2SKarsten Heimrich } 522*12fd6cc2SKarsten Heimrich if (!marked && item) 523*12fd6cc2SKarsten Heimrich item->SetMarked(true); 524*12fd6cc2SKarsten Heimrich dither_rect.right = dither_rect.left + StringWidth("Dot Pattern:") + fDitherType->MaxContentWidth() + 20; 525*12fd6cc2SKarsten Heimrich menufield = new BMenuField(dither_rect, "dithering", "Dot Pattern:", fDitherType); 526*12fd6cc2SKarsten Heimrich 527*12fd6cc2SKarsten Heimrich box->AddChild(menufield); 528*12fd6cc2SKarsten Heimrich width = StringWidth("Dot Pattern:") + 10; 529*12fd6cc2SKarsten Heimrich menufield->SetDivider(width); 530*12fd6cc2SKarsten Heimrich fDitherType->SetTargetForItems(this); 531*12fd6cc2SKarsten Heimrich 532*12fd6cc2SKarsten Heimrich /* halftone preview view */ 533*12fd6cc2SKarsten Heimrich BRect rect(halftone_rect); 534*12fd6cc2SKarsten Heimrich BBox* halftoneBorder = new BBox(rect.InsetByCopy(-1, -1)); 535*12fd6cc2SKarsten Heimrich box->AddChild(halftoneBorder); 536*12fd6cc2SKarsten Heimrich halftoneBorder->SetBorder(B_PLAIN_BORDER); 537*12fd6cc2SKarsten Heimrich 538*12fd6cc2SKarsten Heimrich fHalftone = new HalftoneView(rect.OffsetToCopy(1, 1), "halftone", B_FOLLOW_ALL, B_WILL_DRAW); 539*12fd6cc2SKarsten Heimrich halftoneBorder->AddChild(fHalftone); 540*12fd6cc2SKarsten Heimrich fHalftone->preview(fJobData->getGamma(), fJobData->getInkDensity(), fJobData->getDitherType(), fJobData->getColor() != JobData::kMonochrome); 541*12fd6cc2SKarsten Heimrich 542*12fd6cc2SKarsten Heimrich /* gamma */ 543*12fd6cc2SKarsten Heimrich fGamma = new JSDSlider(gamma_rect, "gamma", "Gamma", new BMessage(kMsgQuality), -300, 300, B_BLOCK_THUMB); 544*12fd6cc2SKarsten Heimrich 545*12fd6cc2SKarsten Heimrich fGamma->SetLimitLabels("Lighter", "Darker"); 546*12fd6cc2SKarsten Heimrich fGamma->SetValue((int32)(100 * log(fJobData->getGamma()) / log(2.0))); 547*12fd6cc2SKarsten Heimrich fGamma->SetHashMarks(B_HASH_MARKS_BOTH); 548*12fd6cc2SKarsten Heimrich fGamma->SetHashMarkCount(7); 549*12fd6cc2SKarsten Heimrich box->AddChild(fGamma); 550*12fd6cc2SKarsten Heimrich fGamma->SetModificationMessage(new BMessage(kMsgQuality)); 551*12fd6cc2SKarsten Heimrich fGamma->SetTarget(this); 552*12fd6cc2SKarsten Heimrich 553*12fd6cc2SKarsten Heimrich /* ink density */ 554*12fd6cc2SKarsten Heimrich fInkDensity = new JSDSlider(ink_density_rect, "inkDensity", "Ink Usage", new BMessage(kMsgQuality), 0, 127, B_BLOCK_THUMB); 555*12fd6cc2SKarsten Heimrich 556*12fd6cc2SKarsten Heimrich fInkDensity->SetLimitLabels("Min", "Max"); 557*12fd6cc2SKarsten Heimrich fInkDensity->SetValue((int32)fJobData->getInkDensity()); 558*12fd6cc2SKarsten Heimrich fInkDensity->SetHashMarks(B_HASH_MARKS_BOTH); 559*12fd6cc2SKarsten Heimrich fInkDensity->SetHashMarkCount(10); 560*12fd6cc2SKarsten Heimrich box->AddChild(fInkDensity); 561*12fd6cc2SKarsten Heimrich fInkDensity->SetModificationMessage(new BMessage(kMsgQuality)); 562*12fd6cc2SKarsten Heimrich fInkDensity->SetTarget(this); 563*12fd6cc2SKarsten Heimrich 564*12fd6cc2SKarsten Heimrich /* page range */ 565*12fd6cc2SKarsten Heimrich 566*12fd6cc2SKarsten Heimrich box = new BBox(pagerange_rect); 567*12fd6cc2SKarsten Heimrich AddChild(box); 568*12fd6cc2SKarsten Heimrich box->SetLabel("Page Range"); 569*12fd6cc2SKarsten Heimrich 570*12fd6cc2SKarsten Heimrich fAll = new BRadioButton(all_button_rect, "all", "All", new BMessage(kMsgRangeAll)); 571*12fd6cc2SKarsten Heimrich box->AddChild(fAll); 572*12fd6cc2SKarsten Heimrich 573*12fd6cc2SKarsten Heimrich BRadioButton *from = new BRadioButton(selection_rect, "selection", "", new BMessage(kMsgRangeSelection)); 574*12fd6cc2SKarsten Heimrich box->AddChild(from); 575*12fd6cc2SKarsten Heimrich 576*12fd6cc2SKarsten Heimrich fFromPage = new BTextControl(from_rect, "from", "From", "", NULL); 577*12fd6cc2SKarsten Heimrich box->AddChild(fFromPage); 578*12fd6cc2SKarsten Heimrich fFromPage->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); 579*12fd6cc2SKarsten Heimrich fFromPage->SetDivider(StringWidth("From") + 7); 580*12fd6cc2SKarsten Heimrich AllowOnlyDigits(fFromPage->TextView(), 6); 581*12fd6cc2SKarsten Heimrich 582*12fd6cc2SKarsten Heimrich fToPage = new BTextControl(to_rect, "to", "To", "", NULL); 583*12fd6cc2SKarsten Heimrich box->AddChild(fToPage); 584*12fd6cc2SKarsten Heimrich fToPage->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); 585*12fd6cc2SKarsten Heimrich fToPage->SetDivider(StringWidth("To") + 7); 586*12fd6cc2SKarsten Heimrich AllowOnlyDigits(fToPage->TextView(), 6); 587*12fd6cc2SKarsten Heimrich 588*12fd6cc2SKarsten Heimrich int first_page = fJobData->getFirstPage(); 589*12fd6cc2SKarsten Heimrich int last_page = fJobData->getLastPage(); 590*12fd6cc2SKarsten Heimrich 591*12fd6cc2SKarsten Heimrich if (first_page <= 1 && last_page <= 0) { 592*12fd6cc2SKarsten Heimrich fAll->SetValue(B_CONTROL_ON); 593*12fd6cc2SKarsten Heimrich } else { 594*12fd6cc2SKarsten Heimrich from->SetValue(B_CONTROL_ON); 595*12fd6cc2SKarsten Heimrich if (first_page < 1) 596*12fd6cc2SKarsten Heimrich first_page = 1; 597*12fd6cc2SKarsten Heimrich if (first_page > last_page) 598*12fd6cc2SKarsten Heimrich last_page = -1; 599*12fd6cc2SKarsten Heimrich 600*12fd6cc2SKarsten Heimrich BString oss1; 601*12fd6cc2SKarsten Heimrich oss1 << first_page; 602*12fd6cc2SKarsten Heimrich fFromPage->SetText(oss1.String()); 603*12fd6cc2SKarsten Heimrich 604*12fd6cc2SKarsten Heimrich BString oss2; 605*12fd6cc2SKarsten Heimrich oss2 << last_page; 606*12fd6cc2SKarsten Heimrich fToPage->SetText(oss2.String()); 607*12fd6cc2SKarsten Heimrich } 608*12fd6cc2SKarsten Heimrich 609*12fd6cc2SKarsten Heimrich fAll->SetTarget(this); 610*12fd6cc2SKarsten Heimrich from->SetTarget(this); 611*12fd6cc2SKarsten Heimrich 612*12fd6cc2SKarsten Heimrich /* paper source */ 613*12fd6cc2SKarsten Heimrich 614*12fd6cc2SKarsten Heimrich marked = false; 615*12fd6cc2SKarsten Heimrich fPaperFeed = new BPopUpMenu(""); 616*12fd6cc2SKarsten Heimrich fPaperFeed->SetRadioMode(true); 617*12fd6cc2SKarsten Heimrich count = fPrinterCap->countCap(PrinterCap::kPaperSource); 618*12fd6cc2SKarsten Heimrich const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)fPrinterCap->enumCap(PrinterCap::kPaperSource); 619*12fd6cc2SKarsten Heimrich while (count--) { 620*12fd6cc2SKarsten Heimrich item = new BMenuItem((*paper_source_cap)->label.c_str(), NULL); 621*12fd6cc2SKarsten Heimrich fPaperFeed->AddItem(item); 622*12fd6cc2SKarsten Heimrich if ((*paper_source_cap)->paper_source == fJobData->getPaperSource()) { 623*12fd6cc2SKarsten Heimrich item->SetMarked(true); 624*12fd6cc2SKarsten Heimrich marked = true; 625*12fd6cc2SKarsten Heimrich } 626*12fd6cc2SKarsten Heimrich paper_source_cap++; 627*12fd6cc2SKarsten Heimrich } 628*12fd6cc2SKarsten Heimrich if (!marked) 629*12fd6cc2SKarsten Heimrich item->SetMarked(true); 630*12fd6cc2SKarsten Heimrich menufield = new BMenuField(paperfeed_rect, "paperSource", "Paper Source:", fPaperFeed); 631*12fd6cc2SKarsten Heimrich AddChild(menufield); 632*12fd6cc2SKarsten Heimrich width = StringWidth("Number of Copies:") + 7; 633*12fd6cc2SKarsten Heimrich menufield->SetDivider(width); 634*12fd6cc2SKarsten Heimrich 635*12fd6cc2SKarsten Heimrich /* Page Per Sheet */ 636*12fd6cc2SKarsten Heimrich 637*12fd6cc2SKarsten Heimrich marked = false; 638*12fd6cc2SKarsten Heimrich fNup = new BPopUpMenu(""); 639*12fd6cc2SKarsten Heimrich fNup->SetRadioMode(true); 640*12fd6cc2SKarsten Heimrich count = sizeof(gNups) / sizeof(gNups[0]); 641*12fd6cc2SKarsten Heimrich const NupCap **nup_cap = gNups; 642*12fd6cc2SKarsten Heimrich while (count--) { 643*12fd6cc2SKarsten Heimrich item = new BMenuItem((*nup_cap)->label.c_str(), NULL); 644*12fd6cc2SKarsten Heimrich fNup->AddItem(item); 645*12fd6cc2SKarsten Heimrich if ((*nup_cap)->nup == fJobData->getNup()) { 646*12fd6cc2SKarsten Heimrich item->SetMarked(true); 647*12fd6cc2SKarsten Heimrich marked = true; 648*12fd6cc2SKarsten Heimrich } 649*12fd6cc2SKarsten Heimrich nup_cap++; 650*12fd6cc2SKarsten Heimrich } 651*12fd6cc2SKarsten Heimrich if (!marked) 652*12fd6cc2SKarsten Heimrich item->SetMarked(true); 653*12fd6cc2SKarsten Heimrich menufield = new BMenuField(nup_rect, "pagePerSheet", "Pages Per Sheet:", fNup); 654*12fd6cc2SKarsten Heimrich menufield->SetDivider(StringWidth("Number of Copies:") + 7); 655*12fd6cc2SKarsten Heimrich AddChild(menufield); 656*12fd6cc2SKarsten Heimrich 657*12fd6cc2SKarsten Heimrich /* duplex */ 658*12fd6cc2SKarsten Heimrich 659*12fd6cc2SKarsten Heimrich if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) { 660*12fd6cc2SKarsten Heimrich fDuplex = new BCheckBox(duplex_rect, "duplex", "Duplex", new BMessage(kMsgDuplexChanged)); 661*12fd6cc2SKarsten Heimrich AddChild(fDuplex); 662*12fd6cc2SKarsten Heimrich if (fJobData->getPrintStyle() != JobData::kSimplex) { 663*12fd6cc2SKarsten Heimrich fDuplex->SetValue(B_CONTROL_ON); 664*12fd6cc2SKarsten Heimrich } 665*12fd6cc2SKarsten Heimrich fDuplex->SetTarget(this); 666*12fd6cc2SKarsten Heimrich } else { 667*12fd6cc2SKarsten Heimrich fDuplex = NULL; 668*12fd6cc2SKarsten Heimrich } 669*12fd6cc2SKarsten Heimrich 670*12fd6cc2SKarsten Heimrich /* copies */ 671*12fd6cc2SKarsten Heimrich 672*12fd6cc2SKarsten Heimrich fCopies = new BTextControl(copies_rect, "copies", "Number of Copies:", "", NULL); 673*12fd6cc2SKarsten Heimrich AddChild(fCopies); 674*12fd6cc2SKarsten Heimrich fCopies->SetDivider(width); 675*12fd6cc2SKarsten Heimrich AllowOnlyDigits(fCopies->TextView(), 3); 676*12fd6cc2SKarsten Heimrich 677*12fd6cc2SKarsten Heimrich BString oss4; 678*12fd6cc2SKarsten Heimrich oss4 << fJobData->getCopies(); 679*12fd6cc2SKarsten Heimrich fCopies->SetText(oss4.String()); 680*12fd6cc2SKarsten Heimrich 681*12fd6cc2SKarsten Heimrich /* collate */ 682*12fd6cc2SKarsten Heimrich 683*12fd6cc2SKarsten Heimrich fCollate = new BCheckBox(collate_rect, "collate", "Collate", new BMessage(kMsgCollateChanged)); 684*12fd6cc2SKarsten Heimrich fCollate->ResizeToPreferred(); 685*12fd6cc2SKarsten Heimrich AddChild(fCollate); 686*12fd6cc2SKarsten Heimrich if (fJobData->getCollate()) { 687*12fd6cc2SKarsten Heimrich fCollate->SetValue(B_CONTROL_ON); 688*12fd6cc2SKarsten Heimrich } 689*12fd6cc2SKarsten Heimrich fCollate->SetTarget(this); 690*12fd6cc2SKarsten Heimrich 691*12fd6cc2SKarsten Heimrich /* reverse */ 692*12fd6cc2SKarsten Heimrich 693*12fd6cc2SKarsten Heimrich fReverse = new BCheckBox(reverse_rect, "reverse", "Reverse Order", new BMessage(kMsgReverseChanged)); 694*12fd6cc2SKarsten Heimrich fReverse->ResizeToPreferred(); 695*12fd6cc2SKarsten Heimrich AddChild(fReverse); 696*12fd6cc2SKarsten Heimrich if (fJobData->getReverse()) { 697*12fd6cc2SKarsten Heimrich fReverse->SetValue(B_CONTROL_ON); 698*12fd6cc2SKarsten Heimrich } 699*12fd6cc2SKarsten Heimrich fReverse->SetTarget(this); 700*12fd6cc2SKarsten Heimrich 701*12fd6cc2SKarsten Heimrich /* pages view */ 702*12fd6cc2SKarsten Heimrich 703*12fd6cc2SKarsten Heimrich fPages = new PagesView(pages_rect, "pages", B_FOLLOW_ALL, B_WILL_DRAW); 704*12fd6cc2SKarsten Heimrich AddChild(fPages); 705*12fd6cc2SKarsten Heimrich fPages->setCollate(fJobData->getCollate()); 706*12fd6cc2SKarsten Heimrich fPages->setReverse(fJobData->getReverse()); 707*12fd6cc2SKarsten Heimrich 708*12fd6cc2SKarsten Heimrich /* page selection */ 709*12fd6cc2SKarsten Heimrich BBox* pageSelectionBox = new BBox(page_selection_rect); 710*12fd6cc2SKarsten Heimrich AddChild(pageSelectionBox); 711*12fd6cc2SKarsten Heimrich pageSelectionBox->SetLabel("Page Selection"); 712*12fd6cc2SKarsten Heimrich 713*12fd6cc2SKarsten Heimrich fAllPages = AddPageSelectionItem(pageSelectionBox, page_selection_all_pages_rect, "allPages", "All Pages", JobData::kAllPages); 714*12fd6cc2SKarsten Heimrich fOddNumberedPages = AddPageSelectionItem(pageSelectionBox, page_selection_odd_pages_rect, "oddPages", "Odd-Numbered Pages", JobData::kOddNumberedPages); 715*12fd6cc2SKarsten Heimrich fEvenNumberedPages = AddPageSelectionItem(pageSelectionBox, page_selection_even_pages_rect, "evenPages", "Even-Numbered Pages", JobData::kEvenNumberedPages); 716*12fd6cc2SKarsten Heimrich 717*12fd6cc2SKarsten Heimrich 718*12fd6cc2SKarsten Heimrich 719*12fd6cc2SKarsten Heimrich /* preview */ 720*12fd6cc2SKarsten Heimrich 721*12fd6cc2SKarsten Heimrich button = new BButton(preview_rect, "preview", "Preview" B_UTF8_ELLIPSIS, new BMessage(kMsgPreview)); 722*12fd6cc2SKarsten Heimrich AddChild(button); 723*12fd6cc2SKarsten Heimrich 724*12fd6cc2SKarsten Heimrich 725*12fd6cc2SKarsten Heimrich /* cancel */ 726*12fd6cc2SKarsten Heimrich 727*12fd6cc2SKarsten Heimrich button = new BButton(cancel_rect, "cancel", "Cancel", new BMessage(kMsgCancel)); 728*12fd6cc2SKarsten Heimrich AddChild(button); 729*12fd6cc2SKarsten Heimrich 730*12fd6cc2SKarsten Heimrich /* ok */ 731*12fd6cc2SKarsten Heimrich 732*12fd6cc2SKarsten Heimrich // TODO OK or "Print"? 733*12fd6cc2SKarsten Heimrich button = new BButton(ok_rect, "ok", "OK", new BMessage(kMsgOK)); 734*12fd6cc2SKarsten Heimrich AddChild(button); 735*12fd6cc2SKarsten Heimrich button->MakeDefault(true); 736*12fd6cc2SKarsten Heimrich 737*12fd6cc2SKarsten Heimrich UpdateButtonEnabledState(); 738*12fd6cc2SKarsten Heimrich } 739*12fd6cc2SKarsten Heimrich 740*12fd6cc2SKarsten Heimrich void 741*12fd6cc2SKarsten Heimrich JobSetupView::UpdateButtonEnabledState() 742*12fd6cc2SKarsten Heimrich { 743*12fd6cc2SKarsten Heimrich bool pageRangeEnabled = fAll->Value() != B_CONTROL_ON; 744*12fd6cc2SKarsten Heimrich fFromPage->SetEnabled(pageRangeEnabled); 745*12fd6cc2SKarsten Heimrich fToPage->SetEnabled(pageRangeEnabled); 746*12fd6cc2SKarsten Heimrich 747*12fd6cc2SKarsten Heimrich bool pageSelectionEnabled = fDuplex == NULL || 748*12fd6cc2SKarsten Heimrich fDuplex->Value() != B_CONTROL_ON; 749*12fd6cc2SKarsten Heimrich fAllPages->SetEnabled(pageSelectionEnabled); 750*12fd6cc2SKarsten Heimrich fOddNumberedPages->SetEnabled(pageSelectionEnabled); 751*12fd6cc2SKarsten Heimrich fEvenNumberedPages->SetEnabled(pageSelectionEnabled); 752*12fd6cc2SKarsten Heimrich } 753*12fd6cc2SKarsten Heimrich 754*12fd6cc2SKarsten Heimrich void 755*12fd6cc2SKarsten Heimrich JobSetupView::MessageReceived(BMessage *msg) 756*12fd6cc2SKarsten Heimrich { 757*12fd6cc2SKarsten Heimrich switch (msg->what) { 758*12fd6cc2SKarsten Heimrich case kMsgRangeAll: 759*12fd6cc2SKarsten Heimrich case kMsgRangeSelection: 760*12fd6cc2SKarsten Heimrich case kMsgDuplexChanged: 761*12fd6cc2SKarsten Heimrich UpdateButtonEnabledState(); 762*12fd6cc2SKarsten Heimrich break; 763*12fd6cc2SKarsten Heimrich 764*12fd6cc2SKarsten Heimrich case kMsgQuality: 765*12fd6cc2SKarsten Heimrich fHalftone->preview(getGamma(), getInkDensity(), getDitherType(), getColor() != JobData::kMonochrome); 766*12fd6cc2SKarsten Heimrich break; 767*12fd6cc2SKarsten Heimrich 768*12fd6cc2SKarsten Heimrich case kMsgCollateChanged: 769*12fd6cc2SKarsten Heimrich fPages->setCollate(fCollate->Value() == B_CONTROL_ON); 770*12fd6cc2SKarsten Heimrich break; 771*12fd6cc2SKarsten Heimrich 772*12fd6cc2SKarsten Heimrich case kMsgReverseChanged: 773*12fd6cc2SKarsten Heimrich fPages->setReverse(fReverse->Value() == B_CONTROL_ON); 774*12fd6cc2SKarsten Heimrich break; 775*12fd6cc2SKarsten Heimrich } 776*12fd6cc2SKarsten Heimrich } 777*12fd6cc2SKarsten Heimrich 778*12fd6cc2SKarsten Heimrich JobData::Color 779*12fd6cc2SKarsten Heimrich JobSetupView::getColor() 780*12fd6cc2SKarsten Heimrich { 781*12fd6cc2SKarsten Heimrich int count = fPrinterCap->countCap(PrinterCap::kColor); 782*12fd6cc2SKarsten Heimrich const ColorCap **color_cap = (const ColorCap**)fPrinterCap->enumCap(PrinterCap::kColor); 783*12fd6cc2SKarsten Heimrich const char *color_label = fColorType->FindMarked()->Label(); 784*12fd6cc2SKarsten Heimrich while (count--) { 785*12fd6cc2SKarsten Heimrich if (!strcmp((*color_cap)->label.c_str(), color_label)) { 786*12fd6cc2SKarsten Heimrich return (*color_cap)->color; 787*12fd6cc2SKarsten Heimrich } 788*12fd6cc2SKarsten Heimrich color_cap++; 789*12fd6cc2SKarsten Heimrich } 790*12fd6cc2SKarsten Heimrich return JobData::kMonochrome; 791*12fd6cc2SKarsten Heimrich } 792*12fd6cc2SKarsten Heimrich 793*12fd6cc2SKarsten Heimrich Halftone::DitherType 794*12fd6cc2SKarsten Heimrich JobSetupView::getDitherType() 795*12fd6cc2SKarsten Heimrich { 796*12fd6cc2SKarsten Heimrich int count = sizeof(gDitherTypes) / sizeof(gDitherTypes[0]); 797*12fd6cc2SKarsten Heimrich const DitherCap **dither_cap = gDitherTypes; 798*12fd6cc2SKarsten Heimrich const char *dithering_label = fDitherType->FindMarked()->Label(); 799*12fd6cc2SKarsten Heimrich while (count --) { 800*12fd6cc2SKarsten Heimrich if (strcmp((*dither_cap)->label.c_str(), dithering_label) == 0) { 801*12fd6cc2SKarsten Heimrich return (*dither_cap)->dither_type; 802*12fd6cc2SKarsten Heimrich } 803*12fd6cc2SKarsten Heimrich dither_cap ++; 804*12fd6cc2SKarsten Heimrich } 805*12fd6cc2SKarsten Heimrich return Halftone::kTypeFloydSteinberg; 806*12fd6cc2SKarsten Heimrich } 807*12fd6cc2SKarsten Heimrich 808*12fd6cc2SKarsten Heimrich float 809*12fd6cc2SKarsten Heimrich JobSetupView::getGamma() 810*12fd6cc2SKarsten Heimrich { 811*12fd6cc2SKarsten Heimrich const float value = (float)fGamma->Value(); 812*12fd6cc2SKarsten Heimrich return pow(2.0, value / 100.0); 813*12fd6cc2SKarsten Heimrich } 814*12fd6cc2SKarsten Heimrich 815*12fd6cc2SKarsten Heimrich float 816*12fd6cc2SKarsten Heimrich JobSetupView::getInkDensity() 817*12fd6cc2SKarsten Heimrich { 818*12fd6cc2SKarsten Heimrich const float value = (float)(127 - fInkDensity->Value()); 819*12fd6cc2SKarsten Heimrich return value; 820*12fd6cc2SKarsten Heimrich } 821*12fd6cc2SKarsten Heimrich 822*12fd6cc2SKarsten Heimrich bool 823*12fd6cc2SKarsten Heimrich JobSetupView::UpdateJobData(bool showPreview) 824*12fd6cc2SKarsten Heimrich { 825*12fd6cc2SKarsten Heimrich int count; 826*12fd6cc2SKarsten Heimrich 827*12fd6cc2SKarsten Heimrich /* 828*12fd6cc2SKarsten Heimrich count = sizeof(gSurfaces) / sizeof(gSurfaces[0]); 829*12fd6cc2SKarsten Heimrich const SurfaceCap **surface_cap = gSurfaces; 830*12fd6cc2SKarsten Heimrich const char *surface_label = fSurfaceType->FindMarked()->Label(); 831*12fd6cc2SKarsten Heimrich while (count--) { 832*12fd6cc2SKarsten Heimrich if (!strcmp((*surface_cap)->label.c_str(), surface_label)) { 833*12fd6cc2SKarsten Heimrich fJobData->setSurfaceType((*surface_cap)->surface_type); 834*12fd6cc2SKarsten Heimrich break; 835*12fd6cc2SKarsten Heimrich } 836*12fd6cc2SKarsten Heimrich surface_cap++; 837*12fd6cc2SKarsten Heimrich } 838*12fd6cc2SKarsten Heimrich */ 839*12fd6cc2SKarsten Heimrich fJobData->setShowPreview(showPreview); 840*12fd6cc2SKarsten Heimrich fJobData->setColor(getColor()); 841*12fd6cc2SKarsten Heimrich fJobData->setGamma(getGamma()); 842*12fd6cc2SKarsten Heimrich fJobData->setInkDensity(getInkDensity()); 843*12fd6cc2SKarsten Heimrich fJobData->setDitherType(getDitherType()); 844*12fd6cc2SKarsten Heimrich 845*12fd6cc2SKarsten Heimrich int first_page; 846*12fd6cc2SKarsten Heimrich int last_page; 847*12fd6cc2SKarsten Heimrich 848*12fd6cc2SKarsten Heimrich if (B_CONTROL_ON == fAll->Value()) { 849*12fd6cc2SKarsten Heimrich first_page = 1; 850*12fd6cc2SKarsten Heimrich last_page = -1; 851*12fd6cc2SKarsten Heimrich } else { 852*12fd6cc2SKarsten Heimrich first_page = atoi(fFromPage->Text()); 853*12fd6cc2SKarsten Heimrich last_page = atoi(fToPage->Text()); 854*12fd6cc2SKarsten Heimrich } 855*12fd6cc2SKarsten Heimrich 856*12fd6cc2SKarsten Heimrich fJobData->setFirstPage(first_page); 857*12fd6cc2SKarsten Heimrich fJobData->setLastPage(last_page); 858*12fd6cc2SKarsten Heimrich 859*12fd6cc2SKarsten Heimrich count = fPrinterCap->countCap(PrinterCap::kPaperSource); 860*12fd6cc2SKarsten Heimrich const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)fPrinterCap->enumCap(PrinterCap::kPaperSource); 861*12fd6cc2SKarsten Heimrich const char *paper_source_label = fPaperFeed->FindMarked()->Label(); 862*12fd6cc2SKarsten Heimrich while (count--) { 863*12fd6cc2SKarsten Heimrich if (!strcmp((*paper_source_cap)->label.c_str(), paper_source_label)) { 864*12fd6cc2SKarsten Heimrich fJobData->setPaperSource((*paper_source_cap)->paper_source); 865*12fd6cc2SKarsten Heimrich break; 866*12fd6cc2SKarsten Heimrich } 867*12fd6cc2SKarsten Heimrich paper_source_cap++; 868*12fd6cc2SKarsten Heimrich } 869*12fd6cc2SKarsten Heimrich 870*12fd6cc2SKarsten Heimrich count = sizeof(gNups) / sizeof(gNups[0]); 871*12fd6cc2SKarsten Heimrich const NupCap **nup_cap = gNups; 872*12fd6cc2SKarsten Heimrich const char *nup_label = fNup->FindMarked()->Label(); 873*12fd6cc2SKarsten Heimrich while (count--) { 874*12fd6cc2SKarsten Heimrich if (!strcmp((*nup_cap)->label.c_str(), nup_label)) { 875*12fd6cc2SKarsten Heimrich fJobData->setNup((*nup_cap)->nup); 876*12fd6cc2SKarsten Heimrich break; 877*12fd6cc2SKarsten Heimrich } 878*12fd6cc2SKarsten Heimrich nup_cap++; 879*12fd6cc2SKarsten Heimrich } 880*12fd6cc2SKarsten Heimrich 881*12fd6cc2SKarsten Heimrich if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) { 882*12fd6cc2SKarsten Heimrich fJobData->setPrintStyle((B_CONTROL_ON == fDuplex->Value()) ? JobData::kDuplex : JobData::kSimplex); 883*12fd6cc2SKarsten Heimrich } 884*12fd6cc2SKarsten Heimrich 885*12fd6cc2SKarsten Heimrich fJobData->setCopies(atoi(fCopies->Text())); 886*12fd6cc2SKarsten Heimrich 887*12fd6cc2SKarsten Heimrich fJobData->setCollate((B_CONTROL_ON == fCollate->Value()) ? true : false); 888*12fd6cc2SKarsten Heimrich fJobData->setReverse((B_CONTROL_ON == fReverse->Value()) ? true : false); 889*12fd6cc2SKarsten Heimrich 890*12fd6cc2SKarsten Heimrich JobData::PageSelection pageSelection = JobData::kAllPages; 891*12fd6cc2SKarsten Heimrich if (fOddNumberedPages->Value() == B_CONTROL_ON) 892*12fd6cc2SKarsten Heimrich pageSelection = JobData::kOddNumberedPages; 893*12fd6cc2SKarsten Heimrich if (fEvenNumberedPages->Value() == B_CONTROL_ON) 894*12fd6cc2SKarsten Heimrich pageSelection = JobData::kEvenNumberedPages; 895*12fd6cc2SKarsten Heimrich fJobData->setPageSelection(pageSelection); 896*12fd6cc2SKarsten Heimrich 897*12fd6cc2SKarsten Heimrich fJobData->save(); 898*12fd6cc2SKarsten Heimrich return true; 899*12fd6cc2SKarsten Heimrich } 900*12fd6cc2SKarsten Heimrich 901*12fd6cc2SKarsten Heimrich //==================================================================== 902*12fd6cc2SKarsten Heimrich 903*12fd6cc2SKarsten Heimrich JobSetupDlg::JobSetupDlg(JobData *job_data, PrinterData *printer_data, const PrinterCap *printer_cap) 904*12fd6cc2SKarsten Heimrich : DialogWindow(BRect(100, 100, 100 + PRINT_WIDTH, 100 + PRINT_HEIGHT), 905*12fd6cc2SKarsten Heimrich "PrintJob Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, 906*12fd6cc2SKarsten Heimrich B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) 907*12fd6cc2SKarsten Heimrich { 908*12fd6cc2SKarsten Heimrich SetResult(B_ERROR); 909*12fd6cc2SKarsten Heimrich AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED)); 910*12fd6cc2SKarsten Heimrich 911*12fd6cc2SKarsten Heimrich fJobSetup = new JobSetupView(Bounds(), job_data, printer_data, printer_cap); 912*12fd6cc2SKarsten Heimrich AddChild(fJobSetup); 913*12fd6cc2SKarsten Heimrich } 914*12fd6cc2SKarsten Heimrich 915*12fd6cc2SKarsten Heimrich void 916*12fd6cc2SKarsten Heimrich JobSetupDlg::MessageReceived(BMessage *msg) 917*12fd6cc2SKarsten Heimrich { 918*12fd6cc2SKarsten Heimrich switch (msg->what) { 919*12fd6cc2SKarsten Heimrich case kMsgOK: 920*12fd6cc2SKarsten Heimrich case kMsgPreview: 921*12fd6cc2SKarsten Heimrich fJobSetup->UpdateJobData(msg->what == kMsgPreview); 922*12fd6cc2SKarsten Heimrich SetResult(B_NO_ERROR); 923*12fd6cc2SKarsten Heimrich PostMessage(B_QUIT_REQUESTED); 924*12fd6cc2SKarsten Heimrich break; 925*12fd6cc2SKarsten Heimrich 926*12fd6cc2SKarsten Heimrich case kMsgCancel: 927*12fd6cc2SKarsten Heimrich PostMessage(B_QUIT_REQUESTED); 928*12fd6cc2SKarsten Heimrich break; 929*12fd6cc2SKarsten Heimrich 930*12fd6cc2SKarsten Heimrich default: 931*12fd6cc2SKarsten Heimrich DialogWindow::MessageReceived(msg); 932*12fd6cc2SKarsten Heimrich break; 933*12fd6cc2SKarsten Heimrich } 934*12fd6cc2SKarsten Heimrich } 935