change on-disk names
[AROS.git] / workbench / c / iprefs / printerprefs.c
blob59aec71b571d76173440644b275e854ab38e67e6
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*********************************************************************************************/
11 #include "global.h"
13 #define DEBUG 0
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>
24 /*********************************************************************************************/
26 static LONG stopchunks[] =
28 ID_PREF, ID_PTXT,
29 ID_PREF, ID_PGFX
32 void PrinterPrefs_Handler(STRPTR filename)
34 struct IFFHandle *iff;
35 struct PrinterTxtPrefs *ptp;
36 struct PrinterGfxPrefs *pgp;
38 D(bug("[PrinterPrefs] filename=%s\n",filename));
40 iff = CreateIFF(filename, stopchunks, 2);
41 if (iff)
43 struct Preferences prefs;
44 GetPrefs(&prefs, sizeof(prefs));
46 while(ParseIFF(iff, IFFPARSE_SCAN) == 0)
48 struct ContextNode *cn = CurrentChunk(iff);
49 switch(cn->cn_ID)
51 case ID_PTXT:
52 ptp = LoadChunk(iff, sizeof(struct PrinterTxtPrefs), MEMF_ANY);
53 if (ptp)
55 strncpy(prefs.PrtDevName, ptp->pt_Driver, DRIVERNAMESIZE);
56 prefs.PrinterPort = ptp->pt_Port;
57 prefs.PaperType = AROS_BE2WORD(ptp->pt_PaperType);
58 prefs.PaperSize = AROS_BE2WORD(ptp->pt_PaperSize);
59 prefs.PaperLength = AROS_BE2WORD(ptp->pt_PaperLength);
60 prefs.PrintPitch = AROS_BE2WORD(ptp->pt_Pitch);
61 prefs.PrintSpacing = AROS_BE2WORD(ptp->pt_Spacing);
62 prefs.PrintLeftMargin = AROS_BE2WORD(ptp->pt_LeftMargin);
63 prefs.PrintRightMargin = AROS_BE2WORD(ptp->pt_RightMargin);
64 prefs.PrintQuality = AROS_BE2WORD(ptp->pt_Quality);
66 FreeVec(ptp);
68 break;
69 case ID_PGFX:
70 pgp = LoadChunk(iff, sizeof(struct PrinterGfxPrefs), MEMF_ANY);
71 if (pgp)
73 prefs.PrintAspect = AROS_BE2WORD(pgp->pg_Aspect);
74 prefs.PrintShade = AROS_BE2WORD(pgp->pg_Shade);
75 prefs.PrintImage = AROS_BE2WORD(pgp->pg_Image);
76 prefs.PrintThreshold = AROS_BE2WORD(pgp->pg_Threshold);
77 //prefs.ColorCorrect = pgp->pg_ColorCorrect;
78 //prefs.Dimensions = pgp->pg_Dimensions;
79 //prefs.Dithering = pgp->pg_Dithering;
80 //prefs.GraphicFlags = AROS_BE2WORD(pgp->pg_GraphicFlags);
81 prefs.PrintDensity = pgp->pg_PrintDensity;
82 prefs.PrintMaxWidth = AROS_BE2WORD(pgp->pg_PrintMaxWidth);
83 prefs.PrintMaxHeight = AROS_BE2WORD(pgp->pg_PrintMaxHeight);
84 prefs.PrintXOffset = pgp->pg_PrintXOffset;
85 //prefs.PrintYOffset = pgp->pg_PrintYOffset;
87 FreeVec(pgp);
89 break;
92 KillIFF(iff);
93 SetPrefs(&prefs, sizeof(prefs), TRUE);