]> git.lyx.org Git - features.git/commitdiff
move ColorSet to a header of its own to reduce #include dependencies
authorAndré Pönitz <poenitz@gmx.net>
Mon, 9 Feb 2009 23:30:24 +0000 (23:30 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 9 Feb 2009 23:30:24 +0000 (23:30 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28426 a592a061-630c-0410-9148-cb99ea01b6c8

18 files changed:
development/scons/scons_manifest.py
src/BufferParams.cpp
src/Color.cpp
src/Color.h
src/ColorSet.h [new file with mode: 0644]
src/Font.cpp
src/FontInfo.h
src/LaTeXFeatures.cpp
src/LyX.cpp
src/LyXRC.cpp
src/Makefile.am
src/MetricsInfo.cpp
src/frontends/qt4/ColorCache.cpp
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiPrefs.cpp
src/insets/InsetBranch.cpp
src/insets/InsetLayout.cpp
src/mathed/InsetMathColor.cpp

index 44362272d53049724d2c24abd4902ebd9cbdc6a9..e2749bf4aefa39f946b54b7610e393f4e8c95312 100644 (file)
@@ -44,6 +44,7 @@ src_header_files = Split('''
     Citation.h
     CmdDef.h
     Color.h
+    ColorSet.h
     ColorCode.h
     CompletionList.h
     Converter.h
index 4d52968de7fcbf537551af8e41e87746c01b2005..816c0c0112964c1b00359c5cb2e95f788c1f49ac 100644 (file)
@@ -23,6 +23,7 @@
 #include "buffer_funcs.h"
 #include "Bullet.h"
 #include "Color.h"
+#include "ColorSet.h"
 #include "Encoding.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
index a8c583d5a8e6b181afab020b880999a83fc12604..79953e3339f78006ea986100873d31cd0b8704cc 100644 (file)
@@ -17,6 +17,7 @@
 #include <config.h>
 
 #include "Color.h"
+#include "ColorSet.h"
 
 #include "support/debug.h"
 #include "support/gettext.h"
index ec1a2d9ba476aed689a4799e4c4dace52107270e..ce65b14438387eab0280fb4b5b669a16f1bdf5ee 100644 (file)
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef LCOLOR_H
-#define LCOLOR_H
+#ifndef COLOR_H
+#define COLOR_H
 
 #include "ColorCode.h"
 
 #include "support/strfwd.h"
 
-#include <map>
-#include <string>
-
 namespace lyx {
 
 /**
@@ -62,98 +59,9 @@ public:
 
 std::ostream & operator<<(std::ostream & os, Color color);
 
-
-/**
- * \class ColorSet
- *
- * A class holding color definitions and associated names for
- * LaTeX, X11, the GUI, and LyX internally.
- *
- * A color can be one of the following kinds:
- *
- * - A real, predefined color, such as black, white, red or green.
- * - A logical color, such as no color, inherit, math
- */
-
-
-// made copyable for same reasons as LyXRC was made copyable. See there for
-// explanation.
-
-class ColorSet
-{
-public:
-       ///
-       ColorSet();
-
-       /** set the given LyX color to the color defined by the X11 name given
-        *  \returns true if successful.
-        */
-       bool setColor(ColorCode col, std::string const & x11name);
-
-       /** set the given LyX color to the color defined by the X11
-        *  name given \returns true if successful. A new color entry
-        *  is created if the color is unknown
-        */
-       bool setColor(std::string const & lyxname, std::string const & x11name);
-
-       /// Get the GUI name of \c color.
-       docstring const getGUIName(ColorCode c) const;
-
-       /// Get the X11 name of \c color.
-       std::string const getX11Name(ColorCode c) const;
-
-       /// Get the LaTeX name of \c color.
-       std::string const getLaTeXName(ColorCode c) const;
-
-       /// Get the LyX name of \c color.
-       std::string const getLyXName(ColorCode c) const;
-
-       /// \returns the ColorCode associated with the LyX name.
-       ColorCode getFromLyXName(std::string const & lyxname) const;
-       /// \returns the ColorCode associated with the LaTeX name.
-       ColorCode getFromLaTeXName(std::string const & latexname) const;
-
-private:
-       ///
-       void addColor(ColorCode c, std::string const & lyxname); 
-       ///
-       class Information {
-       public:
-               /// the name as it appears in the GUI
-               std::string guiname;
-               /// the name used in LaTeX
-               std::string latexname;
-               /// the name for X11
-               std::string x11name;
-               /// the name for LyX
-               std::string lyxname;
-       };
-
-       /// initialise a color entry
-       struct ColorEntry;
-       void fill(ColorEntry const & entry);
-
-       ///
-       typedef std::map<ColorCode, Information> InfoTab;
-       /// the table of color Information
-       InfoTab infotab;
-
-       typedef std::map<std::string, ColorCode> Transform;
-       /// the transform between LyX color name string and integer code.
-       Transform lyxcolors;
-       /// the transform between LaTeX color name string and integer code.
-       Transform latexcolors;
-};
-
-
-/// the current color definitions
-extern ColorSet lcolor;
-/// the system color definitions
-extern ColorSet system_lcolor;
-
 std::string const X11hexname(RGBColor const & col);
 RGBColor rgbFromHexName(std::string const & x11hexname);
 
 } // namespace lyx
 
-#endif
+#endif // COLOR_H
diff --git a/src/ColorSet.h b/src/ColorSet.h
new file mode 100644 (file)
index 0000000..6ee8f40
--- /dev/null
@@ -0,0 +1,119 @@
+// -*- C++ -*-
+/**
+ * \file ColorSet.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Asger Alstrup
+ * \author Lars Gullik Bjønnes
+ * \author Matthias Ettrich
+ * \author Jean-Marc Lasgouttes
+ * \author Angus Leeming
+ * \author John Levon
+ * \author André Pönitz
+ * \author Martin Vermeer
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef COLORSET_H
+#define COLORSET_H
+
+#include "Color.h"
+
+#include <map>
+#include <string>
+
+namespace lyx {
+
+/**
+ * \class ColorSet
+ *
+ * A class holding color definitions and associated names for
+ * LaTeX, X11, the GUI, and LyX internally.
+ *
+ * A color can be one of the following kinds:
+ *
+ * - A real, predefined color, such as black, white, red or green.
+ * - A logical color, such as no color, inherit, math
+ */
+
+
+// made copyable for same reasons as LyXRC was made copyable. See there for
+// explanation.
+
+class ColorSet
+{
+public:
+       ///
+       ColorSet();
+
+       /** set the given LyX color to the color defined by the X11 name given
+        *  \returns true if successful.
+        */
+       bool setColor(ColorCode col, std::string const & x11name);
+
+       /** set the given LyX color to the color defined by the X11
+        *  name given \returns true if successful. A new color entry
+        *  is created if the color is unknown
+        */
+       bool setColor(std::string const & lyxname, std::string const & x11name);
+
+       /// Get the GUI name of \c color.
+       docstring const getGUIName(ColorCode c) const;
+
+       /// Get the X11 name of \c color.
+       std::string const getX11Name(ColorCode c) const;
+
+       /// Get the LaTeX name of \c color.
+       std::string const getLaTeXName(ColorCode c) const;
+
+       /// Get the LyX name of \c color.
+       std::string const getLyXName(ColorCode c) const;
+
+       /// \returns the ColorCode associated with the LyX name.
+       ColorCode getFromLyXName(std::string const & lyxname) const;
+       /// \returns the ColorCode associated with the LaTeX name.
+       ColorCode getFromLaTeXName(std::string const & latexname) const;
+
+private:
+       ///
+       void addColor(ColorCode c, std::string const & lyxname); 
+       ///
+       class Information {
+       public:
+               /// the name as it appears in the GUI
+               std::string guiname;
+               /// the name used in LaTeX
+               std::string latexname;
+               /// the name for X11
+               std::string x11name;
+               /// the name for LyX
+               std::string lyxname;
+       };
+
+       /// initialise a color entry
+       struct ColorEntry;
+       void fill(ColorEntry const & entry);
+
+       ///
+       typedef std::map<ColorCode, Information> InfoTab;
+       /// the table of color Information
+       InfoTab infotab;
+
+       typedef std::map<std::string, ColorCode> Transform;
+       /// the transform between LyX color name string and integer code.
+       Transform lyxcolors;
+       /// the transform between LaTeX color name string and integer code.
+       Transform latexcolors;
+};
+
+
+/// the current color definitions
+extern ColorSet lcolor;
+/// the system color definitions
+extern ColorSet system_lcolor;
+
+} // namespace lyx
+
+#endif // COLORSET_H
index 5b1332eddf91f83cc084f5cf488860f2bea361ea..56e20500bdcffbb0cd123e4282363290cb69c1ea 100644 (file)
@@ -17,7 +17,7 @@
 #include "Font.h"
 
 #include "BufferParams.h" // stateText
-#include "Color.h"
+#include "ColorSet.h"
 #include "Encoding.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
index 8e05cee007da1f6ef6a094a5aa6137cf8ad0f5cc..8db78d5ce1a492fe52e7ada0ecbf491cc1df9ba2 100644 (file)
@@ -42,8 +42,8 @@ public:
                FontState emph,
                FontState underbar,
                FontState noun,
-               FontState number
-               ): family_(family), series_(series), shape_(shape), size_(size), 
+               FontState number)
+               : family_(family), series_(series), shape_(shape), size_(size), 
                color_(color), background_(background), paint_color_(), emph_(emph),
                underbar_(underbar), noun_(noun), number_(number)
        {}
@@ -126,9 +126,6 @@ public:
 private:
        friend bool operator==(FontInfo const & lhs, FontInfo const & rhs);
 
-       /// The color used for painting
-       Color paint_color_;
-
        ///
        FontFamily family_;
        ///
@@ -141,6 +138,8 @@ private:
        ColorCode color_;
        ///
        ColorCode background_;
+       /// The color used for painting
+       Color paint_color_;
        ///
        FontState emph_;
        ///
index 606f2d862f43490dc532a1e083787f9cddb32aed..ea06e62da39f36c3bd93662681727864285f49fe 100644 (file)
@@ -17,8 +17,8 @@
 #include "LaTeXFeatures.h"
 
 #include "Buffer.h"
-#include "Color.h"
 #include "BufferParams.h"
+#include "ColorSet.h"
 #include "Encoding.h"
 #include "Floating.h"
 #include "FloatList.h"
index 550bf83fb3ea27d1938a780676beccf28f9bd6ca..a433a21ebfe2b4eb46be5ac5a9801f70ffd6b3f6 100644 (file)
@@ -21,7 +21,7 @@
 #include "Buffer.h"
 #include "BufferList.h"
 #include "CmdDef.h"
-#include "Color.h"
+#include "ColorSet.h"
 #include "ConverterCache.h"
 #include "Converter.h"
 #include "CutAndPaste.h"
index 1fd1bd249e83ad626ccd676a6b3854301f20fad4..19bbb157a3813b33f86c2c117d6a19e081b9bb56 100644 (file)
 
 #include <config.h>
 
-#include <fstream>
-#include <iostream>
-
 #include "LyXRC.h"
 
-#include "Color.h"
+#include "ColorSet.h"
 #include "Converter.h"
 #include "FontEnums.h"
 #include "Format.h"
@@ -41,6 +38,9 @@
 #include "support/os.h"
 #include "support/userinfo.h"
 
+#include <fstream>
+#include <iostream>
+
 using namespace std;
 using namespace lyx::support;
 
index d616d4476f68d40394efef57008a87e11331ab90..d6bd903275b6485fd28d466c9e44facc6ff0bd1c 100644 (file)
@@ -181,6 +181,7 @@ HEADERFILESCORE = \
        CmdDef.h \
        ColorCode.h \
        Color.h \
+       ColorSet.h \
        CompletionList.h \
        ConverterCache.h \
        Converter.h \
index 1c93af98188aae5fd543087c8afda07b2fed897e..788709cd49cccc413d88582dc21c44256dbc63dd 100644 (file)
@@ -11,7 +11,7 @@
 #include <config.h>
 
 #include "BufferView.h"
-#include "Color.h"
+#include "ColorSet.h"
 #include "MetricsInfo.h"
 
 #include "insets/Inset.h"
 #include "frontends/Painter.h"
 
 #include "support/docstring.h"
-
 #include "support/lassert.h"
 
 using namespace std;
 
+
 namespace lyx {
 
+/////////////////////////////////////////////////////////////////////////
+//
+// MetricsBase
+//
+/////////////////////////////////////////////////////////////////////////
 
 MetricsBase::MetricsBase()
        : bv(0), font(), style(LM_ST_TEXT), fontname("mathnormal"),
@@ -41,12 +46,24 @@ MetricsBase::MetricsBase(BufferView * b, FontInfo const & f, int w)
 {}
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// MetricsInfo
+//
+/////////////////////////////////////////////////////////////////////////
+
 MetricsInfo::MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth, 
        MacroContext const & mc)
        : base(bv, font, textwidth), macrocontext(mc)
 {}
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// PainterInfo
+//
+/////////////////////////////////////////////////////////////////////////
+
 PainterInfo::PainterInfo(BufferView * bv, lyx::frontend::Painter & painter)
        : pain(painter), ltr_pos(false), change_(), selected(false),
        full_repaint(true), background_color(Color_background)
@@ -90,6 +107,12 @@ ColorCode PainterInfo::backgroundColor(Inset const * inset, bool sel) const
 }
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// ScriptChanger
+//
+/////////////////////////////////////////////////////////////////////////
+
 Styles smallerScriptStyle(Styles st)
 {
        switch (st) {
@@ -103,11 +126,17 @@ Styles smallerScriptStyle(Styles st)
        }
 }
 
+
 ScriptChanger::ScriptChanger(MetricsBase & mb)
        : StyleChanger(mb, smallerScriptStyle(mb.style))
 {}
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// FracChanger
+//
+/////////////////////////////////////////////////////////////////////////
 
 Styles smallerFracStyle(Styles st)
 {
@@ -129,12 +158,23 @@ FracChanger::FracChanger(MetricsBase & mb)
 {}
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// ArrayChanger
+//
+/////////////////////////////////////////////////////////////////////////
 
 ArrayChanger::ArrayChanger(MetricsBase & mb)
        : StyleChanger(mb, mb.style == LM_ST_DISPLAY ? LM_ST_TEXT : mb.style)
 {}
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// ShapeChanger
+//
+/////////////////////////////////////////////////////////////////////////
+
 ShapeChanger::ShapeChanger(FontInfo & font, FontShape shape)
        : Changer<FontInfo, FontShape>(font)
 {
@@ -149,9 +189,14 @@ ShapeChanger::~ShapeChanger()
 }
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// StyleChanger
+//
+/////////////////////////////////////////////////////////////////////////
 
 StyleChanger::StyleChanger(MetricsBase & mb, Styles style)
-       :       Changer<MetricsBase>(mb)
+       : Changer<MetricsBase>(mb)
 {
        static const int diff[4][4] =
                { { 0, 0, -3, -5 },
@@ -176,9 +221,14 @@ StyleChanger::~StyleChanger()
 }
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// FontSetChanger
+//
+/////////////////////////////////////////////////////////////////////////
 
 FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name)
-       :       Changer<MetricsBase>(mb)
+       : Changer<MetricsBase>(mb)
 {
        save_ = mb;
        FontSize oldsize = save_.font.size();
@@ -190,7 +240,7 @@ FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name)
 
 
 FontSetChanger::FontSetChanger(MetricsBase & mb, docstring const & name)
-       :       Changer<MetricsBase>(mb)
+       : Changer<MetricsBase>(mb)
 {
        save_ = mb;
        FontSize oldsize = save_.font.size();
@@ -207,8 +257,14 @@ FontSetChanger::~FontSetChanger()
 }
 
 
+/////////////////////////////////////////////////////////////////////////
+//
+// WidthChanger
+//
+/////////////////////////////////////////////////////////////////////////
+
 WidthChanger::WidthChanger(MetricsBase & mb, int w)
-       :       Changer<MetricsBase>(mb)
+       : Changer<MetricsBase>(mb)
 {
        save_ = mb;
        mb.textwidth = w;
@@ -221,7 +277,11 @@ WidthChanger::~WidthChanger()
 }
 
 
-
+/////////////////////////////////////////////////////////////////////////
+//
+// ColorChanger
+//
+/////////////////////////////////////////////////////////////////////////
 
 ColorChanger::ColorChanger(FontInfo & font, string const & color)
        : Changer<FontInfo, string>(font)
index dde6bc6368ba6df40afe7a8f46eb810de2c87599..5b7a416afcc38d7bd5d8a3ebd53718da16bb9060 100644 (file)
 #include <config.h>
 
 #include "ColorCache.h"
-
-#include "Color.h"
-
-#include <string>
-
+#include "ColorSet.h"
 
 namespace lyx {
 
@@ -40,9 +36,9 @@ QColor ColorCache::get(Color color) const
                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);
+                       (base_color.red() + merge_color.red()) / 2,
+                       (base_color.green() + merge_color.green()) / 2,
+                       (base_color.blue() + merge_color.blue()) / 2);
        }
        // used by branches
        return QColor(lcolor.getX11Name(color.baseColor).c_str()); 
index 786fd1404f9cdfe36fb3b3677f5b0d7ff6b668cc..172ac0bce479fd1ca07dee58dfd48eb2cdb15e94 100644 (file)
@@ -15,6 +15,7 @@
 #include "GuiApplication.h"
 
 #include "ColorCache.h"
+#include "ColorSet.h"
 #include "GuiClipboard.h"
 #include "GuiImage.h"
 #include "GuiKeySymbol.h"
index 9f604ae35e43cdf72ad8505971a587fccd357a5f..e3db8af8628dd636c6fb09bd57fbfa0b6c95ea8a 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "BufferList.h"
 #include "Color.h"
+#include "ColorSet.h"
 #include "ConverterCache.h"
 #include "FontEnums.h"
 #include "FuncRequest.h"
index 5353fde278fb73702c3fe0d0fdc595d4cc3e9166..d28ba0deeaaff49fead0109cf1e56643268c75cd 100644 (file)
@@ -16,7 +16,7 @@
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "BranchList.h"
-#include "Color.h"
+#include "ColorSet.h"
 #include "Counters.h"
 #include "Cursor.h"
 #include "DispatchResult.h"
index 4280eb5428ef5489fa0a57593a59a7f2be2929a8..6a8258c54e648ccb93cf622f225c3a289fc0f73b 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "InsetLayout.h"
 
-#include "Color.h"
+#include "ColorSet.h"
 #include "Font.h"
 #include "Lexer.h"
 #include "TextClass.h"
@@ -67,7 +67,7 @@ InsetLayout::InsetLaTeXType translateLaTeXType(std::string const & str)
        return InsetLayout::ILT_ERROR;
 }
 
-}
+} // namespace anon
 
 
 bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
index 076a1afd67c9004f757115509f204e982e45388c..233a38090c2cb252e80453378576e3b7fef700b2 100644 (file)
@@ -10,7 +10,7 @@
 
 #include <config.h>
 
-#include "Color.h"
+#include "ColorSet.h"
 
 #include "InsetMathColor.h"
 #include "LaTeXFeatures.h"