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 "support/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 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 getAsString() const;
69 void setFromString( string const & );
80 class InsetCommand : public InsetButton, public noncopyable {
83 InsetCommand(InsetCommandParams const &);
85 virtual ~InsetCommand() { hide(); };
87 void Write(Buffer const *, std::ostream & os) const
90 virtual void Read(Buffer const *, LyXLex & lex)
92 /// Can remove one InsetBibKey is modified
93 void scanCommand(string const & c) { p_.scanCommand( c ); };
95 virtual int Latex(Buffer const *, std::ostream &,
96 bool fragile, bool free_spc) const;
98 int Ascii(Buffer const *, std::ostream &) const;
100 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
102 virtual int DocBook(Buffer const *, std::ostream &) const;
104 Inset::Code LyxCode() const { return Inset::NO_CODE; }
106 /** Get the label that appears at screen.
108 I thought it was enough to eliminate the argument to avoid
109 confusion with lyxinset::getLabel(int), but I've seen that
110 it wasn't. I hope you never confuse again both methods. (ale)
112 virtual string getScreenLabel() const = 0;
114 string getCommand() const { return p_.getCommand(); }
116 string const & getCmdName() const { return p_.getCmdName(); }
118 string const & getOptions() const { return p_.getOptions(); }
120 string const & getContents() const { return p_.getContents(); }
122 void setCmdName(string const & n) { p_.setCmdName(n); }
124 void setOptions(string const & o) { p_.setOptions(o); }
126 void setContents(string const & c) { p_.setContents(c); }
128 InsetCommandParams const & params() const { return p_; }
130 void setParams(InsetCommandParams const &);
135 InsetCommandParams p_;