]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiSetBorder.h
Proper logos with RTL
[lyx.git] / src / frontends / qt4 / 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  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef GUISETBORDER_H
14 #define GUISETBORDER_H
15
16 #include <QWidget>
17 #include <QPixmap>
18
19 class QColor;
20 class QMouseEvent;
21 class QPaintEvent;
22
23 //namespace lyx {
24
25 class GuiSetBorder : public QWidget
26 {
27         Q_OBJECT
28 public:
29         GuiSetBorder(QWidget * parent = 0, Qt::WindowFlags fl = 0);
30
31         // We need tristate for multi-cell selection
32         enum BorderState {
33                 LINE_UNSET,
34                 LINE_SET,
35                 LINE_UNDECIDED,
36                 LINE_UNDEF
37         };
38
39         BorderState getLeft();
40         BorderState getRight();
41         BorderState getTop();
42         BorderState getBottom();
43
44         bool leftLineSet() { return getLeft() ==  LINE_SET; }
45         bool rightLineSet() { return getRight() ==  LINE_SET; }
46         bool topLineSet() { return getTop() ==  LINE_SET; }
47         bool bottomLineSet() { return getBottom() ==  LINE_SET; }
48
49         bool leftLineUnset() { return getLeft() ==  LINE_UNSET; }
50         bool rightLineUnset() { return getRight() ==  LINE_UNSET; }
51         bool topLineUnset() { return getTop() ==  LINE_UNSET; }
52         bool bottomLineUnset() { return getBottom() ==  LINE_UNSET; }
53
54 Q_SIGNALS:
55         void rightSet();
56         void leftSet();
57         void topSet();
58         void bottomSet();
59         void clicked();
60
61 public Q_SLOTS:
62         void setLeftEnabled(bool);
63         void setRightEnabled(bool);
64         void setTopEnabled(bool);
65         void setBottomEnabled(bool);
66         void setLeft(BorderState);
67         void setRight(BorderState);
68         void setTop(BorderState);
69         void setBottom(BorderState);
70         void setAll(BorderState);
71
72 protected:
73         void mousePressEvent(QMouseEvent * e);
74         void paintEvent(QPaintEvent * e);
75
76 private:
77         void init();
78
79         void drawLine(QColor const & col, int x, int y, int x2, int y2);
80
81         void drawLeft(BorderState);
82         void drawRight(BorderState);
83         void drawTop(BorderState);
84         void drawBottom(BorderState);
85
86         class Border {
87         public:
88                 Border() : set(LINE_SET), enabled(true) {}
89                 BorderState set;
90                 bool enabled;
91         };
92
93         Border left_;
94         Border right_;
95         Border top_;
96         Border bottom_;
97
98         int m;
99         int l;
100         int w;
101         int h;
102
103         QPixmap buffer;
104 };
105
106
107 //} // namespace lyx
108
109 #endif // GUISETBORDER_H