Small Inset isXXX methods cleanup

* rename isStretchableSpace to isHfill
 * inline a trivial method
 * remove InsetIPAMacro::isLineSeparator, which has the same value as default.
This commit is contained in:
Jean-Marc Lasgouttes 2013-07-18 10:55:52 +02:00
parent b2eba66083
commit d32f76f7fe
7 changed files with 12 additions and 29 deletions

View File

@ -3200,8 +3200,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
bool Paragraph::isHfill(pos_type pos) const bool Paragraph::isHfill(pos_type pos) const
{ {
Inset const * inset = getInset(pos); Inset const * inset = getInset(pos);
return inset && (inset->lyxCode() == SPACE_CODE && return inset && inset->isHfill();
inset->isStretchableSpace());
} }

View File

@ -672,8 +672,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
InsetList::const_iterator iend = par.insetList().end(); InsetList::const_iterator iend = par.insetList().end();
for ( ; ii != iend; ++ii) { for ( ; ii != iend; ++ii) {
if (ii->pos >= endpos || ii->pos < row.pos() if (ii->pos >= endpos || ii->pos < row.pos()
|| (ii->inset->lyxCode() != SPACE_CODE || || !ii->inset->isHfill())
!ii->inset->isStretchableSpace()))
continue; continue;
Dimension dim = row.dimension(); Dimension dim = row.dimension();
if (pm.hfillExpansion(row, ii->pos)) if (pm.hfillExpansion(row, ii->pos))

View File

@ -431,8 +431,8 @@ public:
/// is this equivalent to a space (which is BTW different from /// is this equivalent to a space (which is BTW different from
/// a line separator)? /// a line separator)?
virtual bool isSpace() const { return false; } virtual bool isSpace() const { return false; }
/// is this an expandible space (rubber length)? /// does this inset try to use all available space (like \\hfill does)?
virtual bool isStretchableSpace() const { return false; } virtual bool isHfill() const { return false; }
enum DisplayType { enum DisplayType {
Inline = 0, Inline = 0,

View File

@ -620,16 +620,4 @@ void InsetIPAChar::validate(LaTeXFeatures & features) const
} }
bool InsetIPAChar::isLetter() const
{
return true;
}
bool InsetIPAChar::isLineSeparator() const
{
return false;
}
} // namespace lyx } // namespace lyx

View File

@ -167,9 +167,7 @@ public:
/// should this inset be handled like a normal character? /// should this inset be handled like a normal character?
bool isChar() const { return true; } bool isChar() const { return true; }
/// is this equivalent to a letter? /// is this equivalent to a letter?
bool isLetter() const; bool isLetter() const { return true; }
/// should we break lines after this inset?
bool isLineSeparator() const;
private: private:
Inset * clone() const { return new InsetIPAChar(*this); } Inset * clone() const { return new InsetIPAChar(*this); }

View File

@ -199,7 +199,7 @@ int const arrow_size = 8;
void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
if (isStretchableSpace()) { if (isHfill()) {
// The metrics for this kinds are calculated externally in // The metrics for this kinds are calculated externally in
// \c TextMetrics::computeRowMetrics. Those are dummy value: // \c TextMetrics::computeRowMetrics. Those are dummy value:
dim = Dimension(10, 10, 10); dim = Dimension(10, 10, 10);
@ -240,7 +240,7 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
break; break;
case InsetSpaceParams::CUSTOM: case InsetSpaceParams::CUSTOM:
case InsetSpaceParams::CUSTOM_PROTECTED: { case InsetSpaceParams::CUSTOM_PROTECTED: {
int const w = int const w =
params_.length.len().inPixels(mi.base.textwidth, params_.length.len().inPixels(mi.base.textwidth,
fm.width(char_type('M'))); fm.width(char_type('M')));
int const minw = (w < 0) ? 3 * arrow_size : 4; int const minw = (w < 0) ? 3 * arrow_size : 4;
@ -267,7 +267,7 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
{ {
Dimension const dim = dimension(*pi.base.bv); Dimension const dim = dimension(*pi.base.bv);
if (isStretchableSpace() || params_.length.len().value() < 0) { if (isHfill() || params_.length.len().value() < 0) {
int const asc = theFontMetrics(pi.base.font).ascent('M'); int const asc = theFontMetrics(pi.base.font).ascent('M');
int const desc = theFontMetrics(pi.base.font).descent('M'); int const desc = theFontMetrics(pi.base.font).descent('M');
// Pixel height divisible by 2 for prettier fill graphics: // Pixel height divisible by 2 for prettier fill graphics:
@ -459,7 +459,7 @@ void InsetSpaceParams::write(ostream & os) const
os << "\\hspace*{}"; os << "\\hspace*{}";
break; break;
} }
if (!length.len().empty()) if (!length.len().empty())
os << "\n\\length " << length.asString(); os << "\n\\length " << length.asString();
} }
@ -837,7 +837,7 @@ void InsetSpace::forOutliner(docstring & os, size_t) const
} }
bool InsetSpace::isStretchableSpace() const bool InsetSpace::isHfill() const
{ {
return params_.kind == InsetSpaceParams::HFILL return params_.kind == InsetSpaceParams::HFILL
|| params_.kind == InsetSpaceParams::HFILL_PROTECTED || params_.kind == InsetSpaceParams::HFILL_PROTECTED

View File

@ -142,9 +142,8 @@ public:
bool clickable(int, int) const { return true; } bool clickable(int, int) const { return true; }
/// ///
InsetCode lyxCode() const { return SPACE_CODE; } InsetCode lyxCode() const { return SPACE_CODE; }
/// is this an expandible space (rubber length)? /// does this inset try to use all available space (like \\hfill does)?
bool isStretchableSpace() const; bool isHfill() const;
/// should this inset be handled like a normal character? /// should this inset be handled like a normal character?
bool isChar() const { return true; } bool isChar() const { return true; }
/// is this equivalent to a letter? /// is this equivalent to a letter?