]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QViewSource.h
* src/frontends/qt4/ui/TextLayoutUi.ui:
[lyx.git] / src / frontends / qt4 / QViewSource.h
1 // -*- C++ -*-
2 /**
3  * \file QViewSource.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 QVIEWSOURCE_H
15 #define QVIEWSOURCE_H
16
17 #include "frontends/controllers/ControlViewSource.h"
18 #include "frontends/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
47 class QViewSource;
48
49 class QViewSourceDialog : public QWidget, public Ui::QViewSourceUi {
50         Q_OBJECT
51 public:
52         QViewSourceDialog(QViewSource * form);
53
54 public Q_SLOTS:
55         // update content
56         void update();
57
58 private:
59         QViewSource * form_;
60 };
61
62
63 ///
64 class QViewSource : public QObject, public ControlViewSource {
65 public:
66         ///
67         QViewSource(Dialog &);
68         ///
69         QTextDocument * document() { return document_; }
70         ///
71         void update(bool full_source);
72
73 private:
74         ///
75         QTextDocument * document_;
76         /// LaTeX syntax highlighter
77         LaTeXHighlighter * highlighter_;
78 };
79
80
81 } // namespace frontend
82 } // namespace lyx
83
84 #endif // QVIEWSOURCE_H