2003-07-26 André Pönitz <poenitz@gmx.net>
- * lyxtext.h:
+ * paragraph_func.[Ch]:
+ * paragraph.C (realizeFont): inline it whereever it is used
+
+ * rowpainter.C:
+ * text.C:
+ * text2.C:
+ * text3.C: remove Buffer * parameter from a bunch of get*Font functions
+
+
+2003-07-26 André Pönitz <poenitz@gmx.net>
+
+ * lyxtext.h:
* text.C:
* text2.C: get rid of LyXText::need_break_row
if (cols < columns) {
InsetText & inset = loctab->getCellInset(cell);
LyXFont const font = inset.getLyXText(bv)->
- getFont(bv->buffer(), inset.paragraphs.begin(), 0);
+ getFont(inset.paragraphs.begin(), 0);
inset.setText(buf.substr(op, p - op), font);
++cols;
++cell;
if (cols < columns) {
InsetText & inset = tabular.getCellInset(cell);
LyXFont const font = inset.getLyXText(bv)->
- getFont(bv->buffer(), inset.paragraphs.begin(), 0);
+ getFont(inset.paragraphs.begin(), 0);
inset.setText(buf.substr(op, p - op), font);
}
cols = ocol;
if (cell < cells && op < len) {
InsetText & inset = loctab->getCellInset(cell);
LyXFont const font = inset.getLyXText(bv)->
- getFont(bv->buffer(), inset.paragraphs.begin(), 0);
+ getFont(inset.paragraphs.begin(), 0);
inset.setText(buf.substr(op, len - op), font);
}
the_locking_inset->fitInsetCursor(bv);
return;
}
- LyXFont const font = text_.getFont(bv->buffer(), cpar(), cpos());
+
+ LyXFont const font = text_.getFont(cpar(), cpos());
int const asc = font_metrics::maxAscent(font);
int const desc = font_metrics::maxDescent(font);
}
-int InsetText::cx(BufferView * bv) const
+int InsetText::cx(BufferView *) const
{
int x = text_.cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
if (the_locking_inset) {
- LyXFont font = text_.getFont(bv->buffer(), text_.cursor.par(),
- text_.cursor.pos());
+ LyXFont font = text_.getFont(text_.cursor.par(), text_.cursor.pos());
if (font.isVisibleRightToLeft())
x -= the_locking_inset->width();
}
}
-int InsetText::cix(BufferView * bv) const
+int InsetText::cix(BufferView *) const
{
int x = text_.cursor.ix() + top_x + TEXT_TO_INSET_OFFSET;
if (the_locking_inset) {
- LyXFont font = text_.getFont(bv->buffer(), text_.cursor.par(),
- text_.cursor.pos());
+ LyXFont font = text_.getFont(text_.cursor.par(), text_.cursor.pos());
if (font.isVisibleRightToLeft())
x -= the_locking_inset->width();
}
LyXFont current_font;
/// the current font
LyXFont real_current_font;
+ /// our buffer's default layout font
+ //LyXFont defaultfont_;
private:
/** the 'anchor' row: the position of this row remains constant
* with respect to the top of the screen
///
int getRealCursorX() const;
///
- LyXFont const getFont(Buffer const *, ParagraphList::iterator pit,
- lyx::pos_type pos) const;
+ LyXFont getFont(ParagraphList::iterator pit, lyx::pos_type pos) const;
///
- LyXFont const getLayoutFont(Buffer const *,
- ParagraphList::iterator pit) const;
+ LyXFont getLayoutFont(ParagraphList::iterator pit) const;
///
- LyXFont const getLabelFont(Buffer const *,
- ParagraphList::iterator pit) const;
+ LyXFont getLabelFont(ParagraphList::iterator pit) const;
///
- void setCharFont(Buffer const *, ParagraphList::iterator pit,
+ void setCharFont(ParagraphList::iterator pit,
lyx::pos_type pos, LyXFont const & font);
void setCharFont(ParagraphList::iterator pit,
lyx::pos_type pos,
float getCursorX(RowList::iterator rit, lyx::pos_type pos,
lyx::pos_type last, bool boundary) const;
/// used in setlayout
- void makeFontEntriesLayoutSpecific(Buffer const &, Paragraph & par);
+ void makeFontEntriesLayoutSpecific(BufferParams const &, Paragraph & par);
/** forces the redrawing of a paragraph. Needed when manipulating a
right address box
LyXFont tmpfont = getFontSettings(bparams, pos);
tmpfont.realize(layoutfont);
tmpfont.realize(outerfont);
+ tmpfont.realize(bparams.getLyXTextClass().defaultfont());
- return realizeFont(tmpfont, bparams);
+ return tmpfont;
}
LyXFont tmpfont = lout->labelfont;
tmpfont.setLanguage(getParLanguage(bparams));
tmpfont.realize(outerfont);
+ tmpfont.realize(bparams.getLyXTextClass().defaultfont());
- return realizeFont(tmpfont, bparams);
+ return tmpfont;
}
LyXFont tmpfont = lout->font;
tmpfont.setLanguage(getParLanguage(bparams));
tmpfont.realize(outerfont);
+ tmpfont.realize(bparams.getLyXTextClass().defaultfont());
- return realizeFont(tmpfont, bparams);
+ return tmpfont;
}
Language const *
Paragraph::getParLanguage(BufferParams const & bparams) const
{
- if (!empty()) {
+ if (!empty())
return getFirstFontSettings().language();
#warning FIXME we should check the prev par as well (Lgb)
-#if 0
- } else if (previous_) {
- return previous_->getParLanguage(bparams);
-#endif
- }else
- return bparams.language;
+ return bparams.language;
}
return tmpfont;
}
-
-
-LyXFont const realizeFont(LyXFont const & font,
- BufferParams const & params)
-{
- LyXTextClass const & tclass = params.getLyXTextClass();
- LyXFont tmpfont(font);
- tmpfont.realize(tclass.defaultfont());
- return tmpfont;
-}
/// read a paragraph from a .lyx file. Returns number of unrecognised tokens
int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex);
-LyXFont const realizeFont(LyXFont const & font,
- BufferParams const & params);
-
LyXFont const outerFont(ParagraphList::iterator pit,
ParagraphList const & plist);
/// "temporary"
LyXFont const RowPainter::getFont(pos_type pos) const
{
- return text_.getFont(bv_.buffer(), pit_, pos);
+ return text_.getFont(pit_, pos);
}
LyXFont const RowPainter::getLabelFont() const
{
- return text_.getLabelFont(bv_.buffer(), pit_);
+ return text_.getLabelFont(pit_);
}
if (pos >= pit->size())
return 0;
- LyXFont const & font = getFont(bv()->buffer(), pit, pos);
+ LyXFont const & font = getFont(pit, pos);
// The most common case is handled first (Asger)
if (IsPrintable(c)) {
}
}
- LyXFont const labelfont = getLabelFont(bv()->buffer(), row.par());
+ LyXFont const labelfont = getLabelFont(row.par());
switch (layout->margintype) {
case MARGIN_DYNAMIC:
if (!layout->leftmargin.empty()) {
pos_type i = pos;
// We re-use the font resolution for the entire font span when possible
- LyXFont font = getFont(bv()->buffer(), pit, i);
+ LyXFont font = getFont(pit, i);
lyx::pos_type endPosOfFontSpan = pit->getEndPosOfFontSpan(i);
for (; i < last; ++i) {
// add the auto-hfill from label end to the body
if (body_pos && i == body_pos) {
- thiswidth = font_metrics::width(layout->labelsep,
- getLabelFont(bv()->buffer(), pit));
+ thiswidth = font_metrics::width(layout->labelsep, getLabelFont(pit));
if (pit->isLineSeparator(i - 1))
thiswidth -= singleWidth(pit, i - 1);
int left_margin = labelEnd(row);
if (IsPrintable(c)) {
if (pos > endPosOfFontSpan) {
// We need to get the next font
- font = getFont(bv()->buffer(), pit, i);
+ font = getFont(pit, i);
endPosOfFontSpan = pit->getEndPosOfFontSpan(i);
}
if (! font.language()->RightToLeft()) {
if (! pit->empty() && i <= last) {
// We re-use the font resolution for the entire span when possible
- LyXFont font = getFont(bv()->buffer(), pit, i);
+ LyXFont font = getFont(pit, i);
lyx::pos_type endPosOfFontSpan = pit->getEndPosOfFontSpan(i);
while (i <= last) {
if (body_pos > 0 && i == body_pos) {
- w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit));
+ w += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (pit->isLineSeparator(i - 1))
w -= singleWidth(pit, i - 1);
int left_margin = labelEnd(*row);
if (IsPrintable(c)) {
if (i > endPosOfFontSpan) {
// We need to get the next font
- font = getFont(bv()->buffer(), pit, i);
+ font = getFont(pit, i);
endPosOfFontSpan = pit->getEndPosOfFontSpan(i);
}
if (! font.language()->RightToLeft()) {
}
}
if (body_pos > 0 && body_pos > last) {
- w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit));
+ w += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (last >= 0 && pit->isLineSeparator(last))
w -= singleWidth(pit, last);
int const left_margin = labelEnd(*row);
int fill = 0;
string const & labwidstr = pit->params().labelWidthString();
if (!labwidstr.empty()) {
- LyXFont const labfont = getLabelFont(bv()->buffer(), pit);
+ LyXFont const labfont = getLabelFont(pit);
int const labwidth = font_metrics::width(labwidstr, labfont);
fill = max(labwidth - w, 0);
}
// as max get the first character of this row then it can increase but not
// decrease the height. Just some point to start with so we don't have to
// do the assignment below too often.
- LyXFont font = getFont(bv()->buffer(), pit, rit->pos());
+ LyXFont font = getFont(pit, rit->pos());
LyXFont::FONT_SIZE const tmpsize = font.size();
- font = getLayoutFont(bv()->buffer(), pit);
+ font = getLayoutFont(pit);
LyXFont::FONT_SIZE const size = font.size();
font.setSize(tmpsize);
- LyXFont labelfont = getLabelFont(bv()->buffer(), pit);
+ LyXFont labelfont = getLabelFont(pit);
float spacing_val = 1.0;
if (!pit->params().spacing().isDefault()) {
if (!pit->empty()) {
// We re-use the font resolution for the entire font span when possible
- LyXFont font = getFont(bv()->buffer(), pit, rit->pos());
+ LyXFont font = getFont(pit, rit->pos());
lyx::pos_type endPosOfFontSpan = pit->getEndPosOfFontSpan(rit->pos());
// Optimisation
if (IsPrintable(c)) {
if (pos > endPosOfFontSpan) {
// We need to get the next font
- font = getFont(bv()->buffer(), pit, pos);
+ font = getFont(pit, pos);
endPosOfFontSpan = par.getEndPosOfFontSpan(pos);
}
if (! font.language()->RightToLeft()) {
} else {
// Special handling of insets - are any larger?
if (par.isInset(pos)) {
- LyXFont const tmpfont = getFont(bv()->buffer(), pit, pos);
+ LyXFont const tmpfont = getFont(pit, pos);
InsetOld const * tmpinset = par.getInset(pos);
if (tmpinset) {
#if 1 // this is needed for deep update on initialitation
// there height depends on the font of the nearest character
if (pit->params().lineTop())
- maxasc += 2 * font_metrics::ascent('x', getFont(bv()->buffer(),
- pit, 0));
+ maxasc += 2 * font_metrics::ascent('x', getFont(pit, 0));
// and now the pagebreaks
if (pit->params().pagebreakTop())
maxasc += 3 * defaultRowHeight();
// there height depends on the font of the nearest character
if (pit->params().lineBottom())
maxdesc += 2 * font_metrics::ascent('x',
- getFont(bv()->buffer(),
- pit,
- max(pos_type(0), pit->size() - 1)));
+ getFont(pit, max(pos_type(0), pit->size() - 1)));
// and now the pagebreaks
if (pit->params().pagebreakBottom())
!(contains(number_seperators, c) &&
cursor.pos() >= 1 &&
cursor.pos() < cursor.par()->size() &&
- getFont(bv()->buffer(),
- cursor.par(),
- cursor.pos()).number() == LyXFont::ON &&
- getFont(bv()->buffer(),
- cursor.par(),
- cursor.pos() - 1).number() == LyXFont::ON)
+ getFont(cursor.par(), cursor.pos()).number() == LyXFont::ON &&
+ getFont(cursor.par(), cursor.pos() - 1).number() == LyXFont::ON)
)
number(bv()); // Set current_font.number to OFF
} else if (IsDigit(c) &&
cursor.par()->isSeparator(cursor.pos() - 2) ||
cursor.par()->isNewline(cursor.pos() - 2))
) {
- setCharFont(bv()->buffer(),
+ setCharFont(
cursor.par(),
cursor.pos() - 1,
current_font);
} else if (contains(number_seperators, c) &&
cursor.pos() >= 2 &&
- getFont(bv()->buffer(),
+ getFont(
cursor.par(),
cursor.pos() - 2).number() == LyXFont::ON) {
- setCharFont(bv()->buffer(),
+ setCharFont(
cursor.par(),
cursor.pos() - 1,
current_font);
// Here case LyXText::InsertInset already inserted the character
cursor.par()->insertChar(cursor.pos(), c);
}
- setCharFont(bv()->buffer(), cursor.par(), cursor.pos(), rawtmpfont);
+ setCharFont(cursor.par(), cursor.pos(), rawtmpfont);
if (!jumped_over_space) {
// refresh the positions
if (body_pos > 0 &&
(body_pos - 1 > last ||
!pit->isLineSeparator(body_pos - 1))) {
- x += font_metrics::width(layout->labelsep,
- getLabelFont(bv()->buffer(),
- pit));
+ x += font_metrics::width(layout->labelsep, getLabelFont(pit));
if (body_pos - 1 <= last)
x += fill_label_hfill;
}
// Start the selection from here
selection.cursor = cursor;
- string lang_code(
- getFont(bv()->buffer(), cursor.par(), cursor.pos())
- .language()->code());
+ string lang_code = getFont(cursor.par(), cursor.pos()).language()->code();
// and find the end of the word (insets like optional hyphens
// and ligature break are part of a word)
while (cursor.pos() < cursor.par()->size()
if (cursor.pos() < cursor.par()->size()
&& !cursor.par()->isSeparator(cursor.pos())) {
cursor.par()->insertChar(cursor.pos(), ' ');
- setCharFont(bv()->buffer(), cursor.par(),
- cursor.pos(), current_font);
+ setCharFont(cursor.par(), cursor.pos(), current_font);
// refresh the positions
tmprow = row;
while (boost::next(tmprow) != rows().end() &&
ParagraphList::iterator pit = ownerParagraphs().begin();
ParagraphList::iterator end = ownerParagraphs().end();
- current_font = getFont(bview->buffer(), pit, 0);
+ current_font = getFont(pit, 0);
for (; pit != end; ++pit)
insertParagraph(pit, rowlist_.end());
// smaller. (Asger)
// If position is -1, we get the layout font of the paragraph.
// If position is -2, we get the font of the manual label of the paragraph.
-LyXFont const LyXText::getFont(Buffer const * buf, ParagraphList::iterator pit,
- pos_type pos) const
+LyXFont LyXText::getFont(ParagraphList::iterator pit, pos_type pos) const
{
Assert(pos >= 0);
LyXLayout_ptr const & layout = pit->layout();
+#warning broken?
+ BufferParams const & params = bv()->buffer()->params;
// We specialize the 95% common case:
if (!pit->getDepth()) {
if (layout->labeltype == LABEL_MANUAL
&& pos < pit->beginningOfBody()) {
// 1% goes here
- LyXFont f = pit->getFontSettings(buf->params, pos);
+ LyXFont f = pit->getFontSettings(params, pos);
if (pit->inInset())
pit->inInset()->getDrawFont(f);
return f.realize(layout->reslabelfont);
} else {
- LyXFont f = pit->getFontSettings(buf->params, pos);
+ LyXFont f = pit->getFontSettings(params, pos);
if (pit->inInset())
pit->inInset()->getDrawFont(f);
return f.realize(layout->resfont);
layoutfont = layout->font;
}
- LyXFont tmpfont = pit->getFontSettings(buf->params, pos);
+ LyXFont tmpfont = pit->getFontSettings(params, pos);
tmpfont.realize(layoutfont);
if (pit->inInset())
// Realize with the fonts of lesser depth.
tmpfont.realize(outerFont(pit, ownerParagraphs()));
+ //tmpfont.realize(defaultfont_);
- return realizeFont(tmpfont, buf->params);
+ return tmpfont;
}
-LyXFont const LyXText::getLayoutFont(Buffer const * buf,
- ParagraphList::iterator pit) const
+LyXFont LyXText::getLayoutFont(ParagraphList::iterator pit) const
{
LyXLayout_ptr const & layout = pit->layout();
return layout->resfont;
}
- LyXFont font(layout->font);
+ LyXFont font = layout->font;
// Realize with the fonts of lesser depth.
font.realize(outerFont(pit, ownerParagraphs()));
+ //font.realize(defaultfont_);
- return realizeFont(font, buf->params);
+ return font;
}
-LyXFont const LyXText::getLabelFont(Buffer const * buf,
- ParagraphList::iterator pit) const
+LyXFont LyXText::getLabelFont(ParagraphList::iterator pit) const
{
LyXLayout_ptr const & layout = pit->layout();
return layout->reslabelfont;
}
- LyXFont font(layout->labelfont);
+ LyXFont font = layout->labelfont;
// Realize with the fonts of lesser depth.
font.realize(outerFont(pit, ownerParagraphs()));
+ //font.realize(defaultfont_);
- return realizeFont(layout->labelfont, buf->params);
+ return font;
}
pos_type pos, LyXFont const & fnt,
bool toggleall)
{
- Buffer const * buf = bv()->buffer();
- LyXFont font = getFont(buf, pit, pos);
- font.update(fnt, buf->params.language, toggleall);
+ BufferParams const & params = bv()->buffer()->params;
+ LyXFont font = getFont(pit, pos);
+ font.update(fnt, params.language, toggleall);
// Let the insets convert their font
if (pit->isInset(pos)) {
InsetOld * inset = pit->getInset(pos);
if (isEditableInset(inset)) {
- UpdatableInset * uinset =
- static_cast<UpdatableInset *>(inset);
- uinset->setFont(bv(), fnt, toggleall, true);
+ static_cast<UpdatableInset *>(inset)
+ ->setFont(bv(), fnt, toggleall, true);
}
}
- // Plug thru to version below:
- setCharFont(buf, pit, pos, font);
+ // Plug through to version below:
+ setCharFont(pit, pos, font);
}
-void LyXText::setCharFont(Buffer const * buf, ParagraphList::iterator pit,
- pos_type pos, LyXFont const & fnt)
+void LyXText::setCharFont(
+ ParagraphList::iterator pit, pos_type pos, LyXFont const & fnt)
{
- LyXFont font(fnt);
-
- LyXTextClass const & tclass = buf->params.getLyXTextClass();
+ LyXFont font = fnt;
LyXLayout_ptr const & layout = pit->layout();
// Get concrete layout font to reduce against
}
}
- layoutfont.realize(tclass.defaultfont());
+ //layoutfont.realize(defaultfont_);
// Now, reduce font against full layout font
font.reduce(layoutfont);
/* used in setlayout */
// Asger is not sure we want to do this...
-void LyXText::makeFontEntriesLayoutSpecific(Buffer const & buf,
+void LyXText::makeFontEntriesLayoutSpecific(BufferParams const & params,
Paragraph & par)
{
LyXLayout_ptr const & layout = par.layout();
else
layoutfont = layout->font;
- LyXFont tmpfont = par.getFontSettings(buf.params, pos);
+ LyXFont tmpfont = par.getFontSettings(params, pos);
tmpfont.reduce(layoutfont);
par.setFont(pos, tmpfont);
}
do {
pit->applyLayout(lyxlayout);
- makeFontEntriesLayoutSpecific(*bv()->buffer(), *pit);
+ makeFontEntriesLayoutSpecific(bv()->buffer()->params, *pit);
ParagraphList::iterator fppit = pit;
fppit->params().spaceTop(lyxlayout->fill_top ?
VSpace(VSpace::VFILL)
// Determine basis font
LyXFont layoutfont;
if (cursor.pos() < cursor.par()->beginningOfBody()) {
- layoutfont = getLabelFont(bv()->buffer(),
- cursor.par());
+ layoutfont = getLabelFont(cursor.par());
} else {
- layoutfont = getLayoutFont(bv()->buffer(),
- cursor.par());
+ layoutfont = getLayoutFont(cursor.par());
}
// Update current font
real_current_font.update(font,
if (body_pos > 0 && pos == body_pos - 1) {
x += fill_label_hfill +
font_metrics::width(
- rit_par->layout()->labelsep,
- getLabelFont(bv()->buffer(), rit_par));
+ rit_par->layout()->labelsep, getLabelFont(rit_par));
if (rit_par->isLineSeparator(body_pos - 1))
x -= singleWidth(rit_par, body_pos - 1);
}
}
}
- current_font =
- pit->getFontSettings(bv()->buffer()->params, pos);
- real_current_font = getFont(bv()->buffer(), pit, pos);
+ current_font = pit->getFontSettings(bv()->buffer()->params, pos);
+ real_current_font = getFont(pit, pos);
if (cursor.pos() == pit->size() &&
isBoundary(bv()->buffer(), *pit, cursor.pos()) &&
last_tmpx = tmpx;
if (body_pos > 0 && c == body_pos - 1) {
tmpx += fill_label_hfill +
- font_metrics::width(layout->labelsep,
- getLabelFont(bv()->buffer(), rit_par));
+ font_metrics::width(layout->labelsep, getLabelFont(rit_par));
if (rit_par->isLineSeparator(body_pos - 1))
tmpx -= singleWidth(rit_par, body_pos - 1);
}
// get inset dimensions
Assert(par->getInset(pos));
- LyXFont const & font = text.getFont(bv->buffer(), par, pos);
+ LyXFont const & font = text.getFont(par, pos);
int const width = inset->width();
int const inset_x = font.isVisibleRightToLeft()
int y = top_y();
if (cursorRow() == rows().begin()) {
- if (y > 0) {
- int new_y = bv()->text->top_y() - bv()->workHeight();
- //bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y);
+ if (y > 0)
bv()->updateScrollbar();
- }
return;
}
return;
// This is what we used to do, so we wouldn't skip right past
// tall rows, but it's not working right now.
-#if 0
- new_y = bv->text->top_y() - bv->workHeight();
-#endif
} else {
if (inset_owner) {
new_y = bv()->text->cursor.iy()
if (bv->theLockingInset()) {
InsetOld * tli = bv->theLockingInset();
LyXCursor cursor = bv->text->cursor;
- LyXFont font = bv->text->getFont(bv->buffer(),
- cursor.par(), cursor.pos());
+ LyXFont font = bv->text->getFont(cursor.par(), cursor.pos());
int width = tli->width();
int inset_x = font.isVisibleRightToLeft()
? cursor.ix() - width : cursor.ix();