You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
3.1 KiB
C++
136 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include <QIcon>
|
|
#include <QRectF>
|
|
#include <typeinfo>
|
|
|
|
#include "IxSerDes.h"
|
|
#include "ZxDynamic.h"
|
|
|
|
class QMenu;
|
|
class ZxTool;
|
|
class ZxPaintParam;
|
|
class ZxSceneItem;
|
|
|
|
// 2D图元
|
|
class IxRenderItem
|
|
: virtual public IxDynObj
|
|
, virtual public IxSerDes
|
|
{
|
|
public:
|
|
|
|
enum Flags
|
|
{
|
|
// 无标志
|
|
flagNone = 0,
|
|
|
|
// 允许选择
|
|
flagNoSelect = 0x00000001,
|
|
|
|
// 锁定位置
|
|
flagLockPos = 0x00000002,
|
|
|
|
// 锁定尺寸
|
|
flagLockSize = 0x00000004,
|
|
|
|
// 内容只读(不递归)
|
|
flagReadOnly = 0x00000008,
|
|
|
|
// 自动尺寸(Hint).
|
|
// 尺寸由子图元和内容决定, 在doLayout时自动改变.
|
|
flagAutoSize = 0x00000010,
|
|
|
|
// 紧缩(Hint).
|
|
// 图元趋向于占较小空间, 通常和flagAutoSize配合使用
|
|
flagShrink = 0x00000020,
|
|
|
|
// 不可见
|
|
flagHidden = 0x00000040,
|
|
|
|
// 已经选中
|
|
flagSelected = 0x00000080,
|
|
|
|
// 不剪裁
|
|
flagNoClip = 0x00000100,
|
|
|
|
// 坐标偏移(偏移只对子孙图元有作用)
|
|
flagLocalCoord = 0x00000200,
|
|
|
|
// 强制重新布局
|
|
flagForceLayout = 0x00000400,
|
|
|
|
// 可能需要重新布局(非强制)
|
|
flagNeedLayout = 0x00000800,
|
|
|
|
// 可手动删除
|
|
flagManualDelete = 0x00001000,
|
|
|
|
// 静态策略, 不随着选中状态改变 (已经废弃, 请不要再用)
|
|
flagStaticPolicy = 0x00002000,
|
|
|
|
// 平凡的策略, 不浮在最上层
|
|
flagOrdinaryPolicy = 0x00004000,
|
|
|
|
// (在添加到别的图元里时)不自动重新布局
|
|
flagNoAutoLayout = 0x00008000,
|
|
|
|
// 在绘图时不开启反走样
|
|
flagNoAntiAlias = 0x00010000
|
|
|
|
};
|
|
|
|
// 指定父节点, 并加自动入父节点的子图元列表中
|
|
virtual void setParent(IxRenderItem* pParent) = 0;
|
|
|
|
// 获取图元的显示名
|
|
virtual QString getTitle() const = 0;
|
|
|
|
// 获取图元的图标
|
|
virtual QIcon getIcon() const = 0;
|
|
|
|
// 递归绘图, 含自身和子图元
|
|
virtual void paint(QPainter* painter, const ZxPaintParam& param) = 0;
|
|
|
|
// 克隆图元
|
|
virtual IxRenderItem* clone() const = 0;
|
|
|
|
// 获取图元基础边框(位置)
|
|
virtual QRectF getBounds() const = 0;
|
|
|
|
// @endcode
|
|
virtual void setBounds(const QRectF& rect, bool bSendEvent = true) = 0;
|
|
|
|
// 设置图元边框
|
|
virtual void setBounds(float x, float y, float width, float height, bool bSendEvent = true) = 0;
|
|
|
|
// 判断图元是否完全相等
|
|
virtual bool isEqual(const IxRenderItem* pAnother) const = 0;
|
|
|
|
// 辅助函数, 用以简化isEqual的实现
|
|
template <typename T_item>
|
|
static inline bool isSameTypeAndSameParent(const T_item* _this, const IxRenderItem* _p)
|
|
{
|
|
const T_item* p = dynamic_cast<const T_item*>(_p);
|
|
|
|
if (p == 0
|
|
|| typeid(*p) != typeid(const T_item)
|
|
|| typeid(*_this) != typeid(const T_item) ) // 必须都是T_item类型, 派生类也不行
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (_this->getParent() != p->getParent()) // parent 不同不认为是同一个图元
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|