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