1 /* Completes the implementation of the Bullet class
2 * It defines the various LaTeX commands etc. required to
3 * generate the bullets in the bullet-panel's.
6 * ======================================================
8 * LyX, The Document Processor
10 * Copyright 1997-1998 Allan Rae
13 * ====================================================== */
18 #pragma implementation
23 /** The four LaTeX itemize environment default bullets
26 Bullet const ITEMIZE_DEFAULTS[4] = { Bullet( 0, 8 ),//"\\(\\bullet\\)"
27 Bullet( 0, 0 ),//"\\normalfont\\bfseries{--}"
28 Bullet( 0, 6 ),//"\\(\\ast\\)"
29 Bullet( 0, 10 ) };//"\\(\\cdot\\)"
31 // will need these later if still using full text as below
32 // \usepackage{latexsym,pifont,amssymb}
33 // and wasysym when that panel is created
36 Bullet::Bullet(int f, int c, int s)
37 : font(f), character(c), size(s), user_text(0)
39 if (f < MIN || f >= FONTMAX) {
42 if (c < MIN || c >= CHARMAX) {
45 if (s < MIN || s >= SIZEMAX) {
49 #ifdef ENABLE_ASSERTIONS
55 string const & Bullet::getText() const
64 bool operator==(const Bullet & b1, const Bullet & b2)
68 if (b1.user_text && b2.user_text) {
69 /* both have valid text */
70 if (b1.text == b2.text) {
73 } else if (((b1.character == b2.character) &&
74 (b1.font == b2.font)) &&
75 (b1.size == b2.size)) {
82 /*--------------------Private Member Functions-------------------*/
85 void Bullet::generateText() const
88 // user hasn't defined their own text and/or I haven't generated
89 // the text for the current font/character settings yet
90 // thus the calling member function should say:
91 // if (user_text == 0) {
94 // Since a function call is more expensive than a conditional
95 // this is more efficient. Besides this function is internal to
96 // the class so it's only the class author that has access --
97 // external users thus can't make mistakes.
99 if ((font >= 0) && (character >= 0)) {
100 text = bulletEntry(font, character);
102 text = bulletSize(size) + text;
105 // text is now defined and doesn't need to be recalculated
106 // unless font/character or text is modified
111 string const Bullet::bulletSize(short int s)
113 // use a parameter rather than hard code `size' in here
114 // in case some future function may want to retrieve
115 // an arbitrary entry.
116 // See additional comments in bulletEntry() below.
118 static char const * BulletSize[SIZEMAX] = {
119 "\\tiny", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize",
120 "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"
123 return BulletSize[s];
127 string const Bullet::bulletEntry(short int f, short int c)
129 // Despite how this may at first appear the static local variables
130 // are only initialized once..
131 // This is a work-around to avoid the "Static Initialization Problem"
132 // and should work for all compilers. See "C++ FAQs" by Cline and Lomow,
133 // Addison-Wesley, 1994, FAQ-180 pp169-171 for an explanation.
134 // Doing things this way also makes it possible to generate `text' at
135 // the time of construction. It also encapsulates the conversion
136 // of font, character and size entries to text.
138 // The single 2-dim array had to be changed to multiple 1-dim arrays
139 // to get around a compiler bug in an earler version of gcc (< 2.7.2.1)
140 // static string const BulletPanels[FONTMAX][CHARMAX] = {
141 static char const * BulletPanel0[CHARMAX] = {
143 "\\normalfont\\bfseries{--}", "\\(\\vdash\\)",
144 "\\(\\dashv\\)", "\\(\\flat\\)", "\\(\\natural\\)",
145 "\\(\\sharp\\)", "\\(\\ast\\)", "\\(\\star\\)",
146 "\\(\\bullet\\)", "\\(\\circ\\)", "\\(\\cdot\\)",
147 "\\(\\dagger\\)", "\\(\\bigtriangleup\\)",
148 "\\(\\bigtriangledown\\)", "\\(\\triangleleft\\)",
149 "\\(\\triangleright\\)", "\\(\\lhd\\)", "\\(\\rhd\\)",
150 "\\(\\oplus\\)", "\\(\\ominus\\)", "\\(\\otimes\\)",
151 "\\(\\oslash\\)", "\\(\\odot\\)", "\\(\\spadesuit\\)",
152 "\\(\\diamond\\)", "\\(\\Diamond\\)", "\\(\\Box\\)",
153 "\\(\\diamondsuit\\)", "\\(\\heartsuit\\)",
154 "\\(\\clubsuit\\)", "\\(\\rightarrow\\)", "\\(\\leadsto\\)",
155 "\\(\\rightharpoonup\\)", "\\(\\rightharpoondown\\)",
156 "\\(\\Rightarrow\\)", "\\(\\succ\\)"
158 static char const * BulletPanel1[CHARMAX] = {
160 "\\(\\Rrightarrow\\)", "\\(\\rightarrowtail\\)",
161 "\\(\\twoheadrightarrow\\)", "\\(\\rightsquigarrow\\)",
162 "\\(\\looparrowright\\)", "\\(\\multimap\\)",
163 "\\(\\boxtimes\\)", "\\(\\boxplus\\)", "\\(\\boxminus\\)",
164 "\\(\\boxdot\\)", "\\(\\divideontimes\\)", "\\(\\Vvdash\\)",
165 "\\(\\lessdot\\)", "\\(\\gtrdot\\)", "\\(\\maltese\\)",
166 "\\(\\bigstar\\)", "\\(\\checkmark\\)", "\\(\\Vdash\\)",
167 "\\(\\backsim\\)", "\\(\\thicksim\\)",
168 "\\(\\centerdot\\)", "\\(\\circleddash\\)",
169 "\\(\\circledast\\)", "\\(\\circledcirc\\)",
170 "\\(\\vartriangleleft\\)", "\\(\\vartriangleright\\)",
171 "\\(\\vartriangle\\)", "\\(\\triangledown\\)",
172 "\\(\\lozenge\\)", "\\(\\square\\)", "\\(\\blacktriangleleft\\)",
173 "\\(\\blacktriangleright\\)", "\\(\\blacktriangle\\)",
174 "\\(\\blacktriangledown\\)", "\\(\\blacklozenge\\)",
175 "\\(\\blacksquare\\)"
177 static char const * BulletPanel2[CHARMAX] = {
179 "\\ding{108}", "\\ding{109}",
180 "\\ding{119}", "\\Pisymbol{psy}{197}",
181 "\\Pisymbol{psy}{196}", "\\Pisymbol{psy}{183}",
182 "\\ding{71}", "\\ding{70}",
183 "\\ding{118}", "\\ding{117}",
184 "\\Pisymbol{psy}{224}", "\\Pisymbol{psy}{215}",
185 "\\ding{111}", "\\ding{112}",
186 "\\ding{113}", "\\ding{114}",
187 "\\Pisymbol{psy}{68}", "\\Pisymbol{psy}{209}",
188 "\\ding{120}", "\\ding{121}",
189 "\\ding{122}", "\\ding{110}",
190 "\\ding{115}", "\\ding{116}",
191 "\\Pisymbol{psy}{42}", "\\ding{67}",
192 "\\ding{66}", "\\ding{82}",
193 "\\ding{81}", "\\ding{228}",
194 "\\ding{162}", "\\ding{163}",
195 "\\ding{166}", "\\ding{167}",
196 "\\ding{226}", "\\ding{227}"
198 static char const * BulletPanel3[CHARMAX] = {
200 "\\ding{37}", "\\ding{38}",
201 "\\ding{34}", "\\ding{36}",
202 "\\ding{39}", "\\ding{40}",
203 "\\ding{41}", "\\ding{42}",
204 "\\ding{43}", "\\ding{44}",
205 "\\ding{45}", "\\ding{47}",
206 "\\ding{53}", "\\ding{54}",
207 "\\ding{59}", "\\ding{57}",
208 "\\ding{62}", "\\ding{61}",
209 "\\ding{55}", "\\ding{56}",
210 "\\ding{58}", "\\ding{60}",
211 "\\ding{63}", "\\ding{64}",
212 "\\ding{51}", "\\ding{52}",
213 "\\Pisymbol{psy}{170}", "\\Pisymbol{psy}{167}",
214 "\\Pisymbol{psy}{168}", "\\Pisymbol{psy}{169}",
215 "\\ding{164}", "\\ding{165}",
216 "\\ding{171}", "\\ding{168}",
217 "\\ding{169}", "\\ding{170}"
219 static char const * BulletPanel4[CHARMAX] = {
221 "\\ding{65}", "\\ding{76}",
222 "\\ding{75}", "\\ding{72}",
223 "\\ding{80}", "\\ding{74}",
224 "\\ding{78}", "\\ding{77}",
225 "\\ding{79}", "\\ding{85}",
226 "\\ding{90}", "\\ding{98}",
227 "\\ding{83}", "\\ding{84}",
228 "\\ding{86}", "\\ding{87}",
229 "\\ding{88}", "\\ding{89}",
230 "\\ding{92}", "\\ding{91}",
231 "\\ding{93}", "\\ding{105}",
232 "\\ding{94}", "\\ding{99}",
233 "\\ding{103}", "\\ding{104}",
234 "\\ding{106}", "\\ding{107}",
235 "\\ding{68}", "\\ding{69}",
236 "\\ding{100}", "\\ding{101}",
237 "\\ding{102}", "\\ding{96}",
238 "\\ding{95}", "\\ding{97}"
240 static char const * BulletPanel5[CHARMAX] = {
242 "\\ding{223}", "\\ding{224}",
243 "\\ding{225}", "\\ding{232}",
244 "\\ding{229}", "\\ding{230}",
245 "\\ding{238}", "\\ding{237}",
246 "\\ding{236}", "\\ding{235}",
247 "\\ding{234}", "\\ding{233}",
248 "\\ding{239}", "\\ding{241}",
249 "\\ding{250}", "\\ding{251}",
250 "\\ding{49}", "\\ding{50}",
251 "\\ding{217}", "\\ding{245}",
252 "\\ding{243}", "\\ding{248}",
253 "\\ding{252}", "\\ding{253}",
254 "\\ding{219}", "\\ding{213}",
255 "\\ding{221}", "\\ding{222}",
256 "\\ding{220}", "\\ding{212}",
257 "\\Pisymbol{psy}{174}", "\\Pisymbol{psy}{222}",
258 "\\ding{254}", "\\ding{242}",
259 "\\ding{231}", "\\Pisymbol{psy}{45}"
260 }; /* string const BulletPanels[][] */
262 static char const ** BulletPanels[FONTMAX] = {
263 BulletPanel0, BulletPanel1,
264 BulletPanel2, BulletPanel3,
265 BulletPanel4, BulletPanel5
268 return BulletPanels[f][c];