shift rowpainter interface a bit

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7575 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-08-19 16:46:47 +00:00
parent 1f9e9cf517
commit 08492c2703
9 changed files with 102 additions and 109 deletions

View File

@ -3,6 +3,9 @@
* funcrequest.C: initialize button_ member
* text3.C:
* rowpainter.[Ch]: interface consolidation
2003-08-18 André Pönitz <poenitz@gmx.net>
* BufferView.C:

View File

@ -1,4 +1,8 @@
2003-08-19 André Pönitz <poenitz@gmx.net>
* screen.[Ch]: use new rowpainter interface
2003-08-18 André Pönitz <poenitz@gmx.net>
* screen.[Ch]: remove draw()

View File

@ -220,7 +220,7 @@ void LyXScreen::toggleCursor(BufferView & bv)
}
bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
bool LyXScreen::fitManualCursor(BufferView * /*bv*/, LyXText * text,
int /*x*/, int y, int asc, int desc)
{
int const vheight = workarea().workHeight();
@ -237,7 +237,6 @@ bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
return false;
text->top_y(newtop);
//draw();
return true;
}
@ -251,13 +250,7 @@ unsigned int LyXScreen::topCursorVisible(LyXText * text)
RowList::iterator row = text->cursorRow();
#warning SUPER HACK DISABLED (Lgb)
#if 0
// Is this a hack? Yes, probably... (Lgb)
if (!row)
return max(newtop, 0);
#endif
if (cursor.y() - row->baseline() + row->height() - top_y >= vheight) {
if (int(cursor.y() - row->baseline() + row->height() - top_y) >= vheight) {
if (row->height() < vheight
&& row->height() > vheight / 4) {
newtop = cursor.y()
@ -278,9 +271,7 @@ unsigned int LyXScreen::topCursorVisible(LyXText * text)
}
}
newtop = max(newtop, 0);
return newtop;
return max(newtop, 0);
}
@ -290,8 +281,6 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
int const newtop = topCursorVisible(text);
bool const result = (newtop != text->top_y());
text->top_y(newtop);
//if (result)
// draw();
return result;
}
@ -308,7 +297,18 @@ void LyXScreen::redraw(BufferView & bv)
workarea().getPainter().start();
bv.text->updateRowPositions();
drawFromTo(bv.text, &bv);
hideCursor();
int const y = paintText(bv, *bv.text);
// maybe we have to clear the screen at the bottom
int const y2 = workarea().workHeight();
if (y < y2 && !bv.text->isInInset()) {
workarea().getPainter().fillRectangle(0, y,
workarea().workWidth(), y2 - y,
LColor::bottomarea);
}
expose(0, 0, workarea().workWidth(), workarea().workHeight());
workarea().getPainter().end();
@ -347,24 +347,3 @@ void LyXScreen::greyOut()
expose(0, 0, workarea().workWidth(), workarea().workHeight());
workarea().getPainter().end();
}
void LyXScreen::drawFromTo(LyXText * text, BufferView * bv)
{
hideCursor();
int const topy = text->top_y();
int y_text = topy;
ParagraphList::iterator pit;
RowList::iterator rit = text->getRowNearY(y_text, pit);
int y = y_text - topy;
y = paintRows(*bv, *text, pit, rit, 0, y, y, 0);
// maybe we have to clear the screen at the bottom
int const y2 = workarea().workHeight();
if (y < y2 && !text->isInInset()) {
workarea().getPainter().fillRectangle(0, y,
workarea().workWidth(), y2 - y,
LColor::bottomarea);
}
}

View File

@ -108,9 +108,6 @@ protected:
virtual void removeCursor() = 0;
private:
/// y1 and y2 are coordinates of the screen
void drawFromTo(LyXText *, BufferView *);
/// grey out (no buffer)
void greyOut();

View File

@ -1,3 +1,8 @@
2003-08-19 André Pönitz <poenitz@gmx.net>
* insettext.C: use new RowPainter interface
2003-08-18 John Levon <levon@movementarian.org>
* insetref.C: require amsmath for eqref

View File

