mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-26 18:07:18 +00:00
apply added2.diff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3165 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7e61459c3f
commit
b317d8341c
@ -1,3 +1,8 @@
|
|||||||
|
2001-12-05 John Levon <moz@compsoc.man.ac.uk>
|
||||||
|
|
||||||
|
* lyxtext.h:
|
||||||
|
* text.C: better added space drawing
|
||||||
|
|
||||||
2001-12-05 John Levon <moz@compsoc.man.ac.uk>
|
2001-12-05 John Levon <moz@compsoc.man.ac.uk>
|
||||||
|
|
||||||
* LyXView.C:
|
* LyXView.C:
|
||||||
|
@ -590,6 +590,13 @@ private:
|
|||||||
/// paint env depth bar
|
/// paint env depth bar
|
||||||
void paintRowDepthBar(DrawRowParams & p);
|
void paintRowDepthBar(DrawRowParams & p);
|
||||||
|
|
||||||
|
/// get the on-screen size of the length marker
|
||||||
|
int getLengthMarkerHeight(BufferView * bv, VSpace const & vsp) const;
|
||||||
|
|
||||||
|
/// paint an added space marker
|
||||||
|
int drawLengthMarker(DrawRowParams & p, string const & str,
|
||||||
|
VSpace const & vsp, int start);
|
||||||
|
|
||||||
/// paint a first row in a paragraph
|
/// paint a first row in a paragraph
|
||||||
void paintFirstRow(DrawRowParams & p);
|
void paintFirstRow(DrawRowParams & p);
|
||||||
|
|
||||||
|
153
src/text.C
153
src/text.C
@ -1342,8 +1342,7 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
|||||||
maxasc += LYX_PAPER_MARGIN;
|
maxasc += LYX_PAPER_MARGIN;
|
||||||
|
|
||||||
// add the vertical spaces, that the user added
|
// add the vertical spaces, that the user added
|
||||||
if (firstpar->params().spaceTop().kind() != VSpace::NONE)
|
maxasc += getLengthMarkerHeight(bview, firstpar->params().spaceTop());
|
||||||
maxasc += int(firstpar->params().spaceTop().inPixels(bview));
|
|
||||||
|
|
||||||
// do not forget the DTP-lines!
|
// do not forget the DTP-lines!
|
||||||
// there height depends on the font of the nearest character
|
// there height depends on the font of the nearest character
|
||||||
@ -1456,8 +1455,7 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
|||||||
maxdesc += LYX_PAPER_MARGIN;
|
maxdesc += LYX_PAPER_MARGIN;
|
||||||
|
|
||||||
// add the vertical spaces, that the user added
|
// add the vertical spaces, that the user added
|
||||||
if (firstpar->params().spaceBottom().kind() != VSpace::NONE)
|
maxdesc += getLengthMarkerHeight(bview, firstpar->params().spaceBottom());
|
||||||
maxdesc += int(firstpar->params().spaceBottom().inPixels(bview));
|
|
||||||
|
|
||||||
// do not forget the DTP-lines!
|
// do not forget the DTP-lines!
|
||||||
// there height depends on the font of the nearest character
|
// there height depends on the font of the nearest character
|
||||||
@ -3159,6 +3157,80 @@ void LyXText::paintRowDepthBar(DrawRowParams & p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int LyXText::getLengthMarkerHeight(BufferView * bv, VSpace const & vsp) const
|
||||||
|
{
|
||||||
|
if (vsp.kind() != VSpace::LENGTH) {
|
||||||
|
return int(vsp.inPixels(bv));
|
||||||
|
}
|
||||||
|
|
||||||
|
int const space_size = int(vsp.inPixels(bv));
|
||||||
|
int const arrow_size = 10;
|
||||||
|
|
||||||
|
LyXFont font;
|
||||||
|
font.decSize();
|
||||||
|
int const min_size = 2 * arrow_size + 10
|
||||||
|
+ lyxfont::maxAscent(font)
|
||||||
|
+ lyxfont::maxDescent(font);
|
||||||
|
|
||||||
|
return std::max(min_size, space_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int LyXText::drawLengthMarker(DrawRowParams & p, string const & prefix,
|
||||||
|
VSpace const & vsp, int start)
|
||||||
|
{
|
||||||
|
string const str(prefix
|
||||||
|
+ " (" + vsp.asLyXCommand() + ")");
|
||||||
|
|
||||||
|
int const arrow_size = 10;
|
||||||
|
|
||||||
|
int const size = getLengthMarkerHeight(p.bv, vsp);
|
||||||
|
|
||||||
|
// first the string
|
||||||
|
int w = 0;
|
||||||
|
int a = 0;
|
||||||
|
int d = 0;
|
||||||
|
|
||||||
|
LyXFont font;
|
||||||
|
font.setColor(LColor::added_space).decSize();
|
||||||
|
lyxfont::rectText(str, font, w, a, d);
|
||||||
|
|
||||||
|
int const end = start + size;
|
||||||
|
|
||||||
|
p.pain->rectText(p.xo + 2 * arrow_size + 5,
|
||||||
|
start + ((end - start) / 2) + d,
|
||||||
|
str, font,
|
||||||
|
backgroundColor(),
|
||||||
|
backgroundColor());
|
||||||
|
|
||||||
|
// adding or removing space
|
||||||
|
bool const added = !(vsp.length().len().value() < 0.0);
|
||||||
|
|
||||||
|
int const leftx = p.xo;
|
||||||
|
int const midx = leftx + arrow_size;
|
||||||
|
int const rightx = midx + arrow_size;
|
||||||
|
|
||||||
|
// top arrow
|
||||||
|
int const ty1 = added ? (start + arrow_size) : start;
|
||||||
|
int const ty2 = added ? start : (start + arrow_size);
|
||||||
|
|
||||||
|
p.pain->line(leftx, ty1, midx, ty2, LColor::added_space);
|
||||||
|
p.pain->line(midx, ty2, rightx, ty1, LColor::added_space);
|
||||||
|
|
||||||
|
// bottom arrow
|
||||||
|
int const by1 = added ? (end - arrow_size) : end;
|
||||||
|
int const by2 = added ? end : (end - arrow_size);
|
||||||
|
|
||||||
|
p.pain->line(leftx, by1, midx, by2, LColor::added_space);
|
||||||
|
p.pain->line(midx, by2, rightx, by1, LColor::added_space);
|
||||||
|
|
||||||
|
// joining line
|
||||||
|
p.pain->line(midx, ty2, midx, by2, LColor::added_space);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::paintFirstRow(DrawRowParams & p)
|
void LyXText::paintFirstRow(DrawRowParams & p)
|
||||||
{
|
{
|
||||||
Paragraph * par = p.row->par();
|
Paragraph * par = p.row->par();
|
||||||
@ -3209,35 +3281,13 @@ void LyXText::paintFirstRow(DrawRowParams & p)
|
|||||||
p.pain->line(x, y2, x, y1, LColor::added_space);
|
p.pain->line(x, y2, x, y1, LColor::added_space);
|
||||||
|
|
||||||
y_top += 3 * defaultHeight();
|
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
y_top += int(parparams.spaceTop().inPixels(p.bv));
|
y_top += int(parparams.spaceTop().inPixels(p.bv));
|
||||||
|
} else if (parparams.spaceTop().kind() == VSpace::LENGTH) {
|
||||||
|
y_top += drawLengthMarker(p, _("Space above"),
|
||||||
|
parparams.spaceTop(), p.yo + y_top);
|
||||||
|
} else {
|
||||||
|
y_top += int(parparams.spaceTop().inPixels(p.bv));
|
||||||
|
}
|
||||||
|
|
||||||
Buffer const * buffer = p.bv->buffer();
|
Buffer const * buffer = p.bv->buffer();
|
||||||
|
|
||||||
@ -3426,37 +3476,16 @@ void LyXText::paintLastRow(DrawRowParams & p)
|
|||||||
p.pain->line(x, y, x, y2, LColor::added_space);
|
p.pain->line(x, y, x, y2, LColor::added_space);
|
||||||
|
|
||||||
y_bottom -= 3 * defaultHeight();
|
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
|
|
||||||
y_bottom -= int(parparams.spaceBottom().inPixels(p.bv));
|
y_bottom -= int(parparams.spaceBottom().inPixels(p.bv));
|
||||||
|
} else if (parparams.spaceBottom().kind() == VSpace::LENGTH) {
|
||||||
|
int const height = getLengthMarkerHeight(p.bv, parparams.spaceBottom());
|
||||||
|
y_bottom -= drawLengthMarker(p, _("Space below"),
|
||||||
|
parparams.spaceBottom(),
|
||||||
|
p.yo + y_bottom - height);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
y_bottom -= int(parparams.spaceBottom().inPixels(p.bv));
|
||||||
|
}
|
||||||
|
|
||||||
Buffer const * buffer = p.bv->buffer();
|
Buffer const * buffer = p.bv->buffer();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user