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 Qt4
34 class GuiPainter : public QPainter, public Painter {
36 GuiPainter(QPaintDevice *);
37 virtual ~GuiPainter();
39 /// draw a line from point to point
44 line_style = line_solid,
45 float line_width = 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 line_style = line_solid,
59 float line_width = thin_line);
62 virtual void rectangle(
66 line_style = line_solid,
67 float line_width = thin_line);
69 /// draw a filled rectangle
70 virtual void fillRectangle(
78 unsigned int w, unsigned int h,
83 virtual void point(int x, int y, Color);
85 /// draw an image from the image cache
86 virtual void image(int x, int y, int w, int h,
87 lyx::graphics::Image const & image);
89 /// draw a string at position x, y (y is the baseline)
90 virtual int text(int x, int y,
91 docstring const & str, FontInfo const & f);
93 /// draw a char at position x, y (y is the baseline)
94 virtual int text(int x, int y, char_type c, FontInfo const & f);
97 virtual void textDecoration(FontInfo const & f, int x, int y, int width);
99 /// draw a string and enclose it inside a button frame
100 virtual void buttonText(int x, int baseline, docstring const & s,
101 FontInfo const & font, bool mouseHover);
103 /// start monochrome painting mode, i.e. map every color into [min,max]
104 virtual void enterMonochromeMode(Color const & min,
106 /// leave monochrome painting mode
107 virtual void leaveMonochromeMode();
110 * Draw a string and enclose it inside a rectangle. If
111 * back color is specified, the background is cleared with
112 * the given color. If frame is specified, a thin frame is drawn
113 * around the text with the given color.
115 virtual void rectText(int x, int baseline, docstring const & str,
116 FontInfo const & font, Color back, Color frame);
118 /// draw a filled rectangle with the shape of a 3D button
119 virtual void button(int x, int y, int w, int h, bool mouseHover);
121 /// draw a character of a preedit string for cjk support.
122 virtual int preeditText(int x, int y,
123 char_type c, FontInfo const & f, preedit_style style);
125 void wavyHorizontalLine(int x, int y, int width, ColorCode col);
128 /// check the font, and if set, draw an underline
129 void underline(FontInfo const & f,
130 int x, int y, int width);
132 /// check the font, and if set, draw an dashed underline
133 void dashedUnderline(FontInfo const & f,
134 int x, int y, int width);
136 /// check the font, and if set, draw an strike-through line
137 void strikeoutLine(FontInfo const & f,
138 int x, int y, int width);
140 /// check the font, and if set, draw double underline
141 void doubleUnderline(FontInfo const & f,
142 int x, int y, int width);
144 /// draw a bevelled button border
145 void buttonFrame(int x, int y, int w, int h);
147 /// draw small caps text
149 \return width of the drawn text.
151 int smallCapsText(int x, int y,
152 QString const & str, FontInfo const & f);
154 /// set pen parameters
155 void setQPainterPen(QColor const & col,
156 line_style ls = line_solid, float lw = thin_line);
158 QColor current_color_;
159 Painter::line_style current_ls_;
162 bool const use_pixmap_cache_;
164 std::stack<QColor> monochrome_min_;
166 std::stack<QColor> monochrome_max_;
167 /// convert into Qt color, possibly applying the monochrome mode
168 QColor computeColor(Color col);
169 /// possibly apply monochrome mode
170 QColor filterColor(QColor const & col);
172 QString generateStringSignature(QString const & str, FontInfo const & f);
175 } // namespace frontend
178 #endif // GUIPAINTER_H