Debian Codegraph @

src/qutetext.h

raw symbols SCIP
1 /*
2 Copyright (C) 2008, 2009 Andres Cabrera
3 [email protected]
4
5 This file is part of CsoundQt.
6
7 CsoundQt is free software; you can redistribute it
8 and/or modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 CsoundQt 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 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with Csound; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA
21 */
22
23 #ifndef QUTETEXT_H
24 #define QUTETEXT_H
25
26 #include "qutewidget.h"
27 #include "selectcolorbutton.h"
28
29 class QuteText : public QuteWidget
30 {
31 Q_OBJECT
32 public:
33 QuteText(QWidget *parent);
34
35 ~QuteText();
36
37 virtual QString getWidgetLine();
38 virtual QString getWidgetXmlText();
39
40 virtual QString getWidgetType();
41 virtual void setValue(double value);
42 virtual void setValue(QString value);
43
44 void setType(QString type);
45 virtual void setAlignment(QString alignment);
46 void setFont(QString font);
47 void setFontSize(int fontSize);
48 void setTextColor(QColor textColor);
49 void setBgColor(QColor bgColor);
50 void setBg(bool bg);
51 void setBorder(bool border);
52 void setBorderColor(QColor color);
53 void setTransparentForMouse(bool status);
54 virtual void setText(QString text);
55 virtual void refreshWidget();
56 virtual void applyInternalProperties();
57 virtual QString getCabbageLine();
58 virtual QString getQml();
59
60 // Configuraion (Not saved)
61 void setFontScaling(double scaling);
62 void setFontOffset(double offset);
63
64 protected:
65 virtual void createPropertiesDialog();
66 virtual void applyProperties();
67
68 QString m_type; // can be "label", "display", "edit", "scroll". In old widget format can also be "display".
69 // TODO this shouldn't be used anymore with the new format, as the type is found by querying getWidgetType()
70
71 //Configuration options
72 double m_fontScaling, m_fontOffset;
73
74 QTextEdit *text;
75 // QPushButton *textColor;
76 SelectColorButton *textColor;
77 // QPushButton *bgColor;
78 SelectColorButton *bgColor;
79 QCheckBox *bg;
80 // QCheckBox *border;
81 QSpinBox *borderRadius;
82 QSpinBox *borderWidth;
83 QSpinBox *precisionSpinBox;
84 QFontComboBox *font;
85 QSpinBox * fontSize;
86 QComboBox * alignment;
87 QComboBox * vertAlignmentComboBox;
88 QHash<QString, QLabel *>labelPtrs;
89 int m_precision;
90
91 private slots:
92 // void selectTextColor();
93 // void selectBgColor();
94 };
95
96 class QuteLineEdit : public QuteText
97 {
98 Q_OBJECT
99 public:
100 QuteLineEdit(QWidget* parent);
101 ~QuteLineEdit();
102
103 virtual void setText(QString text);
104 virtual QString getWidgetLine();
105 virtual QString getWidgetXmlText();
106 virtual QString getStringValue();
107 virtual double getValue();
108 virtual QString getWidgetType();
109 virtual void dropEvent(QDropEvent *event);
110 virtual void applyInternalProperties();
111 virtual QString getCabbageLine();
112
113 protected:
114 virtual void createPropertiesDialog();
115 // virtual void applyProperties();
116
117 protected slots:
118 void textEdited(QString text);
119 };
120
121 class QuteScrollNumber : public QuteText
122 {
123 Q_OBJECT
124 public:
125 QuteScrollNumber(QWidget* parent);
126 ~QuteScrollNumber();
127
128 virtual void setTextAlignment(int alignment);
129 virtual QString getWidgetLine();
130 virtual QString getCsladspaLine();
131 virtual QString getWidgetXmlText();
132 virtual QString getWidgetType();
133 virtual void setValue(double value);
134 virtual void setMidiValue(int value);
135 virtual bool acceptsMidi() {return true;}
136
137 virtual void applyInternalProperties();
138 virtual QString getCabbageLine();
139
140 protected:
141 virtual void refreshWidget();
142 virtual void createPropertiesDialog();
143 virtual void applyProperties();
144
145 QDoubleSpinBox* resolutionSpinBox;
146 QDoubleSpinBox *minSpinBox;
147 QDoubleSpinBox *maxSpinBox;
148 int m_places;
149 double m_min, m_max;
150
151 public slots:
152 void setResolution(double resolution);
153 void addValue(double delta);
154 void setValueFromWidget(double value);
155 void setValueFromDialog();
156 };
157
158 class ScrollNumberWidget : public QLabel
159 {
160 Q_OBJECT
161 public:
162 ScrollNumberWidget(QWidget* parent) : QLabel(parent)
163 {
164 setContextMenuPolicy(Qt::NoContextMenu);
165 pressed = false;
166 }
167 ~ScrollNumberWidget() {}
168
169 void setResolution(double resolution)
170 {
171 m_resolution = resolution;
172 }
173
174 protected:
175 virtual void mouseMoveEvent(QMouseEvent * event)
176 {
177 if (pressed) {
178 double delta = (oldy - event->y()) * m_resolution;
179 emit addValue(delta);
180 oldy = event->y();
181 }
182 }
183 virtual void mousePressEvent(QMouseEvent * event)
184 {
185 if (event->button() & Qt::LeftButton) {
186 if (event->modifiers() & Qt::AltModifier) {
187 emit setValue(0);
188 }
189 oldy = event->y();
190 pressed = true;
191 }
192 }
193 virtual void mouseReleaseEvent (QMouseEvent * event)
194 {
195 QLabel::mouseReleaseEvent(event);
196 pressed = false;
197 }
198
199 virtual void mouseDoubleClickEvent (QMouseEvent *event) {
200 if(!event->modifiers())
201 emit doubleClick();
202 else
203 QLabel::mouseDoubleClickEvent(event);
204 }
205
206 private:
207 double m_resolution;
208 // double m_min, m_max;
209 int oldy;
210 bool pressed;
211
212 signals:
213 void addValue(double delta);
214 void setValue(double value);
215 void doubleClick();
216 };
217
218 #endif