// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
+ * Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
#endif
#include "insetbutton.h"
+#include <sigc++/signal_system.h>
+#include <boost/utility.hpp>
// Created by Alejandro 970222
/** Used to insert a LaTeX command automatically
*
* Similar to InsetLaTeX but having control of the basic structure of a
- * LaTeX command: \name[options]{contents}.
+ * LaTeX command: \name[options]{contents}.
*/
-class InsetCommand : public InsetButton {
+class InsetCommandParams {
public:
///
- InsetCommand();
+ InsetCommandParams();
///
explicit
- InsetCommand(string const & name, string const & arg = string(),
- string const & opt = string());
+ InsetCommandParams(string const & n,
+ string const & c = string(),
+ string const & o = string());
///
- void Write(Buffer const *, std::ostream &) const;
-
- /// Parse the command.
- void scanCommand(string const & cmd);
+ bool operator==(InsetCommandParams const &) const;
///
- virtual void Read(Buffer const *, LyXLex & lex);
- ///
- virtual int Latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
+ bool operator!=(InsetCommandParams const &) const;
///
- int Ascii(Buffer const *, std::ostream &) const;
- ///
- virtual int Linuxdoc(Buffer const *, std::ostream &) const;
- ///
- virtual int DocBook(Buffer const *, std::ostream &) const;
- ///
- Inset * Clone() const;
- ///
- Inset::Code LyxCode() const
- {
- return Inset::NO_CODE;
- }
-
- /** Get the label that appears at screen.
-
- I thought it was enough to eliminate the argument to avoid
- confusion with lyxinset::getLabel(int), but I've seen that
- it wasn't. I hope you never confuse again both methods. (ale)
- */
- virtual string getScreenLabel() const
- {
- return getCommand();
- }
-
+ void read(LyXLex &);
+ /// Parse the command
+ void scanCommand(string const &);
+ ///
+ void write(std::ostream &) const;
/// Build the complete LaTeX command
- string getCommand() const;
+ string const getCommand() const;
///
- string const & getCmdName() const {
- return cmdname;
- }
+ string const & getCmdName() const { return cmdname; }
///
- string const & getOptions() const {
- return options;
- }
+ string const & getOptions() const { return options; }
///
- string const & getContents() const {
- return contents;
- }
+ string const & getContents() const { return contents; }
///
- void setCmdName(string const & n) {
- cmdname = n;
- }
+ void setCmdName(string const & n) { cmdname = n; }
///
- void setOptions(string const & o) {
- options = o;
- }
+ void setOptions(string const & o) { options = o; }
///
- virtual void setContents(string const & c) {
- contents = c;
- }
+ void setContents(string const & c) { contents = c; }
///
- void addContents(string const & c) {
- contents += c;
- }
+ string const getAsString() const;
+ ///
+ void setFromString(string const &);
private:
- ///
+ ///
string cmdname;
- ///
- string options;
- ///
+ ///
string contents;
+ ///
+ string options;
+};
+
+
+///
+class InsetCommand : public InsetButton, boost::noncopyable {
+public:
+ ///
+ explicit
+ InsetCommand(InsetCommandParams const &, bool same_id = false);
+ ///
+ virtual ~InsetCommand() { hideDialog(); }
+ ///
+ void write(Buffer const *, std::ostream & os) const
+ { p_.write(os); }
+ ///
+ virtual void read(Buffer const *, LyXLex & lex)
+ { p_.read(lex); }
+ /// Can remove one InsetBibKey is modified
+ void scanCommand(string const & c) { p_.scanCommand(c); };
+ ///
+ virtual int latex(Buffer const *, std::ostream &,
+ bool fragile, bool free_spc) const;
+ ///
+ int ascii(Buffer const *, std::ostream &, int linelen) const;
+ ///
+ virtual int linuxdoc(Buffer const *, std::ostream &) const;
+ ///
+ virtual int docbook(Buffer const *, std::ostream &) const;
+ ///
+ Inset::Code lyxCode() const { return Inset::NO_CODE; }
+
+ ///
+ string const getCommand() const { return p_.getCommand(); }
+ ///
+ string const & getCmdName() const { return p_.getCmdName(); }
+ ///
+ string const & getOptions() const { return p_.getOptions(); }
+ ///
+ string const & getContents() const { return p_.getContents(); }
+ ///
+ void setCmdName(string const & n) { p_.setCmdName(n); }
+ ///
+ void setOptions(string const & o) { p_.setOptions(o); }
+ ///
+ void setContents(string const & c) { p_.setContents(c); }
+ ///
+ InsetCommandParams const & params() const { return p_; }
+ ///
+ void setParams(InsetCommandParams const &);
+ ///
+ SigC::Signal0<void> hideDialog;
+
+private:
+ ///
+ InsetCommandParams p_;
};
#endif