Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef LEGENDWIDGET_H
00029 #define LEGENDWIDGET_H
00030
00031 #include "GraphicObject.h"
00032 #include "Legend.h"
00033 #include "SciFigsDLLExport.h"
00034
00035 namespace SciFigs {
00036
00037 class LegendProperties;
00038 class LegendEditor;
00039
00040 class SCIFIGS_EXPORT LegendWidget : public GraphicObject
00041 {
00042 Q_OBJECT
00043
00044 Q_PROPERTY(double lineWidth READ dummyPropertyDouble WRITE setLineSize STORED false)
00045
00046 Q_PROPERTY(QString title READ title WRITE setTitle SCRIPTABLE true)
00047 Q_PROPERTY(double lineSize READ lineSize WRITE setLineSize SCRIPTABLE true)
00048 Q_PROPERTY(QString font READ fontString WRITE setFontString SCRIPTABLE true)
00049 Q_PROPERTY(bool adjustBox READ adjustBox WRITE setAdjustBox SCRIPTABLE true)
00050 public:
00051 LegendWidget(QWidget *parent=0, Qt::WFlags f=0);
00052 ~LegendWidget();
00053
00054 LegendWidget& operator=(const LegendWidget& o);
00055
00056 virtual const QString& xml_tagName() const {return xmlLegendWidgetTag;}
00057 static const QString xmlLegendWidgetTag;
00058
00059 void resize(int n) {_legend.resize(n);}
00060
00061 QString title() const {return _title;}
00062 void setTitle(QString t) {_title=t;}
00063
00064 QString fontString() const {return font().toString();}
00065 void setFontString(QString fs) {QFont f;f.fromString(fs);setFont(f);}
00066
00067 double lineSize() const {return _lineSize;}
00068 void setLineSize(double ls) {_lineSize=ls;}
00069
00070 bool adjustBox() const {return _adjustBox;}
00071 void setAdjustBox(bool t) {_adjustBox=t;}
00072
00073 const Legend& legend() const {return _legend;}
00074 Legend& legend() {return _legend;}
00075
00076 virtual void polish();
00077 virtual void update();
00078
00079 virtual void addProperties(PropertyProxy * pp);
00080 virtual void removeProperties(PropertyProxy * pp);
00081 virtual void properties(PropertyWidget * w) const;
00082 virtual void setProperty(uint wid, int pid, QVariant val);
00083 public slots:
00084 Q_SCRIPTABLE void load(QString fileName);
00085 Q_SCRIPTABLE void save(QString fileName);
00086 protected:
00087 virtual void paint(QPainter& p, double dotpercm,int w, int h, bool mask);
00088 virtual void setPrintSize(double dotpercm);
00089 private:
00090 void adjustSize();
00091 void adjustSize(double dotpercm, int& width, int& height);
00092
00093 Legend _legend;
00094 QString _title;
00095 double _lineSize;
00096 bool _adjustBox;
00097 static uint _category, _tabLegend, _tabFormat;
00098 signals:
00099 void changed(Legend leg);
00100 protected:
00101 XMLMember xml_member(XML_MEMBER_ARGS);
00102 void xml_writeChildren(XML_WRITECHILDREN_ARGS) const;
00103 };
00104
00105 }
00106
00107 #endif // LEGENDWIDGET_H