mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 22:41:09 +00:00
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:
parent
1f9e9cf517
commit
08492c2703
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
* funcrequest.C: initialize button_ member
|
* funcrequest.C: initialize button_ member
|
||||||
|
|
||||||
|
* text3.C:
|
||||||
|
* rowpainter.[Ch]: interface consolidation
|
||||||
|
|
||||||
2003-08-18 André Pönitz <poenitz@gmx.net>
|
2003-08-18 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* BufferView.C:
|
* BufferView.C:
|
||||||
|
@ -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>
|
2003-08-18 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
* screen.[Ch]: remove draw()
|
* screen.[Ch]: remove draw()
|
||||||
|
@ -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 /*x*/, int y, int asc, int desc)
|
||||||
{
|
{
|
||||||
int const vheight = workarea().workHeight();
|
int const vheight = workarea().workHeight();
|
||||||
@ -237,7 +237,6 @@ bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
text->top_y(newtop);
|
text->top_y(newtop);
|
||||||
//draw();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,13 +250,7 @@ unsigned int LyXScreen::topCursorVisible(LyXText * text)
|
|||||||
|
|
||||||
RowList::iterator row = text->cursorRow();
|
RowList::iterator row = text->cursorRow();
|
||||||
|
|
||||||
#warning SUPER HACK DISABLED (Lgb)
|
if (int(cursor.y() - row->baseline() + row->height() - top_y) >= vheight) {
|
||||||
#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 (row->height() < vheight
|
if (row->height() < vheight
|
||||||
&& row->height() > vheight / 4) {
|
&& row->height() > vheight / 4) {
|
||||||
newtop = cursor.y()
|
newtop = cursor.y()
|
||||||
@ -278,9 +271,7 @@ unsigned int LyXScreen::topCursorVisible(LyXText * text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newtop = max(newtop, 0);
|
return max(newtop, 0);
|
||||||
|
|
||||||
return newtop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -290,8 +281,6 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
|
|||||||
int const newtop = topCursorVisible(text);
|
int const newtop = topCursorVisible(text);
|
||||||
bool const result = (newtop != text->top_y());
|
bool const result = (newtop != text->top_y());
|
||||||
text->top_y(newtop);
|
text->top_y(newtop);
|
||||||
//if (result)
|
|
||||||
// draw();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +297,18 @@ void LyXScreen::redraw(BufferView & bv)
|
|||||||
workarea().getPainter().start();
|
workarea().getPainter().start();
|
||||||
|
|
||||||
bv.text->updateRowPositions();
|
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());
|
expose(0, 0, workarea().workWidth(), workarea().workHeight());
|
||||||
|
|
||||||
workarea().getPainter().end();
|
workarea().getPainter().end();
|
||||||
@ -347,24 +347,3 @@ void LyXScreen::greyOut()
|
|||||||
expose(0, 0, workarea().workWidth(), workarea().workHeight());
|
expose(0, 0, workarea().workWidth(), workarea().workHeight());
|
||||||
workarea().getPainter().end();
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -108,9 +108,6 @@ protected:
|
|||||||
virtual void removeCursor() = 0;
|
virtual void removeCursor() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// y1 and y2 are coordinates of the screen
|
|
||||||
void drawFromTo(LyXText *, BufferView *);
|
|
||||||
|
|
||||||
/// grey out (no buffer)
|
/// grey out (no buffer)
|
||||||
void greyOut();
|
void greyOut();
|
||||||
|
|
||||||
|
@ -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>
|
2003-08-18 John Levon <levon@movementarian.org>
|
||||||
|
|
||||||
* insetref.C: require amsmath for eqref
|
* insetref.C: require amsmath for eqref
|
||||||
|
@ -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
|
// update our idea of where we are. Clearly, we should
|
||||||
// not have to know this information.
|
// 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
|
// repaint the background if needed
|
||||||
if (backgroundColor() != LColor::background)
|
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 !!!
|
// no draw is necessary !!!
|
||||||
if (drawFrame_ == LOCKED && !locked && paragraphs.begin()->empty()) {
|
if (drawFrame_ == LOCKED && !locked && paragraphs.begin()->empty()) {
|
||||||
top_baseline = baseline;
|
top_baseline = y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,8 +277,8 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
|
|||||||
if (!owner())
|
if (!owner())
|
||||||
x += scroll();
|
x += scroll();
|
||||||
|
|
||||||
top_baseline = baseline;
|
top_baseline = y;
|
||||||
top_y = baseline - dim_.asc;
|
top_y = y - dim_.asc;
|
||||||
|
|
||||||
if (the_locking_inset && cpar() == inset_par && cpos() == inset_pos) {
|
if (the_locking_inset && cpar() == inset_par && cpos() == inset_pos) {
|
||||||
inset_x = cix() - x + drawTextXOffset;
|
inset_x = cix() - x + drawTextXOffset;
|
||||||
@ -287,33 +287,10 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
|
|||||||
|
|
||||||
x += TEXT_TO_INSET_OFFSET;
|
x += TEXT_TO_INSET_OFFSET;
|
||||||
|
|
||||||
RowList::iterator rit = text_.firstRow();
|
paintTextInset(*bv, text_, x, y);
|
||||||
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);
|
|
||||||
|
|
||||||
if (drawFrame_ == ALWAYS || (drawFrame_ == LOCKED && locked))
|
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)
|
void InsetText::clearSelection(BufferView * bv)
|
||||||
{
|
{
|
||||||
getLyXText(bv)->clearSelection();
|
text_.clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1776,12 +1753,7 @@ bool InsetText::searchBackward(BufferView * bv, string const & str,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!locked) {
|
if (!locked) {
|
||||||
ParagraphList::iterator pit = paragraphs.begin();
|
ParagraphList::iterator pit = boost::prior(paragraphs.end());
|
||||||
ParagraphList::iterator pend = paragraphs.end();
|
|
||||||
|
|
||||||
while (boost::next(pit) != pend)
|
|
||||||
++pit;
|
|
||||||
|
|
||||||
text_.setCursor(pit, pit->size());
|
text_.setCursor(pit, pit->size());
|
||||||
}
|
}
|
||||||
lyx::find::SearchResult result =
|
lyx::find::SearchResult result =
|
||||||
|
@ -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,
|
int paintRows(BufferView const & bv, LyXText const & text,
|
||||||
ParagraphList::iterator pit, RowList::iterator rit,
|
ParagraphList::iterator pit, RowList::iterator rit,
|
||||||
int xo, int y, int yf, int yo)
|
int xo, int y, int yf, int yo)
|
||||||
@ -1099,3 +1075,61 @@ int paintRows(BufferView const & bv, LyXText const & text,
|
|||||||
return y;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,19 +15,17 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "RowList.h"
|
|
||||||
|
|
||||||
class LyXText;
|
class LyXText;
|
||||||
class BufferView;
|
class BufferView;
|
||||||
class VSpace;
|
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
|
/// return the pixel height of a space marker before/after a par
|
||||||
int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp);
|
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
|
#endif // ROWPAINTER_H
|
||||||
|
@ -1454,7 +1454,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bv->beforeChange(this);
|
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 cit = cmd.argument.begin();
|
||||||
string::const_iterator end = cmd.argument.end();
|
string::const_iterator end = cmd.argument.end();
|
||||||
@ -1469,6 +1469,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
// update the minibuffer
|
// update the minibuffer
|
||||||
if (old_font != real_current_font)
|
if (old_font != real_current_font)
|
||||||
bv->owner()->view_state_changed();
|
bv->owner()->view_state_changed();
|
||||||
|
bv->updateScrollbar();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user