PowerDesigner/source/graphicsItem/itemControlHandle.cpp

66 lines
1.4 KiB
C++
Raw Normal View History

2024-08-16 11:39:30 +08:00
#include "graphicsItem/itemControlHandle.h"
#include <QPainter>
#define HNDLE_SIZE 8
2024-08-16 11:39:30 +08:00
ItemControlHandle::ItemControlHandle(QGraphicsItem *parent)
: QGraphicsRectItem(-HNDLE_SIZE / 2,
-HNDLE_SIZE / 2,
HNDLE_SIZE,
HNDLE_SIZE, parent)
{
m_type = T_resize;
m_tag = H_none;
}
ItemControlHandle::~ItemControlHandle()
{
}
void ItemControlHandle::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
painter->setPen(Qt::SolidLine);
painter->setRenderHint(QPainter::Antialiasing, true);
if(m_type==T_resize)
{
painter->setBrush(Qt::white);
painter->drawRect(rect());
}
else if(m_type==T_rotate)
{
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::NoBrush);
painter->drawRect(rect());
}
2024-08-16 11:39:30 +08:00
else if(m_type==T_editShape)
{
painter->setBrush(Qt::green);
painter->drawEllipse(rect().center(), HNDLE_SIZE / 2, HNDLE_SIZE / 2);
}
}
void ItemControlHandle::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
{
QGraphicsRectItem::hoverEnterEvent(event);
}
void ItemControlHandle::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
{
QGraphicsRectItem::hoverLeaveEvent(event);
}
int ItemControlHandle::getSize()
{
int nSize = HNDLE_SIZE;
return nSize;
}
2024-08-16 11:39:30 +08:00
void ItemControlHandle::move(double x, double y)
{
setPos(x, y);
}