#include "InsetSpecialChar.h"
#include "debug.h"
+#include "Dimension.h"
#include "LaTeXFeatures.h"
-#include "LColor.h"
#include "Lexer.h"
#include "MetricsInfo.h"
namespace lyx {
using std::string;
-using std::auto_ptr;
using std::ostream;
}
-bool InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
{
frontend::FontMetrics const & fm =
theFontMetrics(mi.base.font);
case MENU_SEPARATOR: s = " x "; break;
case HYPHENATION: s = "-"; break;
}
- docstring ds(s.begin(), s.end());
+ docstring ds(s.begin(), s.end());
dim.wid = fm.width(ds);
if (kind_ == HYPHENATION && dim.wid > 5)
dim.wid -= 2; // to make it look shorter
- bool const changed = dim_ != dim;
- dim_ = dim;
- return changed;
+
+ setDimCache(mi, dim);
}
void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
{
- LyXFont font = pi.base.font;
+ FontInfo font = pi.base.font;
switch (kind_) {
case HYPHENATION:
{
- font.setColor(LColor::special);
+ font.setColor(Color_special);
pi.pain.text(x, y, char_type('-'), font);
break;
}
case LIGATURE_BREAK:
{
- font.setColor(LColor::special);
+ font.setColor(Color_special);
pi.pain.text(x, y, char_type('|'), font);
break;
}
case END_OF_SENTENCE:
{
- font.setColor(LColor::special);
+ font.setColor(Color_special);
pi.pain.text(x, y, char_type('.'), font);
break;
}
case LDOTS:
{
- font.setColor(LColor::special);
- string ell = ". . . ";
- docstring dell(ell.begin(), ell.end());
+ font.setColor(Color_special);
+ string ell = ". . . ";
+ docstring dell(ell.begin(), ell.end());
pi.pain.text(x, y, dell, font);
break;
}
theFontMetrics(font);
// A triangle the width and height of an 'x'
- int w = fm.width(char_type('x'));
+ int w = fm.width(char_type('x'));
int ox = fm.width(char_type(' ')) + x;
int h = fm.ascent(char_type('x'));
int xp[4], yp[4];
xp[2] = ox + w; yp[2] = y - h/2;
xp[3] = ox; yp[3] = y;
- pi.pain.lines(xp, yp, 4, LColor::special);
+ pi.pain.lines(xp, yp, 4, Color_special);
break;
}
}
int InsetSpecialChar::plaintext(Buffer const &, odocstream & os,
- OutputParams const &) const
+ OutputParams const &) const
{
switch (kind_) {
case HYPHENATION:
int InsetSpecialChar::docbook(Buffer const &, odocstream & os,
- OutputParams const &) const
+ OutputParams const &) const
{
switch (kind_) {
case HYPHENATION:
}
-auto_ptr<InsetBase> InsetSpecialChar::doClone() const
+Inset * InsetSpecialChar::clone() const
{
- return auto_ptr<InsetBase>(new InsetSpecialChar(kind_));
+ return new InsetSpecialChar(kind_);
}
void InsetSpecialChar::validate(LaTeXFeatures & features) const
{
- if (kind_ == MENU_SEPARATOR) {
+ if (kind_ == MENU_SEPARATOR)
features.require("lyxarrow");
- }
}