Debian Codegraph @

src/baseview.h

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2010 by Andres Cabrera *
3 * [email protected] *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20
21 #ifndef BASEVIEW_H
22 #define BASEVIEW_H
23
24 #include <QtWidgets>
25
26 #include "highlighter.h"
27 #include "scoreeditor.h"
28 #include "filebeditor.h"
29
30 class TextEditor;
31 class OpEntryParser;
32
33 typedef enum {
34 EDIT_CSOUND_MODE = 0,
35 EDIT_PYTHON_MODE = 1,
36 EDIT_XML_MODE = 2,
37 EDIT_ORC_MODE = 3,
38 EDIT_SCO_MODE = 4,
39 EDIT_INC_MODE = 5,
40 EDIT_HTML_MODE = 6,
41 EDIT_GENERIC_MODE = -1
42 } editor_mode_t;
43
44 class AppProperties {
45 public:
46 bool used; // Flag to mark if properties are used
47 QString appName;
48 QString targetDir;
49 QString author;
50 QString version;
51 QString date;
52 QString email;
53 QString website;
54 QString instructions;
55
56 bool autorun;
57 bool showRun;
58 bool saveState;
59 int runMode;
60 bool newParser;
61
62 bool useSdk;
63
64 bool useCustomPaths;
65 QString libDir;
66 QString opcodeDir;
67 };
68
69 class BaseView : public QScrollArea
70 {
71 friend class CsoundQt; // FIXME now that it's a friend class some things can be simplified in the code
72 Q_OBJECT
73 public:
74 explicit BaseView(QWidget *parent, OpEntryParser *opcodeTree);
75 ~BaseView();
76
77 void setFullText(QString text, bool goToTop = false);
78 void setBasicText(QString text);
79 void setFileType(editor_mode_t mode); // For higlighting mode
80 void setFont(QFont font);
81 void setFontPointSize(float size);
82 void setTabStopWidth(int width);
83 void setTabIndents(bool indents);
84 void setLineWrapMode(QTextEdit::LineWrapMode mode);
85 void setAutoComplete(bool autoComplete);
86 void setColorVariables(bool color);
87 void setBackgroundColor(QColor color);
88 void setTextColor(QColor color);
89 void setColors(QColor text, QColor background);
90 // void setOpcodeNameList(QStringList list);
91 // void setOpcodeTree(OpEntryParser *opcodeTree);
92 void setOrc(QString text);
93 void setSco(QString text);
94 void clearFileBText();
95 void appendFileBText(QString text);
96 void setOptionsText(QString text);
97 void setLadspaText(QString text);
98 void setCabbageText(QString text);
99 QString getCabbageText();
100 void setOtherCsdText(QString text);
101 void setOtherText(QString text);
102 void setAppText(QString text);
103 void setAppProperties(AppProperties properties);
104 void showLineArea(bool visible);
105 void setTheme(const QString &theme) {
106 m_highlighter.setTheme(theme);
107 auto defaultFormat = m_highlighter.getFormat("default");
108 auto fg = defaultFormat.foreground().color();
109 auto bg = defaultFormat.background().color();
110 if(fg.lightness() < bg.lightness()) {
111 // light
112 m_mainEditor->setLineAreaColors(fg.lighter(140),
113 bg.darker(125));
114 // m_mainEditor->setLineAreaColors(QColor("#303030"), QColor("#C0C0C0"));
115 } else {
116 m_mainEditor->setLineAreaColors(fg.darker(140),
117 bg.lighter(125));
118 // m_mainEditor->setLineAreaColors(QColor("#C0C0C0"), QColor("#303030"));
119
120 }
121 }
122 void enableScoreSyntaxHighlighting(bool state) {
123 m_highlighter.enableScoreSyntaxHighlighting(state);
124 }
125
126 QTextCharFormat getDefaultFormat() {
127 return m_highlighter.getFormat("default");
128 }
129
130 QTextCharFormat getHighlighterFormat(QString format) {
131 return m_highlighter.getFormat(format);
132 }
133
134 QString getFullText();
135 QString getOrc(); // Without tags
136 QString getSco(); // Without tags
137 QString getOptionsText(); // Without tags
138 QString getFileB(); // Embedded files. With tags (for filenames)
139 QString getExtraCsdText(); // All other tags like version and licence with tags
140 QString getExtraText(); // Text outside any known tags
141 QString getAppText();
142 AppProperties getAppProperties();
143
144 void clearUndoRedoStack();
145
146 QString getBasicText(); // What Csound needs (no widgets, misc text, etc.)
147
148 signals:
149
150 public slots:
151 void toggleLineArea();
152 void toggleParameterMode();
153
154 protected:
155 void hideAllEditors();
156
157 editor_mode_t m_mode; //type of text 0=csound 1=python 2=xml 3=orc 4=sco -1=anything else
158 int m_viewMode; // 0 = csd without widget + preset section
159 // 1 = full plain text
160 // From here on, you can have an or'd combination
161 // 2 = show CsInstruments Section
162 // 4 = show CsScore Section
163 // 8 = show CsOptions Section
164 // 16 = show <CsFileB> Section(s)
165 // 32 = show remaining Text outside CsoundSynthesizer tag
166 // 64 = show remaining text inside CsoundSynthesizer tag
167 // 128 = show Widget, Preset and Extra Options sections
168 // 256 = show CsApp section
169 Highlighter m_highlighter;
170 OpEntryParser *m_opcodeTree;
171 QSplitter *splitter;
172 TextEditLineNumbers *m_mainEditor;
173 TextEditor *m_orcEditor;
174 ScoreEditor *m_scoreEditor;
175 TextEditor *m_optionsEditor;
176 FileBEditor *m_filebEditor;
177 TextEditor *m_otherEditor; // Extra text after removing all sections. All this text is to be presented at the start of the csd. Also called information text elsewhere
178 TextEditor *m_otherCsdEditor; // Extra text and tags inside CsoundSynthesizer tags
179 TextEditor *m_widgetEditor;
180 TextEditor *m_appEditor;
181 AppProperties m_appProperties;
182
183 int m_orcStartLine;
184 int m_scoStartLine;
185
186 QVector<QWidget *> editors; // A vector to hold pointers for the above for easy processing
187 };
188
189 #endif // BASEVIEW_H
190