#include "frontends/font_metrics.h"
#include "frontends/nullpainter.h"
+#include "frontends/LyXView.h"
+#include "frontends/WorkArea.h"
#include "frontends/Painter.h"
#include "insets/insettext.h"
#include <boost/crc.hpp>
+using lyx::docstring;
using lyx::frontend::Painter;
using lyx::frontend::NullPainter;
using lyx::char_type;
}
// Draw nikud
- pain_.text(int(x_) + dx, yo_, str, font);
+ docstring dstr(str.begin(), str.end());
+ pain_.text(int(x_) + dx, yo_, dstr, font);
}
}
}
// Draw nikud
- pain_.text(int(x_) + dx, yo_, str, font);
+ docstring dstr(str.begin(), str.end());
+ pain_.text(int(x_) + dx, yo_, dstr, font);
}
Change::Type const prev_change = par_.lookupChange(pos).type;
// first character
+#if 0
string str;
str += par_.getChar(pos);
+#else
+ std::vector<char_type> str;
+ str.push_back(par_.getChar(pos));
+#endif
if (arabic) {
- unsigned char c = str[0];
+ char_type c = str[0];
str[0] = par_.transformChar(c, pos);
}
if (arabic)
c = par_.transformChar(c, pos);
+#if 0
str += c;
+#else
+ str.push_back(c);
+#endif
}
if (prev_change == Change::DELETED)
// Draw text and set the new x position
//lyxerr << "paint row: yo_ " << yo_ << "\n";
+#if 0
pain_.text(int(x_), yo_, str, font);
x_ += font_metrics::width(str, font);
+#else
+ pain_.text(int(x_), yo_, &str[0], str.size(), font);
+ x_ += font_metrics::width(&str[0], str.size(), font);
+#endif
}
pb_font.setColor(LColor::appendix);
pb_font.decSize();
- string const label = _("Appendix");
+ string const label = lyx::to_utf8(_("Appendix"));
int w = 0;
int a = 0;
int d = 0;
- font_metrics::rectText(label, pb_font, w, a, d);
+ docstring dlab(label.begin(), label.end());
+ font_metrics::rectText(dlab, pb_font, w, a, d);
int const text_start = int(xo_ + (width_ - w) / 2);
int const text_end = text_start + w;
- pain_.rectText(text_start, y + d, label, pb_font, LColor::none, LColor::none);
+ pain_.rectText(text_start, y + d, dlab, pb_font, LColor::none, LColor::none);
pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
string const str = par_.getLabelstring();
if (!str.empty()) {
double x = x_;
+ docstring dstr(str.begin(), str.end());
// this is special code for the chapter layout. This is
// printed in an extra row and has a pagebreak at
if (is_rtl) {
x = width_ - leftMargin() -
- font_metrics::width(str, font);
+ font_metrics::width(dstr, font);
}
- pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
+ pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
} else {
+ string lab = layout->labelsep;
+ docstring dlab(lab.begin(), lab.end());
if (is_rtl) {
x = width_ - leftMargin()
- + font_metrics::width(layout->labelsep, font);
+ + font_metrics::width(dlab, font);
} else {
- x = x_ - font_metrics::width(layout->labelsep, font)
- - font_metrics::width(str, font);
+ x = x_ - font_metrics::width(dlab, font)
+ - font_metrics::width(dstr, font);
}
- pain_.text(int(x), yo_, str, font);
+ pain_.text(int(x), yo_, dstr, font);
}
}
LyXFont font = getLabelFont();
if (!par_.getLabelstring().empty()) {
string const str = par_.getLabelstring();
+ docstring dstr(str.begin(), str.end());
double spacing_val = 1.0;
if (!parparams.spacing().isDefault())
spacing_val = parparams.spacing().getValue();
if (is_rtl)
x = leftMargin();
x += (width_ - text_.rightMargin(par_) - leftMargin()) / 2;
- x -= font_metrics::width(str, font) / 2;
+ x -= font_metrics::width(dstr, font) / 2;
} else if (is_rtl) {
x = width_ - leftMargin() -
- font_metrics::width(str, font);
+ font_metrics::width(dstr, font);
}
- pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
+ pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
}
}
}
case END_LABEL_STATIC: {
LyXFont font = getLabelFont();
string const & str = par_.layout()->endlabelstring();
+ docstring dstr(str.begin(), str.end());
double const x = is_rtl ?
- x_ - font_metrics::width(str, font)
+ x_ - font_metrics::width(dstr, font)
: - text_.rightMargin(par_) - row_.width();
- pain_.text(int(x), yo_, str, font);
+ pain_.text(int(x), yo_, dstr, font);
break;
}
}
if (body_pos > 0 && pos == body_pos - 1) {
- int const lwidth = font_metrics::width(layout->labelsep,
+ string lab = layout->labelsep;
+ docstring dlab(lab.begin(), lab.end());
+ int const lwidth = font_metrics::width(dlab,
getLabelFont());
x_ += label_hfill_ + lwidth - width_pos;
static PainterInfo nullpi(pi.base.bv, nop);
int const ww = pi.base.bv->workHeight();
+ theCoords.parPos()[&text][pit] = Point(x, y);
+
Paragraph const & par = text.paragraphs()[pit];
+ if (par.rows().empty())
+ return;
RowList::const_iterator const rb = par.rows().begin();
RowList::const_iterator const re = par.rows().end();
- theCoords.parPos()[&text][pit] = Point(x, y);
y -= rb->ascent();
lyx::size_type rowno(0);
} // namespace anon
-void paintText(BufferView const & bv, ViewMetricsInfo const & vi)
+void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
+ Painter & pain)
{
- Painter & pain = bv.painter();
- LyXText * const text = bv.text();
+ LyXText & text = bv.buffer()->text();
bool const select = bv.cursor().selection();
PainterInfo pi(const_cast<BufferView *>(&bv), pain);
if (repaintAll) {
// Clear background (if not delegated to rows)
pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
- text->backgroundColor());
+ text.backgroundColor());
}
if (select) {
- text->drawSelection(pi, 0, 0);
+ text.drawSelection(pi, 0, 0);
}
int yy = vi.y1;
// draw contents
for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
refreshInside = repaintAll;
- Paragraph const & par = text->getPar(pit);
+ Paragraph const & par = text.getPar(pit);
yy += par.ascent();
- paintPar(pi, *bv.text(), pit, 0, yy, repaintAll);
+ paintPar(pi, text, pit, 0, yy, repaintAll);
yy += par.descent();
}
// Try viewing the User Guide Mobius figure
if (vi.p1 > 0) {
- text->redoParagraph(vi.p1 - 1);
- theCoords.parPos()[bv.text()][vi.p1 - 1] =
- Point(0, vi.y1 - text->getPar(vi.p1 - 1).descent());
+ text.redoParagraph(vi.p1 - 1);
+ theCoords.parPos()[&text][vi.p1 - 1] =
+ Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
}
- if (vi.p2 < lyx::pit_type(text->paragraphs().size()) - 1) {
- text->redoParagraph(vi.p2 + 1);
- theCoords.parPos()[bv.text()][vi.p2 + 1] =
- Point(0, vi.y2 + text->getPar(vi.p2 + 1).ascent());
+ if (vi.p2 < lyx::pit_type(text.paragraphs().size()) - 1) {
+ text.redoParagraph(vi.p2 + 1);
+ theCoords.parPos()[&text][vi.p2 + 1] =
+ Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
}
// and grey out above (should not happen later)
-// lyxerr << "par ascent: " << text->getPar(vi.p1).ascent() << endl;
+// lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
if (vi.y1 > 0 && !vi.singlepar)
pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
// and possibly grey out below
-// lyxerr << "par descent: " << text->getPar(vi.p1).ascent() << endl;
+// lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
if (vi.y2 < bv.workHeight() && !vi.singlepar)
pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
}