]> git.lyx.org Git - features.git/commitdiff
painter: make it possible to draw lines with custom line thicknesses
authorUwe Stöhr <uwestoehr@web.de>
Sun, 5 Sep 2010 14:46:58 +0000 (14:46 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Sun, 5 Sep 2010 14:46:58 +0000 (14:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35283 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/Painter.h
src/frontends/qt4/GuiPainter.cpp
src/frontends/qt4/GuiPainter.h

index 2f2f5bf81197f56cdaf60285778be96ae655258c..31bb2405fd71ab28ffd79dcf334340b6bd1413e7 100644 (file)
@@ -55,12 +55,8 @@ namespace frontend {
 class Painter {
 public:
        Painter() : drawing_enabled_(true) {}
-       /// possible line widths
-       enum line_width {
-               line_thin, //< thin line
-               line_medium, //< medium line
-               line_thick //< thick line
-       };
+
+       float line_width;
 
        /// possible line styles
        enum line_style {
@@ -80,7 +76,7 @@ public:
 
        /// draw a line from point to point
        virtual void line(int x1, int y1, int x2, int y2, Color,
-               line_style = line_solid, line_width = line_thin) = 0;
+               line_style = line_solid, float line_width = 0.5) = 0;
 
        /**
         * lines -  draw a set of lines
@@ -89,11 +85,11 @@ public:
         * @param np size of the points array
         */
        virtual void lines(int const * xp, int const * yp, int np, Color,
-               line_style = line_solid, line_width = line_thin) = 0;
+               line_style = line_solid, float line_width = 0.5) = 0;
 
        /// draw a rectangle
        virtual void rectangle(int x, int y, int w, int h, Color,
-               line_style = line_solid, line_width = line_thin) = 0;
+               line_style = line_solid, float line_width = 0.5) = 0;
 
        /// draw a filled rectangle
        virtual void fillRectangle(int x, int y, int w, int h, Color) = 0;
index fefa7e3a75e63d6d99f66ad78d4b393750490746..fb3e5e9bf840104e72eaabb51aa96137ff741194 100644 (file)
@@ -52,7 +52,7 @@ GuiPainter::GuiPainter(QPaintDevice * device)
        // new QPainter has default QPen:
        current_color_ = guiApp->colorCache().get(Color_black);
        current_ls_ = line_solid;
-       current_lw_ = line_thin;
+       current_lw_ = 0.5;
 }
 
 
@@ -64,7 +64,7 @@ GuiPainter::~GuiPainter()
 
 
 void GuiPainter::setQPainterPen(QColor const & col,
-       Painter::line_style ls, Painter::line_width lw)
+       Painter::line_style ls, float lw)
 {
        if (col == current_color_ && ls == current_ls_ && lw == current_lw_)
                return;
@@ -81,11 +81,7 @@ void GuiPainter::setQPainterPen(QColor const & col,
                case line_onoffdash: pen.setStyle(Qt::DotLine); break;
        }
 
-       switch (lw) {
-               case line_thin: pen.setWidth(0); break;
-               case line_medium: pen.setWidth(1); break;
-               case line_thick: pen.setWidth(3); break;
-       }
+       pen.setWidth(lw);
 
        setPen(pen);
 }
@@ -175,7 +171,7 @@ void GuiPainter::point(int x, int y, Color col)
 void GuiPainter::line(int x1, int y1, int x2, int y2,
        Color col,
        line_style ls,
-       line_width lw)
+       float lw)
 {
        if (!isDrawingEnabled())
                return;
@@ -192,7 +188,7 @@ void GuiPainter::line(int x1, int y1, int x2, int y2,
 void GuiPainter::lines(int const * xp, int const * yp, int np,
        Color col,
        line_style ls,
-       line_width lw)
+       float lw)
 {
        if (!isDrawingEnabled())
                return;
@@ -220,7 +216,7 @@ void GuiPainter::lines(int const * xp, int const * yp, int np,
 void GuiPainter::rectangle(int x, int y, int w, int h,
        Color col,
        line_style ls,
-       line_width lw)
+       float lw)
 {
        if (!isDrawingEnabled())
                return;
index 263b3a851c44cae99c4522f835a3566cb31fa758..ffa95ccab0ab35bee36343d249d25bfc4e56b45d 100644 (file)
@@ -42,7 +42,7 @@ public:
                int x2, int y2,
                Color,
                line_style = line_solid,
-               line_width = line_thin);
+               float line_width = 0.5);
 
        /**
         * lines -  draw a set of lines
@@ -56,7 +56,7 @@ public:
                int np,
                Color,
                line_style = line_solid,
-               line_width = line_thin);
+               float line_width = 0.5);
 
        /// draw a rectangle
        virtual void rectangle(
@@ -64,7 +64,7 @@ public:
                int w, int h,
                Color,
                line_style = line_solid,
-               line_width = line_thin);
+               float line_width = 0.5);
 
        /// draw a filled rectangle
        virtual void fillRectangle(
@@ -150,11 +150,11 @@ private:
 
        /// set pen parameters
        void setQPainterPen(QColor const & col,
-               line_style ls = line_solid, line_width lw = line_thin);
+               line_style ls = line_solid, float lw = 0.5);
 
        QColor current_color_;
        Painter::line_style current_ls_;
-       Painter::line_width current_lw_;
+       float current_lw_;
        ///
        bool const use_pixmap_cache_;
        ///