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.
nmWATI/Include/iBase/iProperty/PtyItems/ZxFontEdit.h

83 lines
1.5 KiB
C

#pragma once
#include <QFont>
#include <QWidget>
#include "iProperty_global.h"
class QComboBox;
class QPaintEvent;
class QMouseEvent;
class QResizeEvent;
class QEvent;
// 字体编辑组件
class I_PROPERTY_EXPORT ZxFontEdit : public QWidget
{
Q_OBJECT
public:
// 枚举变量,标识字体各部分
enum FontSubPart
{
FSP_Family = 0,
FSP_Size,
FSP_Bold,
FSP_Italic,
FSP_Unknown
};
explicit ZxFontEdit(QWidget* parent = 0);
void setFont(const QFont& font);
QFont getFont();
signals:
void sigFontFamilyChanged(QString);
void sigFontSizeChanged(QString);
void sigFontBoldChanged(bool);
void sigFontItalicChanged(bool);
protected slots:
void onFamilyChanged(const QString& s);
void onSizeChanged(const QString& s);
protected:
virtual void paintEvent(QPaintEvent *);
virtual void mousePressEvent(QMouseEvent *);
virtual void mouseReleaseEvent(QMouseEvent *);
virtual void mouseMoveEvent(QMouseEvent *);
virtual void resizeEvent(QResizeEvent *);
virtual void leaveEvent(QEvent *);
protected:
void showFamilyWx();
void hideFamilyWx();
void showSizeWx();
void hideSizeWx();
QRect getSubBounds(FontSubPart part) const;
int getSubFSPIndex(const QPoint& pt);
protected:
QFont m_font;
// 各部分X起始位置以及宽度
int m_arrFspXs[FSP_Unknown];
int m_arrFspWidths[FSP_Unknown];
QComboBox* m_pCbxFontFamily;
QComboBox* m_pCbxFontSize;
FontSubPart m_oCurFsp;
};