fill_style = fill_none, line_style = line_solid,
int line_width = thin_line) = 0;
+ /**
+ * path - draw a path with bezier curves
+ * @param xp array of points' x co-ords
+ * @param yp array of points' y co-ords
+ * @param c1x array of first control points' x co-ords
+ * @param c1y array of first control points' y co-ords
+ * @param c2x array of second control points' x co-ords
+ * @param c2y array of second control points' y co-ords
+ * @param np size of the points array
+ */
+ virtual void path(int const * xp, int const * yp,
+ int const * c1x, int const * c1y,
+ int const * c2x, int const * c2y,
+ int np, Color,
+ fill_style = fill_none, line_style = line_solid,
+ int line_width = thin_line) = 0;
+
/// draw a rectangle
virtual void rectangle(int x, int y, int w, int h, Color,
line_style = line_solid, int line_width = thin_line) = 0;
}
+void GuiPainter::path(int const * xp, int const * yp,
+ int const * c1x, int const * c1y,
+ int const * c2x, int const * c2y,
+ int np,
+ Color col,
+ fill_style fs,
+ line_style ls,
+ int lw)
+{
+ if (!isDrawingEnabled())
+ return;
+
+ QPainterPath bpath;
+ // This is the starting point, so its control points are meaningless
+ bpath.moveTo(xp[0], yp[0]);
+
+ for (int i = 1; i < np; ++i) {
+ bool line = c1x[i] == xp[i - 1] && c1y[i] == yp[i - 1] &&
+ c2x[i] == xp[i] && c2y[i] == yp[i];
+ if (line)
+ bpath.lineTo(xp[i], yp[i]);
+ else
+ bpath.cubicTo(c1x[i], c1y[i], c2x[i], c2y[i], xp[i], yp[i]);
+ }
+ QColor const color = computeColor(col);
+ setQPainterPen(color, ls, lw);
+ bool const text_is_antialiased = renderHints() & TextAntialiasing;
+ setRenderHint(Antialiasing, text_is_antialiased);
+ drawPath(bpath);
+ if (fs != fill_none)
+ fillPath(bpath, QBrush(color));
+ setRenderHint(Antialiasing, false);
+}
+
+
void GuiPainter::rectangle(int x, int y, int w, int h,
Color col,
line_style ls,
#include "frontends/Painter.h"
#include <QPainter>
+#include <QPainterPath>
#include <stack>
class QString;
line_style ls = line_solid,
int lw = thin_line);
+ /**
+ * path - draw a path with bezier curves
+ * @param xp array of points' x co-ords
+ * @param yp array of points' y co-ords
+ * @param c1x array of first control points' x co-ords
+ * @param c1y array of first control points' y co-ords
+ * @param c2x array of second control points' x co-ords
+ * @param c2y array of second control points' y co-ords
+ * @param np size of the points array
+ */
+ virtual void path(int const * xp, int const * yp,
+ int const * c1x, int const * c1y,
+ int const * c2x, int const * c2y,
+ int np, Color,
+ fill_style = fill_none, line_style = line_solid,
+ int line_width = thin_line);
+
/// draw a rectangle
virtual void rectangle(
int x, int y,
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
dim.asc = fm.maxAscent();
dim.des = fm.maxDescent();
- dim.wid = fm.width('m');
+ dim.wid = fm.width('n');
if (params_.kind == InsetSeparatorParams::PLAIN)
- dim.wid *= 5;
+ dim.wid *= 8;
}
font.setColor(ColorName());
frontend::FontMetrics const & fm = theFontMetrics(pi.base.font);
- int const wid = fm.width('m');
+ int const wid = fm.width('n');
int const asc = fm.maxAscent();
- int xp[3];
- int yp[3];
+ int xp[7];
+ int yp[7];
if (params_.kind == InsetSeparatorParams::PLAIN) {
yp[0] = int(y - 0.500 * asc * 0.75);
- yp[1] = int(y - 0.500 * asc * 0.75);
+ yp[1] = yp[0];
xp[0] = int(x);
- xp[1] = int(x + wid * 5);
+ xp[1] = int(x + wid * 8);
pi.pain.lines(xp, yp, 2, ColorName());
} else {
- yp[0] = int(y - 0.875 * asc * 0.5);
- yp[1] = int(y - 0.500 * asc * 0.5);
- yp[2] = int(y - 0.125 * asc * 0.5);
+ yp[0] = int(y - 0.500 * asc * 0.5);
+ yp[1] = int(y - 0.250 * asc * 0.5);
+ yp[2] = int(y);
if (pi.ltr_pos) {
- xp[0] = int(x + wid * 0.375);
- xp[1] = int(x);
- xp[2] = int(x + wid * 0.375);
+ xp[0] = int(x + 1 + wid * 0.375);
+ xp[1] = int(x + 1);
} else {
- xp[0] = int(x + wid * 0.625);
- xp[1] = int(x + wid);
- xp[2] = int(x + wid * 0.625);
+ xp[0] = int(x - 1 + wid * 0.625);
+ xp[1] = int(x - 1 + wid);
}
+ xp[2] = xp[0];
pi.pain.lines(xp, yp, 3, ColorName(), Painter::fill_oddeven);
- yp[0] = int(y - 0.500 * asc * 0.5);
- yp[1] = int(y - 0.500 * asc * 0.5);
- yp[2] = int(y - asc * 0.5);
+ yp[0] = yp[1];
+ yp[2] = int(y - 0.850 * asc * 0.5);
+ yp[3] = int(y - 1.250 * asc * 0.5);
+ yp[4] = yp[3];
+ yp[5] = yp[2];
+ yp[6] = yp[5];
+ xp[0] = xp[1];
if (pi.ltr_pos) {
- xp[0] = int(x);
- xp[1] = int(x + wid);
+ xp[1] = int(x + 1 + wid * 0.50);
xp[2] = int(x + wid);
+ xp[3] = xp[2];
+ xp[4] = int(x + wid * 0.75);
} else {
- xp[0] = int(x + wid);
- xp[1] = int(x);
+ xp[1] = int(x + wid * 0.50);
xp[2] = int(x);
+ xp[3] = xp[2];
+ xp[4] = int(x + wid * 0.25);
+ }
+ xp[5] = xp[4];
+ xp[6] = xp[2];
+
+ int c1x[7];
+ int c1y[7];
+ int c2x[7];
+ int c2y[7];
+
+ for (int i = 1; i < 7; ++i) {
+ c1x[i] = xp[i - 1];
+ c1y[i] = yp[i - 1];
+ c2x[i] = xp[i];
+ c2y[i] = yp[i];
}
- pi.pain.lines(xp, yp, 3, ColorName());
+ int d = pi.ltr_pos ? yp[4] - yp[5] : yp[5] - yp[4];
+
+ c1x[2] = xp[2];
+ c2y[2] = int(y - 0.500 * asc * 0.5);
+ c1x[5] += d;
+ c2x[5] += d;
+
+ pi.pain.path(xp, yp, c1x, c1y, c2x, c2y, 7, ColorName());
}
}