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 line_width = line_thin);
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 line_width = line_thin);
62 virtual void rectangle(
66 line_style = line_solid,
67 line_width = line_thin);
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);
96 /// draw a string and enclose it inside a button frame
97 virtual void buttonText(int x, int baseline, docstring const & s,
98 FontInfo const & font, bool mouseHover);
100 /// start monochrome painting mode, i.e. map every color into [min,max]
101 virtual void enterMonochromeMode(Color const & min,
103 /// leave monochrome painting mode
104 virtual void leaveMonochromeMode();
107 * Draw a string and enclose it inside a rectangle. If
108 * back color is specified, the background is cleared with
109 * the given color. If frame is specified, a thin frame is drawn
110 * around the text with the given color.
112 virtual void rectText(int x, int baseline, docstring const & str,
113 FontInfo const & font, Color back, Color frame);
115 /// draw a filled rectangle with the shape of a 3D button
116 virtual void button(int x, int y, int w, int h, bool mouseHover);
118 /// draw a character of a preedit string for cjk support.
119 virtual int preeditText(int x, int y,
120 char_type c, FontInfo const & f, preedit_style style);
122 void wavyHorizontalLine(int x, int y, int width, ColorCode col);
125 /// check the font, and if set, draw an underline
126 void underline(FontInfo const & f,
127 int x, int y, int width);
129 /// check the font, and if set, draw an dashed underline
130 void dashedUnderline(FontInfo const & f,
131 int x, int y, int width);
133 /// check the font, and if set, draw an strike-through line
134 void strikeoutLine(FontInfo const & f,
135 int x, int y, int width);
137 /// check the font, and if set, draw double underline
138 void doubleUnderline(FontInfo const & f,
139 int x, int y, int width);
141 /// draw a bevelled button border
142 void buttonFrame(int x, int y, int w, int h);
144 /// draw small caps text
146 \return width of the drawn text.
148 int smallCapsText(int x, int y,
149 QString const & str, FontInfo const & f);
151 /// set pen parameters
152 void setQPainterPen(QColor const & col,
153 line_style ls = line_solid, line_width lw = line_thin);
155 QColor current_color_;
156 Painter::line_style current_ls_;
157 Painter::line_width current_lw_;
159 bool const use_pixmap_cache_;
161 std::stack<QColor> monochrome_min_;
163 std::stack<QColor> monochrome_max_;
164 /// convert into Qt color, possibly applying the monochrome mode
165 QColor computeColor(Color col);
166 /// possibly apply monochrome mode
167 QColor filterColor(QColor const & col);
169 QString generateStringSignature(QString const & str, FontInfo const & f);
172 } // namespace frontend
175 #endif // GUIPAINTER_H