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>
|
2000-08-04 13:12:30 +00:00
|
|
|
#include "support/utility.hpp"
|
2000-08-01 17:33:32 +00:00
|
|
|
|
|
|
|
#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());
|
|
|
|
///
|
2000-08-04 13:12:30 +00:00
|
|
|
bool operator==(InsetCommandParams const &) const;
|
|
|
|
///
|
|
|
|
bool operator!=(InsetCommandParams const &) const;
|
|
|
|
///
|
|
|
|
void Read(LyXLex &);
|
|
|
|
/// Parse the command
|
|
|
|
void scanCommand(string const &);
|
|
|
|
///
|
|
|
|
void Write(std::ostream &) const;
|
|
|
|
/// Build the complete LaTeX command
|
2000-09-14 17:53:12 +00:00
|
|
|
string const getCommand() const;
|
2000-08-04 13:12:30 +00:00
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
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; }
|
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
string const getAsString() const;
|
2000-07-27 08:55:59 +00:00
|
|
|
///
|
|
|
|
void setFromString( string const & );
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
string cmdname;
|
|
|
|
///
|
|
|
|
string contents;
|
|
|
|
///
|
|
|
|
string options;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-08-04 13:12:30 +00:00
|
|
|
class InsetCommand : public InsetButton, public noncopyable {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
explicit
|
|
|
|
InsetCommand(InsetCommandParams const &);
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-08-02 11:33:05 +00:00
|
|
|
virtual ~InsetCommand() { hide(); };
|
2000-08-01 17:33:32 +00:00
|
|
|
///
|
2000-08-04 13:12:30 +00:00
|
|
|
void Write(Buffer const *, std::ostream & os) const
|
|
|
|
{ p_.Write( os ); }
|
2000-07-13 09:38:34 +00:00
|
|
|
///
|
2000-08-04 13:12:30 +00:00
|
|
|
virtual void Read(Buffer const *, LyXLex & lex)
|
|
|
|
{ p_.Read( lex ); }
|
|
|
|
/// Can remove one InsetBibKey is modified
|
|
|
|
void scanCommand(string const & c) { p_.scanCommand( c ); };
|
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
|
|
|
///
|
2000-08-04 13:12:30 +00:00
|
|
|
Inset::Code LyxCode() const { return Inset::NO_CODE; }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/** 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-09-14 17:53:12 +00:00
|
|
|
virtual string const getScreenLabel() const = 0;
|
2000-08-04 13:12:30 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
string const getCommand() const { return p_.getCommand(); }
|
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-02 11:33:05 +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
|