@ -251,7 +251,7 @@ int InsetText::textWidth() const
}
void InsetText::draw(PainterInfo & pi, int x, int baseline) const
void InsetText::draw(PainterInfo & pi, int x, int y) const
{
// update our idea of where we are. Clearly, we should
// not have to know this information.
@ -264,11 +264,11 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
// repaint the background if needed
if (backgroundColor() != LColor::background)
clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, baseline);
clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, y);
// no draw is necessary !!!
if (drawFrame_ == LOCKED && !locked && paragraphs.begin()->empty()) {
top_baseline = baseline;
top_baseline = y;
return;
}
@ -277,8 +277,8 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
if (!owner())
x += scroll();
top_baseline = baseline;
top_y = baseline - dim_.asc;
top_baseline = y;
top_y = y - dim_.asc;
if (the_locking_inset && cpar() == inset_par && cpos() == inset_pos) {
inset_x = cix() - x + drawTextXOffset;
@ -287,33 +287,10 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
x += TEXT_TO_INSET_OFFSET;
RowList::iterator rit = text_.firstRow();
RowList::iterator end = text_.endRow();
ParagraphList::iterator pit = paragraphs.begin();
int y_offset = baseline - rit->ascent_of_text();
int first = 0;
int y = y_offset;
while (rit != end && y + rit->height() <= 0) {
y += rit->height();
first += rit->height();
text_.nextRow(pit, rit);
}
if (y_offset < 0) {
text_.top_y(-y_offset);
first = y;
y_offset = 0;
} else {
text_.top_y(first);
first = 0;
}
int yo = y_offset + first;
paintRows(*bv, text_, pit, rit, x, 0, yo, yo);
paintTextInset(*bv, text_, x, y);
if (drawFrame_ == ALWAYS || (drawFrame_ == LOCKED && locked))
drawFrame(pain, int(start_x));
drawFrame(pain, start_x);
}
@ -1629,7 +1606,7 @@ int InsetText::scroll(bool recursive) const
void InsetText::clearSelection(BufferView * bv)
{
getLyXText(bv)->clearSelection();
text_.clearSelection();
}
@ -1776,12 +1753,7 @@ bool InsetText::searchBackward(BufferView * bv, string const & str,
return true;
}
if (!locked) {
ParagraphList::iterator pit = paragraphs.begin();
ParagraphList::iterator pend = paragraphs.end();
while (boost::next(pit) != pend)
++pit;
ParagraphList::iterator pit = boost::prior(paragraphs.end());
text_.setCursor(pit, pit->size());
}
lyx::find::SearchResult result =

View File

@ -1041,30 +1041,6 @@ void RowPainter::paint()
}
} // namespace anon
int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
{
if (vsp.kind() == VSpace::NONE)
return 0;
int const arrow_size = 4;
int const space_size = vsp.inPixels(bv);
LyXFont font;
font.decSize();
int const min_size = max(3 * arrow_size,
font_metrics::maxAscent(font)
+ font_metrics::maxDescent(font));
if (vsp.length().len().value() < 0.0)
return min_size;
else
return max(min_size, space_size);
}
int paintRows(BufferView const & bv, LyXText const & text,
ParagraphList::iterator pit, RowList::iterator rit,
int xo, int y, int yf, int yo)
@ -1099,3 +1075,61 @@ int paintRows(BufferView const & bv, LyXText const & text,
return y;
}
} // namespace anon
int paintText(BufferView & bv, LyXText & text)
{
int const topy = text.top_y();
int y_text = topy;
ParagraphList::iterator pit;
RowList::iterator rit = text.getRowNearY(y_text, pit);
int y = y_text - topy;
return paintRows(bv, text, pit, rit, 0, y, y, 0);
}
void paintTextInset(BufferView & bv, LyXText & text, int x, int baseline)
{
RowList::iterator rit = text.firstRow();
RowList::iterator end = text.endRow();
ParagraphList::iterator pit = text.ownerParagraphs().begin();
int y_offset = baseline - rit->ascent_of_text();
int y = y_offset;
while (rit != end && y + rit->height() <= 0) {
y += rit->height();
text.nextRow(pit, rit);
}
if (y_offset < 0) {
text.top_y(-y_offset);
paintRows(bv, text, pit, rit, x, 0, y, y);
} else {
text.top_y(y - y_offset);
paintRows(bv, text, pit, rit, x, 0, y_offset, y_offset);
}
}
int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
{
if (vsp.kind() == VSpace::NONE)
return 0;
int const arrow_size = 4;
int const space_size = vsp.inPixels(bv);
LyXFont font;
font.decSize();
int const min_size = max(3 * arrow_size,
font_metrics::maxAscent(font)
+ font_metrics::maxDescent(font));
if (vsp.length().len().value() < 0.0)
return min_size;
else
return max(min_size, space_size);
}

View File

@ -15,19 +15,17 @@
#include <config.h>
#include "RowList.h"
class LyXText;
class BufferView;
class VSpace;
/// paint the rows
// return last used y
int paintRows(BufferView const & bv, LyXText const & text,
ParagraphList::iterator pit,
RowList::iterator rit, int xo, int y, int yf, int yo);
/// return the pixel height of a space marker before/after a par
int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp);
/// paint the rows of the main text, return last drawn y value
int paintText(BufferView & bv, LyXText & text);
/// paint the rows of a text inset
void paintTextInset(BufferView & bv, LyXText & text, int x, int y);
#endif // ROWPAINTER_H

View File

@ -1454,7 +1454,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
}
bv->beforeChange(this);
LyXFont const old_font(real_current_font);
LyXFont const old_font = real_current_font;
string::const_iterator cit = cmd.argument.begin();
string::const_iterator end = cmd.argument.end();
@ -1469,6 +1469,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
// update the minibuffer
if (old_font != real_current_font)
bv->owner()->view_state_changed();
bv->updateScrollbar();
break;
}