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 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 line_style ls = line_solid,
59 float lw = thin_line);
62 virtual void rectangle(
66 line_style = line_solid,
67 float lw = 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). The
90 * text direction is given by \c rtl.
91 * \return the width of the drawn text.
93 virtual int text(int x, int y, docstring const & str, FontInfo const & f, bool rtl = false);
95 /** draw a string at position x, y (y is the baseline). The
96 * text direction is enforced by the \c Font.
97 * \return the width of the drawn text.
99 virtual int text(int x, int y, docstring const & str, Font const & f);
101 /** draw a string at position x, y (y is the baseline), but
102 * make sure that the part between \c from and \c to is in
103 * \c other color. The text direction is enforced by the \c Font.
104 * \return the width of the drawn text.
106 virtual int text(int x, int y, docstring const & str, Font const & f,
107 Color other, size_type from, size_type to);
109 /// draw a char at position x, y (y is the baseline)
110 virtual int text(int x, int y, char_type c, FontInfo const & f);
113 virtual void textDecoration(FontInfo const & f, int x, int y, int width);
115 /// draw a string and enclose it inside a button frame
116 virtual void buttonText(int x, int baseline, docstring const & s,
117 FontInfo const & font, bool mouseHover);
119 /// start monochrome painting mode, i.e. map every color into [min,max]
120 virtual void enterMonochromeMode(Color const & min,
122 /// leave monochrome painting mode
123 virtual void leaveMonochromeMode();
126 * Draw a string and enclose it inside a rectangle. If
127 * back color is specified, the background is cleared with
128 * the given color. If frame is specified, a thin frame is drawn
129 * around the text with the given color.
131 virtual void rectText(int x, int baseline, docstring const & str,
132 FontInfo const & font, Color back, Color frame);
134 /// draw a filled rectangle with the shape of a 3D button
135 virtual void button(int x, int y, int w, int h, bool mouseHover);
137 /// draw a character of a preedit string for cjk support.
138 virtual int preeditText(int x, int y,
139 char_type c, FontInfo const & f, preedit_style style);
141 void wavyHorizontalLine(int x, int y, int width, ColorCode col);
144 /// check the font, and if set, draw an underline
145 void underline(FontInfo const & f,
146 int x, int y, int width);
148 /// check the font, and if set, draw an dashed underline
149 void dashedUnderline(FontInfo const & f,
150 int x, int y, int width);
152 /// check the font, and if set, draw an strike-through line
153 void strikeoutLine(FontInfo const & f,
154 int x, int y, int width);
156 /// check the font, and if set, draw double underline
157 void doubleUnderline(FontInfo const & f,
158 int x, int y, int width);
160 /// draw a bevelled button border
161 void buttonFrame(int x, int y, int w, int h);
163 /// set pen parameters
164 void setQPainterPen(QColor const & col,
165 line_style ls = line_solid, float lw = thin_line);
167 QColor current_color_;
168 Painter::line_style current_ls_;
171 bool const use_pixmap_cache_;
173 std::stack<QColor> monochrome_min_;
175 std::stack<QColor> monochrome_max_;
176 /// convert into Qt color, possibly applying the monochrome mode
177 QColor computeColor(Color col);
178 /// possibly apply monochrome mode
179 QColor filterColor(QColor const & col);
181 QString generateStringSignature(QString const & str, FontInfo const & f);
184 } // namespace frontend
187 #endif // GUIPAINTER_H