]> git.lyx.org Git - lyx.git/blob - src/Bullet.h
b31602c3c03487c640a3e8f7b8a31b56532248a0
[lyx.git] / src / Bullet.h
1 // -*- C++ -*-
2 /**
3  * \file Bullet.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Allan Rae
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef BULLET_H
14 #define BULLET_H
15
16 #include "FontEnums.h"
17
18 #include "support/docstring.h"
19
20
21 namespace lyx {
22
23 ///
24 class Bullet {
25 public:
26         ///
27         Bullet(int f = -1, int c = -1, int s = -1);
28
29         ///
30         explicit Bullet(docstring const &);
31
32         ///
33         void setCharacter(int);
34         ///
35         void setFont(int);
36         ///
37         void setSize(int);
38         ///
39         void setText(docstring const &);
40         ///
41         int getCharacter() const;
42         ///
43         int getFont() const;
44         ///
45         int getSize() const;
46         ///
47         FontSize getFontSize() const;
48         ///
49         docstring const & getText() const;
50         ///
51         docstring const & getUnicode() const;
52         ///
53         Bullet & operator=(Bullet const &);
54         ///
55         friend bool operator==(Bullet const &, Bullet const &);
56         ///
57         static docstring const bulletEntry(int, int);
58 protected:
59         ///
60         void testInvariant() const;
61 private:
62         /**
63            This enum makes adding additional panels or changing panel sizes
64            easier. Since you only need change these values for all tests to
65            be correct for the new values.
66
67            Note: MAX means the size of the array so to test you need:
68            (x < MAX)  *not* (x <= MAX)
69         */
70         enum {
71                 ///
72                 MIN = -1,
73                 ///
74                 FONTMAX = 6,
75                 ///
76                 CHARMAX = 36,
77                 ///
78                 SIZEMAX = 10
79         };
80
81         ///
82         void generateText() const;
83         ///
84         void generateUnicode() const;
85         ///
86         static docstring const bulletSize(int);
87         ///
88         static FontSize bulletFontSize(int);
89         ///
90         static docstring const bulletUnicode(int, int);
91
92         ///
93         int font;
94         ///
95         int character;
96         ///
97         int size;
98
99         // size, character and font are array indices to access
100         // the predefined arrays of LaTeX equivalent strings.
101
102         /** flag indicates if user has control of text (1)
103             or if I can use it to generate strings (0)
104             or have already (-1)
105         */
106         mutable short user_text;
107
108         //NOTE: Arranging these four shorts above to be together
109         //      like this should ensure they are in a single cache line
110
111         /** text may contain a user-defined LaTeX symbol command
112             or one generated internally from the font, character
113             and size settings.
114         */
115         mutable docstring text;
116         mutable docstring unicode;
117 };
118
119
120 inline
121 bool operator!=(Bullet const & b1, Bullet const & b2)
122 {
123         return !(b1 == b2);
124 }
125
126 ///
127 extern
128 Bullet const ITEMIZE_DEFAULTS[];
129
130
131 } // namespace lyx
132
133 #endif /* BULLET_H_ */