00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2005-2006 Trolltech ASA. All rights reserved. 00004 ** 00005 ** This file is part of the demonstration applications of the Qt Toolkit. 00006 ** 00007 ** This file may be used under the terms of the GNU General Public 00008 ** License version 2.0 as published by the Free Software Foundation 00009 ** and appearing in the file LICENSE.GPL included in the packaging of 00010 ** this file. Please review the following information to ensure GNU 00011 ** General Public Licensing requirements will be met: 00012 ** http://www.trolltech.com/products/qt/opensource.html 00013 ** 00014 ** If you are unsure which license is appropriate for your use, please 00015 ** review the following information: 00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the 00017 ** sales department at sales@trolltech.com. 00018 ** 00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00021 ** 00022 ****************************************************************************/ 00023 00024 #ifndef XFORM_H 00025 #define XFORM_H 00026 00027 #include "arthurwidgets.h" 00028 00029 #include <QBasicTimer> 00030 #include <QPolygonF> 00031 00032 class HoverPoints; 00033 class QLineEdit; 00034 00035 class XFormView : public ArthurFrame 00036 { 00037 Q_OBJECT 00038 00039 Q_PROPERTY(bool animation READ animation WRITE setAnimation) 00040 Q_PROPERTY(double shear READ shear WRITE setShear) 00041 Q_PROPERTY(double rotation READ rotation WRITE setRotation) 00042 Q_PROPERTY(double scale READ scale WRITE setScale) 00043 00044 public: 00045 XFormView(QWidget *parent); 00046 void paint(QPainter *); 00047 void drawVectorType(QPainter *painter); 00048 void drawPixmapType(QPainter *painter); 00049 void drawTextType(QPainter *painter); 00050 QSize sizeHint() const { return QSize(500, 500); } 00051 00052 void mousePressEvent(QMouseEvent *e); 00053 void resizeEvent(QResizeEvent *e); 00054 HoverPoints *hoverPoints() { return pts; } 00055 00056 QLineEdit *textEditor; 00057 00058 bool animation() const { return timer.isActive(); } 00059 double shear() const { return m_shear; } 00060 double scale() const { return m_scale; } 00061 double rotation() const { return m_rotation; } 00062 void setShear(double s); 00063 void setScale(double s); 00064 void setRotation(double r); 00065 00066 public slots: 00067 void setAnimation(bool animate); 00068 void updateCtrlPoints(const QPolygonF &); 00069 void changeRotation(int rotation); 00070 void changeScale(int scale); 00071 void changeShear(int shear); 00072 00073 void setVectorType(); 00074 void setPixmapType(); 00075 void setTextType(); 00076 void reset(); 00077 00078 signals: 00079 void rotationChanged(int rotation); 00080 void scaleChanged(int scale); 00081 void shearChanged(int shear); 00082 00083 protected: 00084 void timerEvent(QTimerEvent *e); 00085 void wheelEvent(QWheelEvent *); 00086 00087 private: 00088 enum XFormType { VectorType, PixmapType, TextType }; 00089 00090 QPolygonF ctrlPoints; 00091 HoverPoints *pts; 00092 double m_rotation; 00093 double m_scale; 00094 double m_shear; 00095 XFormType type; 00096 QPixmap pixmap; 00097 QBasicTimer timer; 00098 }; 00099 00100 class XFormWidget : public QWidget 00101 { 00102 Q_OBJECT 00103 public: 00104 XFormWidget(QWidget *parent); 00105 00106 private: 00107 XFormView *view; 00108 }; 00109 00110 #endif // XFORM_H
1.5.1