// -*- C++ -*- /* Completes the implementation of the Bullet class * It defines the various LaTeX commands etc. required to * generate the bullets in the bullet-panel's. * * This file is part of *====================================================== * * LyX, The Document Processor * * Copyright (C) 1997-1998 Allan Rae * and the LyX Team *
*======================================================*/
#include <config.h>
#ifdef __GNUG__ #pragma implementation #endif
#include"Bullet.h"
// will need these later if still using full text as below // \usepackage{latexsym,pifont,amssymb} // and wasysym when that panel is created
Bullet::Bullet(constint f, constint c, constint s)
: font(f), character(c), size(s), user_text(0)
{ if (f < MIN || f >= FONTMAX) {
font = MIN;
} if (c < MIN || c >= CHARMAX) {
character = MIN;
} if (s < MIN || s >= SIZEMAX) {
size = MIN;
}
generateText(); #ifdef DEBUG_AS_DEFAULT
testInvariant(); #endif
}
if (b1.user_text && b2.user_text) { /* both have valid text */ if (b1.text == b2.text) {
result = true;
}
} elseif (((b1.character == b2.character) &&
(b1.font == b2.font)) &&
(b1.size == b2.size)) {
result = true;
} return result;
}
/*--------------------Private Member Functions-------------------*/
void Bullet::generateText()
{ // Assumption: // user hasn't defined their own text and/or I haven't generated // the text for the current font/character settings yet // thus the calling member function should say: // if (user_text == 0) { // generateText(); // } // Since a function call is more expensive than a conditional // this is more efficient. Besides this function is internal to // the class so it's only the class author that has access -- // external users thus can't make mistakes.
if ((font >= 0) && (character >= 0)) {
text = bulletEntry(font, character); if (size >= 0) {
text = bulletSize(size) + text;
}
user_text = -1; // text is now defined and doesn't need to be recalculated // unless font/character or text is modified
}
}
const LString & Bullet::bulletSize(constshort & s)
{ // use a parameter rather than hard code `size' in here
// in case some future function may want to retrieve
// an arbitrary entry.
// See additional comments in bulletEntry() below.
const LString & Bullet::bulletEntry(const short & f, const short & c)
{
// Despite how this may at first appear the static local variables
// are only initialized once..
// This is a work-around to avoid the "Static Initialization Problem"
// and should work forall compilers. See "C++ FAQs"by Cline and Lomow,
// Addison-Wesley, 1994, FAQ-180 pp169-171 for an explanation.
// Doing things this way also makes it possible to generate `text' at
// the timeof construction. It also encapsulates the conversion
// of font, character and size entries to text.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.