SciFigs/LegendWidget.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of SciFigs.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2007-04-27
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
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   // Compatibility
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 } // namespace SciFigs
00106 
00107 #endif // LEGENDWIDGET_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines