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_LATEXCOMMAND_H
13 #define INSET_LATEXCOMMAND_H
19 #include "insetbutton.h"
20 #include <sigc++/signal_system.h>
21 #include <boost/utility.hpp>
23 #ifdef SIGC_CXX_NAMESPACES
27 // Created by Alejandro 970222
28 /** Used to insert a LaTeX command automatically
30 * Similar to InsetLaTeX but having control of the basic structure of a
31 * LaTeX command: \name[options]{contents}.
33 class InsetCommandParams {
39 InsetCommandParams( string const & n,
40 string const & c = string(),
41 string const & o = string());
43 bool operator==(InsetCommandParams const &) const;
45 bool operator!=(InsetCommandParams const &) const;
49 void scanCommand(string const &);
51 void Write(std::ostream &) const;
52 /// Build the complete LaTeX command
53 string const getCommand() const;
55 string const & getCmdName() const { return cmdname; }
57 string const & getOptions() const { return options; }
59 string const & getContents() const { return contents; }
61 void setCmdName( string const & n ) { cmdname = n; }
63 void setOptions(string const & o) { options = o; }
65 void setContents(string const & c) { contents = c; }
67 string const getAsString() const;
69 void setFromString( string const & );
81 class InsetCommand : public InsetButton, public noncopyable {
85 InsetCommand(InsetCommandParams const &);
87 virtual ~InsetCommand() { hide(); }
89 void Write(Buffer const *, std::ostream & os) const
92 virtual void Read(Buffer const *, LyXLex & lex)
94 /// Can remove one InsetBibKey is modified
95 void scanCommand(string const & c) { p_.scanCommand( c ); };
97 virtual int Latex(Buffer const *, std::ostream &,
98 bool fragile, bool free_spc) const;
100 int Ascii(Buffer const *, std::ostream &, int linelen) const;
102 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
104 virtual int DocBook(Buffer const *, std::ostream &) const;
106 Inset::Code LyxCode() const { return Inset::NO_CODE; }
108 /** Get the label that appears at screen.
110 I thought it was enough to eliminate the argument to avoid
111 confusion with lyxinset::getLabel(int), but I've seen that
112 it wasn't. I hope you never confuse again both methods. (ale)
114 virtual string const getScreenLabel() const = 0;
116 string const getCommand() const { return p_.getCommand(); }
118 string const & getCmdName() const { return p_.getCmdName(); }
120 string const & getOptions() const { return p_.getOptions(); }
122 string const & getContents() const { return p_.getContents(); }
124 void setCmdName(string const & n) { p_.setCmdName(n); }
126 void setOptions(string const & o) { p_.setOptions(o); }
128 void setContents(string const & c) { p_.setContents(c); }
130 InsetCommandParams const & params() const { return p_; }
132 void setParams(InsetCommandParams const &);
137 InsetCommandParams p_;