| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 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; |
| 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; |
| 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); |
| 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 |
|
| 91 |
|
| 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 |
|
| 112 |
m_mainEditor->setLineAreaColors(fg.lighter(140), |
| 113 |
bg.darker(125)); |
| 114 |
|
| 115 |
} else { |
| 116 |
m_mainEditor->setLineAreaColors(fg.darker(140), |
| 117 |
bg.lighter(125)); |
| 118 |
|
| 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(); |
| 136 |
QString getSco(); |
| 137 |
QString getOptionsText(); |
| 138 |
QString getFileB(); |
| 139 |
QString getExtraCsdText(); |
| 140 |
QString getExtraText(); |
| 141 |
QString getAppText(); |
| 142 |
AppProperties getAppProperties(); |
| 143 |
|
| 144 |
void clearUndoRedoStack(); |
| 145 |
|
| 146 |
QString getBasicText(); |
| 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; |
| 158 |
int m_viewMode; |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 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; |
| 178 |
TextEditor *m_otherCsdEditor; |
| 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; |
| 187 |
}; |
| 188 |
|
| 189 |
#endif |
| 190 |
|