The EnumLColor patch, free of macros.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7759 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-09-15 15:20:22 +00:00
parent 4c0fafb715
commit a6ccea4f21
50 changed files with 307 additions and 139 deletions

View File

@ -1,3 +1,16 @@
2003-09-15 Angus Leeming <leeming@lyx.org>
* LColor.h: add an EnumLColor wrapper for LColor::color.
* lyxfont.[Ch] (color, setColor, realColor):
* lyxtext.h, text.C (backgroundColor):
pass EnumLColor args to/from the functions, rather than LColor::color ones.
* lyxfont.h:
* lyxtext.h: forward declare EnumLColor.
* lyx_main.C: add #include "LColor.h".
2003-09-15 Angus Leeming <leeming@lyx.org>
* .cvsignore: add lyx-gtk.

View File

@ -238,6 +238,23 @@ private:
boost::scoped_ptr<Pimpl> pimpl_;
};
/** \c EnumLColor is a wrapper for LColor::color. It can be forward-declared and
* passed as a function argument without having to expose LColor.h.
*/
class EnumLColor {
LColor::color val_;
public:
/** The default constructor is nasty,
* but allows us to use EnumLColor in STL containers.
*/
EnumLColor() : val_(static_cast<LColor::color>(-1)) {}
EnumLColor(LColor::color val) : val_(val) {}
operator LColor::color() const{ return val_; }
};
/// the current color definitions
extern LColor lcolor;
/// the system color definitions

View File

@ -1,3 +1,16 @@
2003-09-15 Angus Leeming <leeming@lyx.org>
* Painter.C: add #include "LColor.h".
(rectText): pass EnumLColor args, rather than LColor::color ones.
* Painter.h:
* lyx_gui.h: remove #include "LColor.h". Forward declare EnumLColor.
* Painter.h (line, lines, rectangle, fillRectangle, fillPolygon, arc,
point, rectText):
* lyx_gui.h (hexname, update_color):
pass EnumLColor args, rather than LColor::color ones.
2003-09-09 Lars Gullik Bjønnes <larsbj@lyx.org>
* Timeout.C: change Assert to BOOST_ASSERT

View File

