]> git.lyx.org Git - lyx.git/blob - src/insets/insetexternal.h
updates to minipage inset
[lyx.git] / src / insets / insetexternal.h
1 // -*- C++ -*-
2 /* This file is part of*
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *      
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2000 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef INSET_EXTERNAL_H
13 #define INSET_EXTERNAL_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "insetbutton.h"
20 #include "ExternalTemplate.h"
21 #include "LString.h"
22 #include <sigc++/signal_system.h>
23
24 #ifdef SIGC_CXX_NAMESPACES
25 using SigC::Signal0;
26 #endif
27
28 ///
29 class InsetExternal : public InsetButton {
30 public:
31         /// hold parameters settable from the GUI
32         struct InsetExternalParams {
33                 InsetExternalParams(string const & f = string(), 
34                                         string const & p = string(), 
35                                         ExternalTemplate const & t = ExternalTemplate())
36                         : filename(f), parameters(p), templ(t) {}
37                 /// the filename
38                 string filename;
39                 /// the parameters of the current choice
40                 string parameters;
41                 /// the current template used
42                 ExternalTemplate templ;
43         };
44
45         InsetExternal();
46         ///
47         virtual ~InsetExternal();
48         /// what appears in the minibuffer when opening
49         virtual string const EditMessage() const;
50         ///
51         virtual void Edit(BufferView *, int x, int y, unsigned int button);
52         ///
53         virtual EDITABLE Editable() const { return IS_EDITABLE; }
54         ///
55         virtual void Write(Buffer const *, std::ostream &) const;
56         ///
57         virtual void Read(Buffer const *, LyXLex & lex);
58
59         /** returns the number of rows (\n's) of generated tex code.
60          fragile == true means, that the inset should take care about
61          fragile commands by adding a \protect before.
62          If the free_spc (freespacing) variable is set, then this inset
63          is in a free-spacing paragraph.
64          */
65         virtual int Latex(Buffer const *, std::ostream &, bool fragile,
66                           bool free_spc) const;
67         /// write ASCII output to the ostream
68         virtual int Ascii(Buffer const *, std::ostream &, int linelen) const;
69         /// write LinuxDoc output to the ostream
70         virtual int Linuxdoc(Buffer const *, std::ostream &) const;
71         /// write DocBook output to the ostream
72         virtual int DocBook(Buffer const *, std::ostream &) const;
73
74         /// Updates needed features for this inset.
75         virtual void Validate(LaTeXFeatures & features) const;
76
77         /// returns LyX code associated with the inset. Used for TOC, ...)
78         virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
79  
80         ///
81         virtual Inset * Clone(Buffer const &) const;
82
83         /// returns the text of the button
84         virtual string const getScreenLabel() const;
85
86         // The following public members are used from the frontends code
87
88         /// set the parameters from a Params structure
89         virtual void setFromParams(InsetExternalParams const &);
90
91         /// update the file represented by the template
92         void updateExternal() const;
93
94         /// edit file of this template
95         void editExternal() const;
96
97         /// view file of this template
98         void viewExternal() const;
99
100         /// return a copy of our current params
101         InsetExternalParams params() const;
102
103         /// hide connection
104         Signal0<void> hideDialog;
105
106 private:
107         /// Write the output for a specific file format
108         int write(string const & format, Buffer const *,
109                   std::ostream &) const;
110
111         /// Execute this command in the directory of this document
112         void executeCommand(string const & s, Buffer const * buf) const;
113
114         /// Substitute meta-variables in this string
115         string const doSubstitution(Buffer const *, string const & s) const;
116
117         /// our owning view
118         BufferView * view;
119
120         /// the current params
121         InsetExternalParams params_;
122
123         /// A temp filename
124         string tempname;
125 };
126
127 #endif