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"
23 #include <QDockWidget>
33 class LaTeXHighlighter;
35 class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
42 void setBufferView(BufferView const * bv);
43 /// returns true if the string has changed
44 bool setText(QString const & qstr = QString());
46 void saveSession(QString const & session_key) const;
48 void restoreSession(QString const & session_key);
52 void resizeEvent (QResizeEvent * event);
55 /// schedule an update after delay
57 /// schedule an update now
60 void setViewFormat(int const index);
62 void updateDefaultFormat();
64 void contentsChanged();
70 void realUpdateView();
73 /// Get the source code of selected paragraphs, or the whole document.
74 void getContent(BufferView const * view, Buffer::OutputWhat output,
75 docstring & str, std::string const & format, bool master);
77 BufferView const * bv_;
79 QTextDocument * document_;
80 /// LaTeX syntax highlighter
81 LaTeXHighlighter * highlighter_;
85 QTimer * update_timer_;
86 /// TexRow information from the last source view. If TexRow is unavailable
87 /// for the last format then texrow_ is null.
88 unique_ptr<TexRow> texrow_;
92 class GuiViewSource : public DockView
98 GuiView & parent, ///< the main window where to dock.
99 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
100 Qt::WindowFlags flags = 0);
104 /// Controller inherited method.
106 bool initialiseParams(std::string const & source);
107 void clearParams() {}
108 void dispatchParams() {}
109 bool isBufferDependent() const { return true; }
110 bool canApply() const { return true; }
111 bool canApplyToReadOnly() const { return true; }
113 void enableView(bool enable);
114 void saveSession() const;
115 void restoreSession();
116 bool wantInitialFocus() const { return false; }
119 /// The title displayed by the dialog reflects source type.
120 QString title() const;
123 /// The encapsulated widget.
124 ViewSourceWidget * widget_;
127 } // namespace frontend
130 #endif // GUIVIEWSOURCE_H