]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
small simplification
[lyx.git] / src / Buffer.cpp
index 67b9ab70730e4b5bec1d2e60a5d4802ad62cbbd1..26d171c6b88c81747468fb7386e10c180a340b99 100644 (file)
@@ -68,6 +68,8 @@
 #include "mathed/MathSupport.h"
 
 #include "frontends/alert.h"
+#include "frontends/Delegates.h"
+#include "frontends/WorkAreaManager.h"
 
 #include "graphics/Previews.h"
 
@@ -206,13 +208,17 @@ public:
        /// modified. (Used to properly enable 'File->Revert to saved', bug 4114).
        time_t timestamp_;
        unsigned long checksum_;
+
+       ///
+       frontend::WorkAreaManager * wa_;
 };
 
 
 Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_)
        : lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
          filename(file), file_fully_loaded(false), inset(params),
-         toc_backend(&parent), embedded_files(&parent), timestamp_(0), checksum_(0)
+         toc_backend(&parent), embedded_files(&parent), timestamp_(0),
+         checksum_(0), wa_(0)
 {
        inset.setAutoBreakRows(true);
        lyxvc.buffer(&parent);
@@ -221,11 +227,14 @@ Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_)
        // FIXME: And now do something if temppath == string(), because we
        // assume from now on that temppath points to a valid temp dir.
        // See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg67406.html
+
+       if (use_gui)
+               wa_ = new frontend::WorkAreaManager;
 }
 
 
 Buffer::Buffer(string const & file, bool readonly)
-       : pimpl_(new Impl(*this, FileName(file), readonly))
+       : pimpl_(new Impl(*this, FileName(file), readonly)), gui_(0)
 {
        LYXERR(Debug::INFO) << "Buffer::Buffer()" << endl;
 }
@@ -253,7 +262,25 @@ Buffer::~Buffer()
        // Remove any previewed LaTeX snippets associated with this buffer.
        graphics::Previews::get().removeLoader(*this);
 
-       closing(this);
+       if (pimpl_->wa_) {
+               pimpl_->wa_->closeAll();
+               delete pimpl_->wa_;
+       }
+       delete pimpl_;
+}
+
+
+void Buffer::changed() const
+{
+       if (pimpl_->wa_)
+               pimpl_->wa_->redrawAll();
+}
+
+
+frontend::WorkAreaManager & Buffer::workAreaManager() const
+{
+       BOOST_ASSERT(pimpl_->wa_);
+       return *pimpl_->wa_;
 }
 
 
@@ -1893,4 +1920,65 @@ ErrorList & Buffer::errorList(string const & type)
 }
 
 
+void Buffer::structureChanged() const
+{
+       if (gui_)
+               gui_->structureChanged();
+}
+
+
+void Buffer::embeddingChanged() const
+{
+       if (gui_)
+               gui_->embeddingChanged();
+}
+
+
+void Buffer::errors(std::string const & err) const
+{
+       if (gui_)
+               gui_->errors(err);
+}
+
+
+void Buffer::message(docstring const & msg) const
+{
+       if (gui_)
+               gui_->message(msg);
+}
+
+
+void Buffer::busy(bool on) const
+{
+       if (gui_)
+               gui_->busy(on);
+}
+
+
+void Buffer::readonly(bool on) const
+{
+       if (gui_)
+               gui_->readonly(on);
+}
+
+
+void Buffer::updateTitles() const
+{
+       if (gui_)
+               gui_->updateTitles();
+}
+
+
+void Buffer::resetAutosaveTimers() const
+{
+       if (gui_)
+               gui_->resetAutosaveTimers();
+}
+
+
+void Buffer::setGuiDelegate(frontend::GuiBufferDelegate * gui)
+{
+       gui_ = gui;
+}
+
 } // namespace lyx