lyx_mirror/src/mathed/InsetMathFrac.h
Enrico Forestieri 11c2b7792c Replacement for commits bc47054b and ad0d0f6d
The strategy adopted in bc47054b had some drawbacks related to the way
instant preview snippets are generated. See the subthread starting at
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg187916.html
for details.

The strategy adopted in this commit is that of adding macro definitions
only for the macros actually used in a preview snippet, independently
of whether some macro was already used in a previous snippet. In this way
the snippets don't need to be changed according to whether they are
compiled as a whole or separately from each other. This fact was causing
the regeneration of a preview snippet whenever the cursor entered the
corresponding inset, even if the generated image would have not changed.
The problem of defining or redefining a macro is taken care by the
python scripts.
2015-06-14 18:10:29 +02:00

150 lines
2.8 KiB
C++

// -*- C++ -*-
/**
* \file InsetMathFrac.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
* \author André Pönitz
* \author Uwe Stöhr
*
* Full author contact details are available in file CREDITS.
*/
#ifndef MATH_FRAC_H
#define MATH_FRAC_H
#include "InsetMathNest.h"
namespace lyx {
class InsetMathFracBase : public InsetMathNest {
public:
///
InsetMathFracBase(Buffer * buf, idx_type ncells = 2);
///
bool idxUpDown(Cursor &, bool up) const;
///
bool idxBackward(Cursor &) const { return false; }
///
bool idxForward(Cursor &) const { return false; }
///
InsetMathFracBase * asFracBaseInset() { return this; }
///
InsetMathFracBase const * asFracBaseInset() const { return this; }
};
/// Fraction like objects (frac, binom)
class InsetMathFrac : public InsetMathFracBase {
public:
///
enum Kind {
FRAC,
CFRAC,
CFRACLEFT,
CFRACRIGHT,
DFRAC,
TFRAC,
OVER,
ATOP,
NICEFRAC,
UNITFRAC,
UNIT
};
///
explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
///
bool idxForward(Cursor &) const;
///
bool idxBackward(Cursor &) const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo &, int x, int y) const;
///
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
///
void drawT(TextPainter &, int x, int y) const;
/// identifies FracInsets
InsetMathFrac * asFracInset();
/// identifies FracInsets
InsetMathFrac const * asFracInset() const;
///
docstring name() const;
///
bool extraBraces() const;
///
void write(WriteStream & os) const;
///
void maple(MapleStream &) const;
///
void mathematica(MathematicaStream &) const;
///
void octave(OctaveStream &) const;
///
void mathmlize(MathStream &) const;
///
void htmlize(HtmlStream &) const;
///
void validate(LaTeXFeatures & features) const;
public:
Inset * clone() const;
///
Kind kind_;
};
/// Binom like objects
class InsetMathBinom : public InsetMathFracBase {
public:
///
enum Kind {
BINOM,
DBINOM,
TBINOM,
CHOOSE,
BRACE,
BRACK
};
///
explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
///
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo &, int x, int y) const;
/// draw decorations.
void drawDecoration(PainterInfo & pi, int x, int y) const
{ drawMarkers2(pi, x, y); }
///
bool extraBraces() const;
///
void mathmlize(MathStream &) const;
///
void htmlize(HtmlStream &) const;
///
void validate(LaTeXFeatures & features) const;
///
InsetCode lyxCode() const { return MATH_FRAC_CODE; }
private:
Inset * clone() const;
///
int dw(int height) const;
///
Kind kind_;
};
} // namespace lyx
#endif