]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiViewSource.h
2704375a68b07cbf71606a145bd6fc21a89f13d2
[lyx.git] / src / frontends / qt4 / GuiViewSource.h
1 // -*- C++ -*-
2 /**
3  * \file GuiViewSource.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Bo Peng
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUIVIEWSOURCE_H
15 #define GUIVIEWSOURCE_H
16
17 #include "ui_ViewSourceUi.h"
18
19 #include "ControlViewSource.h"
20
21 #include <QWidget>
22 #include <QSyntaxHighlighter>
23 #include <QTextCharFormat>
24
25 class QTextDocument;
26
27 namespace lyx {
28 namespace frontend {
29
30 // used already twice...
31 class LaTeXHighlighter : public QSyntaxHighlighter
32 {
33 public:
34         LaTeXHighlighter(QTextDocument * parent);
35
36 protected:
37         void highlightBlock(QString const & text);
38
39 private:
40         QTextCharFormat commentFormat;
41         QTextCharFormat keywordFormat;
42         QTextCharFormat mathFormat;
43 };
44
45
46 class GuiViewSourceDialog : public QWidget, public Ui::ViewSourceUi
47 {
48         Q_OBJECT
49
50 public:
51         GuiViewSourceDialog(ControlViewSource &);
52
53 public Q_SLOTS:
54         // update content
55         void updateView();
56         ///
57         QTextDocument * document() { return document_; }
58         ///
59         void update(bool full_source);
60
61 private:
62         ///
63         ControlViewSource & controller_;        
64         ///
65         QTextDocument * document_;
66         /// LaTeX syntax highlighter
67         LaTeXHighlighter * highlighter_;
68 };
69
70
71 } // namespace frontend
72 } // namespace lyx
73
74 #endif // GUIVIEWSOURCE_H