A basic class like Length should not depend on something from
frontend.
This change allows to remove several dummy implementations of
theFontMetrics().
16 files changed:
#include "Length.h"
#include "LyXRC.h"
#include "Length.h"
#include "LyXRC.h"
-#include "MetricsInfo.h"
-
-#include "frontends/FontMetrics.h"
#include "support/debug.h"
#include "support/docstream.h"
#include "support/debug.h"
#include "support/docstream.h"
-int Length::inPixels(MetricsBase const & base) const
-{
- FontInfo fi = base.font;
- if (unit_ == Length::MU)
- // mu is 1/18th of an em in the math symbol font
- fi.setFamily(SYMBOL_FAMILY);
- else
- // Math style is only taken into account in the case of mu
- fi.setStyle(LM_ST_TEXT);
- return inPixels(base.textwidth, theFontMetrics(fi).em());
-}
-
-
int Length::inBP() const
{
// return any Length value as a one with
int Length::inBP() const
{
// return any Length value as a one with
// Solaris/x86 version 9 and earlier define these
#undef PC
#undef SP
// Solaris/x86 version 9 and earlier define these
#undef PC
#undef SP
*/
int inPixels(int text_width, int em_width = 0) const;
*/
int inPixels(int text_width, int em_width = 0) const;
- /** return the on-screen size of this length
- *
- * This version of the function uses the current inset width as
- * width and the EM value of the current font.
- */
- int inPixels(MetricsBase const &) const;
/// return the value in Big Postscript points.
/// Caution: Inaccurate for em, ex, mu and percent units.
int inBP() const;
/// return the value in Big Postscript points.
/// Caution: Inaccurate for em, ex, mu and percent units.
int inBP() const;
#include "mathed/MathSupport.h"
#include "mathed/MathSupport.h"
+#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include "support/docstring.h"
#include "frontends/Painter.h"
#include "support/docstring.h"
+int MetricsBase::inPixels(Length const & len) const
+{
+ FontInfo fi = font;
+ if (len.unit() == Length::MU)
+ // mu is 1/18th of an em in the math symbol font
+ fi.setFamily(SYMBOL_FAMILY);
+ else
+ // Math style is only taken into account in the case of mu
+ fi.setStyle(LM_ST_TEXT);
+ return len.inPixels(textwidth, theFontMetrics(fi).em());
+}
+
+
/////////////////////////////////////////////////////////////////////////
//
// MetricsInfo
/////////////////////////////////////////////////////////////////////////
//
// MetricsInfo
namespace frontend { class Painter; }
class BufferView;
namespace frontend { class Painter; }
class BufferView;
int solidLineOffset() const { return solid_line_offset_; }
///
int dottedLineThickness() const { return dotted_line_thickness_; }
int solidLineOffset() const { return solid_line_offset_; }
///
int dottedLineThickness() const { return dotted_line_thickness_; }
+ /** return the on-screen size of this length
+ *
+ * This version of the function uses the current inset width as
+ * width and the EM value of the current font.
+ */
+ int inPixels(Length const & len) const;
+
private:
int solid_line_thickness_;
int solid_line_offset_;
private:
int solid_line_thickness_;
int solid_line_offset_;
-void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
+void InsetBox::metrics(MetricsInfo & mi, Dimension & dim) const
- int textwidth_backup = m.base.textwidth;
+ int textwidth_backup = mi.base.textwidth;
- m.base.textwidth = params_.width.inPixels(m.base);
- InsetCollapsible::metrics(m, dim);
+ mi.base.textwidth = mi.base.inPixels(params_.width);
+ InsetCollapsible::metrics(mi, dim);
- m.base.textwidth = textwidth_backup;
+ mi.base.textwidth = textwidth_backup;
int const max_width = mi.base.textwidth;
Length const width(to_ascii(getParam("width")));
int const max_width = mi.base.textwidth;
Length const width(to_ascii(getParam("width")));
- dim.wid = width.inPixels(mi.base);
+ dim.wid = mi.base.inPixels(width);
// assure that the line inset is not outside of the window
// check that it doesn't exceed the outer boundary
// assure that the line inset is not outside of the window
// check that it doesn't exceed the outer boundary
dim.wid = max(minw, abs(dim.wid));
Length height = Length(to_ascii(getParam("height")));
dim.wid = max(minw, abs(dim.wid));
Length height = Length(to_ascii(getParam("height")));
- height_ = height.inPixels(mi.base);
+ height_ = mi.base.inPixels(height);
// get the length of the parameters in pixels
Length offset = Length(to_ascii(getParam("offset")));
// get the length of the parameters in pixels
Length offset = Length(to_ascii(getParam("offset")));
- offset_ = offset.inPixels(mi.base);
+ offset_ = mi.base.inPixels(offset);
dim.asc = max(fm.maxAscent(), offset_ + height_);
dim.des = max(fm.maxDescent(), - offset_);
dim.asc = max(fm.maxAscent(), offset_ + height_);
dim.des = max(fm.maxDescent(), - offset_);
break;
case InsetSpaceParams::CUSTOM:
case InsetSpaceParams::CUSTOM_PROTECTED: {
break;
case InsetSpaceParams::CUSTOM:
case InsetSpaceParams::CUSTOM_PROTECTED: {
- int const w =
- params_.length.len().inPixels(mi.base);
+ int const w = mi.base.inPixels(params_.length.len());
int const minw = (w < 0) ? 3 * arrow_size : 4;
dim.wid = max(minw, abs(w));
break;
int const minw = (w < 0) ? 3 * arrow_size : 4;
dim.wid = max(minw, abs(w));
break;
MetricsInfo m = mi;
Length const p_width = tabular.getPWidth(cell);
if (!p_width.zero())
MetricsInfo m = mi;
Length const p_width = tabular.getPWidth(cell);
if (!p_width.zero())
- m.base.textwidth = p_width.inPixels(mi.base);
+ m.base.textwidth = mi.base.inPixels(p_width);
tabular.cellInset(cell)->metrics(m, dim);
if (!p_width.zero())
dim.wid = m.base.textwidth;
tabular.cellInset(cell)->metrics(m, dim);
if (!p_width.zero())
dim.wid = m.base.textwidth;
maxdes = max(maxdes, dim.des + offset);
}
int const top_space = tabular.row_info[r].top_space_default ?
maxdes = max(maxdes, dim.des + offset);
}
int const top_space = tabular.row_info[r].top_space_default ?
- default_line_space :
- tabular.row_info[r].top_space.inPixels(mi.base);
+ default_line_space :
+ mi.base.inPixels(tabular.row_info[r].top_space);
tabular.setRowAscent(r, maxasc + ADD_TO_HEIGHT + top_space);
int const bottom_space = tabular.row_info[r].bottom_space_default ?
tabular.setRowAscent(r, maxasc + ADD_TO_HEIGHT + top_space);
int const bottom_space = tabular.row_info[r].bottom_space_default ?
- default_line_space :
- tabular.row_info[r].bottom_space.inPixels(mi.base);
+ default_line_space :
+ mi.base.inPixels(tabular.row_info[r].bottom_space);
tabular.setRowDescent(r, maxdes + ADD_TO_HEIGHT + bottom_space);
}
tabular.setRowDescent(r, maxdes + ADD_TO_HEIGHT + bottom_space);
}
int InsetMathGrid::RowInfo::skipPixels(MetricsInfo const & mi) const
{
int InsetMathGrid::RowInfo::skipPixels(MetricsInfo const & mi) const
{
- return crskip_.inPixels(mi.base);
+ return mi.base.inPixels(crskip_);
if (l)
// Value was hardcoded to 30 pixels
if (l)
// Value was hardcoded to 30 pixels
- dim.wid += Length(0.3, Length::IN).inPixels(mi.base) + l;
+ dim.wid += mi.base.inPixels(Length(0.3, Length::IN)) + l;
}
// reserve some space for marker.
}
// reserve some space for marker.
if (l)
// Value was hardcoded to 30 pixels
if (l)
// Value was hardcoded to 30 pixels
- xmath += Length(0.3, Length::IN).inPixels(pi.base) + l;
+ xmath += pi.base.inPixels(Length(0.3, Length::IN)) + l;
}
InsetMathGrid::draw(pi, xmath + 1, y);
}
InsetMathGrid::draw(pi, xmath + 1, y);
{
dim.asc = 0;
dim.des = 0;
{
dim.asc = 0;
dim.des = 0;
- dim.wid = wid_.inPixels(mi.base);
+ dim.wid = mi.base.inPixels(wid_);
dim.asc = 4;
dim.des = 0;
if (space_info[space_].custom)
dim.asc = 4;
dim.des = 0;
if (space_info[space_].custom)
- dim.wid = abs(length_.inPixels(mi.base));
+ dim.wid = abs(mi.base.inPixels(length_));
else
dim.wid = space_info[space_].width;
}
else
dim.wid = space_info[space_].width;
}
int mathed_mu(FontInfo const & font, double mu)
{
MetricsBase mb(nullptr, font);
int mathed_mu(FontInfo const & font, double mu)
{
MetricsBase mb(nullptr, font);
- return Length(mu, Length::MU).inPixels(mb);
+ return mb.inPixels(Length(mu, Length::MU));
}
int mathed_thinmuskip(FontInfo const & font) { return mathed_mu(font, 3.0); }
}
int mathed_thinmuskip(FontInfo const & font) { return mathed_mu(font, 3.0); }
- //
- // Dummy FontMetrics (needed by Length)
- //
- namespace frontend {
- class FontMetrics {
- int em() const { return 0; };
- };
- } // namespace frontend
-
- class FontInfo;
-
- frontend::FontMetrics const & theFontMetrics(FontInfo const &) {
- static frontend::FontMetrics dummy;
- return dummy;
- }
-
- //
- // Dummy FontMetrics (needed by Length)
- //
- namespace frontend {
- class FontMetrics {
- int em() const { return 0; };
- };
- } // namespace frontend
-
- class FontInfo;
-
- frontend::FontMetrics const & theFontMetrics(FontInfo const &) {
- static frontend::FontMetrics dummy;
- return dummy;
- }
-
-//
-// Dummy FontMetrics (needed by Length)
-//
-
-namespace frontend {
-class FontMetrics {
- int em() const { return 0; };
-};
-} // namespace frontend
-
-class FontInfo;
-
-frontend::FontMetrics const & theFontMetrics(FontInfo const &) {
- static frontend::FontMetrics dummy;
- return dummy;
-}
//
// Keep the linker happy on Windows
//
// Keep the linker happy on Windows