3 * \file GuiViewSource.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * \author Abdelrazak Younes
11 * Full author contact details are available in file CREDITS.
14 #ifndef GUIVIEWSOURCE_H
15 #define GUIVIEWSOURCE_H
17 #include "ui_ViewSourceUi.h"
22 #include <QDockWidget>
38 class LaTeXHighlighter;
41 class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
48 void setBufferView(BufferView const * bv);
49 /// returns true if the string has changed
50 bool setText(QString const & qstr = QString());
52 void saveSession(QString const & session_key) const;
54 void restoreSession(QString const & session_key);
58 void resizeEvent (QResizeEvent * event);
61 /// schedule an update after delay
63 /// schedule an update now
66 void setViewFormat(int const index);
68 void updateDefaultFormat();
70 void contentsChanged();
76 void realUpdateView();
79 /// Get the source code of selected paragraphs, or the whole document.
80 void getContent(BufferView const * view, Buffer::OutputWhat output,
81 docstring & str, std::string const & format, bool master);
83 BufferView const * bv_;
85 QTextDocument * document_;
86 /// LaTeX syntax highlighter
87 LaTeXHighlighter * highlighter_;
91 QTimer * update_timer_;
92 /// TexRow information from the last source view. If TexRow is unavailable
93 /// for the last format then texrow_ is null.
94 unique_ptr<TexRow> texrow_;
98 class GuiViewSource : public DockView
104 GuiView & parent, ///< the main window where to dock.
105 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
106 Qt::WindowFlags flags = 0);
110 /// Controller inherited method.
112 bool initialiseParams(std::string const & source);
113 void clearParams() {}
114 void dispatchParams() {}
115 bool isBufferDependent() const { return true; }
116 bool canApply() const { return true; }
117 bool canApplyToReadOnly() const { return true; }
119 void enableView(bool enable);
120 void saveSession() const;
121 void restoreSession();
122 bool wantInitialFocus() const { return false; }
125 /// The title displayed by the dialog reflects source type.
126 QString title() const;
129 /// The encapsulated widget.
130 ViewSourceWidget * widget_;
133 } // namespace frontend
136 #endif // GUIVIEWSOURCE_H