#pragma once #include #include #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 Part { partFamily, partSize, partBoth, partItalic, _partMax }; explicit ZxFontEdit(QWidget *parent = 0); void setFont( const QFont& font ); QFont getFont(); signals: void signalFontFamilyChanged(QString); void signalFontSizeChanged(QString); void signalFontBoldChanged(bool); void signalFontItalicChanged(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: QRect getPartRect(Part part) const; int getPartIndex(const QPoint& pt); void showFamilyWidget(); void hideFamilyWidget(); void showSizeWidget(); void hideSizeWidget(); // void emitValueChanged(); protected: QFont m_font; int m_x[_partMax]; int m_w[_partMax]; QComboBox* m_comboFamily; QComboBox* m_comboSize; int m_hoverPart; };