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 #ifdef DEBUG_AS_DEFAULT
32 Bullet(const int f = -1, const int c = -1, const int s = -1);
35 Bullet(const string &);
41 void setCharacter(const int);
43 void setFont(const int);
45 void setSize(const int);
47 void setText(const string &);
49 int getCharacter() const;
55 string getText() const;
61 Bullet & operator = (const Bullet &);
63 friend bool operator == (const Bullet &, const Bullet &);
65 friend bool operator != (const Bullet & b1, const Bullet & b2)
72 #ifdef DEBUG_AS_DEFAULT
73 void testInvariant() const
76 assert(font < FONTMAX);
77 assert(character >= MIN);
78 assert(character < CHARMAX);
80 assert(size < SIZEMAX);
81 assert(user_text >= -1);
82 assert(user_text <= 1);
83 // now some relational/operational tests
85 assert(font == -1 && (character == -1 && size == -1));
86 // assert(!text.empty()); // this isn't necessarily an error
88 // else if (user_text == -1) {
89 // assert(!text.empty()); // this also isn't necessarily an error
93 // assert(text.empty()); // not usually true
100 This enum makes adding additional panels or changing panel sizes
101 easier. Since you only need change these values for all tests to
102 be correct for the new values.
104 Note: MAX means the size of the array so to test you need:
105 (x < MAX) *not* (x <= MAX)
121 static const string & bulletSize(const short &);
123 static const string & bulletEntry(const short &, const short &);
132 // size, character and font are array indices to access
133 // the predefined arrays of LaTeX equivalent strings.
135 /** flag indicates if user has control of text (1)
136 or if I can use it to generate strings (0)
141 //NOTE: Arranging these four shorts above to be together
142 // like this should ensure they are in a single cache line
144 /** text may contain a user-defined LaTeX symbol command
145 or one generated internally from the font, character
152 /*----------------Inline Bullet Member Functions------------------*/
154 inline Bullet::Bullet(const string & t)
155 : font(MIN), character(MIN), size(MIN), user_text(1), text(t)
157 #ifdef DEBUG_AS_DEFAULT
163 inline Bullet::~Bullet()
167 inline void Bullet::setCharacter(const int c)
169 if (c < MIN || c >= CHARMAX) {
176 #ifdef DEBUG_AS_DEFAULT
182 inline void Bullet::setFont(const int f)
184 if (f < MIN || f >= FONTMAX) {
191 #ifdef DEBUG_AS_DEFAULT
197 inline void Bullet::setSize(const int s)
199 if (s < MIN || s >= SIZEMAX) {
206 #ifdef DEBUG_AS_DEFAULT
212 inline void Bullet::setText(const string & t)
214 font = character = size = MIN;
217 #ifdef DEBUG_AS_DEFAULT
223 inline int Bullet::getCharacter() const
229 inline int Bullet::getFont() const
235 inline int Bullet::getSize() const
241 inline string Bullet::getText() const
247 inline Bullet & Bullet::operator = (const Bullet & b)
249 #ifdef DEBUG_AS_DEFAULT
253 character = b.character;
255 user_text = b.user_text;
257 #ifdef DEBUG_AS_DEFAULT
258 this->testInvariant();
264 inline const char * Bullet::c_str()
266 return this->getText().c_str();
270 /*-----------------End Bullet Member Functions-----------------*/
272 /** The four LaTeX itemize environment default bullets
274 static Bullet const ITEMIZE_DEFAULTS[4] = { Bullet( 0, 8 ),//"\\(\\bullet\\)"
275 Bullet( 0, 0 ),//"\\normalfont\\bfseries{--}"
276 Bullet( 0, 6 ),//"\\(\\ast\\)"
277 Bullet( 0,10 ) };//"\\(\\cdot\\)"
278 #endif /* BULLET_H_ */