2 /* This file is part of*
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team.
10 * ====================================================== */
12 #ifndef INSET_EXTERNAL_H
13 #define INSET_EXTERNAL_H
19 #include "insetbutton.h"
22 #include <sigc++/signal_system.h>
24 struct ExternalTemplate;
26 #ifdef SIGC_CXX_NAMESPACES
31 class InsetExternal : public InsetButton, public Object {
35 virtual ~InsetExternal();
36 /// what appears in the minibuffer when opening
37 virtual string const EditMessage() const;
39 virtual void Edit(BufferView *, int x, int y, unsigned int button);
41 virtual EDITABLE Editable() const { return IS_EDITABLE; }
43 virtual void Write(Buffer const *, std::ostream &) const;
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.
52 virtual int Latex(Buffer const *, std::ostream &, bool fragile,
55 virtual int Ascii(Buffer const *, std::ostream &, int linelen) const;
57 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
59 virtual int DocBook(Buffer const *, std::ostream &) const;
60 /// Updates needed features for this inset.
61 virtual void Validate(LaTeXFeatures & features) const;
63 /// returns LyX code associated with the inset. Used for TOC, ...)
64 virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
67 virtual Inset * Clone(Buffer const &) const;
69 /// returns the text of the button
70 virtual string const getScreenLabel() const;
72 /// Callback function for the template drop-down
73 static void templateCB(FL_OBJECT *, long);
75 /// Callback function for the browse button
76 static void browseCB(FL_OBJECT *, long);
78 /// Callback function for the edit button
79 static void editCB(FL_OBJECT *, long);
81 /// Callback function for the view button
82 static void viewCB(FL_OBJECT *, long);
84 /// Callback function for the update production button
85 static void updateCB(FL_OBJECT *, long);
87 /// Callback function for the ok button
88 static void okCB(FL_OBJECT *, long);
90 /// Callback function for the cancel button
91 static void cancelCB(FL_OBJECT *, long);
93 /** Redraw the form (on receipt of a Signal indicating, for example,
94 that the xform colors have been re-mapped).
98 /// Write the output for a specific file format
99 int write(string const & format, Buffer const *,
100 std::ostream &) const;
102 /// Apply the changes
103 void doApply(BufferView * bv);
105 /// Execute this command in the directory of this document
106 void executeCommand(string const & s, Buffer const * buf) const;
108 /// Update if automatic
109 void automaticUpdate(BufferView const *) const;
112 void doUpdate(BufferView const *) const;
114 void doEdit(BufferView const *) const;
116 void doView(BufferView const *) const;
118 /// Substitute meta-variables in this string
119 string const doSubstitution(Buffer const *, string const & s) const;
121 /** Get the LyX name of the currently selected
122 template in the choice list
124 string const getCurrentTemplate() const;
126 /// Get a certain template from a LyX name
127 ExternalTemplate const getTemplate(string const & lyxname) const;
130 Get the number starting from 1 of a template with a
131 specific LyX name for the choice list
133 int getTemplateNumber(string const & guiname) const;
135 /// Get the LyX name of a template with a given number starting from 1
136 string const getTemplateName(int n) const;
138 /// Get a string with all the GUI template names separated by |
139 string const getTemplateString() const;
143 InsetExternal * inset;
149 /// The external inset form
150 FD_form_external * form_external;
164 /// Redraw connection.