[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfdisplaylabel.h
Go to the documentation of this file.
1/***************************************************************************
2 * file klfdisplaylabel.h
3 * This file is part of the KLatexFormula Project.
4 * Copyright (C) 2011 by Philippe Faist
5 * philippe.faist at bluewin.ch
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22/* $Id$ */
23
24#ifndef KLFDISPLAYLABEL_H
25#define KLFDISPLAYLABEL_H
26
27#include <QLabel>
28#include <QPicture>
29#include <QTemporaryFile>
30
31#include <klfdefs.h>
32
46class KLF_EXPORT KLFDisplayLabel : public QLabel
47{
48 Q_OBJECT
49
50 Q_PROPERTY(bool enableToolTipPreview READ enableToolTipPreview WRITE setEnableToolTipPreview) ;
51
52 Q_PROPERTY(QString bigPreviewText READ bigPreviewText) ;
53 Q_PROPERTY(bool glowEffect READ glowEffect WRITE setGlowEffect) ;
54 Q_PROPERTY(QColor glowEffectColor READ glowEffectColor WRITE setGlowEffectColor) ;
55 Q_PROPERTY(int glowEffectRadius READ glowEffectRadius WRITE setGlowEffectRadius) ;
56 Q_PROPERTY(bool labelEnabled READ labelEnabled WRITE setLabelEnabled) ;
57public:
58 KLFDisplayLabel(QWidget *parent);
59 virtual ~KLFDisplayLabel();
60
61 enum DisplayState { Clear = 0, Ok, Error };
62 virtual DisplayState currentDisplayState() const { return pDisplayState; }
63
70 virtual QSize labelSize() const { return size(); }
71
72 virtual bool enableToolTipPreview() const { return pEnableToolTipPreview; }
73
74 virtual QString bigPreviewText() const { return _bigPreviewText; }
75
76 inline bool glowEffect() const { return pGE; }
77 inline QColor glowEffectColor() const { return pGEcolor; }
78 inline int glowEffectRadius() const { return pGEradius; }
79
80 inline bool labelEnabled() const { return pLabelEnabled; }
81
82signals:
83 void labelDrag();
84
85public slots:
86 virtual void setEnableToolTipPreview(bool enable) { pEnableToolTipPreview = enable; display_state(pDisplayState); }
87
88 virtual void displayClear();
89 virtual void display(QImage displayimg, QImage tooltipimage, bool labelenabled = true);
90 virtual void displayError(bool labelenabled = false)
91 { displayError(QString(), labelenabled); }
92 virtual void displayError(const QString& errorMessage, bool labelenabled = false);
93
94 void setGlowEffect(bool on) { pGE = on; display_state(pDisplayState); }
95 void setGlowEffectColor(const QColor& color) { pGEcolor = color; display_state(pDisplayState); }
96 void setGlowEffectRadius(int r) { pGEradius = r; display_state(pDisplayState); }
97
98 void setLabelEnabled(bool enabled) { pLabelEnabled = enabled; display_state(pDisplayState); }
99
100protected:
101 virtual void mouseMoveEvent(QMouseEvent *e);
102
103private:
104
105 QPicture calc_display_picture();
106 void display_state(DisplayState state);
107
108 DisplayState pDisplayState;
109 QString pDisplayError;
110 QImage pDisplayImage;
111 QImage pDisplayTooltip;
112
113 QSize pLabelFixedSize;
114 bool pEnableToolTipPreview;
115 QTemporaryFile *mToolTipFile;
116
117 QPalette pDefaultPalette;
118 QPalette pErrorPalette;
119
120 QString _bigPreviewText;
121
122 bool pGE;
123 QColor pGEcolor;
124 int pGEradius;
125
126 void set_error(bool error_on);
127
128 bool pLabelEnabled;
129};
130
131
132
133
134
135
136
137#endif
A label to display a LaTeX-formula-output-like image.
int glowEffectRadius() const
virtual void setEnableToolTipPreview(bool enable)
void setGlowEffectColor(const QColor &color)
bool labelEnabled() const
bool glowEffect() const
virtual void displayError(bool labelenabled=false)
void setGlowEffect(bool on)
QColor glowEffectColor() const
virtual QSize labelSize() const
maximum pixmap size we can display
virtual DisplayState currentDisplayState() const
void setLabelEnabled(bool enabled)
virtual bool enableToolTipPreview() const
void setGlowEffectRadius(int r)
virtual QString bigPreviewText() const
Base declarations for klatexformula and some utilities.
#define KLF_EXPORT
Definition klfdefs.h:41

Generated by doxygen 1.10.0