]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiViewSource.h
404020b18376c1811024cea7ab357c21b3b3b014
[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 "GuiDialog.h"
18 #include "ControlViewSource.h"
19 #include "Application.h"
20 #include "ui_ViewSourceUi.h"
21
22 #include <QWidget>
23 #include <QSyntaxHighlighter>
24 #include <QTextCharFormat>
25
26 class QTextDocument;
27
28 namespace lyx {
29 namespace frontend {
30
31 // used already twice...
32 class LaTeXHighlighter : public QSyntaxHighlighter
33 {
34 public:
35         LaTeXHighlighter(QTextDocument * parent);
36
37 protected:
38         void highlightBlock(QString const & text);
39
40 private:
41         QTextCharFormat commentFormat;
42         QTextCharFormat keywordFormat;
43         QTextCharFormat mathFormat;
44 };
45
46
47 class GuiViewSourceDialog : public GuiDialog, public Ui::ViewSourceUi
48 {
49         Q_OBJECT
50
51 public:
52         GuiViewSourceDialog(LyXView & lv);
53
54 public Q_SLOTS:
55         // update content
56         void updateView();
57         ///
58         QTextDocument * document() { return document_; }
59         ///
60         void update(bool full_source);
61
62 private:
63         ///
64         ControlViewSource & controller() const; 
65         ///
66         QTextDocument * document_;
67         /// LaTeX syntax highlighter
68         LaTeXHighlighter * highlighter_;
69 };
70
71
72 } // namespace frontend
73 } // namespace lyx
74
75 #endif // GUIVIEWSOURCE_H