: UpdatableInset(), lt(0), in_update(false), do_resize(0),
do_reinit(false)
{
- paragraphs.push_back(new Paragraph);
+ paragraphs.push_back(Paragraph());
paragraphs.begin()->layout(bp.getLyXTextClass().defaultLayout());
if (bp.tracking_changes)
paragraphs.begin()->trackChanges();
autoBreakRows = false;
}
top_y = 0;
- insetAscent = 0;
- insetDescent = 0;
- insetWidth = 0;
old_max_width = 0;
no_selection = true;
need_update = FULL;
LyXLayout_ptr old_layout = paragraphs.begin()->layout();
paragraphs.clear();
- paragraphs.push_back(new Paragraph);
+ paragraphs.push_back(Paragraph());
paragraphs.begin()->setInsetOwner(this);
paragraphs.begin()->layout(old_layout);
dim.d = text->height - dim.a + TEXT_TO_INSET_OFFSET;
dim.w = max(textWidth(bv), int(text->width)) + 2 * TEXT_TO_INSET_OFFSET;
dim.w = max(dim.w, 10);
+ // cache it
+ dim_ = dim;
}
Painter & pain = bv->painter();
- // call these methods so that insetWidth, insetAscent and
- // insetDescent have the right values.
- width(bv, f);
- ascent(bv, f);
- descent(bv, f);
+ // call this method so that dim_ has the right value
+ dimension(bv, f, dim_);
// repaint the background if needed
if (backgroundColor() != LColor::background)
x += static_cast<float>(scroll());
top_baseline = baseline;
- top_y = baseline - insetAscent;
+ top_y = baseline - dim_.a;
- if (last_drawn_width != insetWidth) {
+ if (last_drawn_width != dim_.w) {
need_update |= FULL;
- last_drawn_width = insetWidth;
+ last_drawn_width = dim_.w;
}
if (the_locking_inset && (cpar(bv) == inset_par)
drawFrame(pain, int(start_x));
}
- x += insetWidth - TEXT_TO_INSET_OFFSET;
+ x += dim_.w - TEXT_TO_INSET_OFFSET;
if (need_update != INIT) {
need_update = NONE;
{
static int const ttoD2 = TEXT_TO_INSET_OFFSET / 2;
frame_x = x + ttoD2;
- frame_y = top_baseline - insetAscent + ttoD2;
- frame_w = insetWidth - TEXT_TO_INSET_OFFSET;
- frame_h = insetAscent + insetDescent - TEXT_TO_INSET_OFFSET;
+ frame_y = top_baseline - dim_.a + ttoD2;
+ frame_w = dim_.w - TEXT_TO_INSET_OFFSET;
+ frame_h = dim_.a + dim_.d - TEXT_TO_INSET_OFFSET;
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
frame_color);
}
lockInset(bv);
int tmp_x = cmd.x - drawTextXOffset;
- int tmp_y = cmd.y + insetAscent - getLyXText(bv)->top_y();
+ int tmp_y = cmd.y + dim_.a - getLyXText(bv)->top_y();
Inset * inset = getLyXText(bv)->checkInsetHit(tmp_x, tmp_y);
if (the_locking_inset) {
int old_top_y = lt->top_y();
lt->setCursorFromCoordinates(cmd.x - drawTextXOffset,
- cmd.y + insetAscent);
+ cmd.y + dim_.a);
// set the selection cursor!
lt->selection.cursor = lt->cursor;
lt->cursor.x_fix(lt->cursor.x());
return the_locking_inset->localDispatch(cmd1);
int tmp_x = cmd.x - drawTextXOffset;
- int tmp_y = cmd.y + insetAscent - getLyXText(bv)->top_y();
+ int tmp_y = cmd.y + dim_.a - getLyXText(bv)->top_y();
Inset * inset = getLyXText(bv)->checkInsetHit(tmp_x, tmp_y);
bool ret = false;
if (inset) {
}
LyXCursor cur = lt->cursor;
lt->setCursorFromCoordinates
- (cmd.x - drawTextXOffset, cmd.y + insetAscent);
+ (cmd.x - drawTextXOffset, cmd.y + dim_.a);
lt->cursor.x_fix(lt->cursor.x());
if (cur == lt->cursor) {
if (clear)
// FIXME: GUII I've changed this to none: probably WRONG
if (!checkAndActivateInset(bv, cmd.x, tmp_y, mouse_button::none)) {
lt->setCursorFromCoordinates(cmd.x - drawTextXOffset,
- cmd.y + insetAscent);
+ cmd.y + dim_.a);
lt->cursor.x_fix(lt->cursor.x());
}
}
* true (on). */
#if 0
// This should not be needed here and is also WRONG!
- setUndo(bv, Undo::INSERT,
- lt->cursor.par(), boost::next(lt->cursor.par()));
+ setUndo(bv, Undo::INSERT, lt->cursor.par());
#endif
bv->switchKeyMap();
if (lyxrc.auto_region_delete) {
}
-int InsetText::latex(Buffer const * buf, ostream & os, bool fragile, bool) const
+int InsetText::latex(Buffer const * buf, ostream & os,
+ LatexRunParams const & runparams) const
{
TexRow texrow;
- latexParagraphs(buf, paragraphs, os, texrow, fragile);
+ latexParagraphs(buf, paragraphs, os, texrow, runparams);
return texrow.rows();
}
break;
case LATEX_COMMAND:
- buf->sgmlError(&*pit, 0, _("Error: LatexType Command not allowed here.\n"));
+ buf->sgmlError(pit, 0, _("Error: LatexType Command not allowed here.\n"));
return -1;
break;
clear = true;
}
if (lt->selection.set()) {
- setUndo(bv, Undo::EDIT, lt->cursor.par(), boost::next(lt->cursor.par()));
+ setUndo(bv, Undo::EDIT, lt->cursor.par());
}
if (selectall)
selectAll(bv);
{
x -= drawTextXOffset;
int dummyx = x;
- int dummyy = y + insetAscent;
+ int dummyy = y + dim_.a;
Inset * inset = getLyXText(bv)->checkInsetHit(dummyx, dummyy);
// we only do the edit() call if the inset was hit by the mouse
// or if it is a highly editable inset. So we should call this
if (inset) {
if (x < 0)
- x = insetWidth;
+ x = dim_.w;
if (y < 0)
- y = insetDescent;
+ y = dim_.d;
inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
FuncRequest cmd(bv, LFUN_INSET_EDIT, x - inset_x, y - inset_y, button);
// we have to unlock any locked inset otherwise we're in troubles
the_locking_inset = 0;
- paragraphs.clear();
- ParagraphList::iterator pit = plist.begin();
- ParagraphList::iterator pend = plist.end();
- for (; pit != pend; ++pit) {
- Paragraph * new_par = new Paragraph(*pit, same_id);
- new_par->setInsetOwner(this);
- paragraphs.push_back(new_par);
+ #warning CHECK not adhering to same_id here might wreck havoc (Lgb)
+ // But it it makes no difference that is a lot better.
+ if (same_id) {
+ lyxerr << "Same_id called with 'true'" << endl;
+ lyxerr << "Please report this to the list." << endl;
+
+ paragraphs.clear();
+ ParagraphList::iterator it = plist.begin();
+ ParagraphList::iterator end = plist.end();
+ for (; it != end; ++it) {
+ int const id = it->id();
+ paragraphs.push_back(*it);
+ Paragraph & tmp = paragraphs.back();
+ tmp.setInsetOwner(this);
+ tmp.id(id);
+ }
+ } else {
+#warning FIXME.
+ // See if this can be simplified when std::list is in effect.
+ paragraphs.clear();
+
+ ParagraphList::iterator it = plist.begin();
+ ParagraphList::iterator end = plist.end();
+ for (; it != end; ++it) {
+ paragraphs.push_back(*it);
+ Paragraph & tmp = paragraphs.back();
+ tmp.setInsetOwner(this);
+ }
}
reinitLyXText();
void InsetText::clearInset(BufferView * bv, int start_x, int baseline) const
{
Painter & pain = bv->painter();
- int w = insetWidth;
- int h = insetAscent + insetDescent;
- int ty = baseline - insetAscent;
+ int w = dim_.w;
+ int h = dim_.a + dim_.d;
+ int ty = baseline - dim_.a;
if (ty < 0) {
h += ty;
}
-void InsetText::paragraph(Paragraph * p)
-{
- // GENERAL COMMENT: We don't have to free the old paragraphs as the
- // caller of this function has to take care of it. This IS important
- // as we could have to insert a paragraph before this one and just
- // link the actual to a new ones next and set it with this function
- // and are done!
- paragraphs.set(p);
- // set ourself as owner for all the paragraphs inserted!
- for_each(paragraphs.begin(), paragraphs.end(),
- boost::bind(&Paragraph::setInsetOwner, _1, this));
-
- reinitLyXText();
- // redraw myself when asked for
- need_update = INIT;
-}
-
-
Inset * InsetText::getInsetFromID(int id_arg) const
{
if (id_arg == id())
ParagraphList::iterator pend = plist.end();
for (; pit != pend; ++pit) {
- paragraphs.push_back(new Paragraph(*pit, false));
+ paragraphs.push_back(*pit);
}
#endif