@ -13,9 +13,11 @@
#include "Painter.h"
#include "font_metrics.h"
#include "lyxfont.h"
#include "WorkArea.h"
#include "LColor.h"
#include "lyxfont.h"
using std::max;
@ -57,8 +59,8 @@ Painter & Painter::buttonFrame(int x, int y, int w, int h)
Painter & Painter::rectText(int x, int baseline,
string const & str,
LyXFont const & font,
LColor::color back,
LColor::color frame)
EnumLColor back,
EnumLColor frame)
{
int width;
int ascent;

View File

@ -15,8 +15,9 @@
#include "support/std_string.h"
#include "LColor.h"
class EnumLColor;
class LyXFont;
namespace lyx {
@ -77,7 +78,7 @@ public:
virtual Painter & line(
int x1, int y1,
int x2, int y2,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin) = 0;
@ -91,7 +92,7 @@ public:
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin) = 0;
@ -99,7 +100,7 @@ public:
virtual Painter & rectangle(
int x, int y,
int w, int h,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin) = 0;
@ -107,26 +108,26 @@ public:
virtual Painter & fillRectangle(
int x, int y,
int w, int h,
LColor::color) = 0;
EnumLColor) = 0;
/// draw a filled (irregular) polygon
virtual Painter & fillPolygon(
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground) = 0;
EnumLColor) = 0;
/// draw an arc
virtual Painter & arc(
int x, int y,
unsigned int w, unsigned int h,
int a1, int a2,
LColor::color = LColor::foreground) = 0;
EnumLColor) = 0;
/// draw a pixel
virtual Painter & point(
int x, int y,
LColor::color = LColor::foreground) = 0;
EnumLColor) = 0;
/// draw a filled rectangle with the shape of a 3D button
virtual Painter & button(int x, int y,
@ -162,8 +163,8 @@ public:
Painter & rectText(int x, int baseline,
string const & string,
LyXFont const & font,
LColor::color back = LColor::none,
LColor::color frame = LColor::none);
EnumLColor back,
EnumLColor frame);
/// draw a string and enclose it inside a button frame
Painter & buttonText(int x,

View File

@ -1,3 +1,16 @@
2003-09-15 Angus Leeming <leeming@lyx.org>
* ControlCharacter.C (setColor, getColor):
pass EnumLColor args, rather than LColor::color ones.
* ControlPrefs.C: add #include "LColor.h".
* ControlPrefs.h:remove #include "LColor.h".
* ControlPrefs.[Ch] (setColor): pass EnumLColor arg, not than LColor::color one.
* character.h:remove #include "LColor.h".
typedef ColorPair as a std::pair<string, EnumLColor>.
2003-09-15 Lars Gullik Bjønnes <larsbj@gullik.net>
* ControlAboutlyx.C

View File

@ -174,7 +174,7 @@ void ControlCharacter::setBar(frnt::FONT_STATE val)
}
LColor::color ControlCharacter::getColor() const
EnumLColor ControlCharacter::getColor() const
{
if (!font_.get())
return LColor::ignore;
@ -183,7 +183,7 @@ LColor::color ControlCharacter::getColor() const
}
void ControlCharacter::setColor(LColor::color val)
void ControlCharacter::setColor(EnumLColor val)
{
switch (val) {
case LColor::ignore:

View File

@ -17,6 +17,9 @@
#include "character.h"
class EnumLColor;
class ControlCharacter : public Dialog::Controller {
public:
///
@ -41,7 +44,7 @@ public:
///
void setBar(frnt::FONT_STATE);
///
void setColor(LColor::color);
void setColor(EnumLColor);
///
void setLanguage(string const &);
///
@ -58,7 +61,7 @@ public:
///
frnt::FONT_STATE getBar() const;
///
LColor::color getColor() const;
EnumLColor getColor() const;
///
string getLanguage() const;
///

View File

@ -20,6 +20,7 @@
#include "format.h"
#include "gettext.h"
#include "funcrequest.h"
#include "LColor.h"
#include "lfuns.h"
#include "frontends/Dialogs.h"
@ -133,7 +134,7 @@ void ControlPrefs::redrawGUI()
}
void ControlPrefs::setColor(LColor::color col, string const & hex)
void ControlPrefs::setColor(EnumLColor col, string const & hex)
{
string const s = lcolor.getLyXName(col) + ' ' + hex;
lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));

View File

@ -16,10 +16,10 @@
#include "ControlDialog_impl.h"
#include "support/std_string.h"
#include "lyxrc.h"
#include "LColor.h"
class Converters;
class EnumLColor;
class Formats;
class ControlPrefs : public ControlDialogBI {
@ -50,7 +50,7 @@ public:
void redrawGUI();
/// set a color
void setColor(LColor::color col, string const & hex);
void setColor(EnumLColor col, string const & hex);
/// update the screen fonts after change
void updateScreenFonts();

View File

@ -14,11 +14,14 @@
#include "lyxfont.h"
#include "LColor.h"
#include <utility>
#include <vector>
class EnumLColor;
/** Functions of use to the character GUI controller and view */
namespace frnt {
@ -47,7 +50,7 @@ typedef std::pair<string, LyXFont::FONT_SIZE> SizePair;
///
typedef std::pair<string, FONT_STATE> BarPair;
///
typedef std::pair<string, LColor::color> ColorPair;
typedef std::pair<string, EnumLColor> ColorPair;
///
std::vector<FamilyPair> const getFamilyData();

View File

@ -1,3 +1,22 @@
2003-09-15 Angus Leeming <leeming@lyx.org>
* GPainter.C: add #include "LColor.h".
* GPainter.[Ch] (setForeground, point, line, lines, rectangle, fillRectangle,
fillPolygon, arc): pass EnumLColor args, rather than LColor::color ones.
* GScreen.C:
* GWorkArea.C: add #include "LColor.h".
* GWorkArea.h: remove #include "LColor.h".
change typedefs to take an EnumLColor arg rather than an LColor::color one.
* GWorkArea.h (getColor, getXftColor, cacheColor, cacheXftColor):
* GWorkArea.[Ch] (getXftColor, getGdkColor): pass EnumLColor args, rather
than LColor::color ones.
* lyx_gui.C (hexname, update_color): pass EnumLColor args, rather
than LColor::color ones.
2003-09-10 Angus Leeming <leeming@lyx.org>
* GToolbar.C (onLayoutSelected): missed a change from a call to the

View File

@ -18,6 +18,7 @@
#include "lyxrc.h"
#include "encoding.h"
#include "language.h"
#include "LColor.h"
#include "xftFontLoader.h"
#include "xformsImage.h"
#include "frontends/font_metrics.h"
@ -50,7 +51,7 @@ int GPainter::paperHeight() const
}
void GPainter::setForeground(Glib::RefPtr<Gdk::GC> gc, LColor::color clr)
void GPainter::setForeground(Glib::RefPtr<Gdk::GC> gc, EnumLColor clr)
{
Gdk::Color * gclr = owner_.getColorHandler().getGdkColor(clr);
gc->set_foreground(*gclr);
@ -84,7 +85,7 @@ void GPainter::setLineParam(Glib::RefPtr<Gdk::GC> gc,
}
Painter & GPainter::point(int x, int y, LColor::color c)
Painter & GPainter::point(int x, int y, EnumLColor c)
{
setForeground(owner_.getGC(), c);
owner_.getPixmap()->draw_point(owner_.getGC(), x, y);
@ -94,7 +95,7 @@ Painter & GPainter::point(int x, int y, LColor::color c)
Painter & GPainter::line(int x1, int y1,
int x2, int y2,
LColor::color col,
EnumLColor col,
line_style ls,
line_width lw)
{
@ -107,7 +108,7 @@ Painter & GPainter::line(int x1, int y1,
Painter & GPainter::lines(int const * xp, int const * yp,
int np,
LColor::color col,
EnumLColor col,
line_style ls,
line_width lw)
{
@ -126,7 +127,7 @@ Painter & GPainter::lines(int const * xp, int const * yp,
Painter & GPainter::rectangle(int x, int y,
int w, int h,
LColor::color col,
EnumLColor col,
line_style ls,
line_width lw)
{
@ -139,7 +140,7 @@ Painter & GPainter::rectangle(int x, int y,
Painter & GPainter::fillRectangle(int x, int y,
int w, int h,
LColor::color col)
EnumLColor col)
{
setForeground(owner_.getGC(), col);
owner_.getPixmap()->draw_rectangle(owner_.getGC(), true, x, y, w, h);
@ -148,7 +149,7 @@ Painter & GPainter::fillRectangle(int x, int y,
Painter & GPainter::fillPolygon(int const * xp, int const * yp,
int np, LColor::color col)
int np, EnumLColor col)
{
setForeground(owner_.getGC(), col);
std::vector<Gdk::Point> points(np);
@ -164,7 +165,7 @@ Painter & GPainter::fillPolygon(int const * xp, int const * yp,
Painter & GPainter::arc(int x, int y,
unsigned int w, unsigned int h,
int a1, int a2, LColor::color col)
int a1, int a2, EnumLColor col)
{
setForeground(owner_.getGC(), col);
owner_.getPixmap()->draw_arc(owner_.getGC(),

View File

@ -33,15 +33,15 @@ public:
/// return the height of the work area in pixels
virtual int paperHeight() const;
void setForeground(Glib::RefPtr<Gdk::GC> gc, LColor::color clr);
void setForeground(Glib::RefPtr<Gdk::GC> gc, EnumLColor clr);
void setLineParam(Glib::RefPtr<Gdk::GC> gc,
line_style ls, line_width lw);
XftColor * getXftColor(LColor::color clr);
XftColor * getXftColor(EnumLColor clr);
/// draw a line from point to point
virtual Painter & line(
int x1, int y1,
int x2, int y2,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin);
@ -55,7 +55,7 @@ public:
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin);
@ -63,7 +63,7 @@ public:
virtual Painter & rectangle(
int x, int y,
int w, int h,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin);
@ -71,26 +71,26 @@ public:
virtual Painter & fillRectangle(
int x, int y,
int w, int h,
LColor::color);
EnumLColor);
/// draw a filled (irregular) polygon
virtual Painter & fillPolygon(
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground);
EnumLColor);
/// draw an arc
virtual Painter & arc(
int x, int y,
unsigned int w, unsigned int h,
int a1, int a2,
LColor::color = LColor::foreground);
EnumLColor);
/// draw a pixel
virtual Painter & point(
int x, int y,
LColor::color = LColor::foreground);
EnumLColor);
/// draw an image from the image cache
virtual Painter & image(int x, int y,

View File

@ -11,21 +11,26 @@
#include <config.h>
#include <gtkmm.h>
#include <algorithm>
#include "GScreen.h"
#include "GWorkArea.h"
#include "buffer.h"
#include "BufferView.h"
#include "debug.h"
#include "language.h"
#include "LColor.h"
#include "lyxtext.h"
#include "lyxrow.h"
#include "frontends/screen.h"
#include "frontends/font_metrics.h"
#include "GWorkArea.h"
#include "GScreen.h"
#include "lyxtext.h"
#include "lyxrow.h"
#include "Painter.h"
#include "WorkArea.h"
#include "buffer.h"
#include "BufferView.h"
#include "frontends/Painter.h"
#include "frontends/WorkArea.h"
#include "insets/insettext.h"
#include "language.h"
#include "debug.h"
#include <algorithm>
GScreen::GScreen(GWorkArea & o)

View File

@ -13,12 +13,14 @@
#include <X11/Xft/Xft.h>
#include "GWorkArea.h"
#include "debug.h"
#include "funcrequest.h"
#include "GView.h"
#include "GtkmmX.h"
#include "GLyXKeySym.h"
#include "debug.h"
#include "funcrequest.h"
#include "LColor.h"
ColorCache colorCache;
@ -35,7 +37,7 @@ void ColorCache::clear()
}
XftColor * ColorHandler::getXftColor(LColor::color clr)
XftColor * ColorHandler::getXftColor(EnumLColor clr)
{
XftColor * xclr = colorCache.getXftColor(clr);
if (!xclr) {
@ -52,7 +54,7 @@ XftColor * ColorHandler::getXftColor(LColor::color clr)
}
Gdk::Color * ColorHandler::getGdkColor(LColor::color clr)
Gdk::Color * ColorHandler::getGdkColor(EnumLColor clr)
{
Gdk::Color * gclr = colorCache.getColor(clr);
if (!gclr) {

View File

@ -15,33 +15,34 @@
#include <gdk/gdkx.h>
#include "frontends/WorkArea.h"
#include "GPainter.h"
#include "LColor.h"
#include <gtk/gtk.h>
#include <X11/Xft/Xft.h>
class EnumLColor;
class ColorCache
{
typedef std::map<LColor::color, Gdk::Color *> Map;
typedef std::map<EnumLColor, Gdk::Color *> Map;
typedef Map::iterator MapIt;
typedef std::map<LColor::color, XftColor *> Map2;
typedef std::map<EnumLColor, XftColor *> Map2;
typedef Map2::iterator MapIt2;
public:
~ColorCache() { clear(); }
Gdk::Color * getColor(LColor::color clr)
Gdk::Color * getColor(EnumLColor clr)
{
MapIt it = cache_.find(clr);
return it == cache_.end() ? 0 : it->second;
}
XftColor * getXftColor(LColor::color clr)
XftColor * getXftColor(EnumLColor clr)
{
MapIt2 it = cache2_.find(clr);
return it == cache2_.end() ? 0 : it->second;
}
void cacheColor(LColor::color clr, Gdk::Color * gclr)
void cacheColor(EnumLColor clr, Gdk::Color * gclr)
{
cache_[clr] = gclr;
}
void cacheXftColor(LColor::color clr, XftColor * xclr)
void cacheXftColor(EnumLColor clr, XftColor * xclr)
{
cache2_[clr] = xclr;
}
@ -57,8 +58,8 @@ class ColorHandler
{
public:
ColorHandler(GWorkArea& owner) : owner_(owner) {}
XftColor * getXftColor(LColor::color clr);
Gdk::Color * getGdkColor(LColor::color clr);
XftColor * getXftColor(EnumLColor clr);
Gdk::Color * getGdkColor(EnumLColor clr);
private:
GWorkArea & owner_;
};

View File

@ -362,7 +362,7 @@ FuncStatus lyx_gui::getStatus(FuncRequest const & /*ev*/)
}
string const lyx_gui::hexname(LColor::color col)
string const lyx_gui::hexname(EnumLColor col)
{
Gdk::Color gdkColor;
Gdk::Color * gclr = colorCache.getColor(col);
@ -384,7 +384,7 @@ string const lyx_gui::hexname(LColor::color col)
}
void lyx_gui::update_color(LColor::color /*col*/)
void lyx_gui::update_color(EnumLColor /*col*/)
{
colorCache.clear();
}

View File

@ -12,13 +12,13 @@
#ifndef LYX_GUI_H
#define LYX_GUI_H
#include "LColor.h"
#include "support/std_string.h"
#include "FuncStatus.h"
#include <vector>
class Dialogs;
class EnumLColor;
class LyXFont;
class LyXComm;
class FuncRequest;
@ -72,12 +72,12 @@ FuncStatus getStatus(FuncRequest const & ev);
/** Eg, passing LColor::black returns "000000",
* passing LColor::white returns "ffffff".
*/
string const hexname(LColor::color col);
string const hexname(EnumLColor col);
/**
* update an altered GUI color
*/
void update_color(LColor::color col);
void update_color(EnumLColor col);
/**
* update the font cache

View File

@ -1,3 +1,23 @@
2003-09-15 Angus Leeming <leeming@lyx.org>
* QLPainter.C: add #include "LColor.h".
* QLPainter.[Ch] (setPen, point, line, lines, rectangle, fillPolygon, arc):
pass EnumLColor args, rather than LColor::color ones.
* QPrefsDialog.C: add #include "LColor.h".
* QPrefsDialog.h: remove #include "LColor.h". Store a vector<EnumLColor> colors_;
* QWorkArea.C: add #include "LColor.h".
* lcolorcache.C: add #include "LColor.h".
* lcolorcache.h: store a map<EnumLColor, QColor>.
* lcolorcache.[Ch] (get):pass EnumLColor args, rather than LColor::color ones.
* qscreen.C: add #include "LColor.h".
* lyx_gui.C (hexname, update_color): pass EnumLColor args, rather
than LColor::color ones.
2003-09-15 Angus Leeming <leeming@lyx.org>
* QAbout.C (build_dialog):

View File

@ -14,6 +14,7 @@
#include "font_metrics.h"
#include "debug.h"
#include "language.h"
#include "LColor.h"
#include "QWorkArea.h"
#include "qfont_loader.h"
@ -62,7 +63,7 @@ int QLPainter::paperHeight() const
}
QPainter & QLPainter::setPen(LColor::color c,
QPainter & QLPainter::setPen(EnumLColor c,
Painter::line_style ls, Painter::line_width lw)
{
QPen pen = qp_->pen();
@ -84,7 +85,7 @@ QPainter & QLPainter::setPen(LColor::color c,
}
Painter & QLPainter::point(int x, int y, LColor::color c)
Painter & QLPainter::point(int x, int y, EnumLColor c)
{
setPen(c).drawPoint(x, y);
return *this;
@ -93,7 +94,7 @@ Painter & QLPainter::point(int x, int y, LColor::color c)
Painter & QLPainter::line(int x1, int y1,
int x2, int y2,
LColor::color col,
EnumLColor col,
line_style ls,
line_width lw)
{
@ -104,7 +105,7 @@ Painter & QLPainter::line(int x1, int y1,
Painter & QLPainter::lines(int const * xp, int const * yp,
int np,
LColor::color col,
EnumLColor col,
line_style ls,
line_width lw)
{
@ -126,7 +127,7 @@ Painter & QLPainter::lines(int const * xp, int const * yp,
Painter & QLPainter::rectangle(int x, int y,
int w, int h,
LColor::color col,
EnumLColor col,
line_style ls,
line_width lw)
{
@ -137,7 +138,7 @@ Painter & QLPainter::rectangle(int x, int y,
Painter & QLPainter::fillRectangle(int x, int y,
int w, int h,
LColor::color col)
EnumLColor col)
{
qp_->fillRect(x, y, w, h, lcolorcache.get(col));
return *this;
@ -145,7 +146,7 @@ Painter & QLPainter::fillRectangle(int x, int y,
Painter & QLPainter::fillPolygon(int const * xp, int const * yp,
int np, LColor::color col)
int np, EnumLColor col)
{
// Must use new as np is not known at compile time.
boost::scoped_array<QCOORD> points(new QCOORD[np * 2]);
@ -168,7 +169,7 @@ Painter & QLPainter::fillPolygon(int const * xp, int const * yp,
Painter & QLPainter::arc(int x, int y,
unsigned int w, unsigned int h,
int a1, int a2, LColor::color col)
int a1, int a2, EnumLColor col)
{
// LyX usings 1/64ths degree, Qt usings 1/16th
setPen(col).drawArc(x, y, w, h, a1 / 4, a2 / 4);

View File

@ -15,7 +15,6 @@
#include "Painter.h"
#include "support/std_string.h"
#include "LColor.h"
#include <boost/scoped_ptr.hpp>
@ -46,7 +45,7 @@ public:
virtual Painter & line(
int x1, int y1,
int x2, int y2,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin);
@ -60,7 +59,7 @@ public:
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin);
@ -68,7 +67,7 @@ public:
virtual Painter & rectangle(
int x, int y,
int w, int h,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin);
@ -76,26 +75,26 @@ public:
virtual Painter & fillRectangle(
int x, int y,
int w, int h,
LColor::color);
EnumLColor);
/// draw a filled (irregular) polygon
virtual Painter & fillPolygon(
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground);
EnumLColor);
/// draw an arc
virtual Painter & arc(
int x, int y,
unsigned int w, unsigned int h,
int a1, int a2,
LColor::color = LColor::foreground);
EnumLColor);
/// draw a pixel
virtual Painter & point(
int x, int y,
LColor::color = LColor::foreground);
EnumLColor);
/// draw an image from the image cache
virtual Painter & image(int x, int y,
@ -122,7 +121,7 @@ private:
QString const & str, LyXFont const & f);
/// set pen parameters
QPainter & setPen(LColor::color c,
QPainter & setPen(EnumLColor c,
line_style ls = line_solid,
line_width lw = line_thin);

View File

@ -34,6 +34,7 @@
#include "ui/QPrefIdentityModule.h"
#include "gettext.h"
#include "LColor.h"
#include "panelstack.h"
#include <qpushbutton.h>

View File

@ -13,12 +13,11 @@
#define QPREFSDIALOG_H
#include "LColor.h"
#include "ui/QPrefsDialogBase.h"
#include <vector>
class EnumLColor;
class QPrefs;
class QPrefAsciiModule;
class QPrefDateModule;
@ -84,7 +83,7 @@ protected:
private:
std::vector<LColor::color> colors_;
std::vector<EnumLColor> colors_;
QPrefAsciiModule * asciiModule;
QPrefDateModule * dateModule;

View File

@ -12,6 +12,7 @@
#include "QWorkArea.h"
#include "debug.h"
#include "LColor.h"
#include "qt_helpers.h"
#include "lcolorcache.h"
#include "funcrequest.h"

View File

@ -12,6 +12,8 @@
#include "lcolorcache.h"
#include "LColor.h"
LColorCache lcolorcache;
@ -20,7 +22,7 @@ LColorCache::LColorCache()
}
QColor const & LColorCache::get(LColor::color col) const
QColor const & LColorCache::get(EnumLColor col) const
{
lcolor_map::const_iterator cit = colormap.find(col);
if (cit != colormap.end())

View File

@ -14,10 +14,12 @@
#include <map>
#include "LColor.h"
#include <qcolor.h>
class EnumLColor;
// FIXME: use a fixed-size array not a map ?
/**
@ -28,13 +30,13 @@ public:
LColorCache();
/// get the given color
QColor const & get(LColor::color color) const;
QColor const & get(EnumLColor color) const;
/// clear all colors
void clear();
private:
typedef std::map<LColor::color, QColor> lcolor_map;
typedef std::map<EnumLColor, QColor> lcolor_map;
mutable lcolor_map colormap;
};

View File

@ -192,13 +192,13 @@ FuncStatus getStatus(FuncRequest const & ev)
}
string const hexname(LColor::color col)
string const hexname(EnumLColor col)
{
return ltrim(fromqstr(lcolorcache.get(col).name()), "#");
}
void update_color(LColor::color)
void update_color(EnumLColor)
{
// FIXME: Bleh, can't we just clear them all at once ?
lcolorcache.clear();

View File

@ -13,6 +13,7 @@
#include "QWorkArea.h"
#include "qscreen.h"
#include "debug.h"
#include "LColor.h"
#include <qapplication.h>

View File

@ -1,3 +1,26 @@
2003-09-15 Angus Leeming <leeming@lyx.org>
* Color.C:
* ColorHandler.C:
* XPainter.C:
* xformsImage.C
* xscreen.C: add #include "LColor.h".
* Color.h: remove #include "LColor.h".
* Color.[Ch] (getRGBColor):
* ColorHandler.[Ch] (colorPixel, getGCForeground, getGCLinepars, updateColor):
pass EnumLColor args, rather than LColor::color ones.
* FormCharacter.h: store vector<EnumLColor> color_.
* XPainter.[Ch] (point, line, lines, rectangle, fillPolygon):
* lyx_gui.C (hexname, update_color): pass EnumLColor args, rather
than LColor::color ones.
* xformsImage.C:
2003-09-15 Lars Gullik Bjønnes <larsbj@gullik.net>
* Color.C

View File

@ -14,6 +14,8 @@
#include "lyx_forms.h"
#include "LColor.h"
#include "support/std_sstream.h"
#include <cmath>
@ -48,7 +50,7 @@ int hexstrToInt(string const & str)
bool getRGBColor(LColor::color col,
bool getRGBColor(EnumLColor col,
unsigned int & r, unsigned int & g, unsigned int & b)
{
string const name = lcolor.getX11Name(col);

View File

@ -18,12 +18,15 @@
#include "support/std_string.h"
#include "LColor.h"
class EnumLColor;
/** Given col, fills r, g, b in the range 0-255.
The function returns true if successful.
It returns false on failure and sets r, g, b to 0. */
bool getRGBColor(LColor::color col,
bool getRGBColor(EnumLColor col,
unsigned int & r, unsigned int & g, unsigned int & b);
struct RGBColor;

View File

@ -14,6 +14,7 @@
#include "debug.h"
#include "gettext.h"
#include "LColor.h"
#include "support/lstrings.h"
#include "support/tostr.h"
@ -76,7 +77,7 @@ LyXColorHandler::~LyXColorHandler()
}
unsigned long LyXColorHandler::colorPixel(LColor::color c)
unsigned long LyXColorHandler::colorPixel(EnumLColor c)
{
XGCValues val;
XGetGCValues(display, getGCForeground(c), GCForeground, &val);
@ -162,7 +163,7 @@ GC LyXColorHandler::getGCForeground(string const & s)
// Gets GC according to color
// Uses caching
GC LyXColorHandler::getGCForeground(LColor::color c)
GC LyXColorHandler::getGCForeground(EnumLColor c)
{
if (static_cast<unsigned>(c) >= colorGCcache.size()) {
colorGCcache.resize(c + 1, 0);
@ -187,7 +188,7 @@ GC LyXColorHandler::getGCForeground(LColor::color c)
// Gets GC for line
GC LyXColorHandler::getGCLinepars(Painter::line_style ls,
Painter::line_width lw, LColor::color c)
Painter::line_width lw, EnumLColor c)
{
//if (lyxerr.debugging()) {
// lyxerr << "Painter drawable: " << drawable() << endl;
@ -233,7 +234,7 @@ GC LyXColorHandler::getGCLinepars(Painter::line_style ls,
// update GC cache after color redefinition
void LyXColorHandler::updateColor (LColor::color c)
void LyXColorHandler::updateColor (EnumLColor c)
{
// color GC cache
GC gc = colorGCcache[c];

View File

@ -22,6 +22,7 @@
// This is only included to provide stuff for the non-public sections
#include <X11/Xlib.h>
class EnumLColor;
class LyXFont;
/**
@ -35,14 +36,14 @@ public:
///
~LyXColorHandler();
///
unsigned long colorPixel(LColor::color c);
unsigned long colorPixel(EnumLColor c);
///
GC getGCForeground(LColor::color c);
GC getGCForeground(EnumLColor c);
///
GC getGCLinepars(Painter::line_style,
Painter::line_width, LColor::color c);
Painter::line_width, EnumLColor c);
/// update the cache after a color definition change
void updateColor(LColor::color c);
void updateColor(EnumLColor c);
private:
///

View File

@ -16,6 +16,7 @@
#include "FormDialogView.h"
#include "ControlCharacter.h" // for ControlCharacter enum
struct EnumLColor;
struct FD_character;
/**
@ -53,7 +54,7 @@ private:
///
std::vector<frnt::FONT_STATE> bar_;
///
std::vector<LColor::color> color_;
std::vector<EnumLColor> color_;
///
std::vector<string> lang_;
};

View File

@ -22,6 +22,7 @@
#include "encoding.h"
#include "language.h"
#include "LColor.h"
#include "lyxfont.h"
#include "lyxrc.h"
@ -48,7 +49,7 @@ int XPainter::paperHeight() const
}
Painter & XPainter::point(int x, int y, LColor::color c)
Painter & XPainter::point(int x, int y, EnumLColor c)
{
XDrawPoint(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCForeground(c), x, y);
@ -58,7 +59,7 @@ Painter & XPainter::point(int x, int y, LColor::color c)
Painter & XPainter::line(int x1, int y1,
int x2, int y2,
LColor::color col,
EnumLColor col,
line_style ls,
line_width lw)
{
@ -71,7 +72,7 @@ Painter & XPainter::line(int x1, int y1,
Painter & XPainter::lines(int const * xp, int const * yp,
int np,
LColor::color col,
EnumLColor col,
line_style ls,
line_width lw)
{
@ -92,7 +93,7 @@ Painter & XPainter::lines(int const * xp, int const * yp,
Painter & XPainter::rectangle(int x, int y,
int w, int h,
LColor::color col,
EnumLColor col,
line_style ls,
line_width lw)
{
@ -105,7 +106,7 @@ Painter & XPainter::rectangle(int x, int y,
Painter & XPainter::fillRectangle(int x, int y,
int w, int h,
LColor::color col)
EnumLColor col)
{
XFillRectangle(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCForeground(col), x, y, w, h);
@ -114,7 +115,7 @@ Painter & XPainter::fillRectangle(int x, int y,
Painter & XPainter::fillPolygon(int const * xp, int const * yp,
int np, LColor::color col)
int np, EnumLColor col)
{
boost::scoped_array<XPoint> points(new XPoint[np]);
@ -133,7 +134,7 @@ Painter & XPainter::fillPolygon(int const * xp, int const * yp,
Painter & XPainter::arc(int x, int y,
unsigned int w, unsigned int h,
int a1, int a2, LColor::color col)
int a1, int a2, EnumLColor col)
{
XDrawArc(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCForeground(col),

View File

@ -38,7 +38,7 @@ public:
virtual Painter & line(
int x1, int y1,
int x2, int y2,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin);
@ -52,7 +52,7 @@ public:
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin);
@ -60,7 +60,7 @@ public:
virtual Painter & rectangle(
int x, int y,
int w, int h,
LColor::color = LColor::foreground,
EnumLColor,
line_style = line_solid,
line_width = line_thin);
@ -68,26 +68,26 @@ public:
virtual Painter & fillRectangle(
int x, int y,
int w, int h,
LColor::color);
EnumLColor);
/// draw a filled (irregular) polygon
virtual Painter & fillPolygon(
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground);
EnumLColor);
/// draw an arc
virtual Painter & arc(
int x, int y,
unsigned int w, unsigned int h,
int a1, int a2,
LColor::color = LColor::foreground);
EnumLColor);
/// draw a pixel
virtual Painter & point(
int x, int y,
LColor::color = LColor::foreground);
EnumLColor);
/// draw an image from the image cache
virtual Painter & image(int x, int y,

View File

@ -330,7 +330,7 @@ FuncStatus getStatus(FuncRequest const & /*ev*/)
return FuncStatus();
}
string const hexname(LColor::color col)
string const hexname(EnumLColor col)
{
unsigned int r, g, b;
bool const success = getRGBColor(col, r, g, b);
@ -351,7 +351,7 @@ string const hexname(LColor::color col)
}
void update_color(LColor::color col)
void update_color(EnumLColor col)
{
lyxColorHandler->updateColor(col);
}

View File

@ -11,10 +11,14 @@
#include <config.h>
#include "xformsImage.h"
#include "graphics/GraphicsParams.h"
#include "Color.h"
#include "format.h"
#include "debug.h"
#include "format.h"
#include "LColor.h"
#include "graphics/GraphicsParams.h"
#include "support/lstrings.h"
#include "support/lyxfunctional.h" // compare_memfun
#include "support/lyxlib.h"

View File

@ -17,6 +17,7 @@
#include "XWorkArea.h"
#include "debug.h"
#include "LColor.h"
using std::endl;

View File

@ -1,3 +1,9 @@
2003-09-15 Angus Leeming <leeming@lyx.org>
* inset.[Ch] (setBackgroundColor, backgroundColor):
* insettext.[Ch] (setFrameColor):
pass EnumLColor args, rather than LColor::color ones.
2003-09-15 Lars Gullik Bjønnes <larsbj@gullik.net>
* insetcommand.C

View File

@ -84,13 +84,13 @@ LyXText * InsetOld::getLyXText(BufferView const * bv, bool /*recursive*/) const
}
void InsetOld::setBackgroundColor(LColor::color color)
void InsetOld::setBackgroundColor(EnumLColor color)
{
background_color_ = color;
}
LColor::color InsetOld::backgroundColor() const
EnumLColor InsetOld::backgroundColor() const
{
if (background_color_ == LColor::inherit) {
if (owner())

View File

@ -21,6 +21,7 @@
#include "ParagraphList_fwd.h"
class Buffer;
class EnumLColor;
class FuncRequest;
class LatexRunParams;
class LyXCursor;
@ -204,9 +205,9 @@ public:
///
UpdatableInset * owner() const { return owner_; }
///
void setBackgroundColor(LColor::color);
void setBackgroundColor(EnumLColor);
///
LColor::color backgroundColor() const;
EnumLColor backgroundColor() const;
///
int x() const { return top_x; }
///

View File

@ -1451,7 +1451,7 @@ void InsetText::setDrawFrame(DrawFrame how)
}
void InsetText::setFrameColor(LColor::color col)
void InsetText::setFrameColor(EnumLColor col)
{
frame_color = col;
}

View File

@ -28,6 +28,7 @@ class Buffer;
class BufferParams;
class BufferView;
class Dimension;
class EnumLColor;
class LyXCursor;
class Painter;
class Paragraph;
@ -128,7 +129,7 @@ public:
///
void setDrawFrame(DrawFrame);
///
void setFrameColor(LColor::color);
void setFrameColor(EnumLColor);
///
LyXText * getLyXText(BufferView const *,
bool const recursive = false) const;

View File

@ -29,6 +29,7 @@
#include "kbmap.h"
#include "language.h"
#include "lastfiles.h"
#include "LColor.h"
#include "lyxfunc.h"
#include "lyxlex.h"
#include "lyxrc.h"

View File

@ -202,7 +202,7 @@ LyXFont::FONT_MISC_STATE LyXFont::underbar() const
}
LColor::color LyXFont::color() const
EnumLColor LyXFont::color() const
{
return bits.color;
}
@ -282,7 +282,7 @@ LyXFont & LyXFont::setNoun(LyXFont::FONT_MISC_STATE n)
}
LyXFont & LyXFont::setColor(LColor::color c)
LyXFont & LyXFont::setColor(EnumLColor c)
{
bits.color = c;
return *this;
@ -930,7 +930,7 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
}
LColor::color LyXFont::realColor() const
EnumLColor LyXFont::realColor() const
{
if (color() == LColor::none)
return LColor::foreground;

View File

@ -20,6 +20,7 @@
#include "support/std_string.h"
#include <iosfwd>
class EnumLColor;
class LyXLex;
class BufferParams;
class Language;
@ -207,7 +208,7 @@ public:
FONT_MISC_STATE number() const;
///
LColor::color color() const;
EnumLColor color() const;
///
Language const * language() const;
@ -238,7 +239,7 @@ public:
///
LyXFont & setNumber(LyXFont::FONT_MISC_STATE n);
///
LyXFont & setColor(LColor::color c);
LyXFont & setColor(EnumLColor c);
///
LyXFont & setLanguage(Language const * l);
@ -310,7 +311,7 @@ public:
string const stateText(BufferParams * params) const;
///
LColor::color realColor() const;
EnumLColor realColor() const;
///
friend

View File

@ -27,6 +27,7 @@ class Buffer;
class BufferParams;
class BufferView;
class Dimension;
class EnumLColor;
class InsetText;
class LyXCursor;
class MetricsInfo;
@ -398,7 +399,7 @@ public:
lyx::pos_type pos, char c, LyXFont const & Font) const;
/// return the color of the canvas
LColor::color backgroundColor() const;
EnumLColor backgroundColor() const;
///
mutable bool bidi_same_direction;

View File

@ -876,7 +876,7 @@ int LyXText::labelFill(ParagraphList::iterator pit, Row const & row) const
}
LColor::color LyXText::backgroundColor() const
EnumLColor LyXText::backgroundColor() const
{
if (inset_owner)
return inset_owner->backgroundColor();