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 <boost/signals/signal0.hpp>
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 &, bool same_id = false);
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 &, bool) const;
102 Inset::Code lyxCode() const { return Inset::NO_CODE; }
105 string const getCommand() const { return p_.getCommand(); }
107 string const & getCmdName() const { return p_.getCmdName(); }
109 string const & getOptions() const { return p_.getOptions(); }
111 string const & getContents() const { return p_.getContents(); }
113 void setCmdName(string const & n) { p_.setCmdName(n); }
115 void setOptions(string const & o) { p_.setOptions(o); }
117 void setContents(string const & c) { p_.setContents(c); }
119 InsetCommandParams const & params() const { return p_; }
121 void setParams(InsetCommandParams const &);
123 boost::signal0<void> hideDialog;
127 InsetCommandParams p_;