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
|
|
|
|
|
|
|
|
#include "lyxinset.h"
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
// 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}.
|
|
|
|
*/
|
|
|
|
class InsetCommand: public Inset {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
InsetCommand();
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
explicit
|
1999-10-02 16:21:10 +00:00
|
|
|
InsetCommand(string const & name, string const & arg = string(),
|
|
|
|
string const & opt = string());
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
|
|
|
int ascent(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int descent(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int width(Painter &, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
void draw(Painter &, LyXFont const &, int baseline, float & x) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
void Write(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);
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Will not be used when lyxf3
|
1999-11-04 01:40:20 +00:00
|
|
|
void Read(LyXLex & lex);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
virtual int Latex(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-04-24 20:58:23 +00:00
|
|
|
int Ascii(std::ostream &) const;
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
virtual int Linuxdoc(std::ostream &) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
virtual int DocBook(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)
|
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual string getScreenLabel() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return getCommand();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Build the complete LaTeX command
|
1999-10-02 16:21:10 +00:00
|
|
|
string getCommand() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
string const & getCmdName() const {
|
1999-09-27 18:44:28 +00:00
|
|
|
return command;
|
|
|
|
}
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
string const & getOptions() const {
|
1999-09-27 18:44:28 +00:00
|
|
|
return options;
|
|
|
|
}
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
string const & getContents() const {
|
1999-09-27 18:44:28 +00:00
|
|
|
return contents;
|
|
|
|
}
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void setCmdName(string const & n) {
|
1999-09-27 18:44:28 +00:00
|
|
|
command = n;
|
|
|
|
}
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void setOptions(string const & o) {
|
1999-09-27 18:44:28 +00:00
|
|
|
options = o;
|
|
|
|
}
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
virtual void setContents(string const & c) {
|
1999-09-27 18:44:28 +00:00
|
|
|
contents = c;
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string command;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string options;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string contents;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|