Use the new Color class (see r28420) in the Painter code.

See:
http://thread.gmane.org/gmane.editors.lyx.devel/114189

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28421 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-02-09 20:10:11 +00:00
parent 2e7698c4e6
commit a37eaf4f0b
3 changed files with 31 additions and 29 deletions

View File

@ -13,7 +13,7 @@
#ifndef PAINTER_H #ifndef PAINTER_H
#define PAINTER_H #define PAINTER_H
#include "ColorCode.h" #include "Color.h"
#include "support/strfwd.h" #include "support/strfwd.h"
@ -78,7 +78,7 @@ public:
virtual ~Painter() {} virtual ~Painter() {}
/// draw a line from point to point /// draw a line from point to point
virtual void line(int x1, int y1, int x2, int y2, ColorCode, virtual void line(int x1, int y1, int x2, int y2, Color,
line_style = line_solid, line_width = line_thin) = 0; line_style = line_solid, line_width = line_thin) = 0;
/** /**
@ -87,22 +87,22 @@ public:
* @param yp array of points' y co-ords * @param yp array of points' y co-ords
* @param np size of the points array * @param np size of the points array
*/ */
virtual void lines(int const * xp, int const * yp, int np, ColorCode, virtual void lines(int const * xp, int const * yp, int np, Color,
line_style = line_solid, line_width = line_thin) = 0; line_style = line_solid, line_width = line_thin) = 0;
/// draw a rectangle /// draw a rectangle
virtual void rectangle(int x, int y, int w, int h, ColorCode, virtual void rectangle(int x, int y, int w, int h, Color,
line_style = line_solid, line_width = line_thin) = 0; line_style = line_solid, line_width = line_thin) = 0;
/// draw a filled rectangle /// draw a filled rectangle
virtual void fillRectangle(int x, int y, int w, int h, ColorCode) = 0; virtual void fillRectangle(int x, int y, int w, int h, Color) = 0;
/// draw an arc /// draw an arc
virtual void arc(int x, int y, unsigned int w, unsigned int h, virtual void arc(int x, int y, unsigned int w, unsigned int h,
int a1, int a2, ColorCode) = 0; int a1, int a2, Color) = 0;
/// draw a pixel /// draw a pixel
virtual void point(int x, int y, ColorCode) = 0; virtual void point(int x, int y, Color) = 0;
/// draw a filled rectangle with the shape of a 3D button /// 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; 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. * around the text with the given color.
*/ */
virtual void rectText(int x, int baseline, docstring const & str, virtual void rectText(int x, int baseline, docstring const & str,
FontInfo const & font, ColorCode back, ColorCode frame) = 0; FontInfo const & font, Color back, Color frame) = 0;
/// draw a string and enclose it inside a button frame /// draw a string and enclose it inside a button frame
virtual void buttonText(int x, int baseline, docstring const & s, 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; char_type c, FontInfo const & f, preedit_style style) = 0;
/// start monochrome painting mode, i.e. map every color into [min,max] /// start monochrome painting mode, i.e. map every color into [min,max]
virtual void enterMonochromeMode(ColorCode const & min, virtual void enterMonochromeMode(Color const & min,
ColorCode const & max) = 0; Color const & max) = 0;
/// leave monochrome painting mode /// leave monochrome painting mode
virtual void leaveMonochromeMode() = 0; virtual void leaveMonochromeMode() = 0;

View File

@ -112,7 +112,7 @@ QString GuiPainter::generateStringSignature(QString const & str, FontInfo const
} }
QColor GuiPainter::computeColor(ColorCode col) QColor GuiPainter::computeColor(Color col)
{ {
return filterColor(guiApp->colorCache().get(col)); return filterColor(guiApp->colorCache().get(col));
} }
@ -144,7 +144,7 @@ QColor GuiPainter::filterColor(QColor const & col)
} }
void GuiPainter::enterMonochromeMode(ColorCode const & min, ColorCode const & max) void GuiPainter::enterMonochromeMode(Color const & min, Color const & max)
{ {
QColor qmin = filterColor(guiApp->colorCache().get(min)); QColor qmin = filterColor(guiApp->colorCache().get(min));
QColor qmax = filterColor(guiApp->colorCache().get(max)); QColor qmax = filterColor(guiApp->colorCache().get(max));
@ -161,7 +161,7 @@ void GuiPainter::leaveMonochromeMode()
} }
void GuiPainter::point(int x, int y, ColorCode col) void GuiPainter::point(int x, int y, Color col)
{ {
if (!isDrawingEnabled()) if (!isDrawingEnabled())
return; return;
@ -172,7 +172,7 @@ void GuiPainter::point(int x, int y, ColorCode col)
void GuiPainter::line(int x1, int y1, int x2, int y2, void GuiPainter::line(int x1, int y1, int x2, int y2,
ColorCode col, Color col,
line_style ls, line_style ls,
line_width lw) 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, void GuiPainter::lines(int const * xp, int const * yp, int np,
ColorCode col, Color col,
line_style ls, line_style ls,
line_width lw) 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, void GuiPainter::rectangle(int x, int y, int w, int h,
ColorCode col, Color col,
line_style ls, line_style ls,
line_width lw) 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, ColorCode col) void GuiPainter::fillRectangle(int x, int y, int w, int h, Color col)
{ {
if (!isDrawingEnabled()) if (!isDrawingEnabled())
return; return;
@ -239,7 +239,7 @@ void GuiPainter::fillRectangle(int x, int y, int w, int h, ColorCode col)
void GuiPainter::arc(int x, int y, unsigned int w, unsigned int h, void GuiPainter::arc(int x, int y, unsigned int w, unsigned int h,
int a1, int a2, ColorCode col) int a1, int a2, Color col)
{ {
if (!isDrawingEnabled()) if (!isDrawingEnabled())
return; 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, void GuiPainter::rectText(int x, int y, docstring const & str,
FontInfo const & font, ColorCode back, ColorCode frame) FontInfo const & font, Color back, Color frame)
{ {
int width; int width;
int ascent; int ascent;

View File

@ -13,6 +13,8 @@
#ifndef GUIPAINTER_H #ifndef GUIPAINTER_H
#define GUIPAINTER_H #define GUIPAINTER_H
#include "Color.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
#include <QPainter> #include <QPainter>
@ -38,7 +40,7 @@ public:
virtual void line( virtual void line(
int x1, int y1, int x1, int y1,
int x2, int y2, int x2, int y2,
ColorCode, Color,
line_style = line_solid, line_style = line_solid,
line_width = line_thin); line_width = line_thin);
@ -52,7 +54,7 @@ public:
int const * xp, int const * xp,
int const * yp, int const * yp,
int np, int np,
ColorCode, Color,
line_style = line_solid, line_style = line_solid,
line_width = line_thin); line_width = line_thin);
@ -60,7 +62,7 @@ public:
virtual void rectangle( virtual void rectangle(
int x, int y, int x, int y,
int w, int h, int w, int h,
ColorCode, Color,
line_style = line_solid, line_style = line_solid,
line_width = line_thin); line_width = line_thin);
@ -68,17 +70,17 @@ public:
virtual void fillRectangle( virtual void fillRectangle(
int x, int y, int x, int y,
int w, int h, int w, int h,
ColorCode); Color);
/// draw an arc /// draw an arc
virtual void arc( virtual void arc(
int x, int y, int x, int y,
unsigned int w, unsigned int h, unsigned int w, unsigned int h,
int a1, int a2, int a1, int a2,
ColorCode); Color);
/// draw a pixel /// draw a pixel
virtual void point(int x, int y, ColorCode); virtual void point(int x, int y, Color);
/// draw an image from the image cache /// draw an image from the image cache
virtual void image(int x, int y, int w, int h, virtual void image(int x, int y, int w, int h,
@ -96,8 +98,8 @@ public:
FontInfo const & font, bool mouseHover); FontInfo const & font, bool mouseHover);
/// start monochrome painting mode, i.e. map every color into [min,max] /// start monochrome painting mode, i.e. map every color into [min,max]
virtual void enterMonochromeMode(ColorCode const & min, virtual void enterMonochromeMode(Color const & min,
ColorCode const & max); Color const & max);
/// leave monochrome painting mode /// leave monochrome painting mode
virtual void leaveMonochromeMode(); virtual void leaveMonochromeMode();
@ -108,7 +110,7 @@ public:
* around the text with the given color. * around the text with the given color.
*/ */
virtual void rectText(int x, int baseline, docstring const & str, virtual void rectText(int x, int baseline, docstring const & str,
FontInfo const & font, ColorCode back, ColorCode frame); FontInfo const & font, Color back, Color frame);
/// draw a filled rectangle with the shape of a 3D button /// draw a filled rectangle with the shape of a 3D button
virtual void button(int x, int y, int w, int h, bool mouseHover); virtual void button(int x, int y, int w, int h, bool mouseHover);
@ -150,7 +152,7 @@ private:
/// ///
std::stack<QColor> monochrome_max_; std::stack<QColor> monochrome_max_;
/// convert into Qt color, possibly applying the monochrome mode /// convert into Qt color, possibly applying the monochrome mode
QColor computeColor(ColorCode col); QColor computeColor(Color col);
/// possibly apply monochrome mode /// possibly apply monochrome mode
QColor filterColor(QColor const & col); QColor filterColor(QColor const & col);
/// ///