OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / glsleditor / glsleditor.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef GLSLEDITOR_H
35 #define GLSLEDITOR_H
36
37 #include "glsleditor_global.h"
38 #include "glsleditoreditable.h"
39
40 #include <glsl/glsl.h>
41
42 #include <texteditor/basetexteditor.h>
43 #include <texteditor/quickfix.h>
44
45 #include <QtCore/QSharedPointer>
46 #include <QtCore/QSet>
47
48 QT_BEGIN_NAMESPACE
49 class QComboBox;
50 class QTimer;
51 QT_END_NAMESPACE
52
53 namespace Core {
54 class ICore;
55 }
56
57 namespace GLSLEditor {
58 class GLSLTextEditor;
59
60 class GLSLEDITOR_EXPORT Document
61 {
62 public:
63     typedef QSharedPointer<Document> Ptr;
64
65     Document();
66     ~Document();
67
68     GLSL::Engine *engine() const { return _engine; }
69     GLSL::TranslationUnitAST *ast() const { return _ast; }
70     GLSL::Scope *globalScope() const { return _globalScope; }
71
72     GLSL::Scope *scopeAt(int position) const;
73     void addRange(const QTextCursor &cursor, GLSL::Scope *scope);
74
75 private:
76     struct Range {
77         QTextCursor cursor;
78         GLSL::Scope *scope;
79     };
80
81     GLSL::Engine *_engine;
82     GLSL::TranslationUnitAST *_ast;
83     GLSL::Scope *_globalScope;
84     QList<Range> _cursors;
85
86     friend class GLSLTextEditor;
87 };
88
89 class GLSLEDITOR_EXPORT GLSLTextEditor : public TextEditor::BaseTextEditor
90 {
91     Q_OBJECT
92
93 public:
94     GLSLTextEditor(QWidget *parent = 0);
95     ~GLSLTextEditor();
96
97     virtual void unCommentSelection();
98
99     int editorRevision() const;
100     bool isOutdated() const;
101
102     QSet<QString> identifiers() const;
103
104     int languageVariant() const;
105
106     Document::Ptr glslDocument() const;
107
108 public slots:
109     virtual void setFontSettings(const TextEditor::FontSettings &);
110
111 private slots:
112     void updateDocument();
113     void updateDocumentNow();
114
115 protected:
116     bool event(QEvent *e);
117     TextEditor::BaseTextEditorEditable *createEditableInterface();
118     void createToolBar(Internal::GLSLEditorEditable *editable);
119
120 private:
121     void setSelectedElements();
122     QString wordUnderCursor() const;
123
124     const Core::Context m_context;
125
126     QTimer *m_updateDocumentTimer;
127     QComboBox *m_outlineCombo;
128     Document::Ptr m_glslDocument;
129 };
130
131 } // namespace GLSLEditor
132
133 #endif // GLSLEDITOR_H