3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #include "qsetborder.h"
18 QSetBorder::QSetBorder(QWidget * parent, char const * name, WFlags fl)
19 : QWidget(parent, name, fl), buffer(75, 75)
21 /* length of corner line */
22 l = buffer.width() / 10;
24 m = buffer.height() / 10;
36 void QSetBorder::paintEvent(QPaintEvent * e)
38 QWidget::paintEvent(e);
39 bitBlt(this, 0, 0, &buffer, 0, 0, width(), height());
43 void QSetBorder::init()
48 paint.setPen(Qt::black);
50 // FIXME: wow, readable !! :)
52 paint.drawLine(m + l , m, m + l, m + l);
53 paint.drawLine(w - (m + l), m, w - (m + l), m + l);
55 paint.drawLine(m, m + l , m + l, m + l);
56 paint.drawLine(m, h - (m + l), m + l, h - (m + l));
58 paint.drawLine(m + l ,h - m, m + l ,h - (m + l));
59 paint.drawLine(w - (m + l), h - m, w - (m + l), h - (m + l));
61 paint.drawLine(h - m, m+l, h - (m + l), m + l);
62 paint.drawLine(h - m, h - (m + l), h - (m + l),h - (m + l));
68 void QSetBorder::mousePressEvent(QMouseEvent * e)
70 if (e->y() > e->x()) {
71 if (e->y() < height() - e->x()) {
78 if (bottom_.enabled) {
79 setBottom(!bottom_.set);
81 bottomSet(bottom_.set);
85 if (e->y() < height() - e->x()) {
93 setRight(!right_.set);
105 void QSetBorder::drawLine(QColor const & col, int x, int y, int x2, int y2)
108 paint.begin(&buffer);
109 QPen p = paint.pen();
113 paint.drawLine(x, y, x2, y2);
118 void QSetBorder::drawLeft(bool draw)
120 QColor col(draw ? Qt::black : Qt::white);
122 col = QColor("grey");
123 drawLine(col, m + l, m + l + 2, m + l, h - m - l - 1);
127 void QSetBorder::drawRight(bool draw)
129 QColor col(draw ? Qt::black : Qt::white);
131 col = QColor("grey");
132 drawLine(col, h - m - l + 1, m + l + 2, h - m - l + 1, h - m - l - 1);
136 void QSetBorder::drawTop(bool draw)
138 QColor col(draw ? Qt::black : Qt::white);
140 col = QColor("grey");
141 drawLine(col, m + l + 2, m + l, w - m - l - 1, m + l);
145 void QSetBorder::drawBottom(bool draw)
147 QColor col(draw ? Qt::black : Qt::white);
148 if (!bottom_.enabled)
149 col = QColor("grey");
150 drawLine(col, m + l + 2, w - m - l + 1, w - m - l - 1, w - m - l + 1);
154 void QSetBorder::setLeftEnabled(bool border)
156 left_.enabled = border;
161 void QSetBorder::setRightEnabled(bool border)
163 right_.enabled = border;
168 void QSetBorder::setTopEnabled(bool border)
170 top_.enabled = border;
175 void QSetBorder::setBottomEnabled(bool border)
177 bottom_.enabled = border;
182 void QSetBorder::setLeft(bool border)
189 void QSetBorder::setRight(bool border)
196 void QSetBorder::setTop(bool border)
203 void QSetBorder::setBottom(bool border)
205 bottom_.set = border;
210 void QSetBorder::setAll(bool border)
219 bool QSetBorder::getLeft()
225 bool QSetBorder::getRight()
231 bool QSetBorder::getTop()
237 bool QSetBorder::getBottom()