2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright (C) 1995 1996 Matthias Ettrich
10 *======================================================*/
26 /// Scaled point (65536sp = 1pt) TeX's smallest unit.
28 /// Point = 1/72.27in = 0.351mm
30 /// Big point (72bp = 1in), also PostScript point
32 /// Didot point = 1/72 of a French inch, = 0.376mm
34 /// Millimeter = 2.845pt
36 /// Pica = 12pt = 4.218mm
38 /// Cicero = 12dd = 4.531mm
40 /// Centimeter = 10mm = 2.371pc
42 /// Inch = 25.4mm = 72.27pt = 6.022pc
44 /// Height of a small "x" for the current font.
46 /// Width of capital "M" in current font.
48 /// Math unit (18mu = 1em) for positioning in math mode
57 LyXLength() : val(0), uni(LyXLength::PT) {};
58 LyXLength(float v, LyXLength::UNIT u) : val(v), uni(u) {};
60 /** "data" must be a decimal number, followed by a unit. */
61 LyXLength(LString const & data);
67 float value() const { return val; };
69 LyXLength::UNIT unit() const { return uni; };
73 bool operator==(LyXLength other);
76 virtual LString asString() const;
77 virtual LString asLatexString() const { return this->asString(); };
80 /** If "data" is valid, the length represented by it is
81 stored into "result", if that is not NULL. */
82 friend bool isValidLength(LString const & data,
83 LyXLength* result=NULL);
90 extern LyXLength::UNIT unitFromString (LString const & data);
91 extern bool isValidLength(LString const &data, LyXLength* result);
93 /// LyXGlueLength class
94 class LyXGlueLength : public LyXLength {
99 LyXGlueLength(float v, LyXLength::UNIT u,
100 float pv=0.0, LyXLength::UNIT pu=LyXLength::UNIT_NONE,
101 float mv=0.0, LyXLength::UNIT mu=LyXLength::UNIT_NONE)
103 plus_val(pv), minus_val(mv),
104 plus_uni(pu), minus_uni(mu) {};
106 /** "data" must be a decimal number, followed by a unit, and
107 optional "glue" indicated by "+" and "-". You may abbreviate
108 reasonably. Examples:
109 1.2 cm // 4mm +2pt // 2cm -4mm +2mm // 4+0.1-0.2cm
110 The traditional Latex format is also accepted, like
111 4cm plus 10pt minus 10pt */
112 LyXGlueLength(LString const & data);
118 float plusValue() const { return plus_val; };
120 LyXLength::UNIT plusUnit() const { return plus_uni; };
122 float minusValue() const { return minus_val; };
124 LyXLength::UNIT minusUnit() const { return minus_uni; };
128 bool operator==(LyXGlueLength other);
131 virtual LString asString() const;
132 virtual LString asLatexString() const;
135 /** If "data" is valid, the length represented by it is
136 stored into "result", if that is not NULL. */
137 friend bool isValidGlueLength(LString const & data,
138 LyXGlueLength* result=NULL);
141 float plus_val, minus_val;
142 LyXLength::UNIT plus_uni, minus_uni;
145 extern bool isValidGlueLength(LString const &data, LyXGlueLength* result);
151 enum vspace_kind { NONE, DEFSKIP,
152 SMALLSKIP, MEDSKIP, BIGSKIP,
157 len(0.0, LyXLength::PT),
160 VSpace(vspace_kind k) :
162 len (0.0, LyXLength::PT),
165 VSpace(LyXGlueLength l) :
170 VSpace(float v, LyXLength::UNIT u) :
175 /// this constructor is for reading from a .lyx file
176 VSpace(LString const & data);
179 vspace_kind kind() const { return kin; }
180 LyXLength length() const { return len; }
182 // a flag that switches between \vspace and \vspace*
183 bool keep() const { return kp; }
184 void setKeep(bool val) { kp = val; }
186 bool operator== (VSpace other);
189 LString asLyXCommand() const; // how it goes into the LyX file
190 LString asLatexCommand() const;
191 int inPixels() const;