[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
src/klftools/klfdisplaylabel.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  *   file klfdisplaylabel.h
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2011 by Philippe Faist
00005  *   philippe.faist at bluewin.ch
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 /* $Id$ */
00023 
00024 #ifndef KLFDISPLAYLABEL_H
00025 #define KLFDISPLAYLABEL_H
00026 
00027 #include <QLabel>
00028 #include <QPicture>
00029 #include <QTemporaryFile>
00030 
00031 #include <klfdefs.h>
00032 
00046 class KLF_EXPORT KLFDisplayLabel : public QLabel
00047 {
00048   Q_OBJECT
00049 
00050   Q_PROPERTY(bool enableToolTipPreview READ enableToolTipPreview WRITE setEnableToolTipPreview) ;
00051 
00052   Q_PROPERTY(QString bigPreviewText READ bigPreviewText) ;
00053   Q_PROPERTY(bool glowEffect READ glowEffect WRITE setGlowEffect) ;
00054   Q_PROPERTY(QColor glowEffectColor READ glowEffectColor WRITE setGlowEffectColor) ;
00055   Q_PROPERTY(int glowEffectRadius READ glowEffectRadius WRITE setGlowEffectRadius) ;
00056   Q_PROPERTY(bool labelEnabled READ labelEnabled WRITE setLabelEnabled) ;
00057 public:
00058   KLFDisplayLabel(QWidget *parent);
00059   virtual ~KLFDisplayLabel();
00060 
00061   enum DisplayState { Clear = 0, Ok, Error };
00062   virtual DisplayState currentDisplayState() const { return pDisplayState; }
00063 
00070   virtual QSize labelSize() const { return size(); }
00071 
00072   virtual bool enableToolTipPreview() const { return pEnableToolTipPreview; }
00073 
00074   virtual QString bigPreviewText() const { return _bigPreviewText; }
00075 
00076   inline bool glowEffect() const { return pGE; }
00077   inline QColor glowEffectColor() const { return pGEcolor; }
00078   inline int glowEffectRadius() const { return pGEradius; }
00079 
00080   inline bool labelEnabled() const { return pLabelEnabled; }
00081 
00082 signals:
00083   void labelDrag();
00084 
00085 public slots:
00086   virtual void setEnableToolTipPreview(bool enable) { pEnableToolTipPreview = enable; display_state(pDisplayState); }
00087 
00088   virtual void displayClear();
00089   virtual void display(QImage displayimg, QImage tooltipimage, bool labelenabled = true);
00090   virtual void displayError(bool labelenabled = false)
00091   { displayError(QString(), labelenabled); }
00092   virtual void displayError(const QString& errorMessage, bool labelenabled = false);
00093 
00094   void setGlowEffect(bool on) { pGE = on; display_state(pDisplayState); }
00095   void setGlowEffectColor(const QColor& color) { pGEcolor = color; display_state(pDisplayState); }
00096   void setGlowEffectRadius(int r) { pGEradius = r; display_state(pDisplayState); }
00097 
00098   void setLabelEnabled(bool enabled) { pLabelEnabled = enabled; display_state(pDisplayState); }
00099 
00100 protected:
00101   virtual void mouseMoveEvent(QMouseEvent *e);
00102 
00103 private:
00104 
00105   QPicture calc_display_picture();
00106   void display_state(DisplayState state);
00107 
00108   DisplayState pDisplayState;
00109   QString pDisplayError;
00110   QImage pDisplayImage;
00111   QImage pDisplayTooltip;
00112 
00113   QSize pLabelFixedSize;
00114   bool pEnableToolTipPreview;
00115   QTemporaryFile *mToolTipFile;
00116 
00117   QPalette pDefaultPalette;
00118   QPalette pErrorPalette;
00119 
00120   QString _bigPreviewText;
00121 
00122   bool pGE;
00123   QColor pGEcolor;
00124   int pGEradius;
00125 
00126   void set_error(bool error_on);
00127 
00128   bool pLabelEnabled;
00129 };
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 #endif

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net