* funcrequest.C: initialize button_ member
+ * text3.C:
+ * rowpainter.[Ch]: interface consolidation
+
2003-08-18 André Pönitz <poenitz@gmx.net>
* BufferView.C:
+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()
}
-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();
return false;
text->top_y(newtop);
- //draw();
return true;
}
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()
}
}
- newtop = max(newtop, 0);
-
- return newtop;
+ return max(newtop, 0);
}
int const newtop = topCursorVisible(text);
bool const result = (newtop != text->top_y());
text->top_y(newtop);
- //if (result)
- // draw();
return result;
}
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();
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);
- }
-}
virtual void removeCursor() = 0;
private:
- /// y1 and y2 are coordinates of the screen
- void drawFromTo(LyXText *, BufferView *);
-
/// grey out (no buffer)
void greyOut();
+
+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
}
-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.
// 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;
}
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;
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);
}
void InsetText::clearSelection(BufferView * bv)
{
- getLyXText(bv)->clearSelection();
+ text_.clearSelection();
}
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 =
}
-} // 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)
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);
+}
+
+
#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
}
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();
// update the minibuffer
if (old_font != real_current_font)
bv->owner()->view_state_changed();
+ bv->updateScrollbar();
break;
}