#include "BufferView.h"
#include "CutAndPaste.h"
#include "debug.h"
+#include "dimension.h"
#include "funcrequest.h"
#include "gettext.h"
#include "intl.h"
#include "LaTeXFeatures.h"
#include "LColor.h"
+#include "Lsstream.h"
#include "lyxfont.h"
#include "lyxcursor.h"
#include "lyxfind.h"
using lyx::pos_type;
using lyx::textclass_type;
+
// These functions should probably go into bufferview_funcs somehow (Jug)
void InsetText::saveLyXTextState(LyXText * t) const
: 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();
- init();
+ init(0);
}
-InsetText::InsetText(InsetText const & in, bool same_id)
- : UpdatableInset(in, same_id), lt(0), in_update(false), do_resize(0),
+InsetText::InsetText(InsetText const & in)
+ : UpdatableInset(in), lt(0), in_update(false), do_resize(0),
do_reinit(false)
{
- init(&in, same_id);
+ init(&in);
}
+// InsetText::InsetText(InsetText const & in, bool same_id)
+// : UpdatableInset(in, same_id), lt(0), in_update(false), do_resize(0),
+// do_reinit(false)
+// {
+// init(&in, same_id);
+// }
+
+
InsetText & InsetText::operator=(InsetText const & it)
{
init(&it);
}
-void InsetText::init(InsetText const * ins, bool same_id)
+void InsetText::init(InsetText const * ins)
{
if (ins) {
- setParagraphData(ins->paragraphs, same_id);
+ setParagraphData(ins->paragraphs);
autoBreakRows = ins->autoBreakRows;
drawFrame_ = ins->drawFrame_;
frame_color = ins->frame_color;
- if (same_id)
- id_ = ins->id_;
} else {
for_each(paragraphs.begin(), paragraphs.end(),
boost::bind(&Paragraph::setInsetOwner, _1, this));
autoBreakRows = false;
}
top_y = 0;
- insetAscent = 0;
- insetDescent = 0;
- insetWidth = 0;
old_max_width = 0;
no_selection = true;
need_update = FULL;
}
+// void InsetText::init(InsetText const * ins, bool same_id)
+// {
+// if (ins) {
+// setParagraphData(ins->paragraphs, same_id);
+// autoBreakRows = ins->autoBreakRows;
+// drawFrame_ = ins->drawFrame_;
+// frame_color = ins->frame_color;
+// if (same_id)
+// id_ = ins->id_;
+// } else {
+// for_each(paragraphs.begin(), paragraphs.end(),
+// boost::bind(&Paragraph::setInsetOwner, _1, this));
+
+// the_locking_inset = 0;
+// drawFrame_ = NEVER;
+// frame_color = LColor::insetframe;
+// autoBreakRows = false;
+// }
+// top_y = 0;
+// old_max_width = 0;
+// no_selection = true;
+// need_update = FULL;
+// drawTextXOffset = 0;
+// drawTextYOffset = 0;
+// locked = false;
+// old_par = 0;
+// last_drawn_width = -1;
+// cached_bview = 0;
+// sstate.lpar = 0;
+// in_insetAllowed = false;
+// }
+
+
InsetText::~InsetText()
{
paragraphs.clear();
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);
}
-Inset * InsetText::clone(Buffer const &, bool same_id) const
+Inset * InsetText::clone(Buffer const &) const
{
- return new InsetText(*this, same_id);
+ return new InsetText(*this);
}
+// Inset * InsetText::clone(Buffer const &, bool same_id) const
+// {
+// return new InsetText(*this, same_id);
+// }
+
+
void InsetText::write(Buffer const * buf, ostream & os) const
{
os << "Text\n";
}
-int InsetText::ascent(BufferView * bv, LyXFont const &) const
+void InsetText::dimension(BufferView * bv, LyXFont const &,
+ Dimension & dim) const
{
- insetAscent = getLyXText(bv)->rows().begin()->ascent_of_text() +
- TEXT_TO_INSET_OFFSET;
- return insetAscent;
+ LyXText * text = getLyXText(bv);
+ dim.asc = text->rows().begin()->ascent_of_text() + TEXT_TO_INSET_OFFSET;
+ dim.des = text->height - dim.asc + TEXT_TO_INSET_OFFSET;
+ dim.wid = max(textWidth(bv), int(text->width)) + 2 * TEXT_TO_INSET_OFFSET;
+ dim.wid = max(dim.wid, 10);
+ // cache it
+ dim_ = dim;
}
-int InsetText::descent(BufferView * bv, LyXFont const &) const
+int InsetText::textWidth(BufferView * bv, bool fordraw) const
{
- LyXText * llt = getLyXText(bv);
- insetDescent = llt->height - llt->rows().begin()->ascent_of_text() +
- TEXT_TO_INSET_OFFSET;
- return insetDescent;
-}
-
+ int w = autoBreakRows ? getMaxWidth(bv, this) : -1;
-int InsetText::width(BufferView * bv, LyXFont const &) const
-{
- insetWidth = max(textWidth(bv), (int)getLyXText(bv)->width) +
- (2 * TEXT_TO_INSET_OFFSET);
- insetWidth = max(insetWidth, 10);
- return insetWidth;
-}
+ if (fordraw)
+ return max(w - 2 * TEXT_TO_INSET_OFFSET,
+ (int)getLyXText(bv)->width);
+ if (w < 0)
+ return -1;
-int InsetText::textWidth(BufferView * bv, bool fordraw) const
-{
- int w;
- if (!autoBreakRows) {
- w = -1;
- } else {
- w = getMaxWidth(bv, this);
- }
- if (fordraw) {
- return max(w - (2 * TEXT_TO_INSET_OFFSET),
- (int)getLyXText(bv)->width);
- } else if (w < 0) {
- return -1;
- }
- return w - (2 * TEXT_TO_INSET_OFFSET);
+ return w - 2 * TEXT_TO_INSET_OFFSET;
}
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_.asc;
- if (last_drawn_width != insetWidth) {
+ if (last_drawn_width != dim_.wid) {
need_update |= FULL;
- last_drawn_width = insetWidth;
+ last_drawn_width = dim_.wid;
}
if (the_locking_inset && (cpar(bv) == inset_par)
drawFrame(pain, int(start_x));
}
- x += insetWidth - TEXT_TO_INSET_OFFSET;
+ x += dim_.wid - 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_.asc + ttoD2;
+ frame_w = dim_.wid - TEXT_TO_INSET_OFFSET;
+ frame_h = dim_.asc + dim_.des - TEXT_TO_INSET_OFFSET;
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
frame_color);
}
}
-void InsetText::edit(BufferView * bv, int x, int y, mouse_button::state button)
-{
- UpdatableInset::edit(bv, x, y, button);
-
- if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
- return;
- }
- locked = true;
- the_locking_inset = 0;
- inset_pos = inset_x = inset_y = 0;
- inset_boundary = false;
- inset_par = 0;
- old_par = 0;
- int tmp_y = (y < 0) ? 0 : y;
- bool clear = false;
- if (!lt) {
- lt = getLyXText(bv);
- clear = true;
- }
- // we put here -1 and not button as now the button in the
- // edit call should not be needed we will fix this in 1.3.x
- // cycle hopefully (Jug 20020509)
- // FIXME: GUII I've changed this to none: probably WRONG
- if (!checkAndActivateInset(bv, x, tmp_y, mouse_button::none)) {
- lt->setCursorFromCoordinates(x - drawTextXOffset,
- y + insetAscent);
- lt->cursor.x_fix(lt->cursor.x());
- }
- lt->clearSelection();
- finishUndo();
- // If the inset is empty set the language of the current font to the
- // language to the surronding text (if different).
- if (paragraphs.begin()->empty() &&
- boost::next(paragraphs.begin()) == paragraphs.end()&&
- bv->getParentLanguage(this) != lt->current_font.language())
- {
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setLanguage(bv->getParentLanguage(this));
- setFont(bv, font, false);
- }
- if (clear)
- lt = 0;
-
- int code = CURSOR;
- if (drawFrame_ == LOCKED)
- code = CURSOR|DRAW_FRAME;
- updateLocal(bv, code, false);
-
- // Tell the paragraph dialog that we've entered an insettext.
- bv->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
-}
-
-
-void InsetText::edit(BufferView * bv, bool front)
-{
- UpdatableInset::edit(bv, front);
-
- if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
- return;
- }
- locked = true;
- the_locking_inset = 0;
- inset_pos = inset_x = inset_y = 0;
- inset_boundary = false;
- inset_par = 0;
- old_par = 0;
- bool clear = false;
- if (!lt) {
- lt = getLyXText(bv);
- clear = true;
- }
- if (front)
- lt->setCursor(paragraphs.begin(), 0);
- else {
- ParagraphList::iterator it = paragraphs.begin();
- ParagraphList::iterator end = paragraphs.end();
- while (boost::next(it) != end)
- ++it;
-// int const pos = (p->size() ? p->size()-1 : p->size());
- lt->setCursor(it, it->size());
- }
- lt->clearSelection();
- finishUndo();
- // If the inset is empty set the language of the current font to the
- // language to the surronding text (if different).
- if (paragraphs.begin()->empty() &&
- boost::next(paragraphs.begin()) == paragraphs.end() &&
- bv->getParentLanguage(this) != lt->current_font.language()) {
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setLanguage(bv->getParentLanguage(this));
- setFont(bv, font, false);
- }
- if (clear)
- lt = 0;
- int code = CURSOR;
- if (drawFrame_ == LOCKED)
- code = CURSOR|DRAW_FRAME;
- updateLocal(bv, code, false);
-}
-
-
void InsetText::insetUnlock(BufferView * bv)
{
if (the_locking_inset) {
}
if (it.getInset()->getInsetFromID(id)) {
getLyXText(bv)->setCursorIntern(pit, it.getPos());
- it.getInset()->edit(bv);
+ it.getInset()->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
return the_locking_inset->lockInsetInInset(bv, inset);
}
}
lockInset(bv);
int tmp_x = cmd.x - drawTextXOffset;
- int tmp_y = cmd.y + insetAscent - getLyXText(bv)->top_y();
+ int tmp_y = cmd.y + dim_.asc - 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_.asc);
// 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_.asc - 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_.asc);
lt->cursor.x_fix(lt->cursor.x());
if (cur == lt->cursor) {
if (clear)
}
-Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
+Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
{
- BufferView * bv = ev.view();
- switch (ev.action) {
+ BufferView * bv = cmd.view();
+
+ if (cmd.action == LFUN_INSET_EDIT) {
+ UpdatableInset::localDispatch(cmd);
+
+ if (!bv->lockInset(this)) {
+ lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+ return DISPATCHED;
+ }
+
+ locked = true;
+ the_locking_inset = 0;
+ inset_pos = inset_x = inset_y = 0;
+ inset_boundary = false;
+ inset_par = 0;
+ old_par = 0;
+
+ bool clear = false;
+ if (!lt) {
+ lt = getLyXText(bv);
+ clear = true;
+ }
+
+ if (cmd.argument.size()) {
+ if (cmd.argument == "left")
+ lt->setCursor(paragraphs.begin(), 0);
+ else {
+ ParagraphList::iterator it = paragraphs.begin();
+ ParagraphList::iterator end = paragraphs.end();
+ while (boost::next(it) != end)
+ ++it;
+ // int const pos = (p->size() ? p->size()-1 : p->size());
+ lt->setCursor(it, it->size());
+ }
+ } else {
+ int tmp_y = (cmd.y < 0) ? 0 : cmd.y;
+ // we put here -1 and not button as now the button in the
+ // edit call should not be needed we will fix this in 1.3.x
+ // cycle hopefully (Jug 20020509)
+ // 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 + dim_.asc);
+ lt->cursor.x_fix(lt->cursor.x());
+ }
+ }
+
+ lt->clearSelection();
+ finishUndo();
+
+ // If the inset is empty set the language of the current font to the
+ // language to the surronding text (if different).
+ if (paragraphs.begin()->empty() &&
+ boost::next(paragraphs.begin()) == paragraphs.end()&&
+ bv->getParentLanguage(this) != lt->current_font.language())
+ {
+ LyXFont font(LyXFont::ALL_IGNORE);
+ font.setLanguage(bv->getParentLanguage(this));
+ setFont(bv, font, false);
+ }
+
+ if (clear)
+ lt = 0;
+ int code = CURSOR;
+ if (drawFrame_ == LOCKED)
+ code = CURSOR | DRAW_FRAME;
+
+ updateLocal(bv, code, false);
+ // Tell the paragraph dialog that we've entered an insettext.
+ bv->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
+ return DISPATCHED;
+ }
+
+
+ switch (cmd.action) {
case LFUN_MOUSE_PRESS:
- lfunMousePress(ev);
+ lfunMousePress(cmd);
return DISPATCHED;
case LFUN_MOUSE_MOTION:
- lfunMouseMotion(ev);
+ lfunMouseMotion(cmd);
return DISPATCHED;
case LFUN_MOUSE_RELEASE:
- return lfunMouseRelease(ev) ? DISPATCHED : UNDISPATCHED;
+ return lfunMouseRelease(cmd) ? DISPATCHED : UNDISPATCHED;
default:
break;
}
bool was_empty = (paragraphs.begin()->empty() &&
boost::next(paragraphs.begin()) == paragraphs.end());
no_selection = false;
- RESULT result = UpdatableInset::localDispatch(ev);
+ RESULT result = UpdatableInset::localDispatch(cmd);
if (result != UNDISPATCHED)
return DISPATCHED;
result = DISPATCHED;
- if (ev.action < 0 && ev.argument.empty())
+ if (cmd.action < 0 && cmd.argument.empty())
return FINISHED;
if (the_locking_inset) {
- result = the_locking_inset->localDispatch(ev);
+ result = the_locking_inset->localDispatch(cmd);
if (result == DISPATCHED_NOUPDATE)
return result;
else if (result == DISPATCHED) {
if (lt->selection.set())
cursor_update = SELECTION;
- switch (ev.action) {
+ switch (cmd.action) {
// Normal chars
case LFUN_SELFINSERT:
// setErrorMessage(N_("Document is read only"));
break;
}
- if (!ev.argument.empty()) {
+ if (!cmd.argument.empty()) {
/* Automatically delete the currently selected
* text and replace it with what is being
* typed in now. Depends on lyxrc settings
* 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) {
}
}
lt->clearSelection();
- for (string::size_type i = 0; i < ev.argument.length(); ++i) {
+ for (string::size_type i = 0; i < cmd.argument.length(); ++i) {
bv->owner()->getIntl().getTransManager().
- TranslateAndInsert(ev.argument[i], lt);
+ TranslateAndInsert(cmd.argument[i], lt);
}
}
lt->selection.cursor = lt->cursor;
if (clip.empty())
break;
- if (ev.argument == "paragraph") {
+ if (cmd.argument == "paragraph") {
lt->insertStringAsParagraphs(clip);
} else {
lt->insertStringAsLines(clip);
// and current buffer's textclass (number). */
LyXTextClass const & tclass =
bv->buffer()->params.getLyXTextClass();
- string layout = ev.argument;
+ string layout = cmd.argument;
bool hasLayout = tclass.hasLayout(layout);
// If the entry is obsolete, use the new one instead.
// see if we found the layout number:
if (!hasLayout) {
- FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + ev.argument + N_(" not known"));
+ FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + cmd.argument + N_(" not known"));
bv->owner()->dispatch(lf);
break;
}
cur_value = pit->params().spacing().getValue();
}
- istringstream istr(STRCONV(ev.argument));
+ istringstream istr(STRCONV(cmd.argument));
string tmp;
istr >> tmp;
Spacing::Space new_spacing = cur_spacing;
new_spacing = Spacing::Default;
} else {
lyxerr << _("Unknown spacing argument: ")
- << ev.argument << endl;
+ << cmd.argument << endl;
}
if (cur_spacing != new_spacing || cur_value != new_value) {
pit->params().spacing(Spacing(new_spacing, new_value));
case LFUN_ENDBUF:
case LFUN_BEGINNINGBUF:
updwhat = cursor_update;
- if (!bv->dispatch(ev))
+ if (!bv->dispatch(cmd))
result = UNDISPATCHED;
break;
// fallthrough
default:
- if (!bv->dispatch(ev))
+ if (!bv->dispatch(cmd))
result = UNDISPATCHED;
break;
}
int InsetText::latex(Buffer const * buf, ostream & os,
- bool moving_arg, bool) const
+ LatexRunParams const & runparams) const
{
TexRow texrow;
- latexParagraphs(buf, paragraphs,
- paragraphs.begin(), paragraphs.end(),
- os, texrow, moving_arg);
+ 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);
static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
if (!isHighlyEditableInset(inset))
return false;
- inset->edit(bv, front);
+ FuncRequest cmd(bv, LFUN_INSET_EDIT, front ? "left" : "right");
+ inset->localDispatch(cmd);
if (!the_locking_inset)
return false;
updateLocal(bv, CURSOR, false);
{
x -= drawTextXOffset;
int dummyx = x;
- int dummyy = y + insetAscent;
+ int dummyy = y + dim_.asc;
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_.wid;
if (y < 0)
- y = insetDescent;
+ y = dim_.des;
inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
- inset->edit(bv, x - inset_x, y - inset_y, button);
+ FuncRequest cmd(bv, LFUN_INSET_EDIT, x - inset_x, y - inset_y, button);
+ inset->localDispatch(cmd);
if (!the_locking_inset)
return false;
updateLocal(bv, CURSOR, false);
}
-void InsetText::setParagraphData(ParagraphList const & plist, bool same_id)
+void InsetText::setParagraphData(ParagraphList const & plist)
{
// we have to unlock any locked inset otherwise we're in troubles
the_locking_inset = 0;
+ // But it it makes no difference that is a lot better.
+#warning FIXME.
+ // See if this can be simplified when std::list is in effect.
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);
+
+ 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::setParagraphData(ParagraphList const & plist, bool same_id)
+// {
+// // we have to unlock any locked inset otherwise we're in troubles
+// the_locking_inset = 0;
+
+// #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();
+// need_update = INIT;
+// }
+
+
void InsetText::markNew(bool track_changes)
{
ParagraphList::iterator pit = paragraphs.begin();
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_.wid;
+ int h = dim_.asc + dim_.des;
+ int ty = baseline - dim_.asc;
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())
}
-void InsetText::appendParagraphs(Buffer * buffer,
- ParagraphList & plist)
+void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
{
#warning FIXME Check if Changes stuff needs changing here. (Lgb)
// And it probably does. You have to take a look at this John. (Lgb)
#warning John, have a look here. (Lgb)
- BufferParams const & bparams = buffer->params;
#if 0
+ BufferParams const & bparams = buffer->params;
Paragraph * buf;
Paragraph * tmpbuf = newpar;
Paragraph * lastbuffer = buf = new Paragraph(*tmpbuf, false);
mergeParagraph(buffer->params, paragraphs, lastbuffer);
#else
ParagraphList::iterator pit = plist.begin();
- ParagraphList::iterator ins = paragraphs.insert(paragraphs.end(),
- new Paragraph(*pit, false));
+ ParagraphList::iterator ins = paragraphs.insert(paragraphs.end(), *pit);
++pit;
mergeParagraph(buffer->params, paragraphs, boost::prior(ins));
ParagraphList::iterator pend = plist.end();
for (; pit != pend; ++pit) {
- paragraphs.push_back(new Paragraph(*pit, false));
+ paragraphs.push_back(*pit);
}
#endif