]> git.lyx.org Git - lyx.git/blob - src/insets/insetexternal.h
3f1906ecc7f807e6c657611e0f27a3a042df1402
[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 "LString.h"
21 #include "../lyx.h"
22 struct ExternalTemplate;
23
24 class InsetExternal : public InsetButton {
25 public:
26         InsetExternal();
27         ///
28         virtual ~InsetExternal();
29         /// what appears in the minibuffer when opening
30         virtual const char * EditMessage() const;
31         ///
32         virtual void Edit(BufferView *, int x, int y, unsigned int button);
33         ///
34         virtual EDITABLE Editable() const { return IS_EDITABLE; }
35         ///
36         virtual void Write(Buffer const *, std::ostream &) const;
37         ///
38         virtual void Read(Buffer const *, LyXLex & lex);
39         /** returns the number of rows (\n's) of generated tex code.
40          fragile == true means, that the inset should take care about
41          fragile commands by adding a \protect before.
42          If the free_spc (freespacing) variable is set, then this inset
43          is in a free-spacing paragraph.
44          */
45         virtual int Latex(Buffer const *, std::ostream &, bool fragile,
46                           bool free_spc) const;
47         ///
48         virtual int Ascii(Buffer const *, std::ostream &) const;
49         ///
50         virtual int Linuxdoc(Buffer const *, std::ostream &) const;
51         ///
52         virtual int DocBook(Buffer const *, std::ostream &) const;
53         /// Updates needed features for this inset.
54         virtual void Validate(LaTeXFeatures & features) const;
55
56         /// returns LyX code associated with the inset. Used for TOC, ...)
57         virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
58   
59         ///
60         virtual Inset * Clone() const;
61
62         /// returns the text of the button
63         virtual string getScreenLabel() const;
64
65         /// Callback function for the template drop-down
66         static void templateCB(FL_OBJECT *, long);
67
68         /// Callback function for the browse button
69         static void browseCB(FL_OBJECT *, long);
70
71         /// Callback function for the edit button
72         static void editCB(FL_OBJECT *, long);
73
74         /// Callback function for the view button
75         static void viewCB(FL_OBJECT *, long);
76
77         /// Callback function for the update production button
78         static void updateCB(FL_OBJECT *, long);
79
80         /// Callback function for the ok button
81         static void okCB(FL_OBJECT *, long);
82
83         /// Callback function for the cancel button
84         static void cancelCB(FL_OBJECT *, long);
85 private:
86         /// Write the output for a specific file format
87         int write(string const & format, Buffer const *, std::ostream &) const;
88
89         /// Apply the changes
90         void doApply(BufferView * bv);
91
92         /// Execute this command in the directory of this document
93         void executeCommand(string const & s, Buffer const * buf) const;
94
95         /// Update if automatic
96         void automaticUpdate(BufferView const *) const;
97
98         /// Do update
99         void doUpdate(BufferView const *) const;
100         /// Do edit
101         void doEdit(BufferView const *) const;
102         /// Do view
103         void doView(BufferView const *) const;
104
105         /// Substitute meta-variables in this string
106         string doSubstitution(Buffer const *, string const & s) const;
107
108         /// Get the LyX name of the currently selected template in the choice list
109         string getCurrentTemplate() const;
110
111         /// Get a certain template from a LyX name
112         ExternalTemplate getTemplate(string const & lyxname) const;
113
114         /**
115          * Get the number starting from 1 of a template with a 
116          * specific LyX name for the choice list
117          */
118         int getTemplateNumber(string const & guiname) const;
119
120         /// Get the LyX name of a template with a given number starting from 1
121         string getTemplateName(int n) const;
122
123         /// Get a string with all the GUI template names separated by |
124         string getTemplateString() const;
125
126         ///
127         struct Holder {
128                 InsetExternal * inset;
129                 BufferView * view;
130         };
131         ///
132         Holder holder;
133
134         /// The external inset form
135         FD_form_external * form_external;
136
137         ///
138         string templatename;
139
140         ///
141         string filename;
142
143         ///
144         string parameters;
145
146         /// A temp filename
147         string tempname;
148 };
149
150 #endif