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 struct ExternalTemplate;
24 class InsetExternal : public InsetButton {
28 virtual ~InsetExternal();
29 /// what appears in the minibuffer when opening
30 virtual const char * EditMessage() const;
32 virtual void Edit(BufferView *, int x, int y, unsigned int button);
34 virtual EDITABLE Editable() const { return IS_EDITABLE; }
36 virtual void Write(Buffer const *, std::ostream &) const;
38 virtual void Read(Buffer const *, LyXLex & lex);
39 /** returns the number of rows (\n's) of generated tex code.
40 fragile == true means, that the inset should take care about
41 fragile commands by adding a \protect before.
42 If the free_spc (freespacing) variable is set, then this inset
43 is in a free-spacing paragraph.
45 virtual int Latex(Buffer const *, std::ostream &, bool fragile,
48 virtual int Ascii(Buffer const *, std::ostream &) const;
50 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
52 virtual int DocBook(Buffer const *, std::ostream &) const;
53 /// Updates needed features for this inset.
54 virtual void Validate(LaTeXFeatures & features) const;
56 /// returns LyX code associated with the inset. Used for TOC, ...)
57 virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; }
60 virtual Inset * Clone() const;
62 /// returns the text of the button
63 virtual string getScreenLabel() const;
65 /// Callback function for the template drop-down
66 static void templateCB(FL_OBJECT *, long);
68 /// Callback function for the browse button
69 static void browseCB(FL_OBJECT *, long);
71 /// Callback function for the edit button
72 static void editCB(FL_OBJECT *, long);
74 /// Callback function for the view button
75 static void viewCB(FL_OBJECT *, long);
77 /// Callback function for the update production button
78 static void updateCB(FL_OBJECT *, long);
80 /// Callback function for the ok button
81 static void okCB(FL_OBJECT *, long);
83 /// Callback function for the cancel button
84 static void cancelCB(FL_OBJECT *, long);
86 /// Write the output for a specific file format
87 int write(string const & format, Buffer const *, std::ostream &) const;
90 void doApply(BufferView * bv);
92 /// Execute this command in the directory of this document
93 void executeCommand(string const & s, Buffer const * buf) const;
95 /// Update if automatic
96 void automaticUpdate(BufferView const *) const;
99 void doUpdate(BufferView const *) const;
101 void doEdit(BufferView const *) const;
103 void doView(BufferView const *) const;
105 /// Substitute meta-variables in this string
106 string doSubstitution(Buffer const *, string const & s) const;
108 /// Get the LyX name of the currently selected template in the choice list
109 string getCurrentTemplate() const;
111 /// Get a certain template from a LyX name
112 ExternalTemplate getTemplate(string const & lyxname) const;
115 * Get the number starting from 1 of a template with a
116 * specific LyX name for the choice list
118 int getTemplateNumber(string const & guiname) const;
120 /// Get the LyX name of a template with a given number starting from 1
121 string getTemplateName(int n) const;
123 /// Get a string with all the GUI template names separated by |
124 string getTemplateString() const;
128 InsetExternal * inset;
134 /// The external inset form
135 FD_form_external * form_external;