mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
Some more changes for updating text-insets.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@856 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
eb7220abe6
commit
729f944d88
@ -156,11 +156,11 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cleared && ((need_update == FULL) ||
|
||||
if (!cleared && ((inset->need_update == InsetText::FULL) ||
|
||||
(top_x!=int(x)) || (top_baseline!=baseline))) {
|
||||
int w = owner()? width(pain, f) : pain.paperWidth();
|
||||
int h = ascent(pain,f) + descent(pain, f);
|
||||
int tx = (display() && !owner())? 0:int(x);
|
||||
int tx = (needFullRow() && !owner())? 0:int(x);
|
||||
int ty = baseline - ascent(pain,f);
|
||||
|
||||
if (ty < 0)
|
||||
@ -291,8 +291,8 @@ int InsetCollapsable::getMaxTextWidth(Painter & pain,
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::update(BufferView * bv,
|
||||
LyXFont const & font, bool dodraw)
|
||||
void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
|
||||
bool dodraw)
|
||||
{
|
||||
if (!widthCollapsed) {
|
||||
widthCollapsed = width_collapsed(bv->painter(), font);
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
///
|
||||
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
|
||||
///
|
||||
void update(BufferView *, LyXFont const &, bool);
|
||||
void update(BufferView *, LyXFont const &, bool =false);
|
||||
///
|
||||
const char * EditMessage() const;
|
||||
///
|
||||
|
@ -214,14 +214,14 @@ int InsetText::textWidth(Painter & pain) const
|
||||
}
|
||||
#if 0
|
||||
if (owner()) {
|
||||
w = w - top_x + owner()->x();
|
||||
printf("WW2: %d\n",w);
|
||||
w = w - top_x; // + owner()->x();
|
||||
// printf("WW2: %d\n",w);
|
||||
return w; // - top_x + owner()->x();
|
||||
}
|
||||
#endif
|
||||
w -= (2 * TEXT_TO_INSET_OFFSET);
|
||||
// printf("WW2: %d\n",w);
|
||||
return w; // - top_x - (2 * TEXT_TO_INSET_OFFSET);
|
||||
return w - top_x; // - top_x - (2 * TEXT_TO_INSET_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
@ -290,12 +290,12 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
|
||||
if ((drawFrame == ALWAYS) || ((drawFrame == LOCKED) && locked)) {
|
||||
pain.rectangle(top_x, baseline - insetAscent, insetWidth,
|
||||
insetAscent + insetDescent, frame_color);
|
||||
} else {
|
||||
} else if (need_update == CLEAR_FRAME) {
|
||||
pain.rectangle(top_x, baseline - insetAscent, insetWidth,
|
||||
insetAscent + insetDescent,
|
||||
LColor::background);
|
||||
}
|
||||
x += width(pain, f) - TEXT_TO_INSET_OFFSET;
|
||||
x += insetWidth - TEXT_TO_INSET_OFFSET;
|
||||
need_update = NONE;
|
||||
}
|
||||
|
||||
@ -310,9 +310,10 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
|
||||
}
|
||||
int oldw = insetWidth;
|
||||
#if 1
|
||||
insetWidth = max(textWidth(bv->painter()),
|
||||
static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
|
||||
(2 * TEXT_TO_INSET_OFFSET);
|
||||
insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
|
||||
// max(textWidth(bv->painter()),
|
||||
// static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
|
||||
// (2 * TEXT_TO_INSET_OFFSET);
|
||||
#else
|
||||
insetWidth = textWidth(bv->painter());
|
||||
if (insetWidth < 0)
|
||||
@ -322,10 +323,13 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
|
||||
printf("TW(%p): %d-%d-%d-%d\n",this,insetWidth, oldw,
|
||||
textWidth(bv->painter()),static_cast<int>(TEXT(bv)->width));
|
||||
deleteLyXText(bv);
|
||||
need_update = FULL;
|
||||
#if 0
|
||||
if (owner()) {
|
||||
owner()->update(bv, font, dodraw);
|
||||
return;
|
||||
owner()->update(bv, font, dodraw);
|
||||
return;
|
||||
} else {
|
||||
update(bv, font, dodraw);
|
||||
}
|
||||
#else
|
||||
#if 1
|
||||
@ -347,6 +351,9 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
|
||||
TEXT(bv)->UpdateInset(bv, the_locking_inset);
|
||||
}
|
||||
|
||||
if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
|
||||
need_update = FULL;
|
||||
|
||||
long int y_temp = 0;
|
||||
Row * row = TEXT(bv)->GetRowNearY(y_temp);
|
||||
insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
|
||||
@ -408,7 +415,7 @@ void InsetText::InsetUnlock(BufferView * bv)
|
||||
no_selection = false;
|
||||
locked = false;
|
||||
TEXT(bv)->selection = 0;
|
||||
UpdateLocal(bv, CURSOR_PAR, false);
|
||||
UpdateLocal(bv, CLEAR_FRAME, false);
|
||||
bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->GetLayout()+1);
|
||||
}
|
||||
|
||||
@ -1100,10 +1107,9 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
|
||||
}
|
||||
|
||||
|
||||
int InsetText::getMaxTextWidth(Painter & pain,
|
||||
UpdatableInset const * inset) const
|
||||
int InsetText::getMaxWidth(Painter & pain, UpdatableInset const * inset) const
|
||||
{
|
||||
return getMaxWidth(pain, inset) - (2 * TEXT_TO_INSET_OFFSET);
|
||||
return UpdatableInset::getMaxWidth(pain, inset) - (2*TEXT_TO_INSET_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
@ -1148,7 +1154,7 @@ void InsetText::SetDrawFrame(BufferView * bv, DrawFrame how)
|
||||
if (how != drawFrame) {
|
||||
drawFrame = how;
|
||||
if (bv)
|
||||
UpdateLocal(bv, FRAME, false);
|
||||
UpdateLocal(bv, DRAW_FRAME, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1158,7 +1164,7 @@ void InsetText::SetFrameColor(BufferView * bv, LColor::color col)
|
||||
if (frame_color != col) {
|
||||
frame_color = col;
|
||||
if (bv)
|
||||
UpdateLocal(bv, FRAME, false);
|
||||
UpdateLocal(bv, DRAW_FRAME, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,8 @@ public:
|
||||
CURSOR_PAR,
|
||||
CURSOR,
|
||||
SELECTION,
|
||||
FRAME
|
||||
DRAW_FRAME,
|
||||
CLEAR_FRAME
|
||||
};
|
||||
///
|
||||
enum DrawFrame {
|
||||
@ -135,6 +136,8 @@ public:
|
||||
///
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
||||
///
|
||||
int getMaxWidth(Painter &, UpdatableInset const *) const;
|
||||
///
|
||||
void init(InsetText const * ins = 0);
|
||||
///
|
||||
void WriteParagraphData(Buffer const *, std::ostream &) const;
|
||||
@ -153,12 +156,12 @@ public:
|
||||
void deleteLyXText(BufferView *);
|
||||
|
||||
LyXParagraph * par;
|
||||
///
|
||||
mutable UpdateCodes need_update;
|
||||
|
||||
protected:
|
||||
///
|
||||
void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
|
||||
///
|
||||
virtual int getMaxTextWidth(Painter &, UpdatableInset const *) const;
|
||||
|
||||
mutable int drawTextXOffset;
|
||||
mutable int drawTextYOffset;
|
||||
@ -167,8 +170,6 @@ protected:
|
||||
DrawFrame drawFrame;
|
||||
///
|
||||
LColor::color frame_color;
|
||||
///
|
||||
mutable UpdateCodes need_update;
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -567,7 +567,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
|
||||
if (c == LyXParagraph::META_INSET) {
|
||||
Inset * tmpinset = row->par()->GetInset(pos);
|
||||
if (tmpinset) {
|
||||
tmpinset->update(bview, font);
|
||||
tmpinset->update(bview, font, false);
|
||||
tmpinset->draw(bview, font, offset+row->baseline(), x,
|
||||
cleared);
|
||||
}
|
||||
@ -1699,7 +1699,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
row_ptr->width(maxwidth+x);
|
||||
if (inset_owner) {
|
||||
Row * r = firstrow;
|
||||
width = 0;
|
||||
width = max(0,workWidth(bview));
|
||||
while(r) {
|
||||
if (r->width() > width)
|
||||
width = r->width();
|
||||
|
Loading…
x
Reference in New Issue
Block a user