]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiViewSource.h
1f3e56e76973f22bddd73dba9d8e231dd2618944
[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 "ControlViewSource.h"
18 #include "Application.h"
19 #include "ui_ViewSourceUi.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 GuiViewSource;
47
48 class GuiViewSourceDialog : public QWidget, public Ui::ViewSourceUi {
49         Q_OBJECT
50 public:
51         GuiViewSourceDialog(GuiViewSource * form);
52
53 public Q_SLOTS:
54         // update content
55         void update();
56
57 private:
58         GuiViewSource * form_;
59 };
60
61
62 ///
63 class GuiViewSource : public QObject, public ControlViewSource {
64 public:
65         ///
66         GuiViewSource(Dialog &);
67         ///
68         QTextDocument * document() { return document_; }
69         ///
70         void update(bool full_source);
71
72 private:
73         ///
74         QTextDocument * document_;
75         /// LaTeX syntax highlighter
76         LaTeXHighlighter * highlighter_;
77 };
78
79
80 } // namespace frontend
81 } // namespace lyx
82
83 #endif // GUIVIEWSOURCE_H