using std::min;
using std::endl;
using std::pair;
+using lyx::pos_type;
namespace {
// Returns the paragraph position of the last character in the specified row
-LyXText::pos_type LyXText::rowLast(Row const * row) const
+pos_type LyXText::rowLast(Row const * row) const
{
if (row->next() == 0)
return row->par()->size() - 1;
}
-LyXText::pos_type LyXText::rowLastPrintable(Row const * row) const
+pos_type LyXText::rowLastPrintable(Row const * row) const
{
pos_type const last = rowLast(row);
if (last >= row->pos()
// get the next breakpoint in a given paragraph
-LyXText::pos_type
+pos_type
LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
{
Paragraph * par = row->par();
pos_type const pos = row->pos();
-
// position of the last possible breakpoint
// -1 isn't a suitable value, but a flag
pos_type last_separator = -1;
bool const freeSpacing =
textclasslist.Style(bview->buffer()->params.textclass,
- cursor.row()->par()->getLayout()).free_spacing;
+ cursor.row()->par()->getLayout()).free_spacing ||
+ cursor.row()->par()->isFreeSpacing();
if (lyxrc.auto_number) {
// draw a top pagebreak
if (parparams.pagebreakTop()) {
int const y = p.yo + y_top + 2*defaultHeight();
- p.pain->line(0, y, p.width, y, LColor::pagebreak, Painter::line_onoffdash);
+ p.pain->line(p.xo, y, p.xo + p.width, y,
+ LColor::pagebreak, Painter::line_onoffdash);
int w = 0;
int a = 0;
int const y1 = p.yo + y_top + 3 * defaultHeight();
int const y2 = p.yo + 2 + y_top;
- p.pain->line(0, y1, LYX_PAPER_MARGIN, y1, LColor::vfillline);
+ p.pain->line(0, y1, LYX_PAPER_MARGIN, y1, LColor::added_space);
- p.pain->line(0, y2, LYX_PAPER_MARGIN, y2, LColor::vfillline);
+ p.pain->line(0, y2, LYX_PAPER_MARGIN, y2, LColor::added_space);
int const x = LYX_PAPER_MARGIN / 2;
- p.pain->line(x, y2, x, y1, LColor::vfillline);
+ p.pain->line(x, y2, x, y1, LColor::added_space);
y_top += 3 * defaultHeight();
+ } else if (parparams.spaceTop().kind() == VSpace::LENGTH) {
+ string str = string(_("Space above")) + " ("
+ + parparams.spaceTop().asLyXCommand()
+ + ")";
+
+ int const space = int(parparams.spaceTop().inPixels(p.bv));
+ int const y = p.yo + y_top + space / 2;
+
+ p.pain->line(p.xo, y, p.xo + p.width, y,
+ LColor::added_space, Painter::line_onoffdash);
+
+ int w = 0;
+ int a = 0;
+ int d = 0;
+
+ LyXFont pb_font;
+ pb_font.setColor(LColor::added_space).decSize();
+ lyxfont::rectText(str, pb_font, w, a, d);
+
+ // don't draw if it won't fit
+ if (a + d + 4 < space) {
+ p.pain->rectText(p.xo + (p.width - w)/2, y + d,
+ str, pb_font,
+ backgroundColor(),
+ backgroundColor());
+ }
}
- // think about user added space
y_top += int(parparams.spaceTop().inPixels(p.bv));
Buffer const * buffer = p.bv->buffer();
pb_font.setColor(LColor::pagebreak).decSize();
int const y = p.yo + y_bottom - 2 * defaultHeight();
- p.pain->line(0, y, ww, y, LColor::pagebreak, Painter::line_onoffdash);
+ p.pain->line(p.xo, y, p.xo + p.width, y, LColor::pagebreak, Painter::line_onoffdash);
int w = 0;
int a = 0;
int const y = p.yo + y_bottom - 3 * defaultHeight();
int const y2 = p.yo + y_bottom - 2;
- p.pain->line(0, y, x2, y, LColor::vfillline);
- p.pain->line(0, y2, x2, y2, LColor::vfillline);
- p.pain->line(x, y, x, y2, LColor::vfillline);
+ p.pain->line(0, y, x2, y, LColor::added_space);
+ p.pain->line(0, y2, x2, y2, LColor::added_space);
+ p.pain->line(x, y, x, y2, LColor::added_space);
y_bottom -= 3 * defaultHeight();
+ } else if (parparams.spaceBottom().kind() == VSpace::LENGTH) {
+ string str = string(_("Space below"))
+ + " ("
+ + parparams.spaceBottom().asLyXCommand()
+ + ")";
+
+ int const space = int(parparams.spaceBottom().inPixels(p.bv));
+ int const y = p.yo + y_bottom - space / 2;
+
+ p.pain->line(p.xo, y, p.xo + p.width, y,
+ LColor::added_space, Painter::line_onoffdash);
+
+ int w = 0;
+ int a = 0;
+ int d = 0;
+
+ LyXFont pb_font;
+ pb_font.setColor(LColor::added_space).decSize();
+ lyxfont::rectText(str, pb_font, w, a, d);
+
+ // don't draw if it won't fit
+ if (a + d + 4 < space) {
+ p.pain->rectText(p.xo + (p.width - w) / 2, y + d,
+ str, pb_font,
+ backgroundColor(),
+ backgroundColor());
+ }
}
// think about user added space
int const y1 = y0 - defaultHeight() / 2;
p.pain->line(int(p.x), y1, int(p.x), y0,
- LColor::vfillline);
+ LColor::added_space);
if (hfillExpansion(buffer, p.row, pos)) {
int const y2 = (y0 + y1) / 2;
if (pos >= main_body) {
p.pain->line(int(p.x), y2,
int(p.x + p.hfill), y2,
- LColor::vfillline,
+ LColor::added_space,
Painter::line_onoffdash);
p.x += p.hfill;
} else {
p.pain->line(int(p.x), y2,
int(p.x + p.label_hfill), y2,
- LColor::vfillline,
+ LColor::added_space,
Painter::line_onoffdash);
p.x += p.label_hfill;
}
p.pain->line(int(p.x), y1,
int(p.x), y0,
- LColor::vfillline);
+ LColor::added_space);
}
p.x += 2;
++vpos;
// paint text
paintRowText(p);
}
-
+
int LyXText::defaultHeight() const
{
/* returns the column near the specified x-coordinate of the row
* x is set to the real beginning of this column */
-LyXText::pos_type
+pos_type
LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
bool & boundary) const
{