]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiViewSource.h
HTML output for InsetMathCancel.
[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 "DockView.h"
20 #include "GuiView.h"
21 #include "qt_helpers.h"
22
23 #include <QDockWidget>
24 #include <QString>
25 #include <QTextCharFormat>
26
27 class QTextDocument;
28
29 namespace lyx {
30 namespace frontend {
31
32 class GuiViewSource;
33 class LaTeXHighlighter;
34
35 class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
36 {
37         Q_OBJECT
38
39 public:
40         ViewSourceWidget();
41         ///
42         void setBufferView(BufferView const * bv);
43
44 public Q_SLOTS:
45         /// update content
46         void updateView();
47         ///
48         void setViewFormat();
49         ///
50         void updateDefaultFormat();
51         ///
52         void contentsChanged();
53
54 private:
55         ///
56         BufferView const * bv_;
57         ///
58         QTextDocument * document_;
59         /// LaTeX syntax highlighter
60         LaTeXHighlighter * highlighter_;
61         ///
62         bool force_getcontent_;
63         ///
64         QString view_format_;
65 };
66
67
68 class GuiViewSource : public DockView
69 {
70         Q_OBJECT
71
72 public:
73         GuiViewSource(
74                 GuiView & parent, ///< the main window where to dock.
75                 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
76                 Qt::WindowFlags flags = 0);
77
78         ~GuiViewSource();
79
80         /// Controller inherited method.
81         ///@{
82         bool initialiseParams(std::string const & source);
83         void clearParams() {}
84         void dispatchParams() {}
85         bool isBufferDependent() const { return true; }
86         bool canApply() const { return true; }
87         bool canApplyToReadOnly() const { return true; }
88         void updateView();
89         void enableView(bool enable);
90         void saveSession() const;
91         void restoreSession();
92         bool wantInitialFocus() const { return false; }
93         ///@}
94
95         /// The title displayed by the dialog reflects source type.
96         QString title() const;
97
98 private:
99         /// The encapsulated widget.
100         ViewSourceWidget * widget_;
101 };
102
103 } // namespace frontend
104 } // namespace lyx
105
106 #endif // GUIVIEWSOURCE_H