2001-02-16 09:25:43 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
* \file InsetMathFrac.h
|
2003-08-19 13:00:56 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Alejandro Aguilar Sierra
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2009-04-04 11:33:13 +00:00
|
|
|
* \author Uwe Stöhr
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2007-10-25 21:53:06 +00:00
|
|
|
#ifndef MATH_FRAC_H
|
|
|
|
#define MATH_FRAC_H
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2007-10-25 21:53:06 +00:00
|
|
|
#include "InsetMathNest.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-02-26 12:53:35 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
2007-10-25 21:53:06 +00:00
|
|
|
class InsetMathFracBase : public InsetMathNest {
|
|
|
|
public:
|
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathFracBase(Buffer * buf, idx_type ncells = 2);
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
|
|
|
bool idxUpDown(Cursor &, bool up) const;
|
|
|
|
///
|
2007-11-05 19:44:03 +00:00
|
|
|
bool idxBackward(Cursor &) const { return false; }
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
2007-11-05 19:44:03 +00:00
|
|
|
bool idxForward(Cursor &) const { return false; }
|
2015-06-14 16:10:29 +00:00
|
|
|
///
|
|
|
|
InsetMathFracBase * asFracBaseInset() { return this; }
|
|
|
|
///
|
|
|
|
InsetMathFracBase const * asFracBaseInset() const { return this; }
|
2007-10-25 21:53:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-08-19 13:00:56 +00:00
|
|
|
/// Fraction like objects (frac, binom)
|
2006-09-16 18:11:38 +00:00
|
|
|
class InsetMathFrac : public InsetMathFracBase {
|
2001-02-13 13:28:32 +00:00
|
|
|
public:
|
|
|
|
///
|
2006-04-06 09:46:01 +00:00
|
|
|
enum Kind {
|
|
|
|
FRAC,
|
2009-04-05 19:52:53 +00:00
|
|
|
CFRAC,
|
2009-04-06 23:58:42 +00:00
|
|
|
CFRACLEFT,
|
|
|
|
CFRACRIGHT,
|
2009-04-05 19:52:53 +00:00
|
|
|
DFRAC,
|
|
|
|
TFRAC,
|
2006-07-19 10:50:18 +00:00
|
|
|
OVER,
|
2006-04-06 09:46:01 +00:00
|
|
|
ATOP,
|
2007-09-12 08:15:33 +00:00
|
|
|
NICEFRAC,
|
2007-09-15 16:39:51 +00:00
|
|
|
UNITFRAC,
|
2007-09-18 15:04:58 +00:00
|
|
|
UNIT
|
2006-04-06 09:46:01 +00:00
|
|
|
};
|
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
|
2007-09-15 16:39:51 +00:00
|
|
|
///
|
2007-11-05 19:44:03 +00:00
|
|
|
bool idxForward(Cursor &) const;
|
2007-09-15 16:39:51 +00:00
|
|
|
///
|
2007-11-05 19:44:03 +00:00
|
|
|
bool idxBackward(Cursor &) const;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2007-09-21 20:39:47 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
2001-04-25 15:43:57 +00:00
|
|
|
///
|
2003-03-21 14:20:48 +00:00
|
|
|
void draw(PainterInfo &, int x, int y) const;
|
2001-11-13 18:33:48 +00:00
|
|
|
///
|
2003-05-28 13:22:36 +00:00
|
|
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
2002-03-19 16:55:58 +00:00
|
|
|
///
|
2002-03-21 06:57:13 +00:00
|
|
|
void drawT(TextPainter &, int x, int y) const;
|
2002-08-08 16:08:11 +00:00
|
|
|
/// identifies FracInsets
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathFrac * asFracInset();
|
2002-08-08 16:08:11 +00:00
|
|
|
/// identifies FracInsets
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathFrac const * asFracInset() const;
|
2002-08-01 15:53:46 +00:00
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
docstring name() const;
|
2006-07-16 17:19:05 +00:00
|
|
|
///
|
|
|
|
bool extraBraces() const;
|
2001-11-09 08:35:57 +00:00
|
|
|
///
|
|
|
|
void write(WriteStream & os) const;
|
|
|
|
///
|
2003-02-14 14:30:09 +00:00
|
|
|
void maple(MapleStream &) const;
|
2001-11-07 17:30:26 +00:00
|
|
|
///
|
2003-02-14 14:30:09 +00:00
|
|
|
void mathematica(MathematicaStream &) const;
|
2002-07-01 11:17:14 +00:00
|
|
|
///
|
2003-02-14 14:30:09 +00:00
|
|
|
void octave(OctaveStream &) const;
|
2002-04-25 15:37:10 +00:00
|
|
|
///
|
2009-12-31 15:46:39 +00:00
|
|
|
void mathmlize(MathStream &) const;
|
2006-04-06 09:46:01 +00:00
|
|
|
///
|
2010-03-30 02:03:45 +00:00
|
|
|
void htmlize(HtmlStream &) const;
|
|
|
|
///
|
2006-04-06 09:46:01 +00:00
|
|
|
void validate(LaTeXFeatures & features) const;
|
2001-08-17 17:50:00 +00:00
|
|
|
public:
|
2007-10-25 21:53:06 +00:00
|
|
|
Inset * clone() const;
|
2001-08-17 17:50:00 +00:00
|
|
|
///
|
2006-04-06 09:46:01 +00:00
|
|
|
Kind kind_;
|
2001-02-13 13:28:32 +00:00
|
|
|
};
|
2001-02-16 09:25:43 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2009-02-28 02:43:26 +00:00
|
|
|
|
2007-10-25 21:53:06 +00:00
|
|
|
/// Binom like objects
|
|
|
|
class InsetMathBinom : public InsetMathFracBase {
|
|
|
|
public:
|
|
|
|
///
|
2008-03-31 01:23:25 +00:00
|
|
|
enum Kind {
|
|
|
|
BINOM,
|
2009-04-05 19:52:53 +00:00
|
|
|
DBINOM,
|
|
|
|
TBINOM,
|
2008-03-31 01:23:25 +00:00
|
|
|
CHOOSE,
|
|
|
|
BRACE,
|
|
|
|
BRACK
|
|
|
|
};
|
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
|
|
|
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;
|
2008-03-31 01:23:25 +00:00
|
|
|
///
|
2009-12-31 15:46:39 +00:00
|
|
|
void mathmlize(MathStream &) const;
|
2007-10-28 21:48:51 +00:00
|
|
|
///
|
2010-03-31 21:33:33 +00:00
|
|
|
void htmlize(HtmlStream &) const;
|
|
|
|
///
|
2007-10-28 21:48:51 +00:00
|
|
|
void validate(LaTeXFeatures & features) const;
|
2009-07-16 19:00:24 +00:00
|
|
|
///
|
|
|
|
InsetCode lyxCode() const { return MATH_FRAC_CODE; }
|
2007-10-28 21:48:51 +00:00
|
|
|
private:
|
|
|
|
Inset * clone() const;
|
|
|
|
///
|
|
|
|
int dw(int height) const;
|
|
|
|
///
|
2009-04-05 19:52:53 +00:00
|
|
|
Kind kind_;
|
2007-10-28 21:48:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-05 19:52:53 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
2007-10-25 21:53:06 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
#endif
|