scide: DocManager - report warnings via the status bar
[supercollider.git] / editors / sc-ide / widgets / multi_editor.hpp
blobb559a0ffc4ac1af1a1334bd00482ad90f8acdcf8
1 /*
2 SuperCollider Qt IDE
3 Copyright (c) 2012 Jakob Leben & Tim Blechmann
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef SCIDE_WIDGETS_MULTI_EDITOR_HPP_INCLUDED
22 #define SCIDE_WIDGETS_MULTI_EDITOR_HPP_INCLUDED
24 #include <QWidget>
25 #include <QTabBar>
26 #include <QAction>
27 #include <QPushButton>
28 #include <QToolButton>
29 #include <QLineEdit>
30 #include <QCheckBox>
31 #include <QLabel>
32 #include <QGridLayout>
33 #include <QTextDocument>
34 #include <QSplitter>
36 namespace ScIDE {
38 class Main;
39 class Document;
40 class DocumentManager;
41 class CodeEditor;
42 class CodeEditorBox;
43 class MultiSplitter;
44 class SignalMultiplexer;
45 class Session;
46 namespace Settings { class Manager; }
48 class MultiEditor : public QWidget
50 Q_OBJECT
52 public:
54 enum ActionRole
56 // Edit
57 Undo,
58 Redo,
59 Cut,
60 Copy,
61 Paste,
62 IndentLineOrRegion,
63 TriggerAutoCompletion,
64 TriggerMethodCallAid,
65 ToggleComment,
66 ToggleOverwriteMode,
68 CopyLineUp,
69 CopyLineDown,
70 MoveLineUp,
71 MoveLineDown,
73 GotoPreviousBlock,
74 GotoNextBlock,
75 GotoPreviousRegion,
76 GotoNextRegion,
77 GotoPreviousEmptyLine,
78 GotoNextEmptyLine,
80 SelectRegion,
82 // View
83 EnlargeFont,
84 ShrinkFont,
85 ResetFontSize,
86 ShowWhitespace,
88 NextDocument,
89 PreviousDocument,
90 SwitchDocument,
92 SplitHorizontally,
93 SplitVertically,
94 RemoveCurrentSplit,
95 RemoveAllSplits,
97 // Language
98 EvaluateCurrentDocument,
99 EvaluateRegion,
100 EvaluateLine,
102 ActionRoleCount
105 MultiEditor( Main *, QWidget * parent = 0 );
107 int tabCount() { return mTabs->count(); }
108 Document * documentForTab( int index );
109 int tabForDocument( Document * doc );
111 CodeEditor *currentEditor();
112 CodeEditorBox *currentBox() { return mCurrentEditorBox; }
113 void split( Qt::Orientation direction );
115 QAction * action( ActionRole role )
116 { return mActions[role]; }
118 bool stepForwardEvaluation() { return mStepForwardEvaluation; }
120 void applySettings( Settings::Manager * );
122 void saveSession( Session * );
123 void switchSession( Session * );
125 signals:
126 void currentDocumentChanged( Document * );
128 public slots:
130 void setCurrent( Document * );
132 void showNextDocument();
133 void showPreviousDocument();
134 void switchDocument();
136 void splitHorizontally() { split(Qt::Horizontal); }
137 void splitVertically() { split(Qt::Vertical); }
138 void removeCurrentSplit();
139 void removeAllSplits();
141 private slots:
143 void onOpen( Document *, int initialCursorPosition, int selectionLength );
144 void onClose( Document * );
145 void show( Document *, int cursorPosition = -1 );
146 void update( Document * );
147 void onCloseRequest( int index );
148 void onCurrentTabChanged( int index );
149 void onCurrentEditorChanged( CodeEditor * );
150 void onBoxActivated( CodeEditorBox * );
151 void onModificationChanged( bool modified );
152 void evaluateRegion();
153 void evaluateLine();
154 void evaluateDocument();
156 private:
157 void makeSignalConnections();
158 void breakSignalConnections();
159 void createActions();
160 void updateActions();
161 CodeEditorBox *newBox();
162 void setCurrentBox( CodeEditorBox * );
163 void setCurrentEditor( CodeEditor * );
164 void loadBoxState( CodeEditorBox *box, const QVariantList & data, const QList<Document *> & documentList );
165 void loadSplitterState( QSplitter *, const QVariantMap & data, const QList<Document *> & documentList );
167 SignalMultiplexer * mSigMux;
168 SignalMultiplexer * mBoxSigMux;
169 QAction *mActions[ActionRoleCount];
171 // gui
172 QTabBar *mTabs;
173 CodeEditorBox *mCurrentEditorBox;
174 MultiSplitter *mSplitter;
175 QIcon mDocModifiedIcon;
177 // settings
178 bool mStepForwardEvaluation;
181 } // namespace ScIDE
183 #endif // SCIDE_WIDGETS_MULTI_EDITOR_HPP_INCLUDED