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