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>
22 #ifdef SIGC_CXX_NAMESPACES
26 // Created by Alejandro 970222
27 /** Used to insert a LaTeX command automatically
29 * Similar to InsetLaTeX but having control of the basic structure of a
30 * LaTeX command: \name[options]{contents}.
32 class InsetCommandParams {
38 InsetCommandParams( string const & n,
39 string const & c = string(),
40 string const & o = string());
42 string const & getCmdName() const { return cmdname; }
44 string const & getOptions() const { return options; }
46 string const & getContents() const { return contents; }
48 void setCmdName( string const & n ) { cmdname = n; }
50 void setOptions(string const & o) { options = o; }
52 void setContents(string const & c) { contents = c; }
54 string getAsString() const;
56 void setFromString( string const & );
68 class InsetCommand : public InsetButton {
74 InsetCommand(string const & n,
75 string const & c = string(),
76 string const & o = string());
79 InsetCommand(InsetCommandParams const &);
81 virtual ~InsetCommand() { hide(); };
83 void Write(Buffer const *, std::ostream &) const;
85 /// Parse the command.
86 void scanCommand(string const & cmd);
88 virtual void Read(Buffer const *, LyXLex & lex);
90 virtual int Latex(Buffer const *, std::ostream &,
91 bool fragile, bool free_spc) const;
93 int Ascii(Buffer const *, std::ostream &) const;
95 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
97 virtual int DocBook(Buffer const *, std::ostream &) const;
99 Inset * Clone() const;
101 Inset::Code LyxCode() const
103 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 { return getCommand(); }
113 /// Build the complete LaTeX command
114 string getCommand() const;
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_;