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"
23 struct ExternalTemplate;
26 class InsetExternal : public InsetButton {
30 virtual ~InsetExternal();
31 /// what appears in the minibuffer when opening
32 virtual char const * EditMessage() const;
34 virtual void Edit(BufferView *, int x, int y, unsigned int button);
36 virtual EDITABLE Editable() const { return IS_EDITABLE; }
38 virtual void Write(Buffer const *, std::ostream &) const;
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.
47 virtual int Latex(Buffer const *, std::ostream &, bool fragile,
50 virtual int Ascii(Buffer const *, std::ostream &) const;
52 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
54 virtual int DocBook(Buffer const *, std::ostream &) const;
55 /// Updates needed features for this inset.
56 virtual void Validate(LaTeXFeatures & features) const;
58 /// returns LyX code associated with the inset. Used for TOC, ...)
59 virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
62 virtual Inset * Clone() const;
64 /// returns the text of the button
65 virtual string getScreenLabel() const;
67 /// Callback function for the template drop-down
68 static void templateCB(FL_OBJECT *, long);
70 /// Callback function for the browse button
71 static void browseCB(FL_OBJECT *, long);
73 /// Callback function for the edit button
74 static void editCB(FL_OBJECT *, long);
76 /// Callback function for the view button
77 static void viewCB(FL_OBJECT *, long);
79 /// Callback function for the update production button
80 static void updateCB(FL_OBJECT *, long);
82 /// Callback function for the ok button
83 static void okCB(FL_OBJECT *, long);
85 /// Callback function for the cancel button
86 static void cancelCB(FL_OBJECT *, long);
88 /// Write the output for a specific file format
89 int write(string const & format, Buffer const *, std::ostream &) const;
92 void doApply(BufferView * bv);
94 /// Execute this command in the directory of this document
95 void executeCommand(string const & s, Buffer const * buf) const;
97 /// Update if automatic
98 void automaticUpdate(BufferView const *) const;
101 void doUpdate(BufferView const *) const;
103 void doEdit(BufferView const *) const;
105 void doView(BufferView const *) const;
107 /// Substitute meta-variables in this string
108 string doSubstitution(Buffer const *, string const & s) const;
110 /// Get the LyX name of the currently selected template in the choice list
111 string getCurrentTemplate() const;
113 /// Get a certain template from a LyX name
114 ExternalTemplate getTemplate(string const & lyxname) const;
117 * Get the number starting from 1 of a template with a
118 * specific LyX name for the choice list
120 int getTemplateNumber(string const & guiname) const;
122 /// Get the LyX name of a template with a given number starting from 1
123 string getTemplateName(int n) const;
125 /// Get a string with all the GUI template names separated by |
126 string getTemplateString() const;
130 InsetExternal * inset;
136 /// The external inset form
137 FD_form_external * form_external;