2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
9 /*********************************************************************************************/
14 #include <aros/debug.h>
15 #include <aros/macros.h>
16 #include <datatypes/pictureclass.h>
17 #include <prefs/prefhdr.h>
18 #include <prefs/printertxt.h>
19 #include <prefs/printergfx.h>
21 #include <intuition/iprefs.h>
22 #include <proto/datatypes.h>
26 /*********************************************************************************************/
28 static LONG stopchunks
[] =
34 void PrinterPrefs_Handler(STRPTR filename
)
36 struct IFFHandle
*iff
;
37 struct PrinterTxtPrefs
*ptp
;
38 struct PrinterGfxPrefs
*pgp
;
41 BOOL name_too_long
= FALSE
;
43 D(bug("[PrinterPrefs] filename=%s\n", filename
));
45 iff
= CreateIFF(filename
, stopchunks
, 2);
48 struct Preferences prefs
;
49 GetPrefs(&prefs
, sizeof(prefs
));
51 while(ParseIFF(iff
, IFFPARSE_SCAN
) == 0)
53 struct ContextNode
*cn
= CurrentChunk(iff
);
57 ptp
= LoadChunk(iff
, sizeof(struct PrinterTxtPrefs
), MEMF_ANY
);
60 devname
= FilePart(ptp
->pt_Driver
);
61 devnamelen
= strlen(devname
);
62 if (devnamelen
< DEVNAME_SIZE
+ DEV_EXT_LEN
)
64 if (devnamelen
>= DEV_EXT_LEN
&& !strcmp(
65 &devname
[devnamelen
- DEV_EXT_LEN
], ".device"))
67 CopyMem(devname
, prefs
.PrtDevName
, devnamelen
- DEV_EXT_LEN
);
68 prefs
.PrtDevName
[devnamelen
- DEV_EXT_LEN
] = '0';
70 else if (devnamelen
< DEVNAME_SIZE
)
72 strncpy(prefs
.PrtDevName
, devname
, sizeof(prefs
.PrtDevName
) - 1);
81 bug("[IPREFS] ERROR: printer device name (%s) "
82 "is too long!", devname
);
84 prefs
.PrinterPort
= ptp
->pt_Port
;
85 prefs
.PaperType
= AROS_BE2WORD(ptp
->pt_PaperType
);
86 prefs
.PaperSize
= AROS_BE2WORD(ptp
->pt_PaperSize
);
87 prefs
.PaperLength
= AROS_BE2WORD(ptp
->pt_PaperLength
);
88 prefs
.PrintPitch
= AROS_BE2WORD(ptp
->pt_Pitch
);
89 prefs
.PrintSpacing
= AROS_BE2WORD(ptp
->pt_Spacing
);
90 prefs
.PrintLeftMargin
= AROS_BE2WORD(ptp
->pt_LeftMargin
);
91 prefs
.PrintRightMargin
= AROS_BE2WORD(ptp
->pt_RightMargin
);
92 prefs
.PrintQuality
= AROS_BE2WORD(ptp
->pt_Quality
);
98 pgp
= LoadChunk(iff
, sizeof(struct PrinterGfxPrefs
), MEMF_ANY
);
101 prefs
.PrintAspect
= AROS_BE2WORD(pgp
->pg_Aspect
);
102 prefs
.PrintShade
= AROS_BE2WORD(pgp
->pg_Shade
);
103 prefs
.PrintImage
= AROS_BE2WORD(pgp
->pg_Image
);
104 prefs
.PrintThreshold
= AROS_BE2WORD(pgp
->pg_Threshold
);
105 //prefs.ColorCorrect = pgp->pg_ColorCorrect;
106 //prefs.Dimensions = pgp->pg_Dimensions;
107 //prefs.Dithering = pgp->pg_Dithering;
108 //prefs.GraphicFlags = AROS_BE2WORD(pgp->pg_GraphicFlags);
109 prefs
.PrintDensity
= pgp
->pg_PrintDensity
;
110 prefs
.PrintMaxWidth
= AROS_BE2WORD(pgp
->pg_PrintMaxWidth
);
111 prefs
.PrintMaxHeight
= AROS_BE2WORD(pgp
->pg_PrintMaxHeight
);
112 prefs
.PrintXOffset
= pgp
->pg_PrintXOffset
;
113 //prefs.PrintYOffset = pgp->pg_PrintYOffset;
121 SetPrefs(&prefs
, sizeof(prefs
), TRUE
);