2001-02-13 13:28:32 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
* \file InsetMathHull.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.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2001-11-08 12:30:26 +00:00
|
|
|
#ifndef MATH_HULLINSET_H
|
|
|
|
#define MATH_HULLINSET_H
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathGrid.h"
|
2008-02-15 08:09:35 +00:00
|
|
|
|
2010-01-20 19:42:12 +00:00
|
|
|
#include "OutputEnums.h"
|
|
|
|
|
2004-04-13 17:38:16 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2008-03-04 12:22:48 +00:00
|
|
|
class InsetLabel;
|
2008-02-15 08:09:35 +00:00
|
|
|
class ParConstIterator;
|
2004-04-13 17:38:16 +00:00
|
|
|
class RenderPreview;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-02-26 12:53:35 +00:00
|
|
|
|
2003-08-19 13:00:56 +00:00
|
|
|
/// This provides an interface between "LyX insets" and "LyX math insets"
|
2006-09-16 18:11:38 +00:00
|
|
|
class InsetMathHull : public InsetMathGrid {
|
2002-03-21 17:42:56 +00:00
|
|
|
public:
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathHull(Buffer * buf);
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathHull(Buffer * buf, HullType type);
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2010-05-03 22:55:40 +00:00
|
|
|
virtual ~InsetMathHull();
|
2004-04-13 17:38:16 +00:00
|
|
|
///
|
2008-03-04 12:22:48 +00:00
|
|
|
void setBuffer(Buffer &);
|
|
|
|
///
|
2010-03-03 22:13:45 +00:00
|
|
|
void updateBuffer(ParIterator const &, UpdateType);
|
2008-03-04 12:22:48 +00:00
|
|
|
///
|
2008-05-13 08:23:44 +00:00
|
|
|
void addToToc(DocIterator const &);
|
2008-02-15 08:09:35 +00:00
|
|
|
///
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathHull & operator=(InsetMathHull const &);
|
2004-04-13 17:38:16 +00:00
|
|
|
///
|
2002-07-18 11:02:33 +00:00
|
|
|
mode_type currentMode() const;
|
|
|
|
///
|
2007-09-21 20:39:47 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
2008-10-25 10:47:38 +00:00
|
|
|
///
|
|
|
|
void drawBackground(PainterInfo & pi, int x, int y) const;
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2003-03-21 14:20:48 +00:00
|
|
|
void draw(PainterInfo &, int x, int y) const;
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2003-05-28 13:22:36 +00:00
|
|
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
///
|
2002-05-02 07:30:49 +00:00
|
|
|
void drawT(TextPainter &, int x, int y) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
docstring label(row_type row) const;
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
void label(row_type row, docstring const & label);
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2010-01-28 09:18:15 +00:00
|
|
|
std::vector<InsetLabel *> const & getLabels() { return label_; }
|
2010-01-27 08:41:19 +00:00
|
|
|
///
|
2009-12-17 14:09:37 +00:00
|
|
|
ColorCode backgroundColor(PainterInfo const &) const;
|
2008-10-25 10:47:38 +00:00
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
void numbered(row_type row, bool num);
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
bool numbered(row_type row) const;
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
bool numberedType() const;
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
bool ams() const;
|
2001-02-16 09:25:43 +00:00
|
|
|
///
|
2001-07-26 06:56:43 +00:00
|
|
|
void validate(LaTeXFeatures & features) const;
|
2005-10-14 10:50:23 +00:00
|
|
|
/// identifies HullInset
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathHull const * asHullInset() const { return this; }
|
2001-11-09 08:35:57 +00:00
|
|
|
/// identifies HullInset
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathHull * asHullInset() { return this; }
|
2001-02-16 09:25:43 +00:00
|
|
|
|
2002-08-21 13:47:52 +00:00
|
|
|
/// add a row
|
|
|
|
void addRow(row_type row);
|
|
|
|
/// delete a row
|
|
|
|
void delRow(row_type row);
|
2004-11-23 14:43:37 +00:00
|
|
|
/// swap two rows
|
2003-10-06 09:57:03 +00:00
|
|
|
void swapRow(row_type row);
|
2002-08-21 13:47:52 +00:00
|
|
|
/// add a column
|
|
|
|
void addCol(col_type col);
|
|
|
|
/// delete a column
|
|
|
|
void delCol(col_type col);
|
2001-02-16 09:25:43 +00:00
|
|
|
|
2002-07-03 10:36:44 +00:00
|
|
|
/// get type
|
2006-09-03 16:14:51 +00:00
|
|
|
HullType getType() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
/// change type
|
2006-09-03 16:14:51 +00:00
|
|
|
void mutate(HullType newtype);
|
2001-09-04 13:32:06 +00:00
|
|
|
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
int defaultColSpace(col_type col);
|
2001-09-04 13:32:06 +00:00
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
char defaultColAlign(col_type col);
|
2002-06-18 15:44:30 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool idxFirst(Cursor &) const;
|
2002-06-18 15:44:30 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool idxLast(Cursor &) const;
|
2001-02-16 09:25:43 +00:00
|
|
|
|
2001-11-07 18:15:24 +00:00
|
|
|
///
|
2001-11-09 18:02:20 +00:00
|
|
|
void write(WriteStream & os) const;
|
|
|
|
///
|
2009-12-31 15:46:39 +00:00
|
|
|
void mathmlize(MathStream &) const;
|
2001-11-09 18:02:20 +00:00
|
|
|
///
|
|
|
|
void normalize(NormalStream &) const;
|
2002-05-30 07:09:54 +00:00
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
void infoize(odocstream & os) const;
|
2001-08-01 13:28:45 +00:00
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void write(std::ostream & os) const;
|
2004-01-30 11:41:12 +00:00
|
|
|
///
|
2008-11-16 00:18:52 +00:00
|
|
|
void header_write(WriteStream &) const;
|
|
|
|
///
|
|
|
|
void footer_write(WriteStream &) const;
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void read(Lexer & lex);
|
2004-01-30 11:41:12 +00:00
|
|
|
///
|
2008-10-31 15:19:39 +00:00
|
|
|
bool readQuiet(Lexer & lex);
|
2008-10-17 21:40:11 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int plaintext(odocstream &, OutputParams const &) const;
|
2004-01-30 11:41:12 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int docbook(odocstream &, OutputParams const &) const;
|
2009-11-14 15:25:32 +00:00
|
|
|
///
|
2009-12-15 13:14:57 +00:00
|
|
|
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
2005-11-25 14:40:34 +00:00
|
|
|
/// the string that is passed to the TOC
|
2009-07-13 09:50:46 +00:00
|
|
|
void tocString(odocstream &) const;
|
2004-01-30 11:41:12 +00:00
|
|
|
|
2004-04-13 17:38:16 +00:00
|
|
|
/// get notification when the cursor leaves this inset
|
2008-02-22 20:45:18 +00:00
|
|
|
bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
|
2004-01-30 11:41:12 +00:00
|
|
|
///
|
2007-10-13 09:04:52 +00:00
|
|
|
//bool insetAllowed(InsetCode code) const;
|
2004-01-30 11:41:12 +00:00
|
|
|
///
|
2009-11-22 21:45:51 +00:00
|
|
|
void addPreview(DocIterator const & inset_pos,
|
2009-11-22 20:50:35 +00:00
|
|
|
graphics::PreviewLoader &) const;
|
2009-12-05 01:07:38 +00:00
|
|
|
/// Prepare the preview if preview is enabled.
|
2009-12-05 00:43:28 +00:00
|
|
|
void preparePreview(DocIterator const & pos) const;
|
2009-12-05 01:07:38 +00:00
|
|
|
/// Recreates the preview if preview is enabled.
|
|
|
|
void reloadPreview(DocIterator const & pos) const;
|
2008-09-26 15:53:15 +00:00
|
|
|
///
|
|
|
|
void initUnicodeMath() const;
|
2004-01-30 11:41:12 +00:00
|
|
|
|
2006-09-08 13:52:41 +00:00
|
|
|
///
|
|
|
|
static int displayMargin() { return 12; }
|
2007-11-05 23:44:47 +00:00
|
|
|
|
2010-05-22 00:46:57 +00:00
|
|
|
/// Force inset into LTR environment if surroundings are RTL
|
2007-11-05 23:44:47 +00:00
|
|
|
virtual bool forceLTR() const { return true; }
|
2007-05-11 02:34:56 +00:00
|
|
|
|
2008-03-09 15:07:27 +00:00
|
|
|
///
|
|
|
|
virtual docstring contextMenu(BufferView const &, int, int) const;
|
2009-07-16 19:00:24 +00:00
|
|
|
///
|
|
|
|
InsetCode lyxCode() const { return MATH_HULL_CODE; }
|
2008-03-09 15:07:27 +00:00
|
|
|
|
2002-08-15 17:41:24 +00:00
|
|
|
protected:
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathHull(InsetMathHull const &);
|
2004-11-23 23:04:52 +00:00
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
2004-11-23 23:04:52 +00:00
|
|
|
|
2004-04-06 19:25:39 +00:00
|
|
|
/// do we want to handle this event?
|
2007-04-26 14:56:30 +00:00
|
|
|
bool getStatus(Cursor & cur, FuncRequest const & cmd,
|
2004-04-06 19:25:39 +00:00
|
|
|
FuncStatus & status) const;
|
2002-12-01 22:59:25 +00:00
|
|
|
///
|
2010-07-04 16:31:53 +00:00
|
|
|
docstring eolString(row_type row, bool fragile, bool last_eoln) const;
|
2002-08-15 17:41:24 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
private:
|
2007-08-30 18:03:17 +00:00
|
|
|
virtual Inset * clone() const;
|
2001-09-04 13:32:06 +00:00
|
|
|
///
|
2006-09-03 16:14:51 +00:00
|
|
|
void setType(HullType type);
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2001-07-26 06:56:43 +00:00
|
|
|
void validate1(LaTeXFeatures & features);
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring nicelabel(row_type row) const;
|
2002-06-24 15:37:14 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void doExtern(Cursor & cur, FuncRequest & func);
|
2002-08-14 16:43:16 +00:00
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
void glueall();
|
2004-09-13 18:14:37 +00:00
|
|
|
/*!
|
|
|
|
* split every row at the first relation operator.
|
|
|
|
* The number of columns must be 1. One column is added.
|
|
|
|
* The first relation operator and everything after it goes to the
|
|
|
|
* second column.
|
|
|
|
*/
|
|
|
|
void splitTo2Cols();
|
|
|
|
/*!
|
|
|
|
* split every row at the first relation operator.
|
|
|
|
* The number of columns must be < 3. One or two columns are added.
|
|
|
|
* The first relation operator goes to the second column.
|
|
|
|
* Everything after it goes to the third column.
|
|
|
|
*/
|
|
|
|
void splitTo3Cols();
|
|
|
|
/// change number of columns, split or combine columns if necessary.
|
|
|
|
void changeCols(col_type);
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
docstring standardFont() const;
|
Index: src/mathed/InsetMathHull.cpp
===================================================================
--- src/mathed/InsetMathHull.cpp (revisione 34304)
+++ src/mathed/InsetMathHull.cpp (copia locale)
@@ -328,6 +328,23 @@ docstring InsetMathHull::standardFont()
}
+docstring InsetMathHull::standardColor() const
+{
+ docstring color;
+ switch (type_) {
+ case hullRegexp:
+ color = from_ascii("foreground");
+ break;
+ case hullNone:
+ color = from_ascii("foreground");
+ break;
+ default:
+ color = from_ascii("math");
+ }
+ return color;
+}
+
+
bool InsetMathHull::previewState(BufferView * bv) const
{
if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON) {
@@ -417,8 +434,11 @@ void InsetMathHull::draw(PainterInfo & p
return;
}
+ bool const really_change_color = pi.base.font.color() == Color_none;
+ ColorChanger dummy0(pi.base.font, standardColor(), really_change_color);
FontSetChanger dummy1(pi.base, standardFont());
StyleChanger dummy2(pi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
+
InsetMathGrid::draw(pi, x + 1, y);
if (numberedType()) {
Index: src/mathed/MathSupport.cpp
===================================================================
--- src/mathed/MathSupport.cpp (revisione 34311)
+++ src/mathed/MathSupport.cpp (copia locale)
@@ -653,6 +653,13 @@ bool isMathFont(docstring const & name)
}
+bool isTextFont(docstring const & name)
+{
+ fontinfo * f = lookupFont(name);
+ return f && f->color_ == Color_foreground;
+}
+
+
FontInfo getFont(docstring const & name)
{
FontInfo font;
Index: src/mathed/MathSupport.h
===================================================================
--- src/mathed/MathSupport.h (revisione 34311)
+++ src/mathed/MathSupport.h (copia locale)
@@ -51,6 +51,8 @@ bool isFontName(docstring const & name);
bool isMathFont(docstring const & name);
+bool isTextFont(docstring const & name);
+
// converts single cell to string
docstring asString(MathData const & ar);
// converts single inset to string
Index: src/mathed/InsetMathHull.h
===================================================================
--- src/mathed/InsetMathHull.h (revisione 34304)
+++ src/mathed/InsetMathHull.h (copia locale)
@@ -197,6 +197,8 @@ private:
void changeCols(col_type);
///
docstring standardFont() const;
+ ///
+ docstring standardColor() const;
/// consistency check
void check() const;
/// can this change its number of rows?
Index: src/MetricsInfo.cpp
===================================================================
--- src/MetricsInfo.cpp (revisione 34312)
+++ src/MetricsInfo.cpp (copia locale)
@@ -235,11 +235,15 @@ FontSetChanger::FontSetChanger(MetricsBa
save_ = mb;
FontSize oldsize = save_.font.size();
ColorCode oldcolor = save_.font.color();
+ docstring const oldname = from_ascii(save_.fontname);
mb.fontname = name;
mb.font = sane_font;
augmentFont(mb.font, from_ascii(name));
mb.font.setSize(oldsize);
- mb.font.setColor(oldcolor);
+ if (string(name) != "lyxtex"
+ && ((isTextFont(oldname) && oldcolor != Color_foreground)
+ || (isMathFont(oldname) && oldcolor != Color_math)))
+ mb.font.setColor(oldcolor);
}
}
@@ -252,11 +256,15 @@ FontSetChanger::FontSetChanger(MetricsBa
save_ = mb;
FontSize oldsize = save_.font.size();
ColorCode oldcolor = save_.font.color();
+ docstring const oldname = from_ascii(save_.fontname);
mb.fontname = to_utf8(name);
mb.font = sane_font;
augmentFont(mb.font, name);
mb.font.setSize(oldsize);
- mb.font.setColor(oldcolor);
+ if (name != "lyxtex"
+ && ((isTextFont(oldname) && oldcolor != Color_foreground)
+ || (isMathFont(oldname) && oldcolor != Color_math)))
+ mb.font.setColor(oldcolor);
}
}
@@ -294,17 +302,21 @@ WidthChanger::~WidthChanger()
//
/////////////////////////////////////////////////////////////////////////
-ColorChanger::ColorChanger(FontInfo & font, string const & color)
- : Changer<FontInfo, string>(font)
+ColorChanger::ColorChanger(FontInfo & font, docstring const & color,
+ bool really_change_color)
+ : Changer<FontInfo, ColorCode>(font), change_(really_change_color)
{
- save_ = lcolor.getFromLyXName(color);
- font.setColor(lcolor.getFromLyXName(color));
+ if (change_) {
+ save_ = font.color();
+ font.setColor(lcolor.getFromLyXName(to_utf8(color)));
+ }
}
ColorChanger::~ColorChanger()
{
- orig_.setColor(lcolor.getFromLyXName(save_));
+ if (change_)
+ orig_.setColor(save_);
}
Index: src/MetricsInfo.h
===================================================================
--- src/MetricsInfo.h (revisione 34312)
+++ src/MetricsInfo.h (copia locale)
@@ -222,12 +222,16 @@ public:
// temporarily change the used color
-class ColorChanger : public Changer<FontInfo, std::string> {
+class ColorChanger : public Changer<FontInfo, ColorCode> {
public:
///
- ColorChanger(FontInfo & font, std::string const & color);
+ ColorChanger(FontInfo & font, docstring const & color,
+ bool really_change_color = true);
///
~ColorChanger();
+private:
+ ///
+ bool change_;
};
} // namespace lyx
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34320 a592a061-630c-0410-9148-cb99ea01b6c8
2010-04-28 01:40:11 +00:00
|
|
|
///
|
|
|
|
docstring standardColor() const;
|
2001-12-11 15:04:02 +00:00
|
|
|
/// consistency check
|
|
|
|
void check() const;
|
2004-11-23 14:43:37 +00:00
|
|
|
/// can this change its number of rows?
|
|
|
|
bool rowChangeOK() const;
|
2002-08-21 13:47:52 +00:00
|
|
|
/// can this change its number of cols?
|
|
|
|
bool colChangeOK() const;
|
2001-02-16 09:25:43 +00:00
|
|
|
|
2002-07-04 11:00:51 +00:00
|
|
|
/// "none", "simple", "display", "eqnarray",...
|
2006-09-03 16:14:51 +00:00
|
|
|
HullType type_;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2008-03-04 12:22:48 +00:00
|
|
|
std::vector<bool> nonum_;
|
2001-06-25 00:06:33 +00:00
|
|
|
///
|
2008-03-04 12:22:48 +00:00
|
|
|
std::vector<InsetLabel *> label_;
|
2004-04-13 17:38:16 +00:00
|
|
|
///
|
|
|
|
boost::scoped_ptr<RenderPreview> preview_;
|
2005-07-18 00:45:10 +00:00
|
|
|
///
|
|
|
|
mutable bool use_preview_;
|
2004-01-26 10:13:15 +00:00
|
|
|
//
|
|
|
|
// Incorporate me
|
|
|
|
//
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
virtual void mutateToText();
|
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual void revealCodes(Cursor & cur) const;
|
2004-01-26 10:13:15 +00:00
|
|
|
///
|
2009-04-22 20:55:13 +00:00
|
|
|
bool editable() const { return true; }
|
2004-01-26 10:13:15 +00:00
|
|
|
///
|
2008-02-10 19:52:45 +00:00
|
|
|
void edit(Cursor & cur, bool front,
|
2008-02-11 08:20:13 +00:00
|
|
|
EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
|
2004-04-06 19:25:39 +00:00
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
Inset * editXY(Cursor & cur, int x, int y);
|
2005-07-15 00:39:44 +00:00
|
|
|
///
|
2007-05-18 14:32:29 +00:00
|
|
|
DisplayType display() const;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void handleFont(Cursor & cur, docstring const & arg,
|
2006-10-22 10:15:23 +00:00
|
|
|
docstring const & font);
|
2005-07-18 00:45:10 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void handleFont2(Cursor & cur, docstring const & arg);
|
2004-01-26 10:13:15 +00:00
|
|
|
///
|
2005-07-18 00:45:10 +00:00
|
|
|
bool previewState(BufferView * bv) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
};
|
2001-02-16 09:25:43 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
2001-02-13 13:28:32 +00:00
|
|
|
#endif
|