2 /* This file is part of*
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
12 #ifndef INSET_LATEXCOMMAND_H
13 #define INSET_LATEXCOMMAND_H
19 #include "insetbutton.h"
20 #include <sigc++/signal_system.h>
21 #include <boost/utility.hpp>
23 // Created by Alejandro 970222
24 /** Used to insert a LaTeX command automatically
26 * Similar to InsetLaTeX but having control of the basic structure of a
27 * LaTeX command: \name[options]{contents}.
29 class InsetCommandParams {
35 InsetCommandParams( string const & n,
36 string const & c = string(),
37 string const & o = string());
39 bool operator==(InsetCommandParams const &) const;
41 bool operator!=(InsetCommandParams const &) const;
45 void scanCommand(string const &);
47 void Write(std::ostream &) const;
48 /// Build the complete LaTeX command
49 string const getCommand() const;
51 string const & getCmdName() const { return cmdname; }
53 string const & getOptions() const { return options; }
55 string const & getContents() const { return contents; }
57 void setCmdName( string const & n) { cmdname = n; }
59 void setOptions(string const & o) { options = o; }
61 void setContents(string const & c) { contents = c; }
63 string const getAsString() const;
65 void setFromString( string const & );
77 class InsetCommand : public InsetButton, boost::noncopyable {
81 InsetCommand(InsetCommandParams const &);
83 virtual ~InsetCommand() { hideDialog(); }
85 void Write(Buffer const *, std::ostream & os) const
88 virtual void Read(Buffer const *, LyXLex & lex)
90 /// Can remove one InsetBibKey is modified
91 void scanCommand(string const & c) { p_.scanCommand( c ); };
93 virtual int Latex(Buffer const *, std::ostream &,
94 bool fragile, bool free_spc) const;
96 int Ascii(Buffer const *, std::ostream &, int linelen) const;
98 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
100 virtual int DocBook(Buffer const *, std::ostream &) const;
102 Inset::Code LyxCode() const { return Inset::NO_CODE; }
104 /** Get the label that appears at screen.
106 I thought it was enough to eliminate the argument to avoid
107 confusion with lyxinset::getLabel(int), but I've seen that
108 it wasn't. I hope you never confuse again both methods. (ale)
110 virtual string const getScreenLabel() const = 0;
112 string const getCommand() const { return p_.getCommand(); }
114 string const & getCmdName() const { return p_.getCmdName(); }
116 string const & getOptions() const { return p_.getOptions(); }
118 string const & getContents() const { return p_.getContents(); }
120 void setCmdName(string const & n) { p_.setCmdName(n); }
122 void setOptions(string const & o) { p_.setOptions(o); }
124 void setContents(string const & c) { p_.setContents(c); }
126 InsetCommandParams const & params() const { return p_; }
128 void setParams(InsetCommandParams const &);
130 SigC::Signal0<void> hideDialog;
133 InsetCommandParams p_;