2 /* This is the bullet class definition file.
4 * ======================================================
6 * LyX, The Document Processor
8 * Copyright 1995 Matthias Ettrich
9 * Copyright 1995-2001 The LyX Team.
11 * This file Copyright 1997-1999
13 * ====================================================== */
24 #include "support/LAssert.h"
30 Bullet(int f = -1, int c = -1, int s = -1);
33 explicit Bullet(string const &);
36 void setCharacter(int);
42 void setText(string const &);
44 int getCharacter() const;
50 string const & getText() const;
52 Bullet & operator=(Bullet const &);
54 friend bool operator==(Bullet const &, Bullet const &);
56 #ifdef ENABLE_ASSERTIONS
58 void testInvariant() const {
59 lyx::Assert(font >= MIN);
60 lyx::Assert(font < FONTMAX);
61 lyx::Assert(character >= MIN);
62 lyx::Assert(character < CHARMAX);
63 lyx::Assert(size >= MIN);
64 lyx::Assert(size < SIZEMAX);
65 lyx::Assert(user_text >= -1);
66 lyx::Assert(user_text <= 1);
67 // now some relational/operational tests
69 lyx::Assert(font == -1 && (character == -1 && size == -1));
70 // Assert(!text.empty()); // this isn't necessarily an error
72 // else if (user_text == -1) {
73 // Assert(!text.empty()); // this also isn't necessarily an error
77 // Assert(text.empty()); // not usually true
83 This enum makes adding additional panels or changing panel sizes
84 easier. Since you only need change these values for all tests to
85 be correct for the new values.
87 Note: MAX means the size of the array so to test you need:
88 (x < MAX) *not* (x <= MAX)
102 void generateText() const;
104 static string const bulletSize(short int);
106 static string const bulletEntry(short int, short int);
115 // size, character and font are array indices to access
116 // the predefined arrays of LaTeX equivalent strings.
118 /** flag indicates if user has control of text (1)
119 or if I can use it to generate strings (0)
122 mutable short user_text;
124 //NOTE: Arranging these four shorts above to be together
125 // like this should ensure they are in a single cache line
127 /** text may contain a user-defined LaTeX symbol command
128 or one generated internally from the font, character
135 /*----------------Inline Bullet Member Functions------------------*/
138 Bullet::Bullet(string const & t)
139 : font(MIN), character(MIN), size(MIN), user_text(1), text(t)
141 #ifdef ENABLE_ASSERTIONS
148 void Bullet::setCharacter(int c)
150 if (c < MIN || c >= CHARMAX) {
156 #ifdef ENABLE_ASSERTIONS
163 void Bullet::setFont(int f)
165 if (f < MIN || f >= FONTMAX) {
171 #ifdef ENABLE_ASSERTIONS
178 void Bullet::setSize(int s)
180 if (s < MIN || s >= SIZEMAX) {
186 #ifdef ENABLE_ASSERTIONS
193 void Bullet::setText(string const & t)
195 font = character = size = MIN;
198 #ifdef ENABLE_ASSERTIONS
205 int Bullet::getCharacter() const
212 int Bullet::getFont() const
219 int Bullet::getSize() const
226 Bullet & Bullet::operator=(Bullet const & b)
228 #ifdef ENABLE_ASSERTIONS
232 character = b.character;
234 user_text = b.user_text;
236 #ifdef ENABLE_ASSERTIONS
237 this->testInvariant();
242 /*-----------------End Bullet Member Functions-----------------*/
245 bool operator!=(Bullet const & b1, Bullet const & b2)
252 Bullet const ITEMIZE_DEFAULTS[];
254 #endif /* BULLET_H_ */