1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetcommand.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +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
|
|
|
|
|
2003-06-12 08:52:36 +00:00
|
|
|
|
#include "inset.h"
|
2002-07-04 13:54:28 +00:00
|
|
|
|
#include "insetcommandparams.h"
|
2003-10-10 21:08:55 +00:00
|
|
|
|
#include "render_button.h"
|
2003-02-25 14:51:38 +00:00
|
|
|
|
#include "mailinset.h"
|
2004-01-20 14:25:24 +00:00
|
|
|
|
#include "cursor.h"
|
|
|
|
|
|
2000-08-01 17:33:32 +00:00
|
|
|
|
|
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
|
2002-03-21 17:09:55 +00:00
|
|
|
|
* LaTeX command: \name[options]{contents}.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
2000-07-27 08:55:59 +00:00
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
class InsetCommand : public InsetOld {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2004-01-20 14:25:24 +00:00
|
|
|
|
InsetCommand(InsetCommandParams const &, std::string const & mailer_name);
|
2003-12-11 15:23:15 +00:00
|
|
|
|
///
|
|
|
|
|
~InsetCommand();
|
2003-05-26 09:13:55 +00:00
|
|
|
|
///
|
2003-06-12 08:52:36 +00:00
|
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
|
|
|
|
///
|
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2003-06-03 15:10:14 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void write(Buffer const &, std::ostream & os) const
|
2002-02-16 15:59:55 +00:00
|
|
|
|
{ p_.write(os); }
|
2000-07-13 09:38:34 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
virtual void read(Buffer const &, LyXLex & lex)
|
2002-02-16 15:59:55 +00:00
|
|
|
|
{ p_.read(lex); }
|
2000-08-04 13:12:30 +00:00
|
|
|
|
/// Can remove one InsetBibKey is modified
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
|
/// FIXME remove
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void scanCommand(std::string const & c) { p_.scanCommand(c); };
|
2002-03-21 17:09:55 +00:00
|
|
|
|
///
|
2006-10-19 16:51:30 +00:00
|
|
|
|
virtual int latex(Buffer const &, lyx::odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
|
///
|
2006-10-11 19:40:50 +00:00
|
|
|
|
int plaintext(Buffer const &, lyx::odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2000-04-24 20:58:23 +00:00
|
|
|
|
///
|
2006-10-19 21:00:33 +00:00
|
|
|
|
virtual int docbook(Buffer const &, lyx::odocstream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2004-11-25 19:13:07 +00:00
|
|
|
|
InsetBase::Code lyxCode() const { return InsetBase::NO_CODE; }
|
2003-10-29 10:47:21 +00:00
|
|
|
|
|
2000-08-04 13:12:30 +00:00
|
|
|
|
///
|
2003-06-12 08:52:36 +00:00
|
|
|
|
InsetCommandParams const & params() const { return p_; }
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
|
/// FIXME remove
|
|
|
|
|
std::string const getContents() const { return p_.getContents(); }
|
|
|
|
|
/// FIXME remove
|
2005-07-17 14:32:59 +00:00
|
|
|
|
void setContents(std::string const & c)
|
2006-04-05 23:56:29 +00:00
|
|
|
|
{
|
|
|
|
|
updateButtonLabel_ = true;
|
|
|
|
|
p_.setContents(c);
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
|
void setParam(std::string const & name, lyx::docstring const & value)
|
|
|
|
|
{
|
|
|
|
|
updateButtonLabel_ = true;
|
|
|
|
|
p_[name] = value;
|
|
|
|
|
}
|
2003-09-04 14:02:05 +00:00
|
|
|
|
///
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
|
lyx::docstring const & getParam(std::string const & name) const
|
|
|
|
|
{
|
|
|
|
|
return p_[name];
|
|
|
|
|
}
|
|
|
|
|
/// FIXME remove
|
|
|
|
|
virtual void replaceContents(std::string const & from, std::string const & to);
|
|
|
|
|
/// FIXME remove
|
|
|
|
|
std::string const getOptions() const { return p_.getOptions(); }
|
|
|
|
|
/// FIXME remove
|
|
|
|
|
std::string const getSecOptions() const { return p_.getSecOptions(); }
|
2004-03-05 14:49:10 +00:00
|
|
|
|
///
|
2003-10-10 21:08:55 +00:00
|
|
|
|
RenderButton & button() const { return button_; }
|
2003-09-09 18:27:24 +00:00
|
|
|
|
|
2003-06-12 08:52:36 +00:00
|
|
|
|
protected:
|
2003-10-17 18:01:15 +00:00
|
|
|
|
///
|
2004-11-24 21:58:42 +00:00
|
|
|
|
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-04-22 08:57:22 +00:00
|
|
|
|
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
|
|
|
|
///
|
2006-10-19 16:51:30 +00:00
|
|
|
|
lyx::docstring const getCommand() const { return p_.getCommand(); }
|
2003-06-12 08:52:36 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const & getCmdName() const { return p_.getCmdName(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-07-17 14:32:59 +00:00
|
|
|
|
void setCmdName(std::string const & n)
|
2006-04-05 23:56:29 +00:00
|
|
|
|
{
|
|
|
|
|
updateButtonLabel_ = true;
|
|
|
|
|
p_.setCmdName(n);
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-07-17 14:32:59 +00:00
|
|
|
|
void setOptions(std::string const & o)
|
2006-04-05 23:56:29 +00:00
|
|
|
|
{
|
|
|
|
|
updateButtonLabel_ = true;
|
|
|
|
|
p_.setOptions(o);
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-07-17 14:32:59 +00:00
|
|
|
|
void setSecOptions(std::string const & s)
|
2006-04-05 23:56:29 +00:00
|
|
|
|
{
|
|
|
|
|
updateButtonLabel_ = true;
|
|
|
|
|
p_.setSecOptions(s);
|
|
|
|
|
}
|
2004-03-05 14:49:10 +00:00
|
|
|
|
///
|
2000-07-27 08:55:59 +00:00
|
|
|
|
void setParams(InsetCommandParams const &);
|
2003-06-12 08:52:36 +00:00
|
|
|
|
/// This should provide the text for the button
|
2006-10-11 19:40:50 +00:00
|
|
|
|
virtual lyx::docstring const getScreenLabel(Buffer const &) const = 0;
|
2002-02-27 15:19:21 +00:00
|
|
|
|
|
2000-06-07 08:53:40 +00:00
|
|
|
|
private:
|
2000-07-27 08:55:59 +00:00
|
|
|
|
///
|
|
|
|
|
InsetCommandParams p_;
|
2003-12-11 15:23:15 +00:00
|
|
|
|
std::string mailer_name_;
|
2005-07-17 14:32:59 +00:00
|
|
|
|
mutable bool updateButtonLabel_;
|
2003-10-10 21:08:55 +00:00
|
|
|
|
mutable RenderButton button_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
|
|
class InsetCommandMailer : public MailInset {
|
|
|
|
|
public:
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
InsetCommandMailer(std::string const & name, InsetCommand & inset);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
2003-03-10 13:33:39 +00:00
|
|
|
|
virtual InsetBase & inset() const { return inset_; }
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const & name() const { return name_; }
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const inset2string(Buffer const &) const;
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
2003-12-11 15:23:15 +00:00
|
|
|
|
static void string2params(std::string const &, std::string const & name,
|
|
|
|
|
InsetCommandParams &);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const params2string(std::string const & name,
|
2003-12-11 15:23:15 +00:00
|
|
|
|
InsetCommandParams const &);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const name_;
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
|
|
|
|
InsetCommand & inset_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#endif
|