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