Debian Codegraph @

HercPrinter/Stationery.cpp

raw symbols SCIP
1 #include "Stationery.h"
2 #include "HerculesStudio.h"
3
4 static const char *paperSizeNames[] =
5 {
6 "Letter",
7 "Legal",
8 "Ledger/Tabloid",
9 "Letter FanFold",
10 "Legal FanFold",
11 "Std FanFold",
12 "A0",
13 "A1",
14 "A2",
15 "A3",
16 "A4",
17 "A5",
18 "Custom"
19 };
20
21 const char *Stationery::mBarsColorNames[] =
22 {
23 "Green",
24 "Gray",
25 "Light Blue",
26 "None",
27 "Custom"
28 };
29
30
31 const int barsColors[][3] =
32 {
33 {0xdd, 0xff, 0xdd}, // Green
34 {0xd2, 0xd2, 0xd2}, // Gray
35 {0xe0, 0xf0, 0xf0}, // Light Blue
36 {0xff, 0xff, 0xff} // None
37 };
38
39 Stationery::Stationery(const QString& name, const QString& paperSize, const QString& size1, const QString& size2,
40 int topMargin, bool millimeters, bool portrait, const QString& barsColor,
41 const QString& barsRGB, bool Decorated, bool tractorFeedHoles) :
42 mName(name),
43 mPaperSize(paperSize),
44 mSize1(size1),
45 mSize2(size2),
46 mTopMargin(topMargin),
47 mMillimeters(millimeters),
48 mPortrait(portrait),
49 mBarsColor(barsColor),
50 mBarsRGB(barsRGB),
51 mDecorated(Decorated),
52 mTractorFeedHoles(tractorFeedHoles)
53 {
54 }
55
56 unsigned int Stationery::paperSizes()
57 {
58 return sizeof(paperSizeNames)/sizeof(char *);
59 }
60
61 const char *Stationery::paperSize(unsigned int i)
62 {
63 return paperSizeNames[i];
64 }
65
66
67 int Stationery::getBarsColorIndex()
68 {
69 for (int i=0; i<4; i++)
70 {
71 if (mBarsColor.compare(mBarsColorNames[i]) == 0)
72 return i;
73 }
74 return -1;
75 }
76
77 int * Stationery::getBarsColor(int *fill)
78 {
79 if (mBarsColor.compare("Custom") == 0)
80 {
81 QString hex = QString("0x") + mBarsRGB.right(6);
82 int color = hex.toInt(0,16);
83 fill[0] = color >> 16;
84 fill[1] = (color >> 8) & 0xff;
85 fill[2] = color & 0xff;
86 return fill;
87 }
88 int index = getBarsColorIndex();
89 memcpy(fill, barsColors[index], 3*sizeof(int));
90 return fill;
91 }