void InsetText::saveLyXTextState(LyXText * t) const
{
// check if my paragraphs are still valid
- ParagraphList::iterator it = paragraphs.begin();
- ParagraphList::iterator end = paragraphs.end();
+ ParagraphList::iterator it = const_cast<ParagraphList&>(paragraphs).begin();
+ ParagraphList::iterator end = const_cast<ParagraphList&>(paragraphs).end();
for (; it != end; ++it) {
- if (&*it == t->cursor.par())
+ if (it == t->cursor.par())
break;
}
if (it != end && t->cursor.pos() <= it->size()) {
- sstate.lpar = &*t->cursor.par();
+ sstate.lpar = t->cursor.par();
sstate.pos = t->cursor.pos();
sstate.boundary = t->cursor.boundary();
- sstate.selstartpar = &*t->selection.start.par();
+ sstate.selstartpar = t->selection.start.par();
sstate.selstartpos = t->selection.start.pos();
sstate.selstartboundary = t->selection.start.boundary();
- sstate.selendpar = &*t->selection.end.par();
+ sstate.selendpar = t->selection.end.par();
sstate.selendpos = t->selection.end.pos();
sstate.selendboundary = t->selection.end.boundary();
sstate.selection = t->selection.set();
sstate.mark_set = t->selection.mark();
} else {
- sstate.lpar = 0;
+ sstate.lpar = const_cast<ParagraphList&>(paragraphs).end();
}
}
void InsetText::restoreLyXTextState(LyXText * t) const
{
- if (!sstate.lpar)
+ if (sstate.lpar == const_cast<ParagraphList&>(paragraphs).end())
return;
t->selection.set(true);
drawTextXOffset = 0;
drawTextYOffset = 0;
locked = false;
- old_par = 0;
+ old_par = paragraphs.end();
last_drawn_width = -1;
cached_bview = 0;
- sstate.lpar = 0;
+ sstate.lpar = paragraphs.end();
in_insetAllowed = false;
}
void InsetText::writeParagraphData(Buffer const * buf, ostream & os) const
{
- ParagraphList::iterator it = paragraphs.begin();
- ParagraphList::iterator end = paragraphs.end();
+ ParagraphList::const_iterator it = paragraphs.begin();
+ ParagraphList::const_iterator end = paragraphs.end();
Paragraph::depth_type dth = 0;
for (; it != end; ++it) {
it->write(buf, os, buf->params, dth);
Dimension & dim) const
{
LyXText * text = getLyXText(bv);
- dim.a = text->rows().begin()->ascent_of_text() + TEXT_TO_INSET_OFFSET;
- 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);
+ 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;
}
x += static_cast<float>(scroll());
top_baseline = baseline;
- top_y = baseline - dim_.a;
+ top_y = baseline - dim_.asc;
- if (last_drawn_width != dim_.w) {
+ if (last_drawn_width != dim_.wid) {
need_update |= FULL;
- last_drawn_width = dim_.w;
+ last_drawn_width = dim_.wid;
}
if (the_locking_inset && (cpar(bv) == inset_par)
drawFrame(pain, int(start_x));
}
- x += dim_.w - 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 - dim_.a + ttoD2;
- frame_w = dim_.w - TEXT_TO_INSET_OFFSET;
- frame_h = dim_.a + dim_.d - 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);
}
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
inset_boundary = false;
- inset_par = 0;
- old_par = 0;
+ inset_par = paragraphs.end();
+ old_par = paragraphs.end();
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
the_locking_inset = 0;
if (lr)
moveRightIntern(bv, true, false);
- old_par = 0; // force layout setting
+ old_par = paragraphs.end(); // force layout setting
if (scroll())
scroll(bv, 0.0F);
else
lockInset(bv);
int tmp_x = cmd.x - drawTextXOffset;
- int tmp_y = cmd.y + dim_.a - 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 + dim_.a);
+ 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 + dim_.a - 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 + dim_.a);
+ (cmd.x - drawTextXOffset, cmd.y + dim_.asc);
lt->cursor.x_fix(lt->cursor.x());
if (cur == lt->cursor) {
if (clear)
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
inset_boundary = false;
- inset_par = 0;
- old_par = 0;
+ inset_par = paragraphs.end();
+ old_par = paragraphs.end();
bool clear = false;
if (!lt) {
// 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_.a);
+ cmd.y + dim_.asc);
lt->cursor.x_fix(lt->cursor.x());
}
}
{
unsigned int lines = 0;
- ParagraphList::iterator beg = paragraphs.begin();
- ParagraphList::iterator end = paragraphs.end();
- ParagraphList::iterator it = beg;
+ ParagraphList::const_iterator beg = paragraphs.begin();
+ ParagraphList::const_iterator end = paragraphs.end();
+ ParagraphList::const_iterator it = beg;
for (; it != end; ++it) {
string const tmp = buf->asciiParagraph(*it, linelen, it == beg);
lines += lyx::count(tmp.begin(), tmp.end(), '\n');
Paragraph::depth_type depth = 0; // paragraph depth
- ParagraphList::iterator pit = paragraphs.begin();
- ParagraphList::iterator pend = paragraphs.end();
+ ParagraphList::iterator pit = const_cast<ParagraphList&>(paragraphs).begin();
+ ParagraphList::iterator pend = const_cast<ParagraphList&>(paragraphs).end();
for (; pit != pend; ++pit) {
string sgmlparam;
{
vector<string> label_list;
- ParagraphList::iterator pit = paragraphs.begin();
- ParagraphList::iterator pend = paragraphs.end();
+ ParagraphList::const_iterator pit = paragraphs.begin();
+ ParagraphList::const_iterator pend = paragraphs.end();
for (; pit != pend; ++pit) {
InsetList::iterator beg = pit->insetlist.begin();
InsetList::iterator end = pit->insetlist.end();
{
x -= drawTextXOffset;
int dummyx = x;
- int dummyy = y + dim_.a;
+ 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 = dim_.w;
+ x = dim_.wid;
if (y < 0)
- y = dim_.d;
+ y = dim_.des;
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);
// See if this can be simplified when std::list is in effect.
paragraphs.clear();
- ParagraphList::iterator it = plist.begin();
- ParagraphList::iterator end = plist.end();
+ ParagraphList::const_iterator it = plist.begin();
+ ParagraphList::const_iterator end = plist.end();
for (; it != end; ++it) {
paragraphs.push_back(*it);
Paragraph & tmp = paragraphs.back();
if (recursive && the_locking_inset)
return the_locking_inset->getLyXText(lbv, true);
LyXText * lt = cached_text.get();
- lyx::Assert(lt && lt->rows().begin()->par() == paragraphs.begin());
+ lyx::Assert(lt && lt->rows().begin()->par() == const_cast<ParagraphList&>(paragraphs).begin());
return lt;
}
// Super UGLY! (Lgb)
if (locked) {
saveLyXTextState(it->second.text.get());
} else {
- sstate.lpar = 0;
+ sstate.lpar = const_cast<ParagraphList&>(paragraphs).end();
}
}
//
it->second.remove = true;
if (recursive) {
/// then remove all LyXText in text-insets
- for_each(paragraphs.begin(), paragraphs.end(),
+ for_each(const_cast<ParagraphList&>(paragraphs).begin(),
+ const_cast<ParagraphList&>(paragraphs).end(),
boost::bind(&Paragraph::deleteInsetsLyXText, _1, bv));
}
}
LyXText * t = it->second.text.get();
saveLyXTextState(t);
- for_each(paragraphs.begin(), paragraphs.end(),
+ for_each(const_cast<ParagraphList&>(paragraphs).begin(),
+ const_cast<ParagraphList&>(paragraphs).end(),
boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
t->init(bv, true);
saveLyXTextState(t);
- for_each(paragraphs.begin(), paragraphs.end(),
+ for_each(const_cast<ParagraphList&>(paragraphs).begin(),
+ const_cast<ParagraphList&>(paragraphs).end(),
boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
t->init(bv, true);
void InsetText::clearInset(BufferView * bv, int start_x, int baseline) const
{
Painter & pain = bv->painter();
- int w = dim_.w;
- int h = dim_.a + dim_.d;
- int ty = baseline - dim_.a;
+ int w = dim_.wid;
+ int h = dim_.asc + dim_.des;
+ int ty = baseline - dim_.asc;
if (ty < 0) {
h += ty;
if (id_arg == id())
return const_cast<InsetText *>(this);
- ParagraphList::iterator pit = paragraphs.begin();
- ParagraphList::iterator pend = paragraphs.end();
+ ParagraphList::const_iterator pit = paragraphs.begin();
+ ParagraphList::const_iterator pend = paragraphs.end();
for (; pit != pend; ++pit) {
InsetList::iterator it = pit->insetlist.begin();
InsetList::iterator end = pit->insetlist.end();
void InsetText::addPreview(grfx::PreviewLoader & loader) const
{
- ParagraphList::iterator pit = paragraphs.begin();
- ParagraphList::iterator pend = paragraphs.end();
+ ParagraphList::const_iterator pit = paragraphs.begin();
+ ParagraphList::const_iterator pend = paragraphs.end();
for (; pit != pend; ++pit) {
InsetList::iterator it = pit->insetlist.begin();