2 /* This is the bullet class definition file.
4 * ======================================================
6 * LyX, The Document Processor
8 * Copyright 1995 Matthias Ettrich
9 * Copyright 1995-1999 The LyX Team.
11 * This file Copyright 1997-1999
13 * ====================================================== */
24 #include "support/LAssert.h"
30 Bullet(const int f = -1, const int c = -1, const int s = -1);
33 Bullet(string const &);
36 void setCharacter(const int);
38 void setFont(const int);
40 void setSize(const int);
42 void setText(string const &);
44 int getCharacter() const;
50 string getText() const;
56 Bullet & operator = (const Bullet &);
58 friend bool operator == (const Bullet &, const Bullet &);
60 friend bool operator != (const Bullet & b1, const Bullet & b2)
67 #ifdef ENABLE_ASSERTIONS
68 void testInvariant() const
71 Assert(font < FONTMAX);
72 Assert(character >= MIN);
73 Assert(character < CHARMAX);
75 Assert(size < SIZEMAX);
76 Assert(user_text >= -1);
77 Assert(user_text <= 1);
78 // now some relational/operational tests
80 Assert(font == -1 && (character == -1 && size == -1));
81 // Assert(!text.empty()); // this isn't necessarily an error
83 // else if (user_text == -1) {
84 // Assert(!text.empty()); // this also isn't necessarily an error
88 // Assert(text.empty()); // not usually true
95 This enum makes adding additional panels or changing panel sizes
96 easier. Since you only need change these values for all tests to
97 be correct for the new values.
99 Note: MAX means the size of the array so to test you need:
100 (x < MAX) *not* (x <= MAX)
116 static string bulletSize(const short &);
118 static string bulletEntry(const short &, const short &);
127 // size, character and font are array indices to access
128 // the predefined arrays of LaTeX equivalent strings.
130 /** flag indicates if user has control of text (1)
131 or if I can use it to generate strings (0)
136 //NOTE: Arranging these four shorts above to be together
137 // like this should ensure they are in a single cache line
139 /** text may contain a user-defined LaTeX symbol command
140 or one generated internally from the font, character
147 /*----------------Inline Bullet Member Functions------------------*/
149 inline Bullet::Bullet(string const & t)
150 : font(MIN), character(MIN), size(MIN), user_text(1), text(t)
152 #ifdef ENABLE_ASSERTIONS
158 inline void Bullet::setCharacter(const int c)
160 if (c < MIN || c >= CHARMAX) {
167 #ifdef ENABLE_ASSERTIONS
173 inline void Bullet::setFont(const int f)
175 if (f < MIN || f >= FONTMAX) {
182 #ifdef ENABLE_ASSERTIONS
188 inline void Bullet::setSize(const int s)
190 if (s < MIN || s >= SIZEMAX) {
197 #ifdef ENABLE_ASSERTIONS
203 inline void Bullet::setText(string const & t)
205 font = character = size = MIN;
208 #ifdef ENABLE_ASSERTIONS
214 inline int Bullet::getCharacter() const
220 inline int Bullet::getFont() const
226 inline int Bullet::getSize() const
232 inline string Bullet::getText() const
238 inline Bullet & Bullet::operator = (const Bullet & b)
240 #ifdef ENABLE_ASSERTIONS
244 character = b.character;
246 user_text = b.user_text;
248 #ifdef ENABLE_ASSERTIONS
249 this->testInvariant();
255 inline char const * Bullet::c_str()
257 return this->getText().c_str();
261 /*-----------------End Bullet Member Functions-----------------*/
263 /** The four LaTeX itemize environment default bullets
265 static Bullet const ITEMIZE_DEFAULTS[4] = { Bullet( 0, 8 ),//"\\(\\bullet\\)"
266 Bullet( 0, 0 ),//"\\normalfont\\bfseries{--}"
267 Bullet( 0, 6 ),//"\\(\\ast\\)"
268 Bullet( 0, 10 ) };//"\\(\\cdot\\)"
269 #endif /* BULLET_H_ */