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"
21 // Created by Alejandro 970222
22 /** Used to insert a LaTeX command automatically
24 * Similar to InsetLaTeX but having control of the basic structure of a
25 * LaTeX command: \name[options]{contents}.
27 class InsetCommandParams {
33 InsetCommandParams( string const & n,
34 string const & c = string(),
35 string const & o = string());
37 string const & getCmdName() const { return cmdname; }
39 string const & getOptions() const { return options; }
41 string const & getContents() const { return contents; }
43 void setCmdName( string const & n ) { cmdname = n; }
45 void setOptions(string const & o) { options = o; }
47 void setContents(string const & c) { contents = c; }
49 string getAsString() const;
51 void setFromString( string const & );
63 class InsetCommand : public InsetButton {
69 InsetCommand(string const & n,
70 string const & c = string(),
71 string const & o = string());
74 InsetCommand(InsetCommandParams const &);
76 void Write(Buffer const *, std::ostream &) const;
78 /// Parse the command.
79 void scanCommand(string const & cmd);
81 virtual void Read(Buffer const *, LyXLex & lex);
83 virtual int Latex(Buffer const *, std::ostream &,
84 bool fragile, bool free_spc) const;
86 int Ascii(Buffer const *, std::ostream &) const;
88 virtual int Linuxdoc(Buffer const *, std::ostream &) const;
90 virtual int DocBook(Buffer const *, std::ostream &) const;
92 Inset * Clone() const;
94 Inset::Code LyxCode() const
96 return Inset::NO_CODE;
99 /** Get the label that appears at screen.
101 I thought it was enough to eliminate the argument to avoid
102 confusion with lyxinset::getLabel(int), but I've seen that
103 it wasn't. I hope you never confuse again both methods. (ale)
105 virtual string getScreenLabel() const { return getCommand(); }
106 /// Build the complete LaTeX command
107 string getCommand() const;
109 string const & getCmdName() const { return p_.getCmdName(); }
111 string const & getOptions() const { return p_.getOptions(); }
113 string const & getContents() const { return p_.getContents(); }
115 void setCmdName(string const & n) { p_.setCmdName(n); }
117 void setOptions(string const & o) { p_.setOptions(o); }
119 void setContents(string const & c) { p_.setContents(c); }
121 InsetCommandParams const & params() const { return p_; }
123 void setParams(InsetCommandParams const &);
126 InsetCommandParams p_;