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();
68 void realUpdateView();
71 /// Get the source code of selected paragraphs, or the whole document.
72 /// If TexRow is unavailable for the format then t is null.
73 std::auto_ptr<TexRow> getContent(BufferView const * view,
74 Buffer::OutputWhat output, docstring & str,
75 std::string const & format, bool master);
77 BufferView const * bv_;
79 QTextDocument * document_;
80 /// LaTeX syntax highlighter
81 LaTeXHighlighter * highlighter_;
85 QTimer * update_timer_;
89 class GuiViewSource : public DockView
95 GuiView & parent, ///< the main window where to dock.
96 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
97 Qt::WindowFlags flags = 0);
101 /// Controller inherited method.
103 bool initialiseParams(std::string const & source);
104 void clearParams() {}
105 void dispatchParams() {}
106 bool isBufferDependent() const { return true; }
107 bool canApply() const { return true; }
108 bool canApplyToReadOnly() const { return true; }
110 void enableView(bool enable);
111 void saveSession() const;
112 void restoreSession();
113 bool wantInitialFocus() const { return false; }
116 /// The title displayed by the dialog reflects source type.
117 QString title() const;
120 /// The encapsulated widget.
121 ViewSourceWidget * widget_;
124 } // namespace frontend
127 #endif // GUIVIEWSOURCE_H