4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Abdelrazak Younes
10 * Full author contact details are available in file CREDITS.
18 #include "frontends/Painter.h"
32 * GuiPainter - a painter implementation for Qt
34 class GuiPainter : public QPainter, public Painter {
36 GuiPainter(QPaintDevice *, double pixel_ratio);
37 virtual ~GuiPainter();
39 /// draw a line from point to point
44 line_style ls = line_solid,
48 * lines - draw a set of lines
49 * @param xp array of points' x co-ords
50 * @param yp array of points' y co-ords
51 * @param np size of the points array
58 fill_style fs = fill_none,
59 line_style ls = line_solid,
63 virtual void rectangle(
67 line_style = line_solid,
70 /// draw a filled rectangle
71 virtual void fillRectangle(
79 unsigned int w, unsigned int h,
84 virtual void point(int x, int y, Color);
86 /// draw an image from the image cache
87 virtual void image(int x, int y, int w, int h,
88 lyx::graphics::Image const & image);
90 /** draw a string at position x, y (y is the baseline). The
91 * text direction is given by \c rtl.
92 * \return the width of the drawn text.
94 virtual int text(int x, int y, docstring const & str, FontInfo const & f,
95 bool rtl = false, double wordspacing = 0.0);
97 /** draw a string at position x, y (y is the baseline). The
98 * text direction is enforced by the \c Font.
99 * \return the width of the drawn text.
101 virtual int text(int x, int y, docstring const & str, Font const & f,
102 double wordspacing = 0.0);
104 /** draw a string at position x, y (y is the baseline), but
105 * make sure that the part between \c from and \c to is in
106 * \c other color. The text direction is enforced by the \c Font.
107 * \return the width of the drawn text.
109 virtual int text(int x, int y, docstring const & str, Font const & f,
110 Color other, size_type from, size_type to,
111 double const wordspacing);
113 /// draw a char at position x, y (y is the baseline)
114 virtual int text(int x, int y, char_type c, FontInfo const & f);
117 virtual void textDecoration(FontInfo const & f, int x, int y, int width);
119 /// draw a string and enclose it inside a button frame
120 virtual void buttonText(int x, int baseline, docstring const & s,
121 FontInfo const & font, bool mouseHover);
123 /// start monochrome painting mode, i.e. map every color into [min,max]
124 virtual void enterMonochromeMode(Color const & min,
126 /// leave monochrome painting mode
127 virtual void leaveMonochromeMode();
130 * Draw a string and enclose it inside a rectangle. If
131 * back color is specified, the background is cleared with
132 * the given color. If frame is specified, a thin frame is drawn
133 * around the text with the given color.
135 virtual void rectText(int x, int baseline, docstring const & str,
136 FontInfo const & font, Color back, Color frame);
138 /// draw a filled rectangle with the shape of a 3D button
139 virtual void button(int x, int y, int w, int h, bool mouseHover);
141 /// draw a character of a preedit string for cjk support.
142 virtual int preeditText(int x, int y,
143 char_type c, FontInfo const & f, preedit_style style);
145 void wavyHorizontalLine(int x, int y, int width, ColorCode col);
148 /// check the font, and if set, draw an underline
149 void underline(FontInfo const & f,
150 int x, int y, int width, line_style ls = line_solid);
152 /// check the font, and if set, draw an dashed underline
153 void dashedUnderline(FontInfo const & f,
154 int x, int y, int width);
156 /// check the font, and if set, draw an strike-through line
157 void strikeoutLine(FontInfo const & f,
158 int x, int y, int width);
160 /// check the font, and if set, draw double underline
161 void doubleUnderline(FontInfo const & f,
162 int x, int y, int width);
164 /// draw a bevelled button border
165 void buttonFrame(int x, int y, int w, int h);
167 /// set pen parameters
168 void setQPainterPen(QColor const & col,
169 line_style ls = line_solid, int lw = thin_line);
171 // Helper for text() method
172 void do_drawText(int x, int y, QString str, bool rtl, FontInfo const & f, QFont ff);
174 QColor current_color_;
175 Painter::line_style current_ls_;
178 bool const use_pixmap_cache_;
180 std::stack<QColor> monochrome_min_;
182 std::stack<QColor> monochrome_max_;
183 /// convert into Qt color, possibly applying the monochrome mode
184 QColor computeColor(Color col);
185 /// possibly apply monochrome mode
186 QColor filterColor(QColor const & col);
188 QString generateStringSignature(QString const & str, FontInfo const & f);
191 } // namespace frontend
194 #endif // GUIPAINTER_H