1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QFRAME_H |
5 | #define QFRAME_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtWidgets/qwidget.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | |
13 | class QFramePrivate; |
14 | class QStyleOptionFrame; |
15 | |
16 | class Q_WIDGETS_EXPORT QFrame : public QWidget |
17 | { |
18 | Q_OBJECT |
19 | |
20 | Q_PROPERTY(Shape frameShape READ frameShape WRITE setFrameShape) |
21 | Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow) |
22 | Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth) |
23 | Q_PROPERTY(int midLineWidth READ midLineWidth WRITE setMidLineWidth) |
24 | Q_PROPERTY(int frameWidth READ frameWidth) |
25 | Q_PROPERTY(QRect frameRect READ frameRect WRITE setFrameRect DESIGNABLE false) |
26 | |
27 | public: |
28 | explicit QFrame(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); |
29 | ~QFrame(); |
30 | |
31 | int frameStyle() const; |
32 | void setFrameStyle(int); |
33 | |
34 | int frameWidth() const; |
35 | |
36 | QSize sizeHint() const override; |
37 | |
38 | enum Shape { |
39 | NoFrame = 0, // no frame |
40 | Box = 0x0001, // rectangular box |
41 | Panel = 0x0002, // rectangular panel |
42 | WinPanel = 0x0003, // rectangular panel (Windows) |
43 | HLine = 0x0004, // horizontal line |
44 | VLine = 0x0005, // vertical line |
45 | StyledPanel = 0x0006 // rectangular panel depending on the GUI style |
46 | }; |
47 | Q_ENUM(Shape) |
48 | enum Shadow { |
49 | Plain = 0x0010, // plain line |
50 | Raised = 0x0020, // raised shadow effect |
51 | Sunken = 0x0030 // sunken shadow effect |
52 | }; |
53 | Q_ENUM(Shadow) |
54 | |
55 | enum StyleMask { |
56 | Shadow_Mask = 0x00f0, // mask for the shadow |
57 | Shape_Mask = 0x000f // mask for the shape |
58 | }; |
59 | |
60 | Shape frameShape() const; |
61 | void setFrameShape(Shape); |
62 | Shadow frameShadow() const; |
63 | void setFrameShadow(Shadow); |
64 | |
65 | int lineWidth() const; |
66 | void setLineWidth(int); |
67 | |
68 | int midLineWidth() const; |
69 | void setMidLineWidth(int); |
70 | |
71 | QRect frameRect() const; |
72 | void setFrameRect(const QRect &); |
73 | |
74 | protected: |
75 | bool event(QEvent *e) override; |
76 | void paintEvent(QPaintEvent *) override; |
77 | void changeEvent(QEvent *) override; |
78 | void drawFrame(QPainter *); |
79 | |
80 | |
81 | protected: |
82 | QFrame(QFramePrivate &dd, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); |
83 | virtual void initStyleOption(QStyleOptionFrame *option) const; |
84 | |
85 | private: |
86 | Q_DISABLE_COPY(QFrame) |
87 | Q_DECLARE_PRIVATE(QFrame) |
88 | }; |
89 | |
90 | Q_DECLARE_MIXED_ENUM_OPERATORS_SYMMETRIC(int, QFrame::Shape, QFrame::Shadow) |
91 | |
92 | QT_END_NAMESPACE |
93 | |
94 | #endif // QFRAME_H |
95 | |