string const GUIDirectionNames[5] =
{ N_("LTR"), N_("RTL"), N_("Toggle"), N_("Inherit"), N_("Ignore") };
+
+#ifndef USE_PAINTER
string const GUIColorNames[13] =
{ N_("None"), N_("Black"), N_("White"), N_("Red"), N_("Green"), N_("Blue"),
N_("Cyan"), N_("Magenta"),
N_("Yellow"), N_("Math"), N_("Inset"), N_("Inherit"), N_("Ignore") };
-
+#endif
+
//
// Strings used to read and write .lyx format files
//
string const LyXMiscNames[12] =
{ "off", "on", "toggle", "default", "error" };
+#ifndef USE_PAINTER
string const LyXColorNames[13] =
{ "none", "black", "white", "red", "green", "blue", "cyan", "magenta",
"yellow", "matherror", "inseterror", "default", "error" };
+#endif
//
// Strings used to write LaTeX files
string const LaTeXSizeNames[14] =
{ "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large",
"Large", "LARGE", "huge", "Huge", "error8", "error9", "error10", "error11" };
-
+
+#ifndef USE_PAINTER
string const LaTeXColorNames[13] =
{ "none", "black", "white", "red", "green", "blue", "cyan", "magenta",
"yellow", "error12", "error13", "error14", "error15" };
+#endif
+
+#ifdef NEW_BITS
+LyXFont::FontBits LyXFont::sane = { ROMAN_FAMILY,
+ MEDIUM_SERIES,
+ UP_SHAPE,
+ SIZE_NORMAL,
+#ifdef USE_PAINTER
+ LColor::none,
+#else
+ NONE,
+#endif
+ OFF,
+ OFF,
+ OFF,
+ OFF,
+ LTR_DIR };
+
+LyXFont::FontBits LyXFont::inherit = { INHERIT_FAMILY,
+ INHERIT_SERIES,
+ INHERIT_SHAPE,
+ INHERIT_SIZE,
+#ifdef USE_PAINTER
+ LColor::inherit,
+#else
+ INHERIT_COLOR,
+#endif
+ INHERIT,
+ INHERIT,
+ INHERIT,
+ INHERIT,
+ INHERIT_DIR };
+
+LyXFont::FontBits LyXFont::ignore = { IGNORE_FAMILY,
+ IGNORE_SERIES,
+ IGNORE_SHAPE,
+ IGNORE_SIZE,
+#ifdef USE_PAINTER
+ LColor::ignore,
+#else
+ IGNORE_COLOR,
+#endif
+ IGNORE,
+ IGNORE,
+ IGNORE,
+ IGNORE,
+ IGNORE_DIR };
+#endif
/// Decreases font size by one
LyXFont & LyXFont::decSize()
lyxerr <<"Can't LyXFont::decSize on IGNORE_SIZE" << endl;
break;
}
- return (*this);
+ return *this;
}
lyxerr <<"Can't LyXFont::incSize on IGNORE_SIZE" << endl;
break;
}
- return (*this);
+ return *this;
}
setDirection(newfont.direction());
}
+#ifdef USE_PAINTER
+ if(newfont.color() == color() && toggleall)
+ setColor(LColor::inherit); // toggle 'back'
+ else if (newfont.color() != LColor::ignore)
+ setColor(newfont.color());
+#else
if(newfont.color() == color() && toggleall)
- setColor(INHERIT_COLOR); // toggle 'back'
- else if (newfont.color() != IGNORE_COLOR)
+ setColor(LyXFont::INHERIT_COLOR); // toggle 'back'
+ else if (newfont.color() != LyXFont::IGNORE_COLOR)
setColor(newfont.color());
+#endif
}
setNoun(INHERIT);
if (latex() == tmplt.latex())
setLatex(INHERIT);
+#ifdef USE_PAINTER
if (color() == tmplt.color())
- setColor(INHERIT_COLOR);
+ setColor(LColor::inherit);
+#else
+ if (color() == tmplt.color())
+ setColor(LyXFont::INHERIT_COLOR);
+#endif
if (direction() == tmplt.direction())
setDirection(INHERIT_DIR);
}
/// Realize font from a template
// This one is not pretty, but it's extremely fast (Asger)
+#ifdef NEW_BITS
+LyXFont & LyXFont::realize(LyXFont const & tmplt)
+{
+ if (bits == inherit) {
+ bits = tmplt.bits;
+ return *this;
+ }
+
+ if (bits.family == INHERIT_FAMILY) {
+ bits.family = tmplt.bits.family;
+ }
+ if (bits.series == INHERIT_SERIES) {
+ bits.series = tmplt.bits.series;
+ }
+ if (bits.shape == INHERIT_SHAPE) {
+ bits.shape = tmplt.bits.shape;
+ }
+ if (bits.size == INHERIT_SIZE) {
+ bits.size = tmplt.bits.size;
+ }
+ if (bits.emph == INHERIT) {
+ bits.emph = tmplt.bits.emph;
+ }
+ if (bits.underbar == INHERIT) {
+ bits.underbar = tmplt.bits.underbar;
+ }
+ if (bits.noun == INHERIT) {
+ bits.noun = tmplt.bits.noun;
+ }
+ if (bits.latex == INHERIT) {
+ bits.latex = tmplt.bits.latex;
+ }
+#ifdef USE_PAINTER
+ if (bits.color == LColor::inherit) {
+ bits.color = tmplt.bits.color;
+ }
+#else
+ if (bits.color == INHERIT_COLOR) {
+ bits.color = tmplt.bits.color;
+ }
+#endif
+ if (bits.direction == INHERIT_DIR) {
+ bits.direction = tmplt.bits.direction;
+ }
+
+ return *this;
+}
+#else
LyXFont & LyXFont::realize(LyXFont const & tmplt)
{
if (bits == inherit) {
bits &= ~(Misc_Mask << Lat_Pos);
bits |= (tmplt.bits & Misc_Mask << Lat_Pos);
}
+#ifdef USE_PAINTER
+ if ((bits & (Col_Mask << Col_Pos)) == ui32(LColor::inherit) << Col_Pos)
+ {
+ bits &= ~(Col_Mask << Col_Pos);
+ bits |= (tmplt.bits & Col_Mask << Col_Pos);
+ }
+#else
if ((bits & (Col_Mask << Col_Pos)) == ui32(INHERIT_COLOR) << Col_Pos)
{
bits &= ~(Col_Mask << Col_Pos);
bits |= (tmplt.bits & Col_Mask << Col_Pos);
}
+#endif
if ((bits & (Dir_Mask << Dir_Pos)) == ui32(INHERIT_DIR) << Dir_Pos)
{
bits &= ~(Dir_Mask << Dir_Pos);
return *this;
}
+#endif
/// Is font resolved?
+#ifdef USE_PAINTER
+bool LyXFont::resolved() const
+{
+ return (family() != INHERIT_FAMILY && series() != INHERIT_SERIES &&
+ shape() != INHERIT_SHAPE && size() != INHERIT_SIZE &&
+ emph() != INHERIT && underbar() != INHERIT &&
+ noun() != INHERIT && latex() != INHERIT &&
+ color() != LColor::inherit &&
+ direction() != INHERIT_DIR);
+}
+#else
bool LyXFont::resolved() const
{
return (family() != INHERIT_FAMILY && series() != INHERIT_SERIES &&
color() != INHERIT_COLOR &&
direction() != INHERIT_DIR);
}
+#endif
/// Build GUI description of font state
buf += string(_(GUIShapeNames[shape()].c_str())) + ", ";
if (size() != INHERIT_SIZE)
buf += string(_(GUISizeNames[size()].c_str())) + ", ";
+#ifdef USE_PAINTER
+ if (color() != LColor::inherit)
+ buf += lcolor.getGUIName(color()) + ", ";
+#else
if (color() != INHERIT_COLOR)
buf += string(_(GUIColorNames[color()].c_str())) + ", ";
-
+#endif
if (emph() != INHERIT)
buf += string(_("Emphasis ")) + _(GUIMiscNames[emph()].c_str()) + ", ";
if (underbar() != INHERIT)
/// Sets color after LyX text format
LyXFont & LyXFont::setLyXColor(string const & col)
{
+#ifdef USE_PAINTER
+ setColor(lcolor.getFromLyXName(col));
+#else
string s = lowercase(col);
int i= 0;
while (s != LyXColorNames[i] && LyXColorNames[i] != "error") ++i;
} else
lyxerr << "LyXFont::setLyXColor: Unknown Color `"
<< s << '\'' << endl;
+#endif
return *this;
}
/// Sets size after GUI name
LyXFont & LyXFont::setGUISize(string const & siz)
{
+#ifdef USE_PAINTER
+ /// ??????
+ // this is how it was how it was done in the lyx repository...
+ // but this does not make sense.
+ setColor(lcolor.getFromGUIName(siz));
+#else
string s = lowercase(siz);
int i = 0;
while (!lGUISizeNames[i].empty() &&
} else
lyxerr << "LyXFont::setGUISize: Unknown Size `"
<< s << '\'' << endl;
+#endif
return *this;
}
error = true;
}
}
- return * this;
+ return *this;
}
break;
}
}
+#ifdef USE_PAINTER
+ if (orgfont.color() != color()) {
+ os << "\\color " << lcolor.getLyXName(color()) << "\n";
+ }
+#else
if (orgfont.color() != color()) {
os << "\\color " << LyXColorNames[color()] << "\n";
}
+#endif
if (orgfont.direction() != direction()) {
switch (direction()) {
case RTL_DIR: os << "\\direction rtl \n"; break;
/// Writes the head of the LaTeX needed to impose this font
// Returns number of chars written.
-int LyXFont::latexWriteStartChanges(string & file, LyXFont const & base, LyXFont const & prev) const
+int LyXFont::latexWriteStartChanges(string & file, LyXFont const & base,
+ LyXFont const & prev) const
{
LyXFont f = *this;
f.reduce(base);
count += LaTeXShapeNames[f.shape()].length() + 2;
env = true; //We have opened a new environment
}
+#ifdef USE_PAINTER
+ if (f.color() != LColor::inherit) {
+ file += "\\textcolor{";
+ file += lcolor.getLaTeXName(f.color());
+ file += "}{";
+ count += lcolor.getLaTeXName(f.color()).length() + 13;
+ env = true; //We have opened a new environment
+ }
+#else
if (f.color() != INHERIT_COLOR) {
file += "\\textcolor{";
file += LaTeXColorNames[f.color()];
count += LaTeXColorNames[f.color()].length() + 13;
env = true; //We have opened a new environment
}
+#endif
if (f.emph() == ON) {
file += "\\emph{";
count += 6;
/// Writes ending block of LaTeX needed to close use of this font
// Returns number of chars written
// This one corresponds to latexWriteStartChanges(). (Asger)
-int LyXFont::latexWriteEndChanges(string & file, LyXFont const & base, LyXFont const & next) const
+int LyXFont::latexWriteEndChanges(string & file, LyXFont const & base,
+ LyXFont const & next) const
{
LyXFont f = *this; // why do you need this?
f.reduce(base); // why isn't this just "reduce(base);" (Lgb)
++count;
env = true; // Size change need not bother about closing env.
}
+#ifdef USE_PAINTER
+ if (f.color() != LColor::inherit) {
+ file += '}';
+ ++count;
+ env = true; // Size change need not bother about closing env.
+ }
+#else
if (f.color() != INHERIT_COLOR) {
file += '}';
++count;
env = true; // Size change need not bother about closing env.
}
+#endif
if (f.emph() == ON) {
file += '}';
++count;
}
+#ifdef USE_PAINTER
+LColor::color LyXFont::realColor() const
+{
+ if (latex() == ON)
+ return LColor::latex;
+ if (color() == LColor::none)
+ return LColor::foreground;
+ return color();
+}
+#endif
+
+
// Convert logical attributes to concrete shape attribute
LyXFont::FONT_SHAPE LyXFont::realShape() const
{
}
+#ifndef USE_PAINTER
GC LyXFont::getGC() const
{
GC gc;
XSetFont(fl_display, gc, getXFontstruct()->fid);
return gc;
}
+#endif
XFontStruct * LyXFont::getXFontstruct() const
}
+#ifdef USE_PAINTER
+int LyXFont::drawText(char const * s, int n, Pixmap,
+ int, int x) const
+{
+ if (realShape() != LyXFont::SMALLCAPS_SHAPE) {
+ /* XDrawString(fl_display,
+ pm,
+ getGC(),
+ x, baseline,
+ s, n);
+ XFlush(fl_display); */
+ return XTextWidth(getXFontstruct(), s, n);
+
+ } else {
+ // emulate smallcaps since X doesn't support this
+ char c;
+ int sx = x;
+ LyXFont smallfont = *this;
+ smallfont.decSize();
+ smallfont.decSize();
+ smallfont.setShape(LyXFont::UP_SHAPE);
+ for (int i = 0; i < n; ++i) {
+ c = s[i];
+ if (islower(static_cast<unsigned char>(c))){
+ c = toupper(c);
+ /* XDrawString(fl_display,
+ pm,
+ smallfont.getGC(),
+ x, baseline,
+ &c, 1); */
+ x += XTextWidth(smallfont.getXFontstruct(),
+ &c, 1);
+ //XFlush(fl_display);
+ } else {
+ /* XDrawString(fl_display,
+ pm,
+ getGC(),
+ x, baseline,
+ &c, 1);*/
+ x += XTextWidth(getXFontstruct(), &c, 1);
+ //XFlush(fl_display);
+ }
+ }
+ return x - sx;
+ }
+}
+#else
int LyXFont::drawText(char const * s, int n, Pixmap pm,
int baseline, int x) const
{
return x - sx;
}
}
+#endif
int LyXFont::drawString(string const & s, Pixmap pm, int baseline, int x) const