qt/ledset/expertboxlayoutwin.h
2023-08-21 11:21:00 +08:00

71 lines
1.9 KiB
C++

#ifndef EXPERTBOXLAYOUTWIN_H
#define EXPERTBOXLAYOUTWIN_H
#include "basewin.h"
#include "gutil/qjson.h"
#include <QLabel>
#include <QButtonGroup>
#include <QCheckBox>
class ExpertWin;
class BoxPanel;
class ExpertBoxLayoutWin : public BaseWin {
Q_OBJECT
public:
explicit ExpertBoxLayoutWin(ExpertWin *parent = 0);
QCheckBox *fdHasPos, *fdHasSize, *fdHasConn, *fdHasName, *fdHasOutline;
QButtonGroup *grpGrp;
BoxPanel *box{0};
QLabel *fdModNum, *fdBoxSize;
};
class ModuleUnit;
class BoxPanel : public QWidget {
Q_OBJECT
public:
explicit BoxPanel(ExpertBoxLayoutWin *boxWin) : boxWin(boxWin) {}
void fitSize() {
boxRect = childrenRect();
auto www = qMax(1000, boxRect.x()+boxRect.width()+1);
auto hhh = qMax(1000, boxRect.y()+boxRect.height()+1);
if(www!=width() || hhh!=height()) resize(www, hhh);
else update();
boxWin->fdBoxSize->setText(QString("%1 x %2").arg(boxRect.width()).arg(boxRect.height()));
}
QRect boxRect, grpRect;
ExpertBoxLayoutWin *boxWin;
double rate{1};
QRectF rect;
bool isDrawing{false};
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
};
class ModuleUnit : public QWidget {
Q_OBJECT
public:
explicit ModuleUnit(int, int, int, int, const JObj &module, const QString &name, QWidget *parent = nullptr);
void drawed();
int mX, mY, mW, mH;
JObj mModule;
QString name;
BoxPanel *box;
QPoint mPressRel{INT_MIN, INT_MIN};
bool isSel{false};
protected:
void mousePressEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) override;
std::vector<ModuleUnit *> mOtherSels;
};
#endif // EXPERTBOXLAYOUTWIN_H