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 &);
39 void setCharacter(const int);
41 void setFont(const int);
43 void setSize(const int);
45 void setText(string const &);
47 int getCharacter() const;
53 string getText() const;
59 Bullet & operator = (const Bullet &);
61 friend bool operator == (const Bullet &, const Bullet &);
63 friend bool operator != (const Bullet & b1, const Bullet & b2)
70 #ifdef ENABLE_ASSERTIONS
71 void testInvariant() const
74 Assert(font < FONTMAX);
75 Assert(character >= MIN);
76 Assert(character < CHARMAX);
78 Assert(size < SIZEMAX);
79 Assert(user_text >= -1);
80 Assert(user_text <= 1);
81 // now some relational/operational tests
83 Assert(font == -1 && (character == -1 && size == -1));
84 // Assert(!text.empty()); // this isn't necessarily an error
86 // else if (user_text == -1) {
87 // Assert(!text.empty()); // this also isn't necessarily an error
91 // Assert(text.empty()); // not usually true
98 This enum makes adding additional panels or changing panel sizes
99 easier. Since you only need change these values for all tests to
100 be correct for the new values.
102 Note: MAX means the size of the array so to test you need:
103 (x < MAX) *not* (x <= MAX)
119 static string const & bulletSize(const short &);
121 static string const & bulletEntry(const short &, const short &);
130 // size, character and font are array indices to access
131 // the predefined arrays of LaTeX equivalent strings.
133 /** flag indicates if user has control of text (1)
134 or if I can use it to generate strings (0)
139 //NOTE: Arranging these four shorts above to be together
140 // like this should ensure they are in a single cache line
142 /** text may contain a user-defined LaTeX symbol command
143 or one generated internally from the font, character
150 /*----------------Inline Bullet Member Functions------------------*/
152 inline Bullet::Bullet(string const & t)
153 : font(MIN), character(MIN), size(MIN), user_text(1), text(t)
155 #ifdef ENABLE_ASSERTIONS
161 inline Bullet::~Bullet()
165 inline void Bullet::setCharacter(const int c)
167 if (c < MIN || c >= CHARMAX) {
174 #ifdef ENABLE_ASSERTIONS
180 inline void Bullet::setFont(const int f)
182 if (f < MIN || f >= FONTMAX) {
189 #ifdef ENABLE_ASSERTIONS
195 inline void Bullet::setSize(const int s)
197 if (s < MIN || s >= SIZEMAX) {
204 #ifdef ENABLE_ASSERTIONS
210 inline void Bullet::setText(string const & t)
212 font = character = size = MIN;
215 #ifdef ENABLE_ASSERTIONS
221 inline int Bullet::getCharacter() const
227 inline int Bullet::getFont() const
233 inline int Bullet::getSize() const
239 inline string Bullet::getText() const
245 inline Bullet & Bullet::operator = (const Bullet & b)
247 #ifdef ENABLE_ASSERTIONS
251 character = b.character;
253 user_text = b.user_text;
255 #ifdef ENABLE_ASSERTIONS
256 this->testInvariant();
262 inline char const * Bullet::c_str()
264 return this->getText().c_str();
268 /*-----------------End Bullet Member Functions-----------------*/
270 /** The four LaTeX itemize environment default bullets
272 static Bullet const ITEMIZE_DEFAULTS[4] = { Bullet( 0, 8 ),//"\\(\\bullet\\)"
273 Bullet( 0, 0 ),//"\\normalfont\\bfseries{--}"
274 Bullet( 0, 6 ),//"\\(\\ast\\)"
275 Bullet( 0, 10 ) };//"\\(\\cdot\\)"
276 #endif /* BULLET_H_ */