]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/PreviewedInset.h
The std::string mammoth path.
[lyx.git] / src / graphics / PreviewedInset.h
index 4ab1ecda9a11d5723e2e3103057997dfd18ff994..991853b67fae9d8d09e8780b0ac3561f68a4c0d5 100644 (file)
@@ -1,31 +1,31 @@
 // -*- C++ -*-
 /**
- *  \file PreviewedInset.h
- *  Copyright 2002 the LyX Team
- *  Read the file COPYING
+ * \file PreviewedInset.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Angus Leeming <leeming@lyx.org>
+ * \author Angus Leeming
  *
- *  grfx::PreviewedInset is an abstract base class that can help insets to
- *  generate previews. The daughter class must instantiate three small
- *  methods. The Inset would own an instance of this daughter class.
+ * Full author contact details are available in file CREDITS.
+ *
+ * lyx::graphics::PreviewedInset is an abstract base class that can help
+ * insets to generate previews. The daughter class must instantiate two small
+ * methods. The Inset would own an instance of this daughter class.
  */
 
 #ifndef PREVIEWEDINSET_H
 #define PREVIEWEDINSET_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "LString.h"
 #include <boost/signals/trackable.hpp>
 #include <boost/signals/connection.hpp>
 
-class Inset;
+class Buffer;
 class BufferView;
+class InsetOld;
 
-namespace grfx {
+
+namespace lyx {
+namespace graphics {
 
 class PreviewImage;
 class PreviewLoader;
@@ -36,50 +36,72 @@ public:
        static bool activated();
 
        ///
-       PreviewedInset(Inset & inset) : inset_(inset), pimage_(0) {}
+       PreviewedInset(InsetOld & inset);
 
        /** Find the PreviewLoader, add a LaTeX snippet to it and
         *  start the loading process.
         */
-       void generatePreview() const;
+       void generatePreview(Buffer const &);
 
        /** Add a LaTeX snippet to the PreviewLoader but do not start the
         *  loading process.
         */
-       void addPreview(PreviewLoader & ploader) const;
+       void addPreview(PreviewLoader & ploader);
+
+       /** Remove a snippet from the cache of previews.
+        *  Useful if previewing the contents of a file that has changed.
+        */
+       void removePreview();
 
        /// The preview has been generated and is ready to use.
        bool previewReady() const;
 
        /// If !previewReady() returns 0.
-       PreviewImage const * pimage() const { return pimage_; }
+       PreviewImage const * pimage() const;
 
 protected:
+       ///
+       virtual ~PreviewedInset() {}
        /// Allow the daughter classes to cast up to the parent inset.
-       Inset * inset() const { return &inset_; }
+       InsetOld const & inset() const;
+       ///
+       BufferView * view() const;
 
 private:
-       /** This method is connected to the grfx::PreviewLoader::imageReady
-        *  signal.
-        */
+       /// This method is connected to the PreviewLoader::imageReady signal.
        void imageReady(PreviewImage const &) const;
 
        /// Does the owning inset want a preview?
-       virtual bool previewWanted() const = 0;
-       ///
-       virtual BufferView * view() const = 0;
+       virtual bool previewWanted(Buffer const &) const = 0;
        /// a wrapper to Inset::latex
-       virtual string const latexString() const = 0;
+       virtual std::string const latexString(Buffer const &) const = 0;
 
        ///
-       Inset & inset_;
-       /// We don't own this
+       InsetOld & inset_;
+       ///
+       std::string snippet_;
+
+       /// We don't own this. Cached for efficiency reasons.
        mutable PreviewImage const * pimage_;
        ///
-       mutable boost::signals::connection connection_;
+       boost::signals::connection connection_;
 };
 
-} // namespace grfx
 
+inline
+PreviewImage const * PreviewedInset::pimage() const
+{
+       return pimage_;
+}
+
+
+inline
+InsetOld const & PreviewedInset::inset() const
+{
+       return inset_;
+}
+
+} // namespace graphics
+} // namespace lyx
 
 #endif // PREVIEWEDINSET_H