1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of*
|
1999-11-15 10:58:38 +00:00
|
|
|
* ======================================================
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-02-10 17:53:36 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
1999-11-15 10:58:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#ifndef INSET_LATEXCOMMAND_H
|
|
|
|
#define INSET_LATEXCOMMAND_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
#include "insetbutton.h"
|
2000-08-01 17:33:32 +00:00
|
|
|
#include <sigc++/signal_system.h>
|
|
|
|
|
|
|
|
#ifdef SIGC_CXX_NAMESPACES
|
|
|
|
using SigC::Signal0;
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// 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}.
|
|
|
|
*/
|
2000-07-27 08:55:59 +00:00
|
|
|
class InsetCommandParams {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
InsetCommandParams();
|
|
|
|
///
|
|
|
|
explicit
|
|
|
|
InsetCommandParams( string const & n,
|
|
|
|
string const & c = string(),
|
|
|
|
string const & o = string());
|
|
|
|
///
|
|
|
|
string const & getCmdName() const { return cmdname; }
|
|
|
|
///
|
|
|
|
string const & getOptions() const { return options; }
|
|
|
|
///
|
|
|
|
string const & getContents() const { return contents; }
|
|
|
|
///
|
|
|
|
void setCmdName( string const & n ) { cmdname = n; }
|
|
|
|
///
|
|
|
|
void setOptions(string const & o) { options = o; }
|
|
|
|
///
|
|
|
|
void setContents(string const & c) { contents = c; }
|
|
|
|
///
|
|
|
|
string getAsString() const;
|
|
|
|
///
|
|
|
|
void setFromString( string const & );
|
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
string cmdname;
|
|
|
|
///
|
|
|
|
string contents;
|
|
|
|
///
|
|
|
|
string options;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
class InsetCommand : public InsetButton {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
InsetCommand();
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
explicit
|
2000-07-27 08:55:59 +00:00
|
|
|
InsetCommand(string const & n,
|
|
|
|
string const & c = string(),
|
|
|
|
string const & o = string());
|
|
|
|
///
|
|
|
|
explicit
|
|
|
|
InsetCommand(InsetCommandParams const &);
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-08-01 18:11:14 +00:00
|
|
|
virtual ~InsetCommand() { /*hide();*/ };
|
2000-08-01 17:33:32 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void Write(Buffer const *, std::ostream &) const;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Parse the command.
|
1999-11-04 01:40:20 +00:00
|
|
|
void scanCommand(string const & cmd);
|
2000-07-13 09:38:34 +00:00
|
|
|
///
|
|
|
|
virtual void Read(Buffer const *, LyXLex & lex);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
virtual int Latex(Buffer const *, std::ostream &,
|
2000-04-19 01:42:55 +00:00
|
|
|
bool fragile, bool free_spc) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int Ascii(Buffer const *, std::ostream &) const;
|
2000-04-24 20:58:23 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
virtual int Linuxdoc(Buffer const *, std::ostream &) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
virtual int DocBook(Buffer const *, std::ostream &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-24 22:14:46 +00:00
|
|
|
Inset * Clone() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
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)
|
|
|
|
*/
|
2000-07-27 08:55:59 +00:00
|
|
|
virtual string getScreenLabel() const { return getCommand(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Build the complete LaTeX command
|
1999-10-02 16:21:10 +00:00
|
|
|
string getCommand() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
string const & getCmdName() const { return p_.getCmdName(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
string const & getOptions() const { return p_.getOptions(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
string const & getContents() const { return p_.getContents(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
void setCmdName(string const & n) { p_.setCmdName(n); }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
void setOptions(string const & o) { p_.setOptions(o); }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
void setContents(string const & c) { p_.setContents(c); }
|
2000-06-07 08:53:40 +00:00
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
InsetCommandParams const & params() const { return p_; }
|
|
|
|
///
|
|
|
|
void setParams(InsetCommandParams const &);
|
2000-08-01 17:33:32 +00:00
|
|
|
///
|
2000-08-01 18:11:14 +00:00
|
|
|
//Signal0<void> hide;
|
2000-06-07 08:53:40 +00:00
|
|
|
private:
|
2000-07-27 08:55:59 +00:00
|
|
|
///
|
|
|
|
InsetCommandParams p_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|