]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetexternal.h
Rename ascii to plaintext and LatexRunParams to OutputParams.
[lyx.git] / src / insets / insetexternal.h
index 024a2319cef4162366df874c601e3bb6846ab244..c9d5ab2b2fb45e241fd8af8250f4170d20b8dfab 100644 (file)
 #define INSET_EXTERNAL_H
 
 #include "inset.h"
-
-#include "graphics/GraphicsTypes.h"
+#include "ExternalTransforms.h"
 
 #include "support/filename.h"
+#include "support/translator.h"
 
 #include <boost/scoped_ptr.hpp>
 #include <boost/signals/trackable.hpp>
@@ -42,6 +42,20 @@ private:
        std::string tempname_;
 };
 
+/// How is the image to be displayed on the LyX screen?
+enum DisplayType {
+       DefaultDisplay,
+       MonochromeDisplay,
+       GrayscaleDisplay,
+       ColorDisplay,
+       PreviewDisplay,
+       NoDisplay
+};
+
+
+/// The translator between the Display enum and corresponding lyx string.
+Translator<DisplayType, std::string> const & displayTranslator();
+
 } // namespace external
 } // namespace lyx
 
@@ -63,17 +77,22 @@ struct InsetExternalParams {
        /// The external file.
        lyx::support::FileName filename;
        /// How the inset is to be displayed by LyX.
-       lyx::graphics::DisplayType display;
+       lyx::external::DisplayType display;
        /// The scale of the displayed graphic (if shown).
        unsigned int lyxscale;
 
+       lyx::external::ClipData     clipdata;
+       lyx::external::ExtraData    extradata;
+       lyx::external::ResizeData   resizedata;
+       lyx::external::RotationData rotationdata;
+
 private:
        lyx::external::TempName tempname_;
        std::string templatename_;
 };
 
 
-class RenderInset;
+class RenderBase;
 
 ///
 class InsetExternal : public InsetOld, public boost::signals::trackable
@@ -86,9 +105,6 @@ public:
        virtual ~InsetExternal();
        ///
        virtual std::auto_ptr<InsetBase> clone() const;
-       ///
-       virtual dispatch_result localDispatch(FuncRequest const & cmd);
-
        ///
        virtual InsetOld::Code lyxCode() const { return EXTERNAL_CODE; }
        ///
@@ -105,14 +121,16 @@ public:
 
        /// \returns the number of rows (\n's) of generated code.
        virtual int latex(Buffer const &, std::ostream &,
-                         LatexRunParams const &) const;
+                         OutputParams const &) const;
        ///
-       virtual int ascii(Buffer const &, std::ostream &, int linelen) const;
+       virtual int plaintext(Buffer const &, std::ostream &,
+                         OutputParams const &) const;
        ///
-       virtual int linuxdoc(Buffer const &, std::ostream &) const;
+       virtual int linuxdoc(Buffer const &, std::ostream &,
+                            OutputParams const &) const;
        ///
        virtual int docbook(Buffer const &, std::ostream &,
-                           bool mixcont) const;
+                           OutputParams const &) const;
 
        /// Update needed features for this inset.
        virtual void validate(LaTeXFeatures & features) const;
@@ -120,17 +138,31 @@ public:
        ///
        InsetExternalParams const & params() const;
        void setParams(InsetExternalParams const &, Buffer const &);
+       ///
+       void addPreview(lyx::graphics::PreviewLoader &) const;
+       ///
+       void edit(BufferView * bv, bool);
 
+protected:
+       ///
+       virtual
+       DispatchResult
+       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
 private:
        /** This method is connected to the graphics loader, so we are
         *  informed when the image has been loaded.
         */
-       void statusChanged();
+       void statusChanged() const;
+
+       /** Slot receiving a signal that the external file has changed
+        *  and the preview should be regenerated.
+        */
+       void fileChanged() const;
 
        /// The current params
        InsetExternalParams params_;
        /// The thing that actually draws the image on LyX's screen.
-       boost::scoped_ptr<RenderInset> renderer_;
+       boost::scoped_ptr<RenderBase> renderer_;
 };