SpectraPac 2.0(r200)
Evaluates PAC Measurements
|
00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) Qxt Foundation. Some rights reserved. 00004 ** 00005 ** This file is part of the QxtGui module of the Qxt library. 00006 ** 00007 ** This library is free software; you can redistribute it and/or modify it 00008 ** under the terms of the Common Public License, version 1.0, as published 00009 ** by IBM, and/or under the terms of the GNU Lesser General Public License, 00010 ** version 2.1, as published by the Free Software Foundation. 00011 ** 00012 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 00013 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 00014 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 00015 ** FITNESS FOR A PARTICULAR PURPOSE. 00016 ** 00017 ** You should have received a copy of the CPL and the LGPL along with this 00018 ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 00019 ** included with the source distribution for more information. 00020 ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 00021 ** 00022 ** <http://libqxt.org> <foundation@libqxt.org> 00023 ** 00024 ****************************************************************************/ 00025 #ifndef QXTLABEL_H 00026 #define QXTLABEL_H 00027 00028 #include <QFrame> 00029 #include <QObject> 00030 00031 template <typename PUB> 00032 class QxtPrivate 00033 { 00034 public: 00035 virtual ~QxtPrivate() 00036 {} 00037 inline void QXT_setPublic(PUB* pub) 00038 { 00039 qxt_p_ptr = pub; 00040 } 00041 00042 protected: 00043 inline PUB& qxt_p() 00044 { 00045 return *qxt_p_ptr; 00046 } 00047 inline const PUB& qxt_p() const 00048 { 00049 return *qxt_p_ptr; 00050 } 00051 00052 private: 00053 PUB* qxt_p_ptr; 00054 }; 00055 00056 template <typename PUB, typename PVT> 00057 class QxtPrivateInterface 00058 { 00059 friend class QxtPrivate<PUB>; 00060 public: 00061 QxtPrivateInterface() 00062 { 00063 pvt = new PVT; 00064 } 00065 ~QxtPrivateInterface() 00066 { 00067 delete pvt; 00068 } 00069 00070 inline void setPublic(PUB* pub) 00071 { 00072 pvt->QXT_setPublic(pub); 00073 } 00074 inline PVT& operator()() 00075 { 00076 return *static_cast<PVT*>(pvt); 00077 } 00078 inline const PVT& operator()() const 00079 { 00080 return *static_cast<PVT*>(pvt); 00081 } 00082 private: 00083 QxtPrivateInterface(const QxtPrivateInterface&) { } 00084 QxtPrivateInterface& operator=(const QxtPrivateInterface&) { } 00085 QxtPrivate<PUB>* pvt; 00086 }; 00087 00088 class Qxt : public QObject 00089 { 00090 Q_OBJECT 00091 Q_ENUMS(Rotation) 00092 Q_ENUMS(DecorationStyle) 00093 Q_ENUMS(ErrorCode) 00094 00095 public: 00096 enum Rotation 00097 { 00098 NoRotation = 0, 00099 UpsideDown = 180, 00100 Clockwise = 90, 00101 CounterClockwise = 270 00102 }; 00103 }; 00104 00105 class QxtLabelPrivate; 00106 00107 class QxtLabel : public QFrame 00108 { 00109 Q_OBJECT 00110 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) 00111 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) 00112 Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode) 00113 Q_PROPERTY(Qxt::Rotation rotation READ rotation WRITE setRotation) 00114 00115 public: 00116 explicit QxtLabel(QWidget* parent = 0, Qt::WindowFlags flags = 0); 00117 explicit QxtLabel(const QString& text, QWidget* parent = 0, Qt::WindowFlags flags = 0); 00118 virtual ~QxtLabel(); 00119 00120 QString text() const; 00121 00122 Qt::Alignment alignment() const; 00123 void setAlignment(Qt::Alignment alignment); 00124 00125 Qt::TextElideMode elideMode() const; 00126 void setElideMode(Qt::TextElideMode mode); 00127 00128 Qxt::Rotation rotation() const; 00129 void setRotation(Qxt::Rotation rotation); 00130 00131 virtual QSize sizeHint() const; 00132 virtual QSize minimumSizeHint() const; 00133 00134 public slots: 00135 void setText(const QString& text); 00136 00137 signals: 00138 void clicked(); 00139 void textChanged(const QString& text); 00140 00141 protected: 00142 virtual void changeEvent(QEvent* event); 00143 virtual void mousePressEvent(QMouseEvent* event); 00144 virtual void mouseReleaseEvent(QMouseEvent* event); 00145 virtual void paintEvent(QPaintEvent* event); 00146 00147 private: 00148 friend class QxtLabelPrivate; 00149 QxtPrivateInterface<QxtLabel, QxtLabelPrivate> qxt_d; 00150 }; 00151 00152 #endif // QXTLABEL_H