]> git.lyx.org Git - lyx.git/blob - src/lyxlength.h
Use paragraph iterators in CutAndPaste::SwitchLayoutsBetweenClasses
[lyx.git] / src / lyxlength.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *      
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef LYX_LENGTH_H
13 #define LYX_LENGTH_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "LString.h"
20
21 //
22 ///  LyXLength Class
23 //
24 class LyXLength {
25 public:
26         /// length units
27         enum UNIT {
28                 /// Scaled point (65536sp = 1pt) TeX's smallest unit.
29                 SP,
30                 /// Point = 1/72.27in = 0.351mm
31                 PT,
32                 /// Big point (72bp = 1in), also PostScript point
33                 BP,
34                 /// Didot point = 1/72 of a French inch, = 0.376mm
35                 DD,
36                 /// Millimeter = 2.845pt
37                 MM,
38                 /// Pica = 12pt = 4.218mm
39                 PC,
40                 /// Cicero = 12dd = 4.531mm
41                 CC,
42                 /// Centimeter = 10mm = 2.371pc
43                 CM,
44                 /// Inch = 25.4mm = 72.27pt = 6.022pc
45                 IN,
46                 /// Height of a small "x" for the current font.
47                 EX,
48                 /// Width of capital "M" in current font.
49                 EM,
50                 /// Math unit (18mu = 1em) for positioning in math mode
51                 MU,
52                 /// Percent of columnwidth both "%" or "%c"
53                 PW,
54                 ///
55                 PE,
56                 /// Percent of pagewidth
57                 PP,
58                 /// Percent of linewidth
59                 PL,
60                 /// no unit
61                 UNIT_NONE
62         };
63
64         ///
65         LyXLength();
66         ///
67         LyXLength(double v, LyXLength::UNIT u);
68
69         /// "data" must be a decimal number, followed by a unit
70         explicit LyXLength(string const & data);
71
72         ///
73         double value() const;
74         ///
75         LyXLength::UNIT unit() const;
76         ///
77         void value(double);
78         ///
79         void unit(LyXLength::UNIT unit);
80         ///
81         bool zero() const;
82         /// conversion
83         string const asString() const;
84         ///
85         string const asLatexString() const;
86
87         /** If "data" is valid, the length represented by it is
88           stored into "result", if that is not 0. */
89         friend bool isValidLength(string const & data, LyXLength * result = 0);
90
91 private:
92         ///
93         double          val_;
94         ///
95         LyXLength::UNIT unit_;
96 };
97
98 ///
99 bool operator==(LyXLength const & l1, LyXLength const & l2);
100 ///
101 bool isValidLength(string const & data, LyXLength * result);
102 ///
103 char const * stringFromUnit(int unit);
104
105 #endif