par[i].inset().edit(cursor(), true);
cursor().setCursor(makeDocIterator(par, pos), false);
+ par.bottom().text()->redoParagraph(par.bottom().par());
}
-/*
-if the fitCursor call refers to some point in never-explored-land, then we
-don't have y information in insets there, then we cannot even do an update
-to get it (because we need the y infomation for setting top_y first). So
-this is solved in putSelectionAt with:
-
-- setting top_y to the y of the outerPar (that has good info)
-- calling update
-- calling cursor().updatePos()
-- then call fitCursor()
-
-Ab.
-*/
-
void BufferView::putSelectionAt(DocIterator const & cur,
int length, bool backwards)
{
cursor().clearSelection();
- LyXText & text = *cur[0].text();
setCursor(par, cur.pos());
- // hack for the chicken and egg problem
- top_y(text.getPar(par.outerPar()).y);
-
- update();
- //text.setCursor(cursor(), cur.par(), cur.pos());
- cursor().updatePos();
-
if (length) {
if (backwards) {
cursor().setSelection(cursor(), -length);
} else
cursor().setSelection(cursor(), length);
}
-
- fitCursor();
- update();
}
#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "pariterator.h"
+#include "rowpainter.h"
#include "undo.h"
#include "vspace.h"
#include "support/globbing.h"
#include "support/path_defines.h"
#include "support/tostr.h"
+#include "support/types.h"
#include <boost/bind.hpp>
bool BufferView::Pimpl::fitCursor()
{
+ // to get the correct y cursor info
+ lyxerr << "BufferView::fitCursor" << std::endl;
+ lyx::par_type const pit = bv_->cursor().bottom().par();
+ bv_->text()->redoParagraph(pit);
+ refreshPar(*bv_, *bv_->text(), pit);
+
if (!screen().fitCursor(bv_))
return false;
updateScrollbar();
text->init(bv_);
update();
- bv_->cursor().updatePos();
fitCursor();
switchKeyMap();
if (!res.dispatched())
res = cur.dispatch(cmd);
- // Redraw if requested or necessary.
- if (res.update())
- update();
- if (fitCursor())
- update();
+ if (res.dispatched()) {
+ // Redraw if requested or necessary.
+ if (fitCursor() || res.update())
+ update();
+ }
// see workAreaKeyPress
cursor_timeout.restart();
#endif
while (lyx::find::findNextChange(bv_))
bv_->getLyXText()->rejectChange(bv_->cursor());
- update();
break;
}
case LFUN_MARK_OFF:
cur.clearSelection();
- update();
cur.resetAnchor();
cur.message(N_("Mark off"));
break;
case LFUN_MARK_ON:
cur.clearSelection();
cur.mark() = true;
- update();
cur.resetAnchor();
cur.message(N_("Mark on"));
break;
cur.message(N_("Mark set"));
}
cur.resetAnchor();
- update();
break;
case LFUN_CENTER:
+
+2004-04-07 Alfredo Braunstein <abraunst@lyx.org>
+
+ * BufferView.C (setCursor): call redoParagraph (some insets could
+ have been opened)
+ (putSelectionAt): remove the 'double update' trick
+
+ * BufferView_pimpl.C (fitCursor): call refreshPar
+ (workAreaDispatch): remove an uneeded update call
+ (dispatch): remove some manual update calls
+
+ * cursor.[Ch]: remove cached_y_, updatePos
+ (selHandle): set noUpdate when appropriate
+
+ * lyxfunc.C (dispatch): track if we need an update
+
+ * metricsinfo.[Ch]: PainterInfo receive a Painter & on construction
+
+ * rowpainter.[Ch] (RowPainter): remove superfluous xo_ parameter
+ (paintSelection): cheap optimization, do not call cursorX when not
+ needed
+ (paintPars): change signature
+ (refreshPar): add
+ (paintText): adjust
+ (paintTextInset): adjust
+
+ * text.C: adjust
+
2004-04-05 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* lengthcommon.C: compilation fix: remove explicit array size from
LCursor::LCursor(BufferView & bv)
- : DocIterator(), bv_(&bv),
- anchor_(), cached_y_(0), x_target_(-1),
+ : DocIterator(), bv_(&bv), anchor_(), x_target_(-1),
selection_(false), mark_(false)
{}
clear();
push_back(CursorSlice(inset));
anchor_ = DocIterator(inset);
- cached_y_ = 0;
clearTargetX();
selection_ = false;
mark_ = false;
if (!disp_.dispatched()) {
lyxerr << "RESTORING OLD CURSOR!" << endl;
operator=(safe);
+ disp_.dispatched(false);
}
return disp_;
}
}
-void LCursor::updatePos()
-{
- BOOST_ASSERT(!empty());
- if (size() > 1)
- cached_y_ = bv().top_y() + back().inset().yo();
- //cached_y_ = back().inset().yo();
-}
-
-
void LCursor::getDim(int & asc, int & des) const
{
if (inMathed()) {
y = 0;
if (!empty())
inset().getCursorPos(back(), x, y);
- // getCursorPos gives _screen_ coordinates. We need to add
- // top_y to get document coordinates. This is hidden in cached_y_.
- //y += cached_y_ - inset().yo();
- // The rest is non-obvious. The reason we have to have these
- // extra computation is that the getCursorPos() calls rely
- // on the inset's own knowledge of its screen position.
- // If we scroll up or down in a big enough increment,
- // inset->draw() is not called: this doesn't update
- // inset.yo_, so getCursor() returns an old value.
- // Ugly as you like.
}
void LCursor::selHandle(bool sel)
{
//lyxerr << "LCursor::selHandle" << endl;
- if (sel == selection())
+ if (sel == selection()) {
+ if (!sel)
+ noUpdate();
return;
+ }
+
resetAnchor();
selection() = sel;
}
/// access to normalized selection anchor
CursorSlice anchor() const;
- /// cache the absolute coordinate from the top inset
- void updatePos();
/// sets anchor to cursor position
void resetAnchor();
/// access to owning BufferView
DispatchResult disp_;
private:
- ///
- int cached_y_;
/**
* The target x position of the cursor. This is used for when
* we have text like :
+
+2004-04-07 Alfredo Braunstein <abraunst@lyx.org>
+
+ * Makefile.am: adjust
+
+ * Painter.[Ch]: remove Painter & return value everywhere, make
+ virtual all remaining nonvirtual methods
+
+ * nullpainter.[Ch]: add no-op painter
+
2004-04-05 Angus Leeming <leeming@lyx.org>
* Dialogs.h: remove redundant header file. Clean up comments.
key_state.h \
lyx_gui.h \
mouse_state.h \
+ nullpainter.C \
+ nullpainter.h \
screen.C \
screen.h
using std::string;
-Painter & Painter::button(int x, int y, int w, int h)
+void Painter::button(int x, int y, int w, int h)
{
fillRectangle(x, y, w, h, LColor::buttonbg);
buttonFrame(x, y, w, h);
- return * this;
}
-Painter & Painter::buttonFrame(int x, int y, int w, int h)
+void Painter::buttonFrame(int x, int y, int w, int h)
{
// Width of a side of the button
int const d = 2;
x1[2] = x + w; y1[2] = (y + h - d);
x1[3] = x + w; y1[3] = y;
fillPolygon(x1, y1, 4, LColor::right);
-
- return *this;
}
-Painter & Painter::rectText(int x, int baseline,
+void Painter::rectText(int x, int baseline,
string const & str,
LyXFont const & font,
LColor_color back,
}
text(x + 3, baseline, str, font);
- return *this;
}
-Painter & Painter::buttonText(int x, int baseline,
+void Painter::buttonText(int x, int baseline,
string const & str,
LyXFont const & font)
{
button(x, baseline - ascent, width, descent + ascent);
text(x + 4, baseline, str, font);
- return *this;
}
virtual int paperHeight() const = 0;
/// draw a line from point to point
- virtual Painter & line(
+ virtual void line(
int x1, int y1,
int x2, int y2,
LColor_color,
* @param yp array of points' y co-ords
* @param np size of the points array
*/
- virtual Painter & lines(
+ virtual void lines(
int const * xp,
int const * yp,
int np,
line_width = line_thin) = 0;
/// draw a rectangle
- virtual Painter & rectangle(
+ virtual void rectangle(
int x, int y,
int w, int h,
LColor_color,
line_width = line_thin) = 0;
/// draw a filled rectangle
- virtual Painter & fillRectangle(
+ virtual void fillRectangle(
int x, int y,
int w, int h,
LColor_color) = 0;
/// draw a filled (irregular) polygon
- virtual Painter & fillPolygon(
+ virtual void fillPolygon(
int const * xp,
int const * yp,
int np,
LColor_color) = 0;
/// draw an arc
- virtual Painter & arc(
+ virtual void arc(
int x, int y,
unsigned int w, unsigned int h,
int a1, int a2,
LColor_color) = 0;
/// draw a pixel
- virtual Painter & point(
+ virtual void point(
int x, int y,
LColor_color) = 0;
/// draw a filled rectangle with the shape of a 3D button
- virtual Painter & button(int x, int y,
+ virtual void button(int x, int y,
int w, int h);
/// draw an image from the image cache
- virtual Painter & image(int x, int y,
+ virtual void image(int x, int y,
int w, int h,
lyx::graphics::Image const & image) = 0;
/// draw a string at position x, y (y is the baseline)
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
std::string const & str, LyXFont const & f) = 0;
/**
* Draw a string at position x, y (y is the baseline)
* This is just for fast drawing
*/
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
char const * str, size_t l,
LyXFont const & f) = 0;
/// draw a char at position x, y (y is the baseline)
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
char c, LyXFont const & f) = 0;
/**
* the given color. If frame is specified, a thin frame is drawn
* around the text with the given color.
*/
- Painter & rectText(int x, int baseline,
+ virtual void rectText(int x, int baseline,
std::string const & str,
LyXFont const & font,
LColor_color back,
LColor_color frame);
/// draw a string and enclose it inside a button frame
- Painter & buttonText(int x,
+ virtual void buttonText(int x,
int baseline, std::string const & s,
LyXFont const & font);
protected:
/// check the font, and if set, draw an underline
- void underline(LyXFont const & f,
+ virtual void underline(LyXFont const & f,
int x, int y, int width);
/// draw a bevelled button border
- Painter & buttonFrame(int x, int y, int w, int h);
+ virtual void buttonFrame(int x, int y, int w, int h);
};
#endif // PAINTER_H
+
+2004-04-07 Alfredo Braunstein <abraunst@lyx.org>
+
+ * GPainter.[Ch]: adjust to changes in Painter.h
+
2004-04-05 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): set the preferences dialog button policy to
}
-Painter & GPainter::point(int x, int y, LColor_color c)
+void GPainter::point(int x, int y, LColor_color c)
{
setForeground(owner_.getGC(), c);
owner_.getPixmap()->draw_point(owner_.getGC(), x, y);
}
-Painter & GPainter::line(int x1, int y1,
+void GPainter::line(int x1, int y1,
int x2, int y2,
LColor_color col,
line_style ls,
}
-Painter & GPainter::lines(int const * xp, int const * yp,
- int np,
+void GPainter::lines(int const * xp, int const * yp, int np,
LColor_color col,
line_style ls,
line_width lw)
}
-Painter & GPainter::rectangle(int x, int y,
- int w, int h,
+void GPainter::rectangle(int x, int y, int w, int h,
LColor_color col,
line_style ls,
line_width lw)
}
-Painter & GPainter::fillRectangle(int x, int y,
- int w, int h,
+void GPainter::fillRectangle(int x, int y, int w, int h,
LColor_color col)
{
setForeground(owner_.getGC(), col);
}
-Painter & GPainter::fillPolygon(int const * xp, int const * yp,
+void GPainter::fillPolygon(int const * xp, int const * yp,
int np, LColor_color col)
{
setForeground(owner_.getGC(), col);
}
-Painter & GPainter::arc(int x, int y,
- unsigned int w, unsigned int h,
+void GPainter::arc(int x, int y, unsigned int w, unsigned int h,
int a1, int a2, LColor_color col)
{
setForeground(owner_.getGC(), col);
}
-Painter & GPainter::image(int x, int y,
- int w, int h,
+void GPainter::image(int x, int y, int w, int h,
lyx::graphics::Image const & i)
{
lyx::graphics::xformsImage const & image =
}
-Painter & GPainter::text(int x, int y,
- std::string const & s, LyXFont const & f)
+void GPainter::text(int x, int y, std::string const & s, LyXFont const & f)
{
size_t size = s.length() + 1;
wchar_t * wcs = (wchar_t *) alloca(size * sizeof(wchar_t));
}
-Painter & GPainter::text(int x, int y,
- char c, LyXFont const & f)
+void GPainter::text(int x, int y, char c, LyXFont const & f)
{
char s[2] = { c, '\0' };
return text(x, y, s, 1, f);
}
-Painter & GPainter::text(int x, int y, wchar_t const * s, int ls,
- LyXFont const & f)
+void GPainter::text(int x, int y, wchar_t const * s, int ls, LyXFont const & f)
{
XftFont * font = getXftFont(f);
XftColor * xftClr = owner_.getColorHandler().
}
-Painter & GPainter::text(int x, int y,
- char const * s, size_t ls,
- LyXFont const & f)
+void GPainter::text(int x, int y, char const * s, size_t ls, LyXFont const & f)
{
boost::scoped_array<wchar_t> wcs(new wchar_t[ls + 1]);
size_t len;
line_style ls, line_width lw);
XftColor * getXftColor(LColor_color clr);
/// draw a line from point to point
- virtual Painter & line(
+ virtual void line(
int x1, int y1,
int x2, int y2,
LColor_color,
* @param yp array of points' y co-ords
* @param np size of the points array
*/
- virtual Painter & lines(
+ virtual void lines(
int const * xp,
int const * yp,
int np,
line_width = line_thin);
/// draw a rectangle
- virtual Painter & rectangle(
+ virtual void rectangle(
int x, int y,
int w, int h,
LColor_color,
line_width = line_thin);
/// draw a filled rectangle
- virtual Painter & fillRectangle(
+ virtual void fillRectangle(
int x, int y,
int w, int h,
LColor_color);
/// draw a filled (irregular) polygon
- virtual Painter & fillPolygon(
+ virtual void fillPolygon(
int const * xp,
int const * yp,
int np,
LColor_color);
/// draw an arc
- virtual Painter & arc(
+ virtual void arc(
int x, int y,
unsigned int w, unsigned int h,
int a1, int a2,
LColor_color);
/// draw a pixel
- virtual Painter & point(
+ virtual void point(
int x, int y,
LColor_color);
/// draw an image from the image cache
- virtual Painter & image(int x, int y,
+ virtual void image(int x, int y,
int w, int h,
lyx::graphics::Image const & image);
/// draw a string at position x, y (y is the baseline)
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
std::string const & str, LyXFont const & f);
/** Draw a string at position x, y (y is the baseline)
* This is just for fast drawing
*/
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
char const * str, size_t l,
LyXFont const & f);
- virtual Painter & text(int x, int y, wchar_t const * str, int l,
+ virtual void text(int x, int y, wchar_t const * str, int l,
LyXFont const & f);
/// draw a char at position x, y (y is the baseline)
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
char c, LyXFont const & f);
/// draw a wide string at position x, y
- Painter & text(int x, int y,
+ void text(int x, int y,
XChar2b const * str, size_t l,
LyXFont const & f);
--- /dev/null
+/**
+ * \file nullpainter.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include "nullpainter.h"
+
+#include "LColor.h"
+
+#include <limits>
+
+
+int NullPainter::paperHeight() const
+{
+ return std::numeric_limits<int>::max();
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file nullpainter.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef NULLPAINTER_H
+#define NULLPAINTER_H
+
+#include <config.h>
+
+#include "LColor.h"
+#include "Painter.h"
+
+class NullPainter : public Painter {
+public:
+ ///
+ NullPainter() {}
+
+ virtual ~NullPainter() {}
+
+ /// begin painting
+ void start() {}
+ /// end painting
+ void end() {}
+
+ ///
+ int paperWidth() const { return 0; }
+ ///
+ int paperHeight() const;
+
+ ///
+ void line(int, int, int, int, LColor_color,
+ line_style = line_solid, line_width = line_thin) {}
+ ///
+ void lines(int const *, int const *, int, LColor_color,
+ line_style = line_solid, line_width = line_thin) {}
+ ///
+ void rectangle(int, int, int, int, LColor_color,
+ line_style = line_solid, line_width = line_thin) {}
+ ///
+ void fillRectangle(int, int, int, int, LColor_color) {}
+ ///
+ void fillPolygon(int const *, int const *, int, LColor_color) {}
+ ///
+ void arc(int, int, unsigned int, unsigned int,
+ int, int, LColor_color) {}
+ ///
+ void point(int, int, LColor_color) {}
+ ///
+ void button(int, int, int, int) {}
+ ///
+ void image(int, int, int, int, lyx::graphics::Image const &) {}
+ ///
+ void text(int, int, std::string const &, LyXFont const &) {}
+ ///
+ void text(int, int, char const *, size_t, LyXFont const &) {}
+ ///
+ void text(int, int, char, LyXFont const &) {}
+ ///
+ void rectText(int, int, std::string const &,
+ LyXFont const &, LColor_color, LColor_color) {}
+ ///
+ void buttonText(int, int, std::string const &, LyXFont const &) {}
+ ///
+ void underline(LyXFont const &, int, int, int) {}
+ ///
+ void buttonFrame(int, int, int, int) {}
+};
+
+#endif // NULLPAINTER_H
+2004-04-07 Alfredo Braunstein <abraunst@lyx.org>
+
+ * QLPainter.[Ch]: adjust to changes in Painter.h
+
2004-04-05 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): set the preferences dialog button policy to
}
-Painter & QLPainter::point(int x, int y, LColor_color c)
+void QLPainter::point(int x, int y, LColor_color c)
{
setPen(c).drawPoint(x, y);
- return *this;
}
-Painter & QLPainter::line(int x1, int y1,
- int x2, int y2,
+void QLPainter::line(int x1, int y1, int x2, int y2,
LColor_color col,
line_style ls,
line_width lw)
{
setPen(col, ls, lw).drawLine(x1, y1, x2, y2);
- return *this;
}
-Painter & QLPainter::lines(int const * xp, int const * yp,
- int np,
+void QLPainter::lines(int const * xp, int const * yp, int np,
LColor_color col,
line_style ls,
line_width lw)
}
setPen(col, ls, lw).drawPolyline(QPointArray(np, points.get()));
-
- return *this;
}
-Painter & QLPainter::rectangle(int x, int y,
- int w, int h,
+void QLPainter::rectangle(int x, int y, int w, int h,
LColor_color col,
line_style ls,
line_width lw)
{
setPen(col, ls, lw).drawRect(x, y, w, h);
- return *this;
}
-Painter & QLPainter::fillRectangle(int x, int y,
- int w, int h,
- LColor_color col)
+void QLPainter::fillRectangle(int x, int y, int w, int h, LColor_color col)
{
qp_->fillRect(x, y, w, h, lcolorcache.get(col));
- return *this;
}
-Painter & QLPainter::fillPolygon(int const * xp, int const * yp,
+void QLPainter::fillPolygon(int const * xp, int const * yp,
int np, LColor_color col)
{
// Must use new as np is not known at compile time.
boost::scoped_array<QCOORD> points(new QCOORD[np * 2]);
- //if (1) return *this;
+ //if (1) return;
for (int i = 0, j = 0; i < np; ++i) {
points[j++] = xp[i];
qp_->setBrush(lcolorcache.get(col));
qp_->drawPolygon(QPointArray(np, points.get()));
qp_->setBrush(Qt::NoBrush);
-
- return *this;
}
-Painter & QLPainter::arc(int x, int y,
- unsigned int w, unsigned int h,
+void QLPainter::arc(int x, int y, unsigned int w, unsigned int h,
int a1, int a2, LColor_color col)
{
// LyX usings 1/64ths degree, Qt usings 1/16th
setPen(col).drawArc(x, y, w, h, a1 / 4, a2 / 4);
- return *this;
}
-Painter & QLPainter::image(int x, int y,
- int w, int h,
+void QLPainter::image(int x, int y, int w, int h,
lyx::graphics::Image const & i)
{
qp_->drawPixmap(x, y, static_cast<lyx::graphics::QLImage const &>(i).qpixmap(), 0, 0, w, h);
- return *this;
}
-Painter & QLPainter::text(int x, int y,
- string const & s, LyXFont const & f)
+void QLPainter::text(int x, int y, string const & s, LyXFont const & f)
{
return text(x, y, s.data(), s.length(), f);
}
-Painter & QLPainter::text(int x, int y,
- char c, LyXFont const & f)
+void QLPainter::text(int x, int y, char c, LyXFont const & f)
{
char s[2] = { c, '\0' };
return text(x, y, s, 1, f);
}
-Painter & QLPainter::text(int x, int y,
- char const * s, size_t ls,
+void QLPainter::text(int x, int y, char const * s, size_t ls,
LyXFont const & f)
{
setPen(f.realColor());
if (f.underbar() == LyXFont::ON) {
underline(f, x, y, font_metrics::width(s, ls, f));
}
-
- return *this;
}
virtual int paperHeight() const;
/// draw a line from point to point
- virtual Painter & line(
+ virtual void line(
int x1, int y1,
int x2, int y2,
LColor_color,
* @param yp array of points' y co-ords
* @param np size of the points array
*/
- virtual Painter & lines(
+ virtual void lines(
int const * xp,
int const * yp,
int np,
line_width = line_thin);
/// draw a rectangle
- virtual Painter & rectangle(
+ virtual void rectangle(
int x, int y,
int w, int h,
LColor_color,
line_width = line_thin);
/// draw a filled rectangle
- virtual Painter & fillRectangle(
+ virtual void fillRectangle(
int x, int y,
int w, int h,
LColor_color);
/// draw a filled (irregular) polygon
- virtual Painter & fillPolygon(
+ virtual void fillPolygon(
int const * xp,
int const * yp,
int np,
LColor_color);
/// draw an arc
- virtual Painter & arc(
+ virtual void arc(
int x, int y,
unsigned int w, unsigned int h,
int a1, int a2,
LColor_color);
/// draw a pixel
- virtual Painter & point(
+ virtual void point(
int x, int y,
LColor_color);
/// draw an image from the image cache
- virtual Painter & image(int x, int y,
+ virtual void image(int x, int y,
int w, int h,
lyx::graphics::Image const & image);
/// draw a string at position x, y (y is the baseline)
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
std::string const & str, LyXFont const & f);
/** Draw a string at position x, y (y is the baseline)
* This is just for fast drawing
*/
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
char const * str, size_t l,
LyXFont const & f);
/// draw a char at position x, y (y is the baseline)
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
char c, LyXFont const & f);
private:
/// draw small caps text
bv->cursor().getPos(x, y);
bv->cursor().getDim(asc, desc);
- //lyxerr << "LyXScreen::fitCursor: x: " << x << " y: " << y
- // << " top_y: " << top_y << endl;
+ lyxerr << "LyXScreen::fitCursor: x: " << x << " y: " << y
+ << " top_y: " << top_y << endl;
bool const big_row = h / 4 < asc + desc && asc + desc < h;
+
+2004-04-07 Alfredo Braunstein <abraunst@lyx.org>
+
+ * XPainter.[Ch]: adjust to changes in Painter.h
+
2004-04-05 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): set the preferences dialog button policy to
}
-Painter & XPainter::point(int x, int y, LColor_color c)
+void XPainter::point(int x, int y, LColor_color c)
{
XDrawPoint(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCForeground(c), x, y);
- return *this;
}
-Painter & XPainter::line(int x1, int y1,
+void XPainter::line(int x1, int y1,
int x2, int y2,
LColor_color col,
line_style ls,
XDrawLine(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCLinepars(ls, lw, col),
x1, y1, x2, y2);
- return *this;
}
-Painter & XPainter::lines(int const * xp, int const * yp,
+void XPainter::lines(int const * xp, int const * yp,
int np,
LColor_color col,
line_style ls,
XDrawLines(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCLinepars(ls, lw, col),
points.get(), np, CoordModeOrigin);
-
- return *this;
}
-Painter & XPainter::rectangle(int x, int y,
+void XPainter::rectangle(int x, int y,
int w, int h,
LColor_color col,
line_style ls,
XDrawRectangle(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCLinepars(ls, lw, col),
x, y, w, h);
- return *this;
}
-Painter & XPainter::fillRectangle(int x, int y,
+void XPainter::fillRectangle(int x, int y,
int w, int h,
LColor_color col)
{
XFillRectangle(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCForeground(col), x, y, w, h);
- return *this;
}
-Painter & XPainter::fillPolygon(int const * xp, int const * yp,
+void XPainter::fillPolygon(int const * xp, int const * yp,
int np, LColor_color col)
{
boost::scoped_array<XPoint> points(new XPoint[np]);
XFillPolygon(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCForeground(col), points.get(),
np, Nonconvex, CoordModeOrigin);
-
- return *this;
}
-Painter & XPainter::arc(int x, int y,
+void XPainter::arc(int x, int y,
unsigned int w, unsigned int h,
int a1, int a2, LColor_color col)
{
XDrawArc(fl_get_display(), owner_.getPixmap(),
lyxColorHandler->getGCForeground(col),
x, y, w, h, a1, a2);
- return *this;
}
-Painter & XPainter::image(int x, int y,
+void XPainter::image(int x, int y,
int w, int h,
lyx::graphics::Image const & i)
{
XCopyArea(fl_get_display(), image.getPixmap(), owner_.getPixmap(),
gc, 0, 0, w, h, x, y);
XFreeGC(fl_get_display(), gc);
- return *this;
}
-Painter & XPainter::text(int x, int y,
+void XPainter::text(int x, int y,
string const & s, LyXFont const & f)
{
return text(x, y, s.data(), s.length(), f);
}
-Painter & XPainter::text(int x, int y,
+void XPainter::text(int x, int y,
char c, LyXFont const & f)
{
char s[2] = { c, '\0' };
}
-Painter & XPainter::text(int x, int y,
+void XPainter::text(int x, int y,
char const * s, size_t ls,
LyXFont const & f)
{
xs[i].byte2 = c & 0xff;
}
text(x, y, xs.get(), ls, font);
- return *this;
+ return;
}
GC gc = lyxColorHandler->getGCForeground(f.realColor());
if (f.underbar() == LyXFont::ON) {
underline(f, x, y, font_metrics::width(s, ls, f));
}
-
- return *this;
}
-Painter & XPainter::text(int x, int y,
+void XPainter::text(int x, int y,
XChar2b const * s, size_t ls,
LyXFont const & f)
{
if (f.underbar() == LyXFont::ON) {
underline(f, x, y, xfont_metrics::width(s, ls, f));
}
-
- return *this;
}
virtual int paperHeight() const;
/// draw a line from point to point
- virtual Painter & line(
+ virtual void line(
int x1, int y1,
int x2, int y2,
LColor_color,
* @param yp array of points' y co-ords
* @param np size of the points array
*/
- virtual Painter & lines(
+ virtual void lines(
int const * xp,
int const * yp,
int np,
line_width = line_thin);
/// draw a rectangle
- virtual Painter & rectangle(
+ virtual void rectangle(
int x, int y,
int w, int h,
LColor_color,
line_width = line_thin);
/// draw a filled rectangle
- virtual Painter & fillRectangle(
+ virtual void fillRectangle(
int x, int y,
int w, int h,
LColor_color);
/// draw a filled (irregular) polygon
- virtual Painter & fillPolygon(
+ virtual void fillPolygon(
int const * xp,
int const * yp,
int np,
LColor_color);
/// draw an arc
- virtual Painter & arc(
+ virtual void arc(
int x, int y,
unsigned int w, unsigned int h,
int a1, int a2,
LColor_color);
/// draw a pixel
- virtual Painter & point(
+ virtual void point(
int x, int y,
LColor_color);
/// draw an image from the image cache
- virtual Painter & image(int x, int y,
+ virtual void image(int x, int y,
int w, int h,
lyx::graphics::Image const & image);
/// draw a string at position x, y (y is the baseline)
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
std::string const & str, LyXFont const & f);
/** Draw a string at position x, y (y is the baseline)
* This is just for fast drawing
*/
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
char const * str, size_t l,
LyXFont const & f);
/// draw a char at position x, y (y is the baseline)
- virtual Painter & text(int x, int y,
+ virtual void text(int x, int y,
char c, LyXFont const & f);
/// draw a wide string at position x, y
- Painter & text(int x, int y,
+ void text(int x, int y,
XChar2b const * str, size_t l,
LyXFont const & f);
dispatch_buffer.erase();
selection_possible = false;
+ bool update = true;
+
// We cannot use this function here
if (!getStatus(cmd).enabled()) {
lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
}
default: {
+ update = false;
DispatchResult res = view()->cursor().dispatch(cmd);
- if (!res.dispatched());
- view()->dispatch(cmd);
+ if (res.dispatched())
+ update |= res.update();
+ else
+ update |= view()->dispatch(cmd);
+
break;
}
}
if (view()->available()) {
- view()->fitCursor();
- view()->update();
- view()->cursor().updatePos();
+ if (view()->fitCursor() || update)
+ view()->update();
// if we executed a mutating lfun, mark the buffer as dirty
if (getStatus(cmd).enabled()
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)
LyXFont font = p.base.font;
font.setColor(LColor::math);
- PainterInfo pi(p.base.bv);
+ PainterInfo pi(p.base.bv, p.pain);
pi.base.style = LM_ST_TEXT;
pi.base.font = font;
-PainterInfo::PainterInfo(BufferView * bv)
- : pain(bv->painter())
+PainterInfo::PainterInfo(BufferView * bv, Painter & pa)
+ : pain(pa)
{
base.bv = bv;
}
//
struct PainterInfo {
///
- explicit PainterInfo(BufferView * bv);
+ PainterInfo(BufferView * bv, Painter & pain);
///
void draw(int x, int y, char c);
#include "vspace.h"
#include "frontends/font_metrics.h"
+#include "frontends/nullpainter.h"
#include "frontends/Painter.h"
#include "insets/insettext.h"
class RowPainter {
public:
/// initialise and run painter
- RowPainter(BufferView const & bv, LyXText const & text,
- par_type pit, RowList::iterator rit, int xo, int yo);
+ RowPainter(BufferView const & bv, Painter & pain, LyXText const & text,
+ par_type pit, RowList::iterator rit, int y);
private:
// paint various parts
void paintBackground();
};
-RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
- par_type pit, RowList::iterator rit, int xo, int yo)
- : bv_(bv), pain_(bv_.painter()), text_(text), pars_(text.paragraphs()),
- rit_(rit), row_(*rit), pit_(pit), xo_(xo), yo_(yo), width_(text_.width())
+RowPainter::RowPainter(BufferView const & bv, Painter & pain,
+ LyXText const & text, par_type pit, RowList::iterator rit, int y)
+ : bv_(bv), pain_(pain), text_(text), pars_(text.paragraphs()),
+ rit_(rit), row_(*rit), pit_(pit),
+ xo_(text_.xo_), yo_(y), width_(text_.width())
{
//lyxerr << "RowPainter: x: " << x_ << " xo: " << xo << " yo: " << yo
// << " pit->y: " << pit_->y
{
InsetBase const * inset = pars_[pit_].getInset(pos);
BOOST_ASSERT(inset);
- PainterInfo pi(const_cast<BufferView *>(&bv_));
+ PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
pi.base.font = getFont(pos);
inset->drawSelection(pi, int(x_), yo_ + row_.baseline());
inset->draw(pi, int(x_), yo_ + row_.baseline());
// the current selection
LCursor const & cur = bv_.cursor();
- int const startx = text_.cursorX(cur.selBegin());
- int const endx = text_.cursorX(cur.selEnd());
int const starty = text_.cursorY(cur.selBegin());
int const endy = text_.cursorY(cur.selEnd());
par_type startpit = cur.selBegin().par();
if (text_.bidi.same_direction()) {
if (sel_on_one_row) {
+ int const startx = text_.cursorX(cur.selBegin());
+ int const endx = text_.cursorX(cur.selEnd());
int const x1 = is_rtl ? endx : startx;
int const x2 = is_rtl ? startx : endx;
pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
} else if (sel_starts_here) {
+ int const startx = text_.cursorX(cur.selBegin());
int const x1 = is_rtl ? int(xo_) : startx;
int const x2 = is_rtl ? startx : int(xo_) + width_;
pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
} else if (sel_ends_here) {
+ int const endx = text_.cursorX(cur.selEnd());
int const x1 = is_rtl ? endx : int(xo_);
int const x2 = is_rtl ? int(xo_) + width_ : endx;
pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
}
-int paintPars(BufferView const & bv, LyXText const & text,
- par_type pit, int xo, int yo, int y)
+int paintPars(BufferView const & bv, Painter & pain,
+ LyXText const & text, par_type pit, par_type end)
{
//lyxerr << " paintRows: pit: " << &*pit << endl;
- int const y2 = bv.painter().paperHeight();
- y -= bv.top_y();
-
ParagraphList & pars = text.paragraphs();
- for ( ; pit != par_type(pars.size()); ++pit) {
+
+ int y = pars[pit].y + text.yo_ - bv.top_y();
+ int const y2 = pain.paperHeight();
+
+ for (; pit != end; ++pit) {
RowList::iterator row = pars[pit].rows.begin();
RowList::iterator rend = pars[pit].rows.end();
for ( ; row != rend; ++row) {
- RowPainter(bv, text, pit, row, xo, y + yo);
+ RowPainter(bv, pain, text, pit, row, y);
y += row->height();
+ if (y >= y2)
+ break;
}
- if (yo + y >= y2)
- break;
- }
+ }
return y;
}
+
} // namespace anon
+void refreshPar(BufferView const & bv, LyXText const & text, par_type pit)
+{
+
+ static NullPainter nop;
+ paintPars(bv, nop, text, pit, pit + 1);
+}
+
+
int paintText(BufferView const & bv)
{
- par_type pit;
- bv.text()->updateParPositions();
- bv.text()->getRowNearY(bv.top_y(), pit);
+ par_type pit, end;
+ getParsInRange(bv.text()->paragraphs(), bv.top_y(),
+ bv.top_y() + bv.workHeight(), pit, end);
//lyxerr << "top_y: " << bv.top_y() << " y: " << pit->y << endl;
- return paintPars(bv, *bv.text(), pit, 0, 0, bv.text()->paragraphs()[pit].y);
+ return paintPars(bv, bv.painter(), *bv.text(), pit, end);
}
-void paintTextInset(LyXText const & text, PainterInfo & pi, int xo, int yo)
+void paintTextInset(LyXText const & text, PainterInfo & pi)
{
- paintPars(*pi.base.bv, text, 0, xo, yo, 0);
+ paintPars(*pi.base.bv, pi.pain, text, 0, text.paragraphs().size());
}
#ifndef ROWPAINTER_H
#define ROWPAINTER_H
+#include "support/types.h"
+
class LyXText;
class BufferView;
class PainterInfo;
/// paint the rows of the main text, return last drawn y value
int paintText(BufferView const & bv);
+/// refresh a par of the main text
+void refreshPar(BufferView const & bv, LyXText const & text,
+ lyx::par_type pit);
+
/// paint the rows of a text inset
-void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y);
+void paintTextInset(LyXText const & text, PainterInfo & pi);
#endif // ROWPAINTER_H
{
xo_ = x;
yo_ = y;
- paintTextInset(*this, pi, x, y);
+ paintTextInset(*this, pi);
}