]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/GuiSetBorder.h
Remove obsolete (and false) comment.
[lyx.git] / src / frontends / qt / GuiSetBorder.h
1 // -*- C++ -*-
2 /**
3  * \file GuiSetBorder.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  * \author John Levon
9  * \author Jürgen Spitzmüller
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUISETBORDER_H
15 #define GUISETBORDER_H
16
17 #include <QWidget>
18 #include <QPixmap>
19
20 class QColor;
21 class QMouseEvent;
22 class QPaintEvent;
23
24 //namespace lyx {
25
26 class GuiSetBorder : public QWidget
27 {
28         Q_OBJECT
29 public:
30         GuiSetBorder(QWidget * parent = nullptr, Qt::WindowFlags fl = nullptr);
31
32         // We need tristate for multi-cell selection
33         enum BorderState {
34                 LINE_UNSET,
35                 LINE_SET,
36                 LINE_UNDECIDED,
37                 LINE_UNDEF
38         };
39
40         BorderState getLeft();
41         BorderState getRight();
42         BorderState getTop();
43         BorderState getBottom();
44         BorderState getTopLeftTrim();
45         BorderState getTopRightTrim();
46         BorderState getBottomLeftTrim();
47         BorderState getBottomRightTrim();
48
49         bool leftLineSet() { return getLeft() ==  LINE_SET; }
50         bool rightLineSet() { return getRight() ==  LINE_SET; }
51         bool topLineSet() { return getTop() ==  LINE_SET; }
52         bool bottomLineSet() { return getBottom() ==  LINE_SET; }
53
54         bool leftLineUnset() { return getLeft() ==  LINE_UNSET; }
55         bool rightLineUnset() { return getRight() ==  LINE_UNSET; }
56         bool topLineUnset() { return getTop() ==  LINE_UNSET; }
57         bool bottomLineUnset() { return getBottom() ==  LINE_UNSET; }
58
59         bool topLineLTSet() { return getTopLeftTrim() ==  LINE_SET; }
60         bool bottomLineLTSet() { return getBottomLeftTrim() ==  LINE_SET; }
61         bool topLineRTSet() { return getTopRightTrim() ==  LINE_SET; }
62         bool bottomLineRTSet() { return getBottomRightTrim() ==  LINE_SET; }
63
64         bool topLineLTUnset() { return getTopLeftTrim() ==  LINE_UNSET; }
65         bool bottomLineLTUnset() { return getBottomLeftTrim() ==  LINE_UNSET; }
66         bool topLineRTUnset() { return getTopRightTrim() ==  LINE_UNSET; }
67         bool bottomLineRTUnset() { return getBottomRightTrim() ==  LINE_UNSET; }
68
69 Q_SIGNALS:
70         void rightSet();
71         void leftSet();
72         void topSet();
73         void bottomSet();
74         void topLTSet();
75         void bottomLTSet();
76         void topRTSet();
77         void bottomRTSet();
78         void clicked();
79
80 public Q_SLOTS:
81         void setLeftEnabled(bool);
82         void setRightEnabled(bool);
83         void setTopEnabled(bool);
84         void setBottomEnabled(bool);
85         void setTopLeftTrimEnabled(bool);
86         void setTopRightTrimEnabled(bool);
87         void setBottomLeftTrimEnabled(bool);
88         void setBottomRightTrimEnabled(bool);
89         void setLeft(BorderState);
90         void setRight(BorderState);
91         void setTop(BorderState);
92         void setBottom(BorderState);
93         void setTopLeftTrim(BorderState);
94         void setTopRightTrim(BorderState);
95         void setBottomLeftTrim(BorderState);
96         void setBottomRightTrim(BorderState);
97         void setAll(BorderState);
98
99 protected:
100         void mousePressEvent(QMouseEvent * e);
101         void paintEvent(QPaintEvent * e);
102
103 private:
104         void init();
105
106         void drawLine(QColor const & col, int x, int y, int x2, int y2);
107
108         void drawLeft(BorderState);
109         void drawRight(BorderState);
110         void drawTop(BorderState);
111         void undrawWideTopLine(bool const right = false);
112         void drawBottom(BorderState);
113         void undrawWideBottomLine(bool const right = false);
114         void drawTopLeftTrim(BorderState);
115         void drawTopRightTrim(BorderState);
116         void drawBottomLeftTrim(BorderState);
117         void drawBottomRightTrim(BorderState);
118
119         class Border {
120         public:
121                 Border() : set(LINE_SET), enabled(true) {}
122                 BorderState set;
123                 bool enabled;
124         };
125
126         Border left_;
127         Border right_;
128         Border top_;
129         Border bottom_;
130         /// trim areas
131         Border top_trim_left_;
132         Border top_trim_right_;
133         Border bottom_trim_left_;
134         Border bottom_trim_right_;
135
136         int margin;
137         int corner_length;
138         int bwidth;
139         int bheight;
140
141         QPixmap buffer;
142
143         bool bottom_drawn_wide_;
144         bool top_drawn_wide_;
145 };
146
147
148 //} // namespace lyx
149
150 #endif // GUISETBORDER_H