2010-11-21 17:00:12 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file InsetScript.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Georg Baum
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INSET_SCRIPT_H
|
|
|
|
#define INSET_SCRIPT_H
|
|
|
|
|
2020-12-02 20:34:28 +00:00
|
|
|
#include "FontInfo.h"
|
2010-11-21 17:00:12 +00:00
|
|
|
#include "InsetText.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
class InsetScriptParams
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Type {
|
|
|
|
Subscript,
|
|
|
|
Superscript
|
|
|
|
};
|
|
|
|
/// \c type defaults to Subscript
|
|
|
|
InsetScriptParams();
|
|
|
|
///
|
|
|
|
void write(std::ostream & os) const;
|
|
|
|
///
|
|
|
|
void read(Lexer & lex);
|
|
|
|
///
|
|
|
|
int shift(FontInfo const & font) const;
|
|
|
|
///
|
|
|
|
Type type;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// InsetScript
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/// The subscript and superscript inset
|
|
|
|
class InsetScript : public InsetText
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
InsetScript(Buffer *, InsetScriptParams const & = InsetScriptParams());
|
|
|
|
///
|
|
|
|
InsetScript(Buffer *, std::string const &);
|
|
|
|
///
|
|
|
|
~InsetScript();
|
|
|
|
///
|
|
|
|
static std::string params2string(InsetScriptParams const &);
|
|
|
|
///
|
|
|
|
static void string2params(std::string const &, InsetScriptParams &);
|
|
|
|
///
|
|
|
|
InsetScriptParams const & params() const { return params_; }
|
2010-11-25 13:00:31 +00:00
|
|
|
|
|
|
|
/// \name Public functions inherited from Inset class
|
|
|
|
//@{
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetCode lyxCode() const override { return SCRIPT_CODE; }
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring layoutName() const override;
|
2020-01-15 10:08:38 +00:00
|
|
|
|
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
int topOffset(BufferView const *) const override { return 0; }
|
2020-01-15 10:08:38 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
int bottomOffset(BufferView const *) const override { return 0; }
|
2020-01-15 10:08:38 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
int leftOffset(BufferView const *) const override { return 0; }
|
2020-01-15 10:08:38 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
int rightOffset(BufferView const *) const override { return 0; }
|
2020-01-15 10:08:38 +00:00
|
|
|
|
2018-09-12 13:26:15 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metrics(MetricsInfo &, Dimension &) const override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void draw(PainterInfo & pi, int x, int y) const override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2010-11-25 13:00:31 +00:00
|
|
|
void cursorPos(BufferView const & bv,
|
2020-10-01 07:42:11 +00:00
|
|
|
CursorSlice const & sl, bool boundary, int & x, int & y) const override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void write(std::ostream &) const override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void read(Lexer & lex) override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool forcePlainLayout(idx_type = 0) const override { return true; }
|
2016-05-12 12:10:30 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool allowParagraphCustomization(idx_type = 0) const override { return false; }
|
2016-05-12 15:31:47 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool neverIndent() const override { return true; }
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool inheritFont() const override { return true; }
|
2017-03-27 13:00:43 +00:00
|
|
|
///
|
2013-03-08 19:52:18 +00:00
|
|
|
int plaintext(odocstringstream & ods, OutputParams const & op,
|
2020-10-01 07:42:11 +00:00
|
|
|
size_t max_length = INT_MAX) const override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void docbook(XMLStream &, OutputParams const &) const override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
|
|
|
void edit(Cursor & cur, bool front,
|
2020-10-01 07:42:11 +00:00
|
|
|
EntryDirection entry_from = ENTRY_DIRECTION_IGNORE) override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * editXY(Cursor & cur, int x, int y) override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool insetAllowed(InsetCode code) const override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring toolTip(BufferView const & bv, int x, int y) const override;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * clone() const override { return new InsetScript(*this); }
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
std::string contextMenuName() const override;
|
2010-11-25 13:00:31 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/// \name Public functions inherited from InsetText class
|
|
|
|
//@{
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool allowMultiPar() const override { return false; }
|
2010-11-25 13:00:31 +00:00
|
|
|
//@}
|
2010-11-21 17:00:12 +00:00
|
|
|
|
2010-11-25 13:00:31 +00:00
|
|
|
protected:
|
|
|
|
/// \name Protected functions inherited from Inset class
|
|
|
|
//@{
|
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd) override;
|
2010-11-25 13:00:31 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// used by the constructors
|
|
|
|
void init();
|
|
|
|
///
|
|
|
|
friend class InsetScriptParams;
|
2010-11-21 17:00:12 +00:00
|
|
|
///
|
|
|
|
InsetScriptParams params_;
|
2019-03-22 15:13:30 +00:00
|
|
|
/// The font of containing inset; this is necessary to compute shift
|
|
|
|
mutable FontInfo outer_font_;
|
2010-11-21 17:00:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif
|