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