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,
45 float lw = thin_line);
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,
60 float lw = thin_line);
63 virtual void rectangle(
67 line_style = line_solid,
68 float lw = thin_line);
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, bool rtl = false);
96 /** draw a string at position x, y (y is the baseline). The
97 * text direction is enforced by the \c Font.
98 * \return the width of the drawn text.
100 virtual int text(int x, int y, docstring const & str, Font const & f);
102 /** draw a string at position x, y (y is the baseline), but
103 * make sure that the part between \c from and \c to is in
104 * \c other color. The text direction is enforced by the \c Font.
105 * \return the width of the drawn text.
107 virtual int text(int x, int y, docstring const & str, Font const & f,
108 Color other, size_type from, size_type to);
110 /// draw a char at position x, y (y is the baseline)
111 virtual int text(int x, int y, char_type c, FontInfo const & f);
114 virtual void textDecoration(FontInfo const & f, int x, int y, int width);
116 /// draw a string and enclose it inside a button frame
117 virtual void buttonText(int x, int baseline, docstring const & s,
118 FontInfo const & font, bool mouseHover);
120 /// start monochrome painting mode, i.e. map every color into [min,max]
121 virtual void enterMonochromeMode(Color const & min,
123 /// leave monochrome painting mode
124 virtual void leaveMonochromeMode();
127 * Draw a string and enclose it inside a rectangle. If
128 * back color is specified, the background is cleared with
129 * the given color. If frame is specified, a thin frame is drawn
130 * around the text with the given color.
132 virtual void rectText(int x, int baseline, docstring const & str,
133 FontInfo const & font, Color back, Color frame);
135 /// draw a filled rectangle with the shape of a 3D button
136 virtual void button(int x, int y, int w, int h, bool mouseHover);
138 /// draw a character of a preedit string for cjk support.
139 virtual int preeditText(int x, int y,
140 char_type c, FontInfo const & f, preedit_style style);
142 void wavyHorizontalLine(int x, int y, int width, ColorCode col);
145 /// check the font, and if set, draw an underline
146 void underline(FontInfo const & f,
147 int x, int y, int width);
149 /// check the font, and if set, draw an dashed underline
150 void dashedUnderline(FontInfo const & f,
151 int x, int y, int width);
153 /// check the font, and if set, draw an strike-through line
154 void strikeoutLine(FontInfo const & f,
155 int x, int y, int width);
157 /// check the font, and if set, draw double underline
158 void doubleUnderline(FontInfo const & f,
159 int x, int y, int width);
161 /// draw a bevelled button border
162 void buttonFrame(int x, int y, int w, int h);
164 /// set pen parameters
165 void setQPainterPen(QColor const & col,
166 line_style ls = line_solid, float lw = thin_line);
168 QColor current_color_;
169 Painter::line_style current_ls_;
172 bool const use_pixmap_cache_;
174 std::stack<QColor> monochrome_min_;
176 std::stack<QColor> monochrome_max_;
177 /// convert into Qt color, possibly applying the monochrome mode
178 QColor computeColor(Color col);
179 /// possibly apply monochrome mode
180 QColor filterColor(QColor const & col);
182 QString generateStringSignature(QString const & str, FontInfo const & f);
185 } // namespace frontend
188 #endif // GUIPAINTER_H