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