bot.text()->redoParagraph(pit);
Paragraph const & par = bot.text()->paragraphs()[pit];
anchor_ref_ = pit;
- offset_ref_ = bv_funcs::coordOffset(cursor_, cursor_.boundary()).y_
+ offset_ref_ = bv_funcs::coordOffset(*this, cursor_, cursor_.boundary()).y_
+ par.ascent() - height_ / 2;
}
// the next two should probably go elsewhere
// this give the position relative to (0, baseline) of outermost
// paragraph
-Point coordOffset(DocIterator const & dit, bool boundary)
+Point coordOffset(BufferView const & bv, DocIterator const & dit,
+ bool boundary)
{
int x = 0;
int y = 0;
CursorSlice const & sl = dit[i];
int xx = 0;
int yy = 0;
- sl.inset().cursorPos(sl, boundary && ((i+1) == dit.depth()), xx, yy);
+ sl.inset().cursorPos(bv, sl, boundary && ((i+1) == dit.depth()), xx, yy);
x += xx;
y += yy;
//lyxerr << "LCursor::getPos, i: "
//lyxerr << "cursor out of view" << std::endl;
return Point(-1, -1);
}
- Point p = coordOffset(dit, boundary); // offset from outer paragraph
+ Point p = coordOffset(bv, dit, boundary); // offset from outer paragraph
p.y_ += it->second.y_;
return p;
}
CurStatus status(BufferView const * bv, DocIterator const & dit);
-lyx::Point coordOffset(DocIterator const & dit, bool boundary);
+lyx::Point coordOffset(BufferView const & bv, DocIterator const & dit, bool boundary);
/// Moves cursor to the next inset with one of the given codes.
void gotoInset(BufferView * bv, std::vector<InsetBase_code> const & codes,
int yo;
InsetBase const * inset = &it.inset();
Point o = c.bv().coordCache().getInsets().xy(inset);
- inset->cursorPos(it.top(), c.boundary(), xo, yo);
+ inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo);
// Convert to absolute
xo += o.x_;
yo += o.y_;
{}
-void InsetBase::cursorPos(CursorSlice const &, bool, int & x, int & y) const
+void InsetBase::cursorPos(BufferView const & bv, CursorSlice const &,
+ bool, int & x, int & y) const
{
lyxerr << "InsetBase::cursorPos called directly" << std::endl;
x = 100;
/// do we cover screen position x/y?
virtual bool covers(BufferView & bv, int x, int y) const;
/// get the screen positions of the cursor (see note in cursor.C)
- virtual void cursorPos(CursorSlice const & sl, bool boundary,
- int & x, int & y) const;
+ virtual void cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool boundary, int & x, int & y) const;
/// is this an inset that can be moved into?
virtual bool isActive() const { return nargs() > 0; }
}
-void InsetCaption::cursorPos
- (CursorSlice const & sl, bool boundary, int & x, int & y) const
+void InsetCaption::cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool boundary, int & x, int & y) const
{
- InsetText::cursorPos(sl, boundary, x, y);
+ InsetText::cursorPos(bv, sl, boundary, x, y);
x += labelwidth_;
}
///
virtual lyx::docstring const editMessage() const;
///
- virtual void cursorPos
- (CursorSlice const & sl, bool boundary, int & x, int & y) const;
+ virtual void cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool boundary, int & x, int & y) const;
///
bool descendable() const { return true; }
///
}
-void InsetCollapsable::cursorPos
- (CursorSlice const & sl, bool boundary, int & x, int & y) const
+void InsetCollapsable::cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool boundary, int & x, int & y) const
{
BOOST_ASSERT(status() != Collapsed);
- InsetText::cursorPos(sl, boundary, x, y);
+ InsetText::cursorPos(bv, sl, boundary, x, y);
if (status() == Open) {
if (openinlined_)
///
void drawSelection(PainterInfo & pi, int x, int y) const;
/// return x,y of given position relative to the inset's baseline
- void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
+ void cursorPos(BufferView const & bv, CursorSlice const & sl,
+ bool boundary, int & x, int & y) const;
///
bool hitButton(FuncRequest const &) const;
///
}
-void InsetTabular::cursorPos
- (CursorSlice const & sl, bool boundary, int & x, int & y) const
+void InsetTabular::cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool boundary, int & x, int & y) const
{
- cell(sl.idx())->cursorPos(sl, boundary, x, y);
+ cell(sl.idx())->cursorPos(bv, sl, boundary, x, y);
// y offset correction
int const row = tabular.row_of_cell(sl.idx());
///
Code lyxCode() const { return InsetBase::TABULAR_CODE; }
/// get offset of this cursor slice relative to our upper left corner
- void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
+ void cursorPos(BufferView const & bv, CursorSlice const & sl,
+ bool boundary, int & x, int & y) const;
///
bool tabularFeatures(LCursor & cur, std::string const & what);
///
}
-void InsetText::cursorPos
- (CursorSlice const & sl, bool boundary, int & x, int & y) const
+void InsetText::cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool boundary, int & x, int & y) const
{
x = text_.cursorX(sl, boundary) + border_;
y = text_.cursorY(sl, boundary);
void validate(LaTeXFeatures & features) const;
/// return x,y of given position relative to the inset's baseline
- void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
+ void cursorPos(BufferView const & bv, CursorSlice const & sl,
+ bool boundary, int & x, int & y) const;
///
Code lyxCode() const { return TEXT_CODE; }
///
}
-void InsetMathMBox::cursorPos
- (CursorSlice const & sl, bool boundary, int & x, int & y) const
+void InsetMathMBox::cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool boundary, int & x, int & y) const
{
x = text_.cursorX(sl, boundary);
y = text_.cursorY(sl, boundary);
///
LyXText * getText(int) const;
///
- void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
+ void cursorPos(BufferView const & bv, CursorSlice const & sl,
+ bool boundary, int & x, int & y) const;
protected:
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
}
-void MathMacro::cursorPos(CursorSlice const & sl, bool boundary, int & x,
- int & y) const
+void MathMacro::cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool boundary, int & x, int & y) const
{
// We may have 0 arguments, but InsetMathNest requires at least one.
if (nargs() > 0)
- InsetMathNest::cursorPos(sl, boundary, x, y);
+ InsetMathNest::cursorPos(bv, sl, boundary, x, y);
}
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
/// get cursor position
- void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
+ void cursorPos(BufferView const & bv, CursorSlice const & sl,
+ bool boundary, int & x, int & y) const;
///
InsetBase * editXY(LCursor & cur, int x, int y);
///
}
-void InsetMathNest::cursorPos(CursorSlice const & sl, bool /*boundary*/,
- int & x, int & y) const
+void InsetMathNest::cursorPos(BufferView const & bv,
+ CursorSlice const & sl, bool /*boundary*/,
+ int & x, int & y) const
{
// FIXME: This is a hack. Ideally, the coord cache should not store
// absolute positions, but relative ones. This would mean to call
// absolute again when actually drawing the cursor. What a mess.
BOOST_ASSERT(ptr_cmp(&sl.inset(), this));
MathArray const & ar = sl.cell();
- CoordCache & coord_cache = sl.text()->bv()->coordCache();
+ CoordCache const & coord_cache = bv.coordCache();
if (!coord_cache.getArrays().has(&ar)) {
// this can (semi-)legally happen if we just created this cell
// and it never has been drawn before. So don't ASSERT.
/// identifies NestInsets
InsetMathNest const * asNestInset() const { return this; }
/// get cursor position
- void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
+ void cursorPos(BufferView const & bv, CursorSlice const & sl,
+ bool boundary, int & x, int & y) const;
///
void edit(LCursor & cur, bool left);
///
#include "support/docstring.h"
+#include <string>
+
class PainterInfo;
class LyXFont;
class Dimension;