2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
32 /// Scaled point (65536sp = 1pt) TeX's smallest unit.
34 /// Point = 1/72.27in = 0.351mm
36 /// Big point (72bp = 1in), also PostScript point
38 /// Didot point = 1/72 of a French inch, = 0.376mm
40 /// Millimeter = 2.845pt
42 /// Pica = 12pt = 4.218mm
44 /// Cicero = 12dd = 4.531mm
46 /// Centimeter = 10mm = 2.371pc
48 /// Inch = 25.4mm = 72.27pt = 6.022pc
50 /// Height of a small "x" for the current font.
52 /// Width of capital "M" in current font.
54 /// Math unit (18mu = 1em) for positioning in math mode
56 /// Percent of columnwidth both "%" or "%c"
60 /// Percent of pagewidth
62 /// Percent of linewidth
71 LyXLength(double v, LyXLength::UNIT u);
73 /// "data" must be a decimal number, followed by a unit
74 explicit LyXLength(string const & data);
79 LyXLength::UNIT unit() const;
82 virtual string const asString() const;
84 virtual string const asLatexString() const;
86 /** If "data" is valid, the length represented by it is
87 stored into "result", if that is not 0. */
88 friend bool isValidLength(string const & data, LyXLength * result = 0);
94 LyXLength::UNIT unit_;
98 bool operator==(LyXLength const & l1, LyXLength const & l2);
100 LyXLength::UNIT unitFromString (string const & data);
102 bool isValidLength(string const & data, LyXLength * result);
104 const char * stringFromUnit(int unit);
109 /// LyXGlueLength class
111 class LyXGlueLength : public LyXLength {
114 LyXGlueLength(double v,
117 LyXLength::UNIT pu = LyXLength::UNIT_NONE,
119 LyXLength::UNIT mu = LyXLength::UNIT_NONE);
121 /** "data" must be a decimal number, followed by a unit, and
122 optional "glue" indicated by "+" and "-". You may abbreviate
123 reasonably. Examples:
124 1.2 cm // 4mm +2pt // 2cm -4mm +2mm // 4+0.1-0.2cm
125 The traditional Latex format is also accepted, like
126 4cm plus 10pt minus 10pt */
127 explicit LyXGlueLength(string const & data);
130 double plusValue() const;
132 LyXLength::UNIT plusUnit() const;
134 double minusValue() const;
136 LyXLength::UNIT minusUnit() const;
139 virtual string const asString() const;
141 virtual string const asLatexString() const;
144 /** If "data" is valid, the length represented by it is
145 stored into "result", if that is not 0. */
146 friend bool isValidGlueLength(string const & data,
147 LyXGlueLength* result = 0);
155 LyXLength::UNIT plus_unit_;
157 LyXLength::UNIT minus_unit_;
161 bool operator==(LyXGlueLength const & l1, LyXGlueLength const & l2);
163 bool operator!=(LyXGlueLength const & l1, LyXGlueLength const & l2);
165 bool isValidGlueLength(string const & data, LyXGlueLength * result);
173 /// The different kinds of spaces.
193 explicit VSpace(vspace_kind k);
195 explicit VSpace(LyXGlueLength l);
197 explicit VSpace(double v, LyXLength::UNIT u);
199 /// Constructor for reading from a .lyx file
200 explicit VSpace(string const & data);
203 vspace_kind kind() const;
205 LyXGlueLength length() const;
207 // a flag that switches between \vspace and \vspace*
210 void setKeep(bool val);
212 bool operator==(VSpace const &) const;
215 /// how it goes into the LyX file
216 string const asLyXCommand() const;
218 string const asLatexCommand(BufferParams const & params) const;
220 int inPixels(BufferView * bv) const;
222 int inPixels(int default_height, int default_skip, int default_width=0) const;