]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiViewSource.h
c409f7cff84ed1b67529e100b9aa69c1606dc0fd
[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 "support/debug.h"
24
25 #include <QDockWidget>
26 #include <QString>
27 #include <QTextCharFormat>
28
29 class QTextDocument;
30
31 namespace lyx {
32 namespace frontend {
33
34 class GuiViewSource;
35 class LaTeXHighlighter;
36
37 class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
38 {
39         Q_OBJECT
40
41 public:
42         ViewSourceWidget(GuiViewSource &);
43
44 public Q_SLOTS:
45         // update content
46         void updateView();
47
48 private:
49         ///
50         GuiViewSource & controller_;    
51         ///
52         QTextDocument * document_;
53         /// LaTeX syntax highlighter
54         LaTeXHighlighter * highlighter_;
55 };
56
57
58 class GuiViewSource : public DockView
59 {
60         Q_OBJECT
61
62 public:
63         GuiViewSource(
64                 GuiView & parent, ///< the main window where to dock.
65                 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
66                 Qt::WindowFlags flags = 0);
67
68         ~GuiViewSource();
69
70         /// Controller inherited method.
71         ///@{
72         bool initialiseParams(std::string const & source);
73         void clearParams() {}
74         void dispatchParams() {}
75         bool isBufferDependent() const { return true; }
76         bool canApply() const { return true; }
77         bool canApplyToReadOnly() const { return true; }
78         void updateView();
79         void enableView(bool enable);
80         ///@}
81
82         /// The title displayed by the dialog reflects source type.
83         QString title() const;
84
85         /** get the source code of selected paragraphs, or the whole document
86                 \param fullSource get full source code
87          */
88         QString getContent(bool fullSource);
89         // cursor position in the source code
90         struct Row { int begin; int end; };
91         Row getRows() const;
92
93 private:
94         /// The encapsulated widget.
95         ViewSourceWidget * widget_;
96 };
97
98 } // namespace frontend
99 } // namespace lyx
100
101 #endif // GUIVIEWSOURCE_H