From 814a8411ebeac155f9ee9df915bce4ff731dd21b Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Sun, 8 Feb 2009 01:11:27 +0000 Subject: [PATCH] Reverse unwanted commits. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28388 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Changes.cpp | 8 ++----- src/Changes.h | 4 ++-- src/Color.cpp | 39 -------------------------------- src/Color.h | 35 ---------------------------- src/FontInfo.cpp | 4 +--- src/FontInfo.h | 7 +----- src/frontends/Painter.h | 20 ++++++++-------- src/frontends/qt4/ColorCache.cpp | 16 ++++--------- src/frontends/qt4/ColorCache.h | 4 ++-- src/frontends/qt4/GuiPainter.cpp | 18 +++++++-------- src/frontends/qt4/GuiPainter.h | 22 ++++++++---------- src/mathed/InsetMathNest.cpp | 3 +-- src/mathed/MathAutoCorrect.cpp | 2 +- src/mathed/MathAutoCorrect.h | 2 +- src/rowpainter.cpp | 6 ++--- 15 files changed, 47 insertions(+), 143 deletions(-) diff --git a/src/Changes.cpp b/src/Changes.cpp index 538893ad82..b49f255150 100644 --- a/src/Changes.cpp +++ b/src/Changes.cpp @@ -54,9 +54,9 @@ bool Change::isSimilarTo(Change const & change) const } -Color Change::color() const +ColorCode Change::color() const { - Color color = Color_none; + ColorCode color = Color_none; switch (author % 5) { case 0: color = Color_changedtextauthor1; @@ -74,10 +74,6 @@ Color Change::color() const color = Color_changedtextauthor5; break; } - - if (deleted()) - color.mergeColor = Color_white; - return color; } diff --git a/src/Changes.h b/src/Changes.h index 643a7fae38..09ac0aa0fe 100644 --- a/src/Changes.h +++ b/src/Changes.h @@ -15,7 +15,7 @@ #ifndef CHANGES_H #define CHANGES_H -#include "Color.h" +#include "ColorCode.h" #include "support/strfwd.h" #include "support/types.h" @@ -45,7 +45,7 @@ public: /// is the change similar to the given change such that both can be merged? bool isSimilarTo(Change const & change) const; /// The color of this change on screen - Color color() const; + ColorCode color() const; /// bool changed() const { return type != UNCHANGED; } /// diff --git a/src/Color.cpp b/src/Color.cpp index 6c6e32481f..7995eba380 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -84,45 +84,6 @@ RGBColor rgbFromHexName(string const & x11hexname) } -Color::Color(ColorCode base_color) : baseColor(base_color), - mergeColor(Color_ignore) -{} - - -bool Color::operator==(Color const & color) const -{ - return baseColor == color.baseColor; -} - - -bool Color::operator!=(Color const & color) const -{ - return baseColor != color.baseColor; -} - - -bool Color::operator<(Color const & color) const -{ - return baseColor < color.baseColor; -} - - -bool Color::operator<=(Color const & color) const -{ - return baseColor <= color.baseColor; -} - - -std::ostream & operator<<(std::ostream & os, Color color) -{ - os << to_ascii(lcolor.getGUIName(color.baseColor)); - if (color.mergeColor != Color_ignore) - os << "[merged with:" - << to_ascii(lcolor.getGUIName(color.mergeColor)) << "]"; - return os; -} - - ColorSet::ColorSet() { char const * grey40 = "#666666"; diff --git a/src/Color.h b/src/Color.h index ec1a2d9ba4..2841dc5ba6 100644 --- a/src/Color.h +++ b/src/Color.h @@ -28,41 +28,6 @@ namespace lyx { -/** - * \class Color - * - * A class holding a definition of a certain color. - * - * A color can be one of the following kinds: - * - * - a single color, then mergeColor = Color_ignore - * - a merged color, i.e. the average of the base and merge colors. - */ - -class Color -{ -public: - /// - Color(ColorCode base_color = Color_none); - - /// comparison operators. - //@{ - bool operator==(Color const & color) const; - bool operator!=(Color const & color) const; - bool operator<(Color const & color) const; - bool operator<=(Color const & color) const; - //@} - - /// the base color - ColorCode baseColor; - /// The color that is merged with the base color. Set - /// mergeColor to Color_ignore if no merging is wanted. - ColorCode mergeColor; -}; - -std::ostream & operator<<(std::ostream & os, Color color); - - /** * \class ColorSet * diff --git a/src/FontInfo.cpp b/src/FontInfo.cpp index b2ee8d7d27..c5b1c85a9b 100644 --- a/src/FontInfo.cpp +++ b/src/FontInfo.cpp @@ -278,10 +278,8 @@ bool FontInfo::resolved() const } -Color FontInfo::realColor() const +ColorCode FontInfo::realColor() const { - if (draw_color_ != Color_none) - return draw_color_; if (color_ == Color_none) return Color_foreground; return color_; diff --git a/src/FontInfo.h b/src/FontInfo.h index 29f26f2d8f..24951445ba 100644 --- a/src/FontInfo.h +++ b/src/FontInfo.h @@ -19,7 +19,6 @@ #include "tex2lyx/Font.h" #else -#include "Color.h" #include "ColorCode.h" #include "FontEnums.h" @@ -75,8 +74,6 @@ public: void setColor(ColorCode c) { color_ = c; } ColorCode background() const { return background_; } void setBackground(ColorCode b) { background_ = b; } - Color drawColor() const { return draw_color_; } - void setDrawColor(Color c) { draw_color_ = c; } ///@} /// @@ -92,7 +89,7 @@ public: bool resolved() const; /// - Color realColor() const; + ColorCode realColor() const; /// Converts logical attributes to concrete shape attribute /// Try hard to inline this as it shows up with 4.6 % in the profiler. @@ -138,8 +135,6 @@ private: /// ColorCode background_; /// - Color draw_color_; - /// FontState emph_; /// FontState underbar_; diff --git a/src/frontends/Painter.h b/src/frontends/Painter.h index 6bc46ec241..ab65b55adb 100644 --- a/src/frontends/Painter.h +++ b/src/frontends/Painter.h @@ -13,7 +13,7 @@ #ifndef PAINTER_H #define PAINTER_H -#include "Color.h" +#include "ColorCode.h" #include "support/strfwd.h" @@ -78,7 +78,7 @@ public: virtual ~Painter() {} /// draw a line from point to point - virtual void line(int x1, int y1, int x2, int y2, Color, + virtual void line(int x1, int y1, int x2, int y2, ColorCode, line_style = line_solid, line_width = line_thin) = 0; /** @@ -87,22 +87,22 @@ public: * @param yp array of points' y co-ords * @param np size of the points array */ - virtual void lines(int const * xp, int const * yp, int np, Color, + virtual void lines(int const * xp, int const * yp, int np, ColorCode, line_style = line_solid, line_width = line_thin) = 0; /// draw a rectangle - virtual void rectangle(int x, int y, int w, int h, Color, + virtual void rectangle(int x, int y, int w, int h, ColorCode, line_style = line_solid, line_width = line_thin) = 0; /// draw a filled rectangle - virtual void fillRectangle(int x, int y, int w, int h, Color) = 0; + virtual void fillRectangle(int x, int y, int w, int h, ColorCode) = 0; /// draw an arc virtual void arc(int x, int y, unsigned int w, unsigned int h, - int a1, int a2, Color) = 0; + int a1, int a2, ColorCode) = 0; /// draw a pixel - virtual void point(int x, int y, Color) = 0; + virtual void point(int x, int y, ColorCode) = 0; /// draw a filled rectangle with the shape of a 3D button virtual void button(int x, int y, int w, int h, bool mouseHover) = 0; @@ -136,7 +136,7 @@ public: * around the text with the given color. */ virtual void rectText(int x, int baseline, docstring const & str, - FontInfo const & font, Color back, Color frame) = 0; + FontInfo const & font, ColorCode back, ColorCode frame) = 0; /// draw a string and enclose it inside a button frame virtual void buttonText(int x, int baseline, docstring const & s, @@ -147,8 +147,8 @@ public: char_type c, FontInfo const & f, preedit_style style) = 0; /// start monochrome painting mode, i.e. map every color into [min,max] - virtual void enterMonochromeMode(Color const & min, - Color const & max) = 0; + virtual void enterMonochromeMode(ColorCode const & min, + ColorCode const & max) = 0; /// leave monochrome painting mode virtual void leaveMonochromeMode() = 0; diff --git a/src/frontends/qt4/ColorCache.cpp b/src/frontends/qt4/ColorCache.cpp index ec809a1dd5..69520fc738 100644 --- a/src/frontends/qt4/ColorCache.cpp +++ b/src/frontends/qt4/ColorCache.cpp @@ -28,22 +28,14 @@ void ColorCache::init() /// get the given color -QColor ColorCache::get(Color color) const +QColor ColorCache::get(ColorCode color) const { if (!initialized_) const_cast(this)->init(); - if (color <= Color_ignore && color.mergeColor == Color_ignore) - return lcolors_[color.baseColor]; - if (color.mergeColor != Color_ignore) { - QColor base_color = get(color.baseColor).toRgb(); - QColor merge_color = get(color.mergeColor).toRgb(); - return QColor( - (base_color.red() + merge_color.red())/2, - (base_color.green() + merge_color.green())/2, - (base_color.blue() + merge_color.blue())/2); - } + if (color <= Color_ignore) + return lcolors_[color]; // used by branches - return QColor(lcolor.getX11Name(color.baseColor).c_str()); + return QColor(lcolor.getX11Name(color).c_str()); } diff --git a/src/frontends/qt4/ColorCache.h b/src/frontends/qt4/ColorCache.h index 88db6bb565..1716d5c044 100644 --- a/src/frontends/qt4/ColorCache.h +++ b/src/frontends/qt4/ColorCache.h @@ -12,7 +12,7 @@ #ifndef COLORCACHE_H #define COLORCACHE_H -#include "Color.h" +#include "ColorCode.h" #include @@ -29,7 +29,7 @@ public: ColorCache() : initialized_(false) {} /// get the given color - QColor get(Color color) const; + QColor get(ColorCode color) const; /// clear all colors void clear() { initialized_ = false; } diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp index f4bd49587c..0122475a7f 100644 --- a/src/frontends/qt4/GuiPainter.cpp +++ b/src/frontends/qt4/GuiPainter.cpp @@ -112,7 +112,7 @@ QString GuiPainter::generateStringSignature(QString const & str, FontInfo const } -QColor GuiPainter::computeColor(Color col) +QColor GuiPainter::computeColor(ColorCode col) { return filterColor(guiApp->colorCache().get(col)); } @@ -144,7 +144,7 @@ QColor GuiPainter::filterColor(QColor const & col) } -void GuiPainter::enterMonochromeMode(Color const & min, Color const & max) +void GuiPainter::enterMonochromeMode(ColorCode const & min, ColorCode const & max) { QColor qmin = filterColor(guiApp->colorCache().get(min)); QColor qmax = filterColor(guiApp->colorCache().get(max)); @@ -161,7 +161,7 @@ void GuiPainter::leaveMonochromeMode() } -void GuiPainter::point(int x, int y, Color col) +void GuiPainter::point(int x, int y, ColorCode col) { if (!isDrawingEnabled()) return; @@ -172,7 +172,7 @@ void GuiPainter::point(int x, int y, Color col) void GuiPainter::line(int x1, int y1, int x2, int y2, - Color col, + ColorCode col, line_style ls, line_width lw) { @@ -189,7 +189,7 @@ void GuiPainter::line(int x1, int y1, int x2, int y2, void GuiPainter::lines(int const * xp, int const * yp, int np, - Color col, + ColorCode col, line_style ls, line_width lw) { @@ -217,7 +217,7 @@ void GuiPainter::lines(int const * xp, int const * yp, int np, void GuiPainter::rectangle(int x, int y, int w, int h, - Color col, + ColorCode col, line_style ls, line_width lw) { @@ -229,7 +229,7 @@ void GuiPainter::rectangle(int x, int y, int w, int h, } -void GuiPainter::fillRectangle(int x, int y, int w, int h, Color col) +void GuiPainter::fillRectangle(int x, int y, int w, int h, ColorCode col) { if (!isDrawingEnabled()) return; @@ -239,7 +239,7 @@ void GuiPainter::fillRectangle(int x, int y, int w, int h, Color col) void GuiPainter::arc(int x, int y, unsigned int w, unsigned int h, - int a1, int a2, Color col) + int a1, int a2, ColorCode col) { if (!isDrawingEnabled()) return; @@ -450,7 +450,7 @@ void GuiPainter::buttonFrame(int x, int y, int w, int h) void GuiPainter::rectText(int x, int y, docstring const & str, - FontInfo const & font, Color back, Color frame) + FontInfo const & font, ColorCode back, ColorCode frame) { int width; int ascent; diff --git a/src/frontends/qt4/GuiPainter.h b/src/frontends/qt4/GuiPainter.h index fa87940d45..c28857e68f 100644 --- a/src/frontends/qt4/GuiPainter.h +++ b/src/frontends/qt4/GuiPainter.h @@ -13,8 +13,6 @@ #ifndef GUIPAINTER_H #define GUIPAINTER_H -#include "Color.h" - #include "frontends/Painter.h" #include @@ -40,7 +38,7 @@ public: virtual void line( int x1, int y1, int x2, int y2, - Color, + ColorCode, line_style = line_solid, line_width = line_thin); @@ -54,7 +52,7 @@ public: int const * xp, int const * yp, int np, - Color, + ColorCode, line_style = line_solid, line_width = line_thin); @@ -62,7 +60,7 @@ public: virtual void rectangle( int x, int y, int w, int h, - Color, + ColorCode, line_style = line_solid, line_width = line_thin); @@ -70,17 +68,17 @@ public: virtual void fillRectangle( int x, int y, int w, int h, - Color); + ColorCode); /// draw an arc virtual void arc( int x, int y, unsigned int w, unsigned int h, int a1, int a2, - Color); + ColorCode); /// draw a pixel - virtual void point(int x, int y, Color); + virtual void point(int x, int y, ColorCode); /// draw an image from the image cache virtual void image(int x, int y, int w, int h, @@ -98,8 +96,8 @@ public: FontInfo const & font, bool mouseHover); /// start monochrome painting mode, i.e. map every color into [min,max] - virtual void enterMonochromeMode(Color const & min, - Color const & max); + virtual void enterMonochromeMode(ColorCode const & min, + ColorCode const & max); /// leave monochrome painting mode virtual void leaveMonochromeMode(); @@ -110,7 +108,7 @@ public: * around the text with the given color. */ virtual void rectText(int x, int baseline, docstring const & str, - FontInfo const & font, Color back, Color frame); + FontInfo const & font, ColorCode back, ColorCode frame); /// draw a filled rectangle with the shape of a 3D button virtual void button(int x, int y, int w, int h, bool mouseHover); @@ -152,7 +150,7 @@ private: /// std::stack monochrome_max_; /// convert into Qt color, possibly applying the monochrome mode - QColor computeColor(Color col); + QColor computeColor(ColorCode col); /// possibly apply monochrome mode QColor filterColor(QColor const & col); /// diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 2ee7c81aba..b4b0c0d343 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -1634,8 +1634,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c) // try auto-correction - if (lyxrc.autocorrection_math && cur.autocorrect() && cur.pos() != 0 - && math_autocorrect(cur.prevAtom(), c)) + if (lyxrc.autocorrection_math && cur.autocorrect() && cur.pos() != 0 && math_autocorrect(cur.prevAtom(), c)) return true; // no special circumstances, so insert the character without any fuss diff --git a/src/mathed/MathAutoCorrect.cpp b/src/mathed/MathAutoCorrect.cpp index fcc9f7705a..85f699c404 100644 --- a/src/mathed/MathAutoCorrect.cpp +++ b/src/mathed/MathAutoCorrect.cpp @@ -170,7 +170,7 @@ void initAutoCorrect() } // namespace anon -bool math_autocorrect(MathAtom & at, char_type c) +bool math_autocorrect(MathAtom & at, char c) { static bool initialized = false; diff --git a/src/mathed/MathAutoCorrect.h b/src/mathed/MathAutoCorrect.h index 10b6e72886..8b77f363f1 100644 --- a/src/mathed/MathAutoCorrect.h +++ b/src/mathed/MathAutoCorrect.h @@ -17,7 +17,7 @@ namespace lyx { class MathAtom; // make "corrections" according to file lib/autocorrect -bool math_autocorrect(MathAtom & at, char_type c); +bool math_autocorrect(MathAtom & at, char c); } // namespace lyx diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index ad9cc611f6..c5d0bd1291 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -304,9 +304,9 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font, FontInfo copy = font; if (change_running.changed()) - copy.setDrawColor(change_running.color()); + copy.setColor(change_running.color()); else if (selection) - copy.setDrawColor(Color_selectiontext); + copy.setColor(Color_selectiontext); x_ += pi_.pain.text(int(x_), yo_, s, copy); } @@ -595,7 +595,7 @@ void RowPainter::paintLast() FontMetrics const & fm = theFontMetrics(pi_.base.bv->buffer().params().getFont()); int const length = fm.maxAscent() / 2; - Color col = change.color(); + ColorCode col = change.color(); pi_.pain.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - length, col, Painter::line_solid, Painter::line_thick);