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