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.
16 #include "frontends/Painter.h"
30 * GuiPainter - a painter implementation for Qt4
32 class GuiPainter : public QPainter, public Painter {
34 GuiPainter(QPaintDevice *);
35 virtual ~GuiPainter();
37 /// draw a line from point to point
42 line_style = line_solid,
43 line_width = line_thin);
46 * lines - draw a set of lines
47 * @param xp array of points' x co-ords
48 * @param yp array of points' y co-ords
49 * @param np size of the points array
56 line_style = line_solid,
57 line_width = line_thin);
60 virtual void rectangle(
64 line_style = line_solid,
65 line_width = line_thin);
67 /// draw a filled rectangle
68 virtual void fillRectangle(
76 unsigned int w, unsigned int h,
81 virtual void point(int x, int y, ColorCode);
83 /// draw an image from the image cache
84 virtual void image(int x, int y, int w, int h,
85 lyx::graphics::Image const & image);
87 /// draw a string at position x, y (y is the baseline)
88 virtual int text(int x, int y,
89 docstring const & str, FontInfo const & f);
91 /// draw a char at position x, y (y is the baseline)
92 virtual int text(int x, int y, char_type c, FontInfo const & f);
94 /// draw a string and enclose it inside a button frame
95 virtual void buttonText(int x, int baseline, docstring const & s,
96 FontInfo const & font, bool mouseHover);
98 /// start monochrome painting mode, i.e. map every color into [min,max]
99 virtual void enterMonochromeMode(ColorCode const & min,
100 ColorCode const & max);
101 /// leave monochrome painting mode
102 virtual void leaveMonochromeMode();
105 * Draw a string and enclose it inside a rectangle. If
106 * back color is specified, the background is cleared with
107 * the given color. If frame is specified, a thin frame is drawn
108 * around the text with the given color.
110 virtual void rectText(int x, int baseline, docstring const & str,
111 FontInfo const & font, ColorCode back, ColorCode frame);
113 /// draw a filled rectangle with the shape of a 3D button
114 virtual void button(int x, int y, int w, int h, bool mouseHover);
116 /// draw a character of a preedit string for cjk support.
117 virtual int preeditText(int x, int y,
118 char_type c, FontInfo const & f, preedit_style style);
121 /// check the font, and if set, draw an underline
122 void underline(FontInfo const & f,
123 int x, int y, int width);
125 /// check the font, and if set, draw an dashed underline
126 void dashedUnderline(FontInfo const & f,
127 int x, int y, int width);
129 /// draw a bevelled button border
130 void buttonFrame(int x, int y, int w, int h);
132 /// draw small caps text
134 \return width of the drawn text.
136 int smallCapsText(int x, int y,
137 QString const & str, FontInfo const & f);
139 /// set pen parameters
140 void setQPainterPen(QColor const & col,
141 line_style ls = line_solid, line_width lw = line_thin);
143 QColor current_color_;
144 Painter::line_style current_ls_;
145 Painter::line_width current_lw_;
147 bool const use_pixmap_cache_;
149 std::stack<QColor> monochrome_min_;
151 std::stack<QColor> monochrome_max_;
152 /// convert into Qt color, possibly applying the monochrome mode
153 QColor computeColor(ColorCode col);
154 /// possibly apply monochrome mode
155 QColor filterColor(QColor const & col);
157 QString generateStringSignature(QString const & str, FontInfo const & f);
160 } // namespace frontend
163 #endif // GUIPAINTER_H