1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8     begin                : Jan 2005
9     copyright            : (C) 2005 by Craig Bradney
10     email                : cbradney@zip.com.au
11  ***************************************************************************/
12 
13 /***************************************************************************
14  *                                                                         *
15  *   This program is free software; you can redistribute it and/or modify  *
16  *   it under the terms of the GNU General Public License as published by  *
17  *   the Free Software Foundation; either version 2 of the License, or     *
18  *   (at your option) any later version.                                   *
19  *                                                                         *
20  ***************************************************************************/
21 
22 #ifndef UNITS_H
23 #define UNITS_H
24 
25 #include "scribusapi.h"
26 #include <QString>
27 #include <QStringList>
28 
29 #define UNITMIN 0
30 #define UNITMAX 7
31 
32 enum scUnit {
33 	SC_POINTS      = 0,
34 	SC_PT          = 0,
35 	SC_MILLIMETERS = 1,
36 	SC_MM          = 1,
37 	SC_INCHES      = 2,
38 	SC_IN          = 2,
39 	SC_PICAS       = 3,
40 	SC_P           = 3,
41 	SC_CENTIMETERS = 4,
42 	SC_CM          = 4,
43 	SC_CICERO      = 5,
44 	SC_C           = 5,
45 	SC_DEGREES     = 6,
46 	SC_DEG         = 6,
47 	SC_PERCENT     = 7,
48 	SC_PCT         = 7
49 };
50 
51 double SCRIBUS_API unitGetRatioFromIndex(const int index);
52 int SCRIBUS_API unitGetBaseFromIndex(const int index);
53 QString SCRIBUS_API unitGetStrFromIndex(const int index);
54 QString SCRIBUS_API unitGetUntranslatedStrFromIndex(const int index);
55 QString SCRIBUS_API unitGetSuffixFromIndex(const int index);
56 int SCRIBUS_API unitGetDecimalsFromIndex(const int index);
57 int SCRIBUS_API unitGetPrecisionFromIndex(const int index);
58 double SCRIBUS_API unitValueFromString(const QString& value);
59 scUnit SCRIBUS_API unitIndexFromString(const QString& value);
60 QStringList SCRIBUS_API unitGetTextUnitList();
61 int SCRIBUS_API unitGetMaxIndex();
62 double SCRIBUS_API mm2pts(double mm);
63 double SCRIBUS_API in2pts(double in);
64 double SCRIBUS_API p2pts(double p);
65 double SCRIBUS_API cm2pts(double cm);
66 double SCRIBUS_API c2pts(double c);
67 double SCRIBUS_API pts2mm(double pts);
68 double SCRIBUS_API pts2in(double pts);
69 double SCRIBUS_API pts2p(double pts);
70 double SCRIBUS_API pts2cm(double pts);
71 double SCRIBUS_API pts2c(double pts);
72 double SCRIBUS_API pts2value(double unitValue, int unit);
73 double SCRIBUS_API value2pts(double unitValue, int unit);
74 double SCRIBUS_API value2value(double unitValue, int primaryUnit, int secondaryUnit);
75 QString SCRIBUS_API value2String(double unitValue, int unitIndex, bool round2Precision, bool appendSuffix);
76 //Ruler specific functions
77 double SCRIBUS_API unitRulerGetIter1FromIndex(const int index);
78 double SCRIBUS_API unitRulerGetIter2FromIndex(const int index);
79 bool SCRIBUS_API unitValidForDocUnit(const int index);
80 
81 #endif // UNITS_H
82 
83