mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
* Layout.h
- leftMargin, rightMargin, labelsep, labelindent, parindent are now docstring. * TextClass.h: - leftMargin() and rightMargin(): now return a docstring. All other files: adapt to change above. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19633 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2f751fe117
commit
98008dc568
@ -375,22 +375,22 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
|
||||
|
||||
case LT_LEFTMARGIN: // left margin type
|
||||
if (lexrc.next())
|
||||
leftmargin = lexrc.getString();
|
||||
leftmargin = lexrc.getDocString();
|
||||
break;
|
||||
|
||||
case LT_RIGHTMARGIN: // right margin type
|
||||
if (lexrc.next())
|
||||
rightmargin = lexrc.getString();
|
||||
rightmargin = lexrc.getDocString();
|
||||
break;
|
||||
|
||||
case LT_LABELINDENT: // label indenting flag
|
||||
if (lexrc.next())
|
||||
labelindent = lexrc.getString();
|
||||
labelindent = lexrc.getDocString();
|
||||
break;
|
||||
|
||||
case LT_PARINDENT: // paragraph indent. flag
|
||||
if (lexrc.next())
|
||||
parindent = lexrc.getString();
|
||||
parindent = lexrc.getDocString();
|
||||
break;
|
||||
|
||||
case LT_PARSKIP: // paragraph skip size
|
||||
@ -420,7 +420,7 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
|
||||
|
||||
case LT_LABELSEP: // label separator
|
||||
if (lexrc.next()) {
|
||||
labelsep = subst(lexrc.getString(), 'x', ' ');
|
||||
labelsep = from_utf8(subst(lexrc.getString(), 'x', ' '));
|
||||
}
|
||||
break;
|
||||
|
||||
|
10
src/Layout.h
10
src/Layout.h
@ -250,15 +250,15 @@ public:
|
||||
Font reslabelfont;
|
||||
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
std::string leftmargin;
|
||||
docstring leftmargin;
|
||||
/// Text that dictates how wide the right margin is on the screen
|
||||
std::string rightmargin;
|
||||
docstring rightmargin;
|
||||
/// Text that dictates how much space to leave after a potential label
|
||||
std::string labelsep;
|
||||
docstring labelsep;
|
||||
/// Text that dictates how much space to leave before a potential label
|
||||
std::string labelindent;
|
||||
docstring labelindent;
|
||||
/// Text that dictates the width of the indentation of indented pars
|
||||
std::string parindent;
|
||||
docstring parindent;
|
||||
///
|
||||
double parskip;
|
||||
///
|
||||
|
@ -179,13 +179,11 @@ int ParagraphMetrics::rightMargin(Buffer const & buffer) const
|
||||
{
|
||||
BufferParams const & params = buffer.params();
|
||||
TextClass const & tclass = params.getTextClass();
|
||||
docstring trmarg = from_utf8(tclass.rightmargin());
|
||||
docstring lrmarg = from_utf8(par_->layout()->rightmargin);
|
||||
frontend::FontMetrics const & fm = theFontMetrics(params.getFont());
|
||||
int const r_margin =
|
||||
lyx::rightMargin()
|
||||
+ fm.signedWidth(trmarg)
|
||||
+ fm.signedWidth(lrmarg)
|
||||
+ fm.signedWidth(tclass.rightmargin())
|
||||
+ fm.signedWidth(par_->layout()->rightmargin)
|
||||
* 4 / (par_->getDepth() + 4);
|
||||
|
||||
return r_margin;
|
||||
|
62
src/Text.cpp
62
src/Text.cpp
@ -416,16 +416,15 @@ int Text::leftMargin(Buffer const & buffer, int max_width,
|
||||
TextClass const & tclass = buffer.params().getTextClass();
|
||||
Layout_ptr const & layout = par.layout();
|
||||
|
||||
string parindent = layout->parindent;
|
||||
docstring parindent = layout->parindent;
|
||||
|
||||
int l_margin = 0;
|
||||
|
||||
if (isMainText(buffer))
|
||||
l_margin += changebarMargin();
|
||||
|
||||
// FIXME UNICODE
|
||||
docstring leftm = from_utf8(tclass.leftmargin());
|
||||
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(leftm);
|
||||
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
|
||||
tclass.leftmargin());
|
||||
|
||||
if (par.getDepth() != 0) {
|
||||
// find the next level paragraph
|
||||
@ -456,55 +455,41 @@ int Text::leftMargin(Buffer const & buffer, int max_width,
|
||||
switch (layout->margintype) {
|
||||
case MARGIN_DYNAMIC:
|
||||
if (!layout->leftmargin.empty()) {
|
||||
// FIXME UNICODE
|
||||
docstring leftm = from_utf8(layout->leftmargin);
|
||||
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(leftm);
|
||||
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
|
||||
layout->leftmargin);
|
||||
}
|
||||
if (!par.getLabelstring().empty()) {
|
||||
// FIXME UNICODE
|
||||
docstring labin = from_utf8(layout->labelindent);
|
||||
l_margin += labelfont_metrics.signedWidth(labin);
|
||||
docstring labstr = par.getLabelstring();
|
||||
l_margin += labelfont_metrics.width(labstr);
|
||||
docstring labsep = from_utf8(layout->labelsep);
|
||||
l_margin += labelfont_metrics.width(labsep);
|
||||
l_margin += labelfont_metrics.signedWidth(layout->labelindent);
|
||||
l_margin += labelfont_metrics.width(par.getLabelstring());
|
||||
l_margin += labelfont_metrics.width(layout->labelsep);
|
||||
}
|
||||
break;
|
||||
|
||||
case MARGIN_MANUAL: {
|
||||
// FIXME UNICODE
|
||||
docstring labin = from_utf8(layout->labelindent);
|
||||
l_margin += labelfont_metrics.signedWidth(labin);
|
||||
l_margin += labelfont_metrics.signedWidth(layout->labelindent);
|
||||
// The width of an empty par, even with manual label, should be 0
|
||||
if (!par.empty() && pos >= par.beginOfBody()) {
|
||||
if (!par.getLabelWidthString().empty()) {
|
||||
docstring labstr = par.getLabelWidthString();
|
||||
l_margin += labelfont_metrics.width(labstr);
|
||||
docstring labsep = from_utf8(layout->labelsep);
|
||||
l_margin += labelfont_metrics.width(labsep);
|
||||
l_margin += labelfont_metrics.width(layout->labelsep);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MARGIN_STATIC: {
|
||||
// FIXME UNICODE
|
||||
docstring leftm = from_utf8(layout->leftmargin);
|
||||
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(leftm)
|
||||
* 4 / (par.getDepth() + 4);
|
||||
l_margin += theFontMetrics(buffer.params().getFont()).
|
||||
signedWidth(layout->leftmargin) * 4 / (par.getDepth() + 4);
|
||||
break;
|
||||
}
|
||||
|
||||
case MARGIN_FIRST_DYNAMIC:
|
||||
if (layout->labeltype == LABEL_MANUAL) {
|
||||
if (pos >= par.beginOfBody()) {
|
||||
// FIXME UNICODE
|
||||
l_margin += labelfont_metrics.signedWidth(
|
||||
from_utf8(layout->leftmargin));
|
||||
l_margin += labelfont_metrics.signedWidth(layout->leftmargin);
|
||||
} else {
|
||||
// FIXME UNICODE
|
||||
l_margin += labelfont_metrics.signedWidth(
|
||||
from_utf8(layout->labelindent));
|
||||
l_margin += labelfont_metrics.signedWidth(layout->labelindent);
|
||||
}
|
||||
} else if (pos != 0
|
||||
// Special case to fix problems with
|
||||
@ -512,14 +497,13 @@ int Text::leftMargin(Buffer const & buffer, int max_width,
|
||||
|| (layout->labeltype == LABEL_STATIC
|
||||
&& layout->latextype == LATEX_ENVIRONMENT
|
||||
&& !isFirstInSequence(pit, pars_))) {
|
||||
// FIXME UNICODE
|
||||
l_margin += labelfont_metrics.signedWidth(from_utf8(layout->leftmargin));
|
||||
l_margin += labelfont_metrics.signedWidth(layout->leftmargin);
|
||||
} else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
|
||||
&& layout->labeltype != LABEL_BIBLIO
|
||||
&& layout->labeltype !=
|
||||
LABEL_CENTERED_TOP_ENVIRONMENT) {
|
||||
l_margin += labelfont_metrics.signedWidth(from_utf8(layout->labelindent));
|
||||
l_margin += labelfont_metrics.width(from_utf8(layout->labelsep));
|
||||
l_margin += labelfont_metrics.signedWidth(layout->labelindent);
|
||||
l_margin += labelfont_metrics.width(layout->labelsep);
|
||||
l_margin += labelfont_metrics.width(par.getLabelstring());
|
||||
}
|
||||
break;
|
||||
@ -574,8 +558,8 @@ int Text::leftMargin(Buffer const & buffer, int max_width,
|
||||
|| buffer.params().paragraph_separation ==
|
||||
BufferParams::PARSEP_INDENT))
|
||||
{
|
||||
docstring din = from_utf8(parindent);
|
||||
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(din);
|
||||
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
|
||||
parindent);
|
||||
}
|
||||
|
||||
return l_margin;
|
||||
@ -1749,8 +1733,6 @@ int Text::cursorX(BufferView const & bv, CursorSlice const & sl,
|
||||
// Use font span to speed things up, see below
|
||||
FontSpan font_span;
|
||||
Font font;
|
||||
FontMetrics const & labelfm = theFontMetrics(
|
||||
getLabelFont(buffer, par));
|
||||
|
||||
// If the last logical character is a separator, skip it, unless
|
||||
// it's in the last row of a paragraph; see skipped_sep_vpos declaration
|
||||
@ -1763,9 +1745,9 @@ int Text::cursorX(BufferView const & bv, CursorSlice const & sl,
|
||||
continue;
|
||||
pos_type pos = bidi.vis2log(vpos);
|
||||
if (body_pos > 0 && pos == body_pos - 1) {
|
||||
// FIXME UNICODE
|
||||
docstring const lsep = from_utf8(par.layout()->labelsep);
|
||||
x += m.label_hfill + labelfm.width(lsep);
|
||||
FontMetrics const & labelfm = theFontMetrics(
|
||||
getLabelFont(buffer, par));
|
||||
x += m.label_hfill + labelfm.width(par.layout()->labelsep);
|
||||
if (par.isLineSeparator(body_pos - 1))
|
||||
x -= singleWidth(buffer, par, body_pos - 1);
|
||||
}
|
||||
|
@ -398,12 +398,12 @@ bool TextClass::read(FileName const & filename, bool merge)
|
||||
|
||||
case TC_LEFTMARGIN: // left margin type
|
||||
if (lexrc.next())
|
||||
leftmargin_ = lexrc.getString();
|
||||
leftmargin_ = lexrc.getDocString();
|
||||
break;
|
||||
|
||||
case TC_RIGHTMARGIN: // right margin type
|
||||
if (lexrc.next())
|
||||
rightmargin_ = lexrc.getString();
|
||||
rightmargin_ = lexrc.getDocString();
|
||||
break;
|
||||
case TC_INSETLAYOUT:
|
||||
if (lexrc.next()) {
|
||||
@ -903,13 +903,13 @@ Font const & TextClass::defaultfont() const
|
||||
}
|
||||
|
||||
|
||||
string const & TextClass::leftmargin() const
|
||||
docstring const & TextClass::leftmargin() const
|
||||
{
|
||||
return leftmargin_;
|
||||
}
|
||||
|
||||
|
||||
string const & TextClass::rightmargin() const
|
||||
docstring const & TextClass::rightmargin() const
|
||||
{
|
||||
return rightmargin_;
|
||||
}
|
||||
|
@ -163,10 +163,10 @@ public:
|
||||
Font const & defaultfont() const;
|
||||
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
std::string const & leftmargin() const;
|
||||
docstring const & leftmargin() const;
|
||||
|
||||
/// Text that dictates how wide the right margin is on the screen
|
||||
std::string const & rightmargin() const;
|
||||
docstring const & rightmargin() const;
|
||||
|
||||
/// The type of command used to produce a title
|
||||
LYX_TITLE_LATEX_TYPES titletype() const;
|
||||
@ -225,10 +225,10 @@ private:
|
||||
*/
|
||||
Font defaultfont_;
|
||||
/// Text that dictates how wide the left margin is on the screen
|
||||
std::string leftmargin_;
|
||||
docstring leftmargin_;
|
||||
|
||||
/// Text that dictates how wide the right margin is on the screen
|
||||
std::string rightmargin_;
|
||||
docstring rightmargin_;
|
||||
|
||||
/// The type of command used to produce a title
|
||||
LYX_TITLE_LATEX_TYPES titletype_;
|
||||
|
@ -385,8 +385,8 @@ RowMetrics TextMetrics::computeRowMetrics(pit_type const pit,
|
||||
if (body_pos > 0
|
||||
&& (body_pos > end || !par.isLineSeparator(body_pos - 1)))
|
||||
{
|
||||
docstring const lsep = from_utf8(layout->labelsep);
|
||||
result.x += theFontMetrics(text_->getLabelFont(buffer, par)).width(lsep);
|
||||
result.x += theFontMetrics(text_->getLabelFont(buffer, par)).
|
||||
width(layout->labelsep);
|
||||
if (body_pos <= end)
|
||||
result.x += result.label_hfill;
|
||||
}
|
||||
@ -493,15 +493,15 @@ void TextMetrics::rowBreakPoint(int width, pit_type const pit,
|
||||
FontIterator fi = FontIterator(buffer, *text_, par, pos);
|
||||
pos_type point = end;
|
||||
pos_type i = pos;
|
||||
FontMetrics const & fm = theFontMetrics(text_->getLabelFont(buffer, par));
|
||||
for ( ; i < end; ++i, ++fi) {
|
||||
char_type const c = par.getChar(i);
|
||||
int thiswidth = text_->singleWidth(par, i, c, *fi);
|
||||
|
||||
// add the auto-hfill from label end to the body
|
||||
if (body_pos && i == body_pos) {
|
||||
docstring lsep = from_utf8(layout->labelsep);
|
||||
int add = fm.width(lsep);
|
||||
FontMetrics const & fm = theFontMetrics(
|
||||
text_->getLabelFont(buffer, par));
|
||||
int add = fm.width(layout->labelsep);
|
||||
if (par.isLineSeparator(i - 1))
|
||||
add -= text_->singleWidth(buffer, par, i - 1);
|
||||
|
||||
@ -576,20 +576,19 @@ void TextMetrics::setRowWidth(int right_margin,
|
||||
pos_type const end = row.endpos();
|
||||
|
||||
Paragraph const & par = text_->getPar(pit);
|
||||
docstring const labelsep = from_utf8(par.layout()->labelsep);
|
||||
int w = text_->leftMargin(buffer, max_width_, pit, row.pos());
|
||||
int label_end = labelEnd(pit);
|
||||
|
||||
pos_type const body_pos = par.beginOfBody();
|
||||
pos_type i = row.pos();
|
||||
|
||||
FontMetrics const & fm = theFontMetrics(text_->getLabelFont(buffer, par));
|
||||
|
||||
if (i < end) {
|
||||
FontIterator fi = FontIterator(buffer, *text_, par, i);
|
||||
for ( ; i < end; ++i, ++fi) {
|
||||
if (body_pos > 0 && i == body_pos) {
|
||||
w += fm.width(labelsep);
|
||||
FontMetrics const & fm = theFontMetrics(
|
||||
text_->getLabelFont(buffer, par));
|
||||
w += fm.width(par.layout()->labelsep);
|
||||
if (par.isLineSeparator(i - 1))
|
||||
w -= text_->singleWidth(buffer, par, i - 1);
|
||||
w = max(w, label_end);
|
||||
@ -600,7 +599,9 @@ void TextMetrics::setRowWidth(int right_margin,
|
||||
}
|
||||
|
||||
if (body_pos > 0 && body_pos >= end) {
|
||||
w += fm.width(labelsep);
|
||||
FontMetrics const & fm = theFontMetrics(
|
||||
text_->getLabelFont(buffer, par));
|
||||
w += fm.width(par.layout()->labelsep);
|
||||
if (end > 0 && par.isLineSeparator(end - 1))
|
||||
w -= text_->singleWidth(buffer, par, end - 1);
|
||||
w = max(w, label_end);
|
||||
@ -842,16 +843,13 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
|
||||
return 0;
|
||||
}
|
||||
|
||||
frontend::FontMetrics const & fm
|
||||
= theFontMetrics(text_->getLabelFont(buffer, par));
|
||||
|
||||
while (vc < end && tmpx <= x) {
|
||||
c = bidi.vis2log(vc);
|
||||
last_tmpx = tmpx;
|
||||
if (body_pos > 0 && c == body_pos - 1) {
|
||||
// FIXME UNICODE
|
||||
docstring const lsep = from_utf8(layout->labelsep);
|
||||
tmpx += r.label_hfill + fm.width(lsep);
|
||||
FontMetrics const & fm = theFontMetrics(
|
||||
text_->getLabelFont(buffer, par));
|
||||
tmpx += r.label_hfill + fm.width(layout->labelsep);
|
||||
if (par.isLineSeparator(body_pos - 1))
|
||||
tmpx -= text_->singleWidth(buffer, par, body_pos - 1);
|
||||
}
|
||||
|
@ -623,13 +623,11 @@ void RowPainter::paintFirst()
|
||||
|
||||
pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
|
||||
} else {
|
||||
// FIXME UNICODE
|
||||
docstring lab = from_utf8(layout->labelsep);
|
||||
if (is_rtl) {
|
||||
x = width_ - leftMargin()
|
||||
+ fm.width(lab);
|
||||
+ fm.width(layout->labelsep);
|
||||
} else {
|
||||
x = x_ - fm.width(lab)
|
||||
x = x_ - fm.width(layout->labelsep)
|
||||
- fm.width(str);
|
||||
}
|
||||
|
||||
@ -818,9 +816,8 @@ void RowPainter::paintText()
|
||||
}
|
||||
|
||||
if (body_pos > 0 && pos == body_pos - 1) {
|
||||
// FIXME UNICODE
|
||||
int const lwidth = theFontMetrics(getLabelFont())
|
||||
.width(from_utf8(layout->labelsep));
|
||||
.width(layout->labelsep);
|
||||
|
||||
x_ += label_hfill_ + lwidth - width_pos;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user