]> git.lyx.org Git - lyx.git/blob - src/Bullet.h
Avoid full metrics computation with Update:FitCursor
[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         /// The text to be output
49         docstring const & getText() const;
50         /// The label displayed in the workarea
51         docstring const & getLabel() 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         static docstring const bulletSize(int);
85         ///
86         static FontSize bulletFontSize(int);
87         ///
88         static docstring const bulletLabel(int, int);
89
90         ///
91         int font;
92         ///
93         int character;
94         ///
95         int size;
96
97         // size, character and font are array indices to access
98         // the predefined arrays of LaTeX equivalent strings.
99
100         /** flag indicates if user has control of text (1)
101             or if I can use it to generate strings (0)
102             or have already (-1)
103         */
104         mutable short user_text;
105
106         //NOTE: Arranging these four shorts above to be together
107         //      like this should ensure they are in a single cache line
108
109         /** text may contain a user-defined LaTeX symbol command
110             or one generated internally from the font, character
111             and size settings.
112         */
113         mutable docstring text;
114         mutable docstring label;
115 };
116
117
118 inline
119 bool operator!=(Bullet const & b1, Bullet const & b2)
120 {
121         return !(b1 == b2);
122 }
123
124 ///
125 extern
126 Bullet const ITEMIZE_DEFAULTS[];
127
128
129 } // namespace lyx
130
131 #endif /* BULLET_H_ */