Debian Codegraph @

src/documentpage.h

raw symbols SCIP
1 /*
2 Copyright (C) 2008-2010 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 DOCUMENTPAGE_H
24 #define DOCUMENTPAGE_H
25
26 #include <QtPrintSupport/QPrinter>
27 #include <QtPrintSupport/QPrintDialog>
28 #include <QRegularExpression>
29 #include <QTextEdit>
30 #include <QDomElement>
31 #include <QStack>
32 #include <QDockWidget>
33 #include <vector>
34 #include "basedocument.h"
35
36 class OpEntryParser;
37 class DocumentView;
38 class LiveEventFrame;
39 class EventSheet;
40 class LiveEventControl;
41 class SndfileHandle;
42 class MidiLearnDialog;
43 class QuteWidget;
44
45 class DocumentPage : public BaseDocument
46 {
47 Q_OBJECT
48 public:
49 DocumentPage(QWidget *parent, OpEntryParser *opcodeTree, ConfigLists *configlists,
50 MidiLearnDialog *midiLearn);
51 ~DocumentPage();
52 void setCompanionFileName(QString name);
53 void setEditorFocus();
54 void showLineNumbers(bool show);
55 void insertText(QString text, int section = -1);
56 void setFullText(QString text);
57 void setBasicText(QString text);
58 void setOrc(QString text);
59 void setSco(QString text);
60 void setWidgetsText(QString text);
61 void setPresetsText(QString text);
62 void setOptionsText(QString text);
63 void loadTextString(QString &text); // sets the text string and resets the undo history
64 int setTextString(QString &text);
65 void toggleLineArea();
66 void toggleParameterMode();
67 void showParametersInEditor();
68 void setHighlightingTheme(QString theme);
69 void setParsedUDOs(QStringList udos);
70 void enableScoreSyntaxHighlighting(bool status);
71 virtual QString getFullText();
72 QString getDotText();
73 QString getMacWidgetsText();
74 QString getMacPresetsText();
75 QString getMacOptionsText();
76 QString getSelectedText(int section = -1);
77 QString getSelectedWidgetsText();
78 QString getMacOptions(QString option);
79 QString getHtmlText();
80 int getViewMode();
81 QString getLiveEventsText();
82 QString wordUnderCursor();
83 QString lineUnderCursor();
84 QRect getWidgetLayoutOuterGeometry();
85 void setWidgetLayoutOuterGeometry(QRect r);
86 void setLineEnding(int lineEndingMode);
87 void setChannelValue(QString channel, double value);
88 double getChannelValue(QString channel);
89 void setChannelString(QString channel, QString value);
90 QString getChannelString(QString channel);
91 void setWidgetProperty(QString widgetid, QString property, QVariant value);
92 QVariant getWidgetProperty(QString widgetid, QString property);
93 QStringList getWidgetUuids();
94 QStringList listWidgetProperties(QString widgetid); // widgetid can be eihter uuid (prefered) or channel
95 bool destroyWidget(QString widgetid);
96 void loadPreset(int preSetIndex);
97 QString createNewLabel(int x = -1, int y = -1, QString channel = QString());
98 QString createNewDisplay(int x = -1, int y = -1, QString channel = QString());
99 QString createNewScrollNumber(int x = -1, int y = -1, QString channel = QString());
100 QString createNewLineEdit(int x = -1, int y = -1, QString channel = QString());
101 QString createNewSpinBox(int x = -1, int y = -1, QString channel = QString());
102 QString createNewSlider(int x = -1, int y = -1, QString channel = QString());
103 QString createNewButton(int x = -1, int y = -1, QString channel = QString());
104 QString createNewKnob(int x = -1, int y = -1, QString channel = QString());
105 QString createNewCheckBox(int x = -1, int y = -1, QString channel = QString());
106 QString createNewMenu(int x = -1, int y = -1, QString channel = QString());
107 QString createNewMeter(int x = -1, int y = -1, QString channel = QString());
108 QString createNewConsole(int x = -1, int y = -1, QString channel = QString());
109 QString createNewGraph(int x = -1, int y = -1, QString channel = QString());
110 QString createNewScope(int x = -1, int y = -1, QString channel = QString());
111 EventSheet* getSheet(int sheetIndex);
112 EventSheet* getSheet(QString sheetName);
113 int lineCount(bool countExtras = false);
114 int characterCount(bool countExtras = false);
115 int instrumentCount();
116 int udoCount();
117 int widgetCount();
118 QString embeddedFiles();
119 QString getFilePath();
120 QStringList getScheduledEvents(unsigned long ksmpscount);
121 bool isModified();
122 bool isRunning();
123 bool isRecording();
124 bool usesFltk();
125 void updateCsLadspaText();
126 void updateCabbageText();
127 void focusWidgets();
128 QString getFileName();
129 QString getCompanionFileName();
130 // Edition- are routed to section with focus
131 void copy();
132 void cut();
133 void paste();
134 void undo();
135 void redo();
136 void gotoNextRow();
137 // Get internal components
138 DocumentView *getView(); // Needed to pass view for placing it as tab widget in main application
139 // void *getCsound();
140 // Document view properties and actions
141 void setTextFont(QFont font);
142 void setTabStopWidth(int tabWidth);
143 void setTabIndents(bool indents);
144 void setLineWrapMode(QTextEdit::LineWrapMode wrapLines);
145 void setColorVariables(bool colorVariables);
146 // void setOpcodeNameList(QStringList opcodeNameList);
147 void setAutoComplete(bool autoComplete, int delay = 0);
148 void setAutoParameterMode(bool autoParameterMode);
149 QString getActiveSection();
150 QString getActiveText();
151 void print(QPrinter *printer);
152 void findReplace();
153 void findString(); // For find again
154 void getToIn();
155 void inToGet();
156 // Widget Layout properties
157 void showWidgetTooltips(bool visible);
158 void setKeyRepeatMode(bool keyRepeat); // Also for console widget
159 void setOpenProperties(bool open);
160 void setFontOffset(double offset);
161 void setFontScaling(double offset);
162 void setGraphUpdateRate(int rate);
163 // void passWidgetClipboard(QString text);
164 // Console properties
165 void setConsoleFont(QFont font);
166 void setConsoleColors(QColor fontColor, QColor bgColor);
167 void setEditorColors(QColor text, QColor background);
168
169 // Event Sheet Properties
170 void setScriptDirectory(QString dir);
171 void setDebugLiveEvents(bool debug);
172 // Internal Options setters
173 void setConsoleBufferSize(int size);
174 void setWidgetEnabled(bool enabled);
175 void useOldFormat(bool use);
176 void setPythonExecutable(QString pythonExec);
177 virtual void registerButton(QuteButton *button);
178 void queueMidiIn(std::vector<unsigned char> *message);
179 void queueVirtualMidiIn(std::vector<unsigned char> &message);
180 // Member public variables
181 bool askForFile;
182 bool readOnly; // Used for manual files and internal examples
183 QVector<QString> widgetHistory; // Undo/ Redo history
184 int widgetHistoryIndex; // Current point in history
185 QString getQml();
186 QString getMidiControllerInstrument();
187 void parseUdos(bool force=false);
188 void gotoLine(int line);
189 void gotoLineDialog();
190 void goBackToPreviousPosition();
191 void autocomplete();
192
193 public slots:
194 virtual int play(CsoundOptions *options);
195 void stop();
196 int record(int format);
197 void perfEnded();
198 void setHelp();
199 int runPython(); // Called when file is a python file
200 void closeExtraPanels();
201 void showWidgets(bool show = true);
202 void hideWidgets();
203 void passSelectedWidget(QuteWidget* widget);
204 void passUnselectedWidget(QuteWidget* widget);
205 void showMidiLearn(QuteWidget *widget);
206 void applyMacOptions(QStringList options);
207 void setMacOption(QString option, QString newValue);
208 void setModified(bool mod = true);
209 // For Csound Engine
210 void sendCodeToEngine(QString code);
211 //Passed directly to widget layout
212 void setWidgetEditMode(bool active);
213 void duplicateWidgets();
214 // Passed directly to document view
215 void jumpToLine(int line);
216 void comment();
217 void uncomment();
218 void indent();
219 void unindent();
220 void killLine();
221 void killToEnd();
222 void setViewMode(int mode);
223 void showOrc(bool);
224 void showScore(bool);
225 void showOptions(bool);
226 void showFileB(bool);
227 void showOther(bool);
228 void showOtherCsd(bool);
229 void showWidgetEdit(bool);
230 // Slots for live events
231 void newLiveEventPanel(QString text = QString());
232 LiveEventFrame * createLiveEventPanel(QString text = QString());
233 void deleteLiveEventPanel(LiveEventFrame *frame);
234 void showLiveEventControl(bool visible);
235 void showLiveEventPanels();
236 void hideLiveEventPanels();
237
238 void stopAllSlot();
239 void newPanelSlot();
240 void playPanelSlot(int index);
241 void loopPanelSlot(int index, bool loop);
242 void stopPanelSlot(int index);
243 void setPanelVisibleSlot(int index, bool visible);
244 void setPanelSyncSlot(int index, int mode);
245 void setPanelNameSlot(int index, QString name);
246 void setPanelTempoSlot(int index, double tempo);
247 void setPanelLoopLengthSlot(int index, double length);
248 void setPanelLoopRangeSlot(int index, double start, double end);
249
250
251 private:
252 virtual void init(QWidget *parent,OpEntryParser *opcodeTree);
253 CsoundOptions getParentOptions();
254 void deleteAllLiveEvents();
255 virtual WidgetLayout* newWidgetLayout();
256 QString companionFile;
257 QStringList m_macOptions;
258 QString m_macPresets;
259 QString m_macGUI;
260 bool m_pythonRunning;
261 QString m_pythonExecutable;
262 QList<LiveEventFrame *> m_liveFrames;
263 LiveEventControl *m_liveEventControl;
264 MidiLearnDialog *m_midiLearn;
265 // DocumentView *m_view;
266 // Options
267 bool saveLiveEvents;
268 bool saveOldFormat;
269 int m_lineEnding;
270 QString m_colorTheme;
271 QStringList m_parsedUdos;
272 bool m_parseUdosNeeded;
273 QRegularExpression regexUdo;
274
275 private slots:
276 void textChanged();
277 void liveEventControlClosed();
278 void renamePanel(LiveEventFrame *panel,QString newName);
279 void setPanelLoopRange(LiveEventFrame *panel, double start, double end);
280 void setPanelLoopLength(LiveEventFrame *panel, double length);
281 void setPanelTempo(LiveEventFrame *panel, double tempo);
282 void setPanelLoopEnabled(LiveEventFrame *panel, bool enabled);
283 void evaluatePython(QString code);
284
285 signals:
286 void currentTextUpdated(); // To let inspector know it must update
287 void setCurrentAudioFile(QString name);
288 void liveEventsVisible(bool); // To change the action in the main window
289 void modified(); // Triggered whenever the children change
290 void unmodified();
291 void stopSignal(); // To tell main application that running has stopped
292 void setHelpSignal(); // Propagated from view
293 void setWidgetClipboardSignal(QString text);
294 void evaluatePythonSignal(QString code);
295 void closeExtraPanelsSignal();
296 };
297
298 #endif