-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidgetselection.h
125 lines (100 loc) · 2.76 KB
/
widgetselection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef QSELECTWIDGET_H
#define QSELECTWIDGET_H
#include <QWidget>
#include <QHash>
class WidgetHandle: public QWidget
{
Q_OBJECT
public:
enum Type
{
LeftTop,
Top,
RightTop,
Right,
RightBottom,
Bottom,
LeftBottom,
Left,
TypeCount
};
WidgetHandle(QWidget* parent,Type t);
void setWidget(QWidget *w);
void setCurrent(bool b);
protected:
protected:
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
protected:
void updateCursor();
void trySetGeometry(QWidget *w, int x, int y, int width, int height);
void tryResize(QWidget *w, int width, int height);
signals:
void sizeChanged(int x,int y,int width,int height);
void mouse_button_release(const QRect& old,const QRect & now);
protected:
Type m_type;
QWidget * m_widget;
bool m_current;
QPoint m_origPressPos;
QRect m_geom, m_origGeom;
};
class WidgetSelection: public QObject
{
Q_OBJECT
public:
WidgetSelection(QWidget *parent);
void setWidget(QWidget *w);
QWidget *widget();
bool isUsed() const;
void hide();
void show();
void update();
void updateGeometry();
void setCurrent(bool b);
protected:
bool eventFilter(QObject *object, QEvent *event);
protected slots:
void changedsize(int x,int y,int width,int height);
void mouse_button_release(const QRect& old,const QRect & now);
signals:
void sizeChanged(QWidget* wid,const QRect& old,const QRect & now);
protected:
WidgetHandle *m_handles[WidgetHandle::TypeCount];
QWidget *m_widget;
QWidget *m_formWindow;
};
class Selection : public QObject
{
Q_OBJECT
public:
Selection(QWidget *formwindow);
~Selection();
void clear();
void clearSelectionPool();
void repaintSelection(QWidget *w);
void repaintSelection();
bool isContainWidget(QWidget *w) const;
QWidgetList selectedWidgets() const;
WidgetSelection *addWidget(QWidget *w);
QWidget* removeWidget(QWidget *w);
QWidget* current();
void raiseList(const QWidgetList& l);
void raiseWidget(QWidget *w);
void updateGeometry(QWidget *w);
void hide(QWidget *w);
void show(QWidget *w);
void setCurrent(QWidget *w);
signals:
void sizeChanged(QWidget* wid,const QRect& old,const QRect & now);
private:
typedef QList<WidgetSelection *> SelectionPool;
SelectionPool m_selectionPool;
typedef QHash<QWidget *, WidgetSelection *> SelectionHash;
SelectionHash m_usedSelections;
WidgetSelection * m_current;
QWidget* m_formwindow;
};
#endif // QSELECTWIDGET_H