-
Notifications
You must be signed in to change notification settings - Fork 8
/
EEOFramelessWidget.h
64 lines (51 loc) · 1.62 KB
/
EEOFramelessWidget.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
#ifndef EEOFRAMELESSWIDGET_H
#define EEOFRAMELESSWIDGET_H
#include <QWidget>
#include <QMargins>
#include <QVBoxLayout>
#include <functional>
#include "eeowidgets_global.h"
class Movable;
class EEOWIDGETSSHARED_EXPORT EEOFramelessWidget : public QWidget
{
Q_OBJECT
public:
EEOFramelessWidget(QWidget* parent = nullptr);
~EEOFramelessWidget();
public:
void setResizeable(bool resizeable = true);
bool isResizeable(){ return m_bResizeable; }
void setContentsMargins(const QMargins &margins);
void setContentsMargins(int left, int top, int right, int bottom);
QMargins contentsMargins() const;
QRect contentsRect() const;
void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
void addDragWidget(QWidget* widget);
void addDragRect(QRect rect);
void addDragHeight(int height);
void setDragFunction(std::function<bool(int xpt, int yPt)> func);
#ifdef Q_OS_MAC
// show Minumuzed can used in MacOS, minimize window by oc code
void showCustomMinimized();
#endif
private:
QMargins m_margins;
QMargins m_frames;
bool m_bJustMaximized = false;
bool m_bResizeable = true;
QList<QWidget*> m_dragWidgets;
QList<QRect> m_dragRects;
QList<int> m_dragHeights;
std::function<bool(int xpt, int yPt)> m_canDragFunc;
protected:
static const int m_nBorderWidth;
QVBoxLayout* m_mainLayout = nullptr;
void paintEvent(QPaintEvent* event) final;
virtual bool isDragAtWidget(int xPt, int yPt);
#ifdef Q_OS_WIN
bool nativeEvent(const QByteArray & eventType, void * message, long * result) final;
#else
Movable* m_pMovable = nullptr;
#endif
};
#endif