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
28 using SigC::Connection;
32 class InsetExternal : public InsetButton, public Object {
36 virtual ~InsetExternal();
37 /// what appears in the minibuffer when opening
38 virtual string const EditMessage() const;
40 virtual void Edit(BufferView *, int x, int y, unsigned int button);
42 virtual EDITABLE Editable() const { return IS_EDITABLE; }
44 virtual void Write(Buffer const *, std::ostream &) const;
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.
53 virtual int Latex(Buffer const *, std::ostream &, bool fragile,
56 virtual int Ascii(Buffer const *, std::ostream &, int linelen) const;
58 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
60 virtual int DocBook(Buffer const *, std::ostream &) const;
61 /// Updates needed features for this inset.
62 virtual void Validate(LaTeXFeatures & features) const;
64 /// returns LyX code associated with the inset. Used for TOC, ...)
65 virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
68 virtual Inset * Clone(Buffer const &) const;
70 /// returns the text of the button
71 virtual string const getScreenLabel() const;
73 /// Callback function for the template drop-down
74 static void templateCB(FL_OBJECT *, long);
76 /// Callback function for the browse button
77 static void browseCB(FL_OBJECT *, long);
79 /// Callback function for the edit button
80 static void editCB(FL_OBJECT *, long);
82 /// Callback function for the view button
83 static void viewCB(FL_OBJECT *, long);
85 /// Callback function for the update production button
86 static void updateCB(FL_OBJECT *, long);
88 /// Callback function for the ok button
89 static void okCB(FL_OBJECT *, long);
91 /// Callback function for the cancel button
92 static void cancelCB(FL_OBJECT *, long);
94 /** Redraw the form (on receipt of a Signal indicating, for example,
95 that the xform colors have been re-mapped).
99 /// Write the output for a specific file format
100 int write(string const & format, Buffer const *,
101 std::ostream &) const;
103 /// Apply the changes
104 void doApply(BufferView * bv);
106 /// Execute this command in the directory of this document
107 void executeCommand(string const & s, Buffer const * buf) const;
109 /// Update if automatic
110 void automaticUpdate(BufferView const *) const;
113 void doUpdate(BufferView const *) const;
115 void doEdit(BufferView const *) const;
117 void doView(BufferView const *) const;
119 /// Substitute meta-variables in this string
120 string const doSubstitution(Buffer const *, string const & s) const;
122 /** Get the LyX name of the currently selected
123 template in the choice list
125 string const getCurrentTemplate() const;
127 /// Get a certain template from a LyX name
128 ExternalTemplate const getTemplate(string const & lyxname) const;
131 Get the number starting from 1 of a template with a
132 specific LyX name for the choice list
134 int getTemplateNumber(string const & guiname) const;
136 /// Get the LyX name of a template with a given number starting from 1
137 string const getTemplateName(int n) const;
139 /// Get a string with all the GUI template names separated by |
140 string const getTemplateString() const;
144 InsetExternal * inset;
150 /// The external inset form
151 FD_form_external * form_external;
165 /// Redraw connection.