]> git.lyx.org Git - features.git/commitdiff
I guess Windows folks are not too happy with files named color.h and Color.h
authorAndré Pönitz <poenitz@gmx.net>
Thu, 26 Apr 2007 19:21:38 +0000 (19:21 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 26 Apr 2007 19:21:38 +0000 (19:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18048 a592a061-630c-0410-9148-cb99ea01b6c8

src/BranchList.h
src/Color.cpp
src/Color.h
src/LaTeXFeatures.cpp
src/Makefile.am
src/color.cpp [deleted file]
src/color.h [deleted file]
src/frontends/qt4/ColorCache.cpp
src/frontends/qt4/GuiApplication.cpp

index 550887a85a0e01378a46eab10702f4b27c007296..0da9fe261f5e4b456dc55a784ce822c3aaa05d54 100644 (file)
@@ -30,9 +30,7 @@
 #ifndef BRANCHES_H
 #define BRANCHES_H
 
-#include "color.h"
-
-#include "support/docstring.h"
+#include "Color.h"
 
 #include <list>
 
index 125321c1de1ca6937a2c8dabf61c9a67dd7f3613..3474850fbcac8772a6861fa8d842ea4cae57c1ef 100644 (file)
 #include "support/lstrings.h"
 
 #include <map>
+#include <cmath>
+#include <sstream>
+#include <iomanip>
 
 
-namespace lyx {
+#ifndef CXX_GLOBAL_CSTD
+using std::floor;
+#endif
 
-using support::compare_ascii_no_case;
-using support::ascii_lowercase;
+using std::max;
+using std::min;
+using std::setw;
 
-using std::endl;
+using std::istringstream;
+using std::ostringstream;
 using std::string;
+using std::endl;
+
+using lyx::support::compare_ascii_no_case;
+using lyx::support::ascii_lowercase;
 
 
 namespace {
 
 struct ColorEntry {
-       Color::color lcolor;
+       lyx::Color::color lcolor;
        char const * guiname;
        char const * latexname;
        char const * x11name;
        char const * lyxname;
 };
 
+int const nohue = -1;
+
+int hexstrToInt(string const & str)
+{
+       int val = 0;
+       istringstream is(str);
+       is >> std::setbase(16) >> val;
+       return val;
+}
+
+} // namespace anon
+
+
+
+namespace lyx {
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// RGBColor
+//
+/////////////////////////////////////////////////////////////////////
+
+
+string const X11hexname(RGBColor const & col)
+{
+       ostringstream ostr;
+
+       ostr << '#' << std::setbase(16) << std::setfill('0')
+            << setw(2) << col.r
+            << setw(2) << col.g
+            << setw(2) << col.b;
+
+       return ostr.str();
 }
 
+
+RGBColor::RGBColor(string const & x11hexname)
+       : r(0), g(0), b(0)
+{
+       BOOST_ASSERT(x11hexname.size() == 7 && x11hexname[0] == '#');
+       r = hexstrToInt(x11hexname.substr(1,2));
+       g = hexstrToInt(x11hexname.substr(3,2));
+       b = hexstrToInt(x11hexname.substr(5,2));
+}
+
+
+RGBColor::RGBColor(HSVColor const & hsv)
+{
+       double h = hsv.h;
+       double const s = hsv.s;
+       double const v = hsv.v;
+
+       double rd, gd, bd;
+
+       if (h == nohue || s == 0.0) {
+               rd = gd = bd = v;
+       } else {
+               if (h == 360.0) h = 0.0;
+               h /= 60.0;
+
+               int const j = max(0, static_cast<int>(::floor(h)));
+               //if (j < 0) j = 0;
+
+               double const f = h - j;
+               double const p = v * (1.0 - s);
+               double const q = v * (1.0 - (s * f));
+               double const t = v * (1.0 - (s * (1.0 - f)));
+
+               switch (j) {
+               case 0:
+                       rd = v;
+                       gd = t;
+                       bd = p;
+                       break;
+               case 1:
+                       rd = q;
+                       gd = v;
+                       bd = p;
+                       break;
+               case 2:
+                       rd = p;
+                       gd = v;
+                       bd = t;
+                       break;
+               case 3:
+                       rd = p;
+                       gd = q;
+                       bd = v;
+                       break;
+               case 4:
+                       rd = t;
+                       gd = p;
+                       bd = v;
+                       break;
+               case 5:
+                       rd = v;
+                       gd = p;
+                       bd = q;
+                       break;
+               default:
+                       rd = v;
+                       gd = t;
+                       bd = p;
+                       break;  // should never happen.
+               }
+       }
+
+       r = static_cast<int>(::floor((rd * 255.0) + 0.5));
+       g = static_cast<int>(::floor((gd * 255.0) + 0.5));
+       b = static_cast<int>(::floor((bd * 255.0) + 0.5));
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// HSVColor
+//
+/////////////////////////////////////////////////////////////////////
+
+HSVColor::HSVColor(RGBColor const & rgb)
+{
+       double const r = rgb.r / 255.0;
+       double const g = rgb.g / 255.0;
+       double const b = rgb.b / 255.0;
+
+       double const maxval = max(max(r, g), b);
+       double const minval = min(min(r, g), b);
+
+       v = maxval;
+
+       double const diff = maxval - minval;
+       if (maxval != 0.0)
+               s = diff / maxval;
+       else
+               s = 0.0;
+
+       h = nohue;
+       if (s != 0.0) {
+               double const rc = (maxval - r) / diff;
+               double const gc = (maxval - g) / diff;
+               double const bc = (maxval - b) / diff;
+
+               if (r == maxval)
+                       h = bc - gc;
+               else if (g == maxval)
+                       h = 2.0 + rc - bc;
+               else if (b == maxval)
+                       h = 4.0 + gc - rc;
+
+               h *= 60.0;
+               if (h < 0)
+                       h += 360;
+       }
+}
+
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// Color::Pimpl
+//
+/////////////////////////////////////////////////////////////////////
+
 class Color::Pimpl {
 public:
        ///
index c64ba1656643e35fb774412b7872f46e2a3eccb9..b2a43b7784f7f34e7f42261625d1dcde1d0e22f6 100644 (file)
@@ -251,6 +251,55 @@ extern Color lcolor;
 extern Color system_lcolor;
 
 
+struct RGBColor;
+/// returns a string of form #rrggbb, given an RGBColor struct
+std::string const X11hexname(RGBColor const & col);
+
+struct HSVColor {
+       double h;
+       double s;
+       double v;
+       HSVColor() : h(0.0), s(0.0), v(0.0) {}
+       HSVColor(double hue, double sat, double val)
+               : h(hue), s(sat), v(val) {}
+       HSVColor(RGBColor const &);
+};
+
+struct RGBColor {
+       unsigned int r;
+       unsigned int g;
+       unsigned int b;
+       RGBColor() : r(0), g(0), b(0) {}
+       RGBColor(unsigned int red, unsigned int green, unsigned int blue)
+               : r(red), g(green), b(blue) {}
+       RGBColor(HSVColor const &);
+       /// \param x11hexname is of the form "#ffa071"
+       RGBColor(std::string const & x11hexname);
+};
+
+struct NamedColor : public RGBColor {
+       std::string lyxname;
+       std::string guiname;
+       NamedColor() : RGBColor() {}
+       NamedColor(std::string const & lyx, std::string const & gui,
+                  RGBColor const & c)
+               : RGBColor(c), lyxname(lyx), guiname(gui) {}
+       RGBColor const & color() const { return *this; }
+};
+
+inline
+bool operator==(RGBColor const & c1, RGBColor const & c2)
+{
+       return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
+}
+
+
+inline
+bool operator!=(RGBColor const & c1, RGBColor const & c2)
+{
+       return !(c1 == c2);
+}
+
 } // namespace lyx
 
 #endif
index 5dc426eecc1c7faefc5b542a63bfa7f783878989..7b46065b8bc9a330132a880f94384c596a5abe65 100644 (file)
 #include "LaTeXFeatures.h"
 
 #include "BufferParams.h"
-#include "color.h"
+#include "Color.h"
 #include "debug.h"
 #include "Encoding.h"
 #include "Floating.h"
 #include "FloatList.h"
-#include "Color.h"
 #include "Language.h"
 #include "Lexer.h"
 #include "lyx_sty.h"
index 9751daab0631e96bfa850a4fcb9e057f8e32cdb7..088efd053925abdd36de25b4f995f69d5772525c 100644 (file)
@@ -60,144 +60,123 @@ endif
 
 
 lyx_SOURCES = \
-       Bidi.cpp \
-       Bidi.h \
-       BufferView.cpp \
-       BufferView.h \
-       Bullet.cpp \
-       Bullet.h \
-       BranchList.cpp \
-       BranchList.h \
-       Chktex.cpp \
-       Chktex.h \
-       color.cpp \
-       color.h \
-       ConverterCache.cpp \
-       ConverterCache.h \
-       CutAndPaste.cpp \
-       CutAndPaste.h \
-       DepTable.cpp \
-       DepTable.h \
-       FloatList.cpp \
-       FloatList.h \
-       Floating.cpp \
-       Floating.h \
-       FontIterator.cpp \
-       FontIterator.h \
-       FuncStatus.cpp \
-       FuncStatus.h \
-       InsetList.cpp \
-       InsetList.h \
-       Color.cpp \
-       Color.h \
-       LaTeX.cpp \
-       LaTeX.h \
-       LaTeXFeatures.cpp \
-       LaTeXFeatures.h \
-       LyXAction.cpp \
-       LyXAction.h \
-       MenuBackend.cpp \
-       MenuBackend.h \
-       ParagraphList.h \
-       ParagraphList_fwd.h \
-       ParagraphParameters.cpp \
-       ParagraphParameters.h \
-       PrinterParams.cpp \
-       PrinterParams.h \
-       RowList_fwd.h \
-       Spacing.cpp \
-       Spacing.h \
-       Thesaurus.cpp \
-       Thesaurus.h \
-       ToolbarBackend.cpp \
-       ToolbarBackend.h \
-       UpdateFlags.h \
-       WordLangTuple.h \
+       $(ASPELL) $(PSPELL) $(ISPELL) SpellBase.cpp \
        Author.cpp \
        Author.h \
+       Bidi.cpp \
+       Bidi.h \
        boost.cpp \
-       Box.h \
        Box.cpp \
+       Box.h \
+       BranchList.cpp \
+       BranchList.h \
        Buffer.cpp \
-       Buffer.h \
        buffer_funcs.cpp \
        buffer_funcs.h \
+       Buffer.h \
        BufferList.cpp \
        BufferList.h \
        BufferParams.cpp \
        BufferParams.h \
+       BufferView.cpp \
        bufferview_funcs.cpp \
        bufferview_funcs.h \
+       BufferView.h \
+       Bullet.cpp \
+       Bullet.h \
        Changes.cpp \
        Changes.h \
+       Chktex.cpp \
+       Chktex.h \
+       Color.cpp \
+       Color.h \
        config.h.in \
+       ConverterCache.cpp \
+       ConverterCache.h \
        Converter.cpp \
        Converter.h \
-       Counters.cpp \
-       Counters.h \
        CoordCache.cpp \
        CoordCache.h \
+       Counters.cpp \
+       Counters.h \
        Cursor.cpp \
        Cursor.h \
        CursorSlice.cpp \
        CursorSlice.h \
+       CutAndPaste.cpp \
+       CutAndPaste.h \
        debug.cpp \
        debug.h \
+       DepTable.cpp \
+       DepTable.h \
        Dimension.cpp \
        Dimension.h \
+       DispatchResult.h \
        DocIterator.cpp \
        DocIterator.h \
-       DispatchResult.h \
        Encoding.cpp \
        Encoding.h \
        ErrorList.cpp \
        ErrorList.h \
        Exporter.cpp \
        Exporter.h \
-       gettext.cpp \
-       gettext.h \
-       factory.h \
        factory.cpp \
+       factory.h \
+       Floating.cpp \
+       Floating.h \
+       FloatList.cpp \
+       FloatList.h \
+       FontIterator.cpp \
+       FontIterator.h \
        Format.cpp \
        Format.h \
-       FuncRequest.h \
        FuncRequest.cpp \
+       FuncRequest.h \
+       FuncStatus.cpp \
+       FuncStatus.h \
+       gettext.cpp \
+       gettext.h \
        Graph.cpp \
        Graph.h \
        Importer.cpp \
        Importer.h \
-       Intl.cpp \
-       Intl.h \
        InsetIterator.cpp \
        InsetIterator.h \
+       InsetList.cpp \
+       InsetList.h \
+       Intl.cpp \
+       Intl.h \
        kb_keymap.cpp \
        kb_keymap.h \
        kb_sequence.cpp \
        kb_sequence.h \
+       KmodInfo.h \
        Language.cpp \
        Language.h \
-       Session.cpp \
-       Session.h \
+       LaTeX.cpp \
+       LaTeXFeatures.cpp \
+       LaTeXFeatures.h \
+       LaTeX.h \
        layout.h \
        lengthcommon.cpp \
        lengthcommon.h \
        Lexer.cpp \
        Lexer.h \
        lfuns.h \
+       LyXAction.cpp \
+       LyXAction.h \
        lyx_cb.cpp \
        lyx_cb.h \
        LyX.cpp \
-       LyX.h \
-       lyx_sty.cpp \
-       lyx_sty.h \
-       LyXFont.cpp \
-       LyXFont.h \
        lyxfind.cpp \
        lyxfind.h \
+       LyXFont.cpp \
+       LyXFont.h \
        LyXFunc.cpp \
        LyXFunc.h \
        LyXGlueLength.cpp \
        LyXGlueLength.h \
+       LyX.h \
        LyXLayout.cpp \
        LyXLayout.h \
        lyxlayout_ptr_fwd.h \
@@ -205,19 +184,21 @@ lyx_SOURCES = \
        LyXLength.h \
        LyXRC.cpp \
        LyXRC.h \
-       Row.cpp \
-       Row.h \
        LyXServer.cpp \
        LyXServer.h \
        LyXServerSocket.cpp \
        LyXServerSocket.h \
-       LyXText.h \
+       lyx_sty.cpp \
+       lyx_sty.h \
        LyXTextClass.cpp \
        LyXTextClass.h \
        LyXTextClassList.cpp \
        LyXTextClassList.h \
+       LyXText.h \
        LyXVC.cpp \
        LyXVC.h \
+       MenuBackend.cpp \
+       MenuBackend.h \
        Messages.cpp \
        Messages.h \
        MetricsInfo.cpp \
@@ -225,56 +206,73 @@ lyx_SOURCES = \
        Mover.cpp \
        Mover.h \
        output.cpp \
-       output.h \
-       OutputParams.cpp \
-       OutputParams.h \
        output_docbook.cpp \
        output_docbook.h \
+       output.h \
        output_latex.cpp \
        output_latex.h \
+       OutputParams.cpp \
+       OutputParams.h \
        output_plaintext.cpp \
        output_plaintext.h \
        paper.h \
        Paragraph.cpp \
+       paragraph_funcs.cpp \
+       paragraph_funcs.h \
        Paragraph.h \
+       ParagraphList_fwd.h \
+       ParagraphList.h \
        ParagraphMetrics.cpp \
        ParagraphMetrics.h \
-       paragraph_funcs.cpp \
-       paragraph_funcs.h \
+       ParagraphParameters.cpp \
+       ParagraphParameters.h \
        ParIterator.cpp \
        ParIterator.h \
-       $(ASPELL) $(PSPELL) $(ISPELL) SpellBase.cpp \
-       SpellBase.h \
+       PrinterParams.cpp \
+       PrinterParams.h \
+       Row.cpp \
+       Row.h \
+       RowList_fwd.h \
        rowpainter.cpp \
        rowpainter.h \
+       Session.cpp \
+       Session.h \
        sgml.cpp \
        sgml.h \
+       Spacing.cpp \
+       Spacing.h \
+       SpellBase.h \
        tex-accent.cpp \
        tex-accent.h \
-       tex-strings.cpp \
-       tex-strings.h \
        TexRow.cpp \
        TexRow.h \
-       text.cpp \
+       tex-strings.cpp \
+       tex-strings.h \
        text2.cpp \
        text3.cpp \
+       text.cpp \
        TextMetrics.cpp \
        TextMetrics.h \
+       Thesaurus.cpp \
+       Thesaurus.h \
        TocBackend.cpp \
        TocBackend.h \
        toc.cpp \
        toc.h \
+       ToolbarBackend.cpp \
+       ToolbarBackend.h \
        Trans.cpp \
        Trans.h \
-       KmodInfo.h \
        TransState.cpp \
        TransState.h \
        Undo.cpp \
        Undo.h \
+       UpdateFlags.h \
        VCBackend.cpp \
        VCBackend.h \
        version.C \
        version.h \
+       WordLangTuple.h \
        VSpace.cpp \
        VSpace.h
 
diff --git a/src/color.cpp b/src/color.cpp
deleted file mode 100644 (file)
index 1722b8b..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * \file color.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "color.h"
-
-#include "Color.h"
-
-#include <cmath>
-#include <sstream>
-#include <iomanip>
-
-#ifndef CXX_GLOBAL_CSTD
-using std::floor;
-#endif
-
-using std::max;
-using std::min;
-using std::setw;
-
-using std::istringstream;
-using std::ostringstream;
-using std::string;
-
-namespace lyx {
-
-namespace {
-
-int const nohue = -1;
-
-int hexstrToInt(string const & str)
-{
-       int val = 0;
-       istringstream is(str);
-       is >> std::setbase(16) >> val;
-       return val;
-}
-
-} // namespace anon
-
-
-
-string const X11hexname(RGBColor const & col)
-{
-       ostringstream ostr;
-
-       ostr << '#' << std::setbase(16) << std::setfill('0')
-            << setw(2) << col.r
-            << setw(2) << col.g
-            << setw(2) << col.b;
-
-       return ostr.str();
-}
-
-
-RGBColor::RGBColor(string const & x11hexname)
-       : r(0), g(0), b(0)
-{
-       BOOST_ASSERT(x11hexname.size() == 7 && x11hexname[0] == '#');
-       r = hexstrToInt(x11hexname.substr(1,2));
-       g = hexstrToInt(x11hexname.substr(3,2));
-       b = hexstrToInt(x11hexname.substr(5,2));
-}
-
-
-RGBColor::RGBColor(HSVColor const & hsv)
-{
-       double h = hsv.h;
-       double const s = hsv.s;
-       double const v = hsv.v;
-
-       double rd, gd, bd;
-
-       if (h == nohue || s == 0.0) {
-               rd = gd = bd = v;
-       } else {
-               if (h == 360.0) h = 0.0;
-               h /= 60.0;
-
-               int const j = max(0, static_cast<int>(::floor(h)));
-               //if (j < 0) j = 0;
-
-               double const f = h - j;
-               double const p = v * (1.0 - s);
-               double const q = v * (1.0 - (s * f));
-               double const t = v * (1.0 - (s * (1.0 - f)));
-
-               switch (j) {
-               case 0:
-                       rd = v;
-                       gd = t;
-                       bd = p;
-                       break;
-               case 1:
-                       rd = q;
-                       gd = v;
-                       bd = p;
-                       break;
-               case 2:
-                       rd = p;
-                       gd = v;
-                       bd = t;
-                       break;
-               case 3:
-                       rd = p;
-                       gd = q;
-                       bd = v;
-                       break;
-               case 4:
-                       rd = t;
-                       gd = p;
-                       bd = v;
-                       break;
-               case 5:
-                       rd = v;
-                       gd = p;
-                       bd = q;
-                       break;
-               default:
-                       rd = v;
-                       gd = t;
-                       bd = p;
-                       break;  // should never happen.
-               }
-       }
-
-       r = static_cast<int>(::floor((rd * 255.0) + 0.5));
-       g = static_cast<int>(::floor((gd * 255.0) + 0.5));
-       b = static_cast<int>(::floor((bd * 255.0) + 0.5));
-}
-
-
-HSVColor::HSVColor(RGBColor const & rgb)
-{
-       double const r = rgb.r / 255.0;
-       double const g = rgb.g / 255.0;
-       double const b = rgb.b / 255.0;
-
-       double const maxval = max(max(r, g), b);
-       double const minval = min(min(r, g), b);
-
-       v = maxval;
-
-       double const diff = maxval - minval;
-       if (maxval != 0.0)
-               s = diff / maxval;
-       else
-               s = 0.0;
-
-       h = nohue;
-       if (s != 0.0) {
-               double const rc = (maxval - r) / diff;
-               double const gc = (maxval - g) / diff;
-               double const bc = (maxval - b) / diff;
-
-               if (r == maxval)
-                       h = bc - gc;
-               else if (g == maxval)
-                       h = 2.0 + rc - bc;
-               else if (b == maxval)
-                       h = 4.0 + gc - rc;
-
-               h *= 60.0;
-               if (h < 0)
-                       h += 360;
-       }
-}
-
-} // namespace lyx
diff --git a/src/color.h b/src/color.h
deleted file mode 100644 (file)
index 7270991..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-// -*- C++ -*-
-/**
- * \file color.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-/* structs RGBColor and HSVColor to enable simple conversion between
- * color spaces.
- */
-
-#ifndef COLOR_H
-#define COLOR_H
-
-#include <string>
-
-namespace lyx {
-
-struct RGBColor;
-/// returns a string of form #rrggbb, given an RGBColor struct
-std::string const X11hexname(RGBColor const & col);
-
-struct HSVColor {
-       double h;
-       double s;
-       double v;
-       HSVColor() : h(0.0), s(0.0), v(0.0) {}
-       HSVColor(double hue, double sat, double val)
-               : h(hue), s(sat), v(val) {}
-       HSVColor(RGBColor const &);
-};
-
-struct RGBColor {
-       unsigned int r;
-       unsigned int g;
-       unsigned int b;
-       RGBColor() : r(0), g(0), b(0) {}
-       RGBColor(unsigned int red, unsigned int green, unsigned int blue)
-               : r(red), g(green), b(blue) {}
-       RGBColor(HSVColor const &);
-       /// \param x11hexname is of the form "#ffa071"
-       RGBColor(std::string const & x11hexname);
-};
-
-struct NamedColor : public RGBColor {
-       std::string lyxname;
-       std::string guiname;
-       NamedColor() : RGBColor() {}
-       NamedColor(std::string const & lyx, std::string const & gui,
-                  RGBColor const & c)
-               : RGBColor(c), lyxname(lyx), guiname(gui) {}
-       RGBColor const & color() const { return *this; }
-};
-
-inline
-bool operator==(RGBColor const & c1, RGBColor const & c2)
-{
-       return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
-}
-
-
-inline
-bool operator!=(RGBColor const & c1, RGBColor const & c2)
-{
-       return !(c1 == c2);
-}
-
-} // namespace lyx
-
-#endif
index 7c5127d9f29fd18f4ba4050c158a9007e420fc3c..4a77f0ff63eb3a1be43d48e3328ab3dab6374ac3 100644 (file)
@@ -10,9 +10,7 @@
 
 #include <config.h>
 
-#include "color.h"
 #include "ColorCache.h"
-
 #include "Color.h"
 
 
index 971cf53e9efd00a3d55f9198c6904264175e187b..86dd43e9b308fdf4f58065d226de31dfec3c41dc 100644 (file)
@@ -27,7 +27,7 @@
 #include "support/Package.h"
 
 #include "BufferView.h"
-#include "color.h"
+#include "Color.h"
 #include "debug.h"
 #include "FuncRequest.h"
 #include "LyX.h"