|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QTextEdit>
|
|
|
|
|
#include "ZxObjRect.h"
|
|
|
|
|
|
|
|
|
|
class I_PLOTCURVE_T_EXPORT ZxObjText
|
|
|
|
|
: public ZxObjRect
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
ZX_DECLARE_DYNAMIC
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
ZxObjText();
|
|
|
|
|
ZxObjText(const QString& sName,
|
|
|
|
|
ZxSubAxisX* pAxisX,
|
|
|
|
|
ZxSubAxisY* pAxisY);
|
|
|
|
|
~ZxObjText();
|
|
|
|
|
|
|
|
|
|
virtual void init(const QString& sName,
|
|
|
|
|
ZxSubAxisX* pAxisX,
|
|
|
|
|
ZxSubAxisY* pAxisY);
|
|
|
|
|
|
|
|
|
|
// 击中
|
|
|
|
|
virtual bool hitTest(const QPointF& pt);
|
|
|
|
|
|
|
|
|
|
// 击中后,ButtonUp后的处理
|
|
|
|
|
// pt1:鼠标Down点,pt2:鼠标Up点
|
|
|
|
|
virtual bool runMove(const QPointF& pt1, const QPointF& pt2);
|
|
|
|
|
|
|
|
|
|
// resetBounds内部调用
|
|
|
|
|
virtual void resetOthers();
|
|
|
|
|
void changeTextEditPos();
|
|
|
|
|
|
|
|
|
|
// 计算文本大小
|
|
|
|
|
QSizeF calTextSize(const QString& sText);
|
|
|
|
|
|
|
|
|
|
// 根据文本大小,自动调整,并且以某点为中心
|
|
|
|
|
void resetBoundsEx(const QString& sText,
|
|
|
|
|
const QPointF& ptCenter);
|
|
|
|
|
// 封装
|
|
|
|
|
virtual void initTools();
|
|
|
|
|
|
|
|
|
|
// 当该对象未选中,反选其它,如文本框
|
|
|
|
|
virtual void deselectOthers();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
// 设置图元对象的属性标志
|
|
|
|
|
virtual void initFlags();
|
|
|
|
|
|
|
|
|
|
// 初始化Text
|
|
|
|
|
virtual void initTextEdit();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual void paintBack(QPainter* painter, const ZxPaintParam& param);
|
|
|
|
|
virtual void onSerialize(ZxSerializer* ser);
|
|
|
|
|
virtual void onDeserialize(ZxSerializer* ser);
|
|
|
|
|
|
|
|
|
|
virtual void onLoadTempl(ZxSerializer* ser);
|
|
|
|
|
virtual void onSaveTempl(ZxSerializer* ser);
|
|
|
|
|
|
|
|
|
|
virtual void onDeserialized();
|
|
|
|
|
virtual void fillPtyPano(IxPtyPano* sheet);
|
|
|
|
|
|
|
|
|
|
virtual void onLeftDoubleClick(const QPointF& pt);
|
|
|
|
|
virtual void showEditWidget(bool bVisible);
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
|
|
void slotTextEditDestroy();
|
|
|
|
|
virtual void slotTextContentChanged();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// 文本
|
|
|
|
|
QString getText(void) const;
|
|
|
|
|
void setText(QString text);
|
|
|
|
|
|
|
|
|
|
// 文本颜色
|
|
|
|
|
QColor getTextColor(void) const;
|
|
|
|
|
void setTextColor(QColor color);
|
|
|
|
|
|
|
|
|
|
// 文本字体
|
|
|
|
|
QFont getFont(void) const;
|
|
|
|
|
void setFont(QFont font);
|
|
|
|
|
|
|
|
|
|
// 是否自适应宽度
|
|
|
|
|
bool isAutoAdjust() const;
|
|
|
|
|
void setAutoAdjust(bool bAutoAdjust);
|
|
|
|
|
|
|
|
|
|
// 是否双击手工编辑
|
|
|
|
|
bool isManulEdit() const;
|
|
|
|
|
void setManulEdit(bool bManulEdit);
|
|
|
|
|
|
|
|
|
|
// 对齐模式
|
|
|
|
|
int getAlignFlag() const;
|
|
|
|
|
void setAlignFlag(int nAlignFlag);
|
|
|
|
|
int getAlignHor() const;
|
|
|
|
|
void setAlignHor(int n);
|
|
|
|
|
int getAlignVert() const;
|
|
|
|
|
void setAlignVert(int n);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
QString m_sText; //文本
|
|
|
|
|
QColor m_oTextClr; //字体颜色
|
|
|
|
|
QFont m_oTextFont; //字体
|
|
|
|
|
bool m_bAutoAdjust; //是否自动调整边框(根据文本)
|
|
|
|
|
bool m_bManulEdit; //是否允许用户双击手工编辑
|
|
|
|
|
int m_nAlignFlag; //对齐模式
|
|
|
|
|
// int m_nAlignHor; //水平对齐模式,左中右 0 1 2
|
|
|
|
|
// int m_nAlignVert; //竖直对齐模式,上中下 0 1 2
|
|
|
|
|
|
|
|
|
|
// 临时变量
|
|
|
|
|
QTextEdit* m_pTempEdit;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|