Fixed update of insets in insets.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@835 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2000-06-26 15:10:49 +00:00
parent 9c1f7465bc
commit e80ad470cb
16 changed files with 180 additions and 116 deletions

View File

@ -1,3 +1,12 @@
2000-06-26 Juergen Vigna <jug@sad.it>
* src/lyxrow.C (width): added this functions and variable.
* src/insets/insetcite.C (create_form_citation_form): some Gravity
changes.
* src/text.C (SetHeightOfRow): fixed calcualting of width.
2000-06-26 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/BufferView.h: add a magic "friend" declaration to please

View File

@ -78,11 +78,29 @@ size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @4->
shortcut:
resize: FL_RESIZE_NONE
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: addBtn
name: bibBrsr
callback: citation_cb
argument: InsetCitation::ADD
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 40 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
@ -96,11 +114,29 @@ size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @9+
shortcut:
resize: FL_RESIZE_NONE
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: delBtn
name: bibBrsr
callback: citation_cb
argument: InsetCitation::DELETE
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 90 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
@ -114,11 +150,29 @@ size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @8->
shortcut:
resize: FL_RESIZE_NONE
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: upBtn
name: bibBrsr
callback: citation_cb
argument: InsetCitation::UP
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 140 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
@ -132,11 +186,29 @@ size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: @2->
shortcut:
resize: FL_RESIZE_NONE
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: downBtn
name: bibBrsr
callback: citation_cb
argument: InsetCitation::DOWN
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 190 40 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Button
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_South FL_South
name: bibBrsr
callback: citation_cb
argument: InsetCitation::BIBBRSR
--------------------
class: FL_BROWSER
@ -174,77 +246,5 @@ name: style
callback:
argument:
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 100 620 250 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Text before
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: textBefore
callback:
argument:
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 100 660 250 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Text after
shortcut:
resize: FL_RESIZE_X
gravity: FL_NoGravity FL_NoGravity
name: textAftr
callback:
argument:
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 190 730 110 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: OK
shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast
name: ok
callback: citation_cb
argument: InsetCitation::OK
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 310 730 110 40
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Cancel
shortcut: ^[
resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast
name: cancel
callback: citation_cb
argument: InsetCitation::CANCEL
==============================
create_the_forms
--------------------

View File

@ -137,7 +137,7 @@ void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
void UpdatableInset::draw(BufferView *, LyXFont const &,
int /* baseline */, float & x) const
int /* baseline */, float & x, bool/*cleared*/) const
{
if (scx) x += float(scx);
// ATTENTION: don't do the following here!!!

View File

@ -66,21 +66,25 @@ FD_citation_form *create_form_citation_form(void)
fdui->addBtn = obj =
fl_add_button(FL_NORMAL_BUTTON,200,40,40,40,"@4->");
fl_set_object_gravity(obj, FL_South, FL_South);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,citation_cb,InsetCitation::ADD);
fdui->delBtn = obj =
fl_add_button(FL_NORMAL_BUTTON,200,90,40,40,"@9+");
fl_set_object_gravity(obj, FL_South, FL_South);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,citation_cb,InsetCitation::DELETE);
fdui->upBtn = obj =
fl_add_button(FL_NORMAL_BUTTON,200,140,40,40,"@8->");
fl_set_object_gravity(obj, FL_South, FL_South);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,citation_cb,InsetCitation::UP);
fdui->downBtn = obj =
fl_add_button(FL_NORMAL_BUTTON,200,190,40,40,"@2->");
fl_set_object_gravity(obj, FL_South, FL_South);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,citation_cb,InsetCitation::DOWN);
@ -102,6 +106,7 @@ FD_citation_form *create_form_citation_form(void)
fdui->textAftr = obj =
fl_add_input(FL_NORMAL_INPUT,100,660,250,30,_("Text after"));
fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
fl_set_object_resize(obj, FL_RESIZE_X);
fdui->ok = obj =
@ -384,7 +389,7 @@ void InsetCitation::setSize( FD_citation_form * form,
fl_set_form_size( form->form, 430, formHeight );
// No resizing is alowed in the y-direction
fl_set_form_minsize( form->form, 300, formHeight );
fl_set_form_minsize( form->form, 430, formHeight );
fl_set_form_maxsize( form->form, 1000, formHeight );
int ypos = 0;

View File

@ -29,7 +29,7 @@ InsetCollapsable::InsetCollapsable() : InsetText()
autocollapse = true;
autoBreakRows = true;
framecolor = LColor::footnoteframe;
widthOffset = 6; // 2+2 (behind+back), 1+1 (frame)
widthOffset = 2 * TEXT_TO_INSET_OFFSET + 2; // 1+1 (frame)
button_length = button_top_y = button_bottom_y = 0;
setInsetName("Collapsable");
}
@ -153,11 +153,10 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
draw_collapsed(pain, f, baseline, x);
x -= TEXT_TO_INSET_OFFSET;
int w = InsetText::width(pain, f) + 2 * TEXT_TO_INSET_OFFSET;
int w = InsetText::width(pain, f) + (2 * TEXT_TO_INSET_OFFSET);
int h = ascent(pain,f) + descent(pain, f);
int save_x = static_cast<int>(x);
x += TEXT_TO_INSET_OFFSET;
drawTextXOffset = int(x) - top_x;
InsetText::draw(bv, f, baseline, x, cleared);
pain.rectangle(save_x, baseline - ascent(pain, f), w, h, framecolor);
}
@ -251,3 +250,9 @@ int InsetCollapsable::getMaxTextWidth(Painter & pain,
return getMaxWidth(pain, inset) -
width_collapsed(pain, labelfont) - widthOffset;
}
void InsetCollapsable::update(BufferView * bv, LyXFont const & font, bool dodraw)
{
drawTextXOffset = width_collapsed(bv->painter(), font);
InsetText::update(bv, font, dodraw);
}

View File

@ -53,6 +53,8 @@ public:
///
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
///
void update(BufferView *, LyXFont const &, bool =false);
///
void Edit(BufferView *, int, int, unsigned int);
///
EDITABLE Editable() const;

View File

@ -46,7 +46,6 @@ public:
bool InsertInsetAllowed(Inset * inset) const;
///
LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
///
};
#endif

View File

@ -157,7 +157,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
int nx;
float cx;
UpdatableInset::draw(bv,font,baseline,x);
UpdatableInset::draw(bv,font,baseline,x,cleared);
if ((need_update == INIT)|| (top_x != int(x)) || (top_baseline != baseline)) {
need_update = FULL;
top_x = int(x);

View File

@ -83,6 +83,7 @@ InsetText & InsetText::operator=(InsetText const & it)
void InsetText::init(InsetText const * ins)
{
top_y = last_width = last_height = 0;
insetAscent = insetDescent = insetWidth = 0;
the_locking_inset = 0;
cursor_visible = false;
@ -216,11 +217,11 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
{
Painter & pain = bv->painter();
xpos = x;
UpdatableInset::draw(bv, f, baseline, x);
if (!cleared && locked && ((need_update==FULL) || (top_x!=int(x)) ||
(top_baseline!=baseline))) {
if (!cleared && ((need_update==FULL) || (top_x!=int(x)) ||
(top_baseline!=baseline))) {
#if 0
// && locked && ((need_update==FULL) || (top_x!=int(x)) ||
// (top_baseline!=baseline))) {
need_update = NONE;
top_x = int(x);
top_baseline = baseline;
@ -232,9 +233,24 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
width(pain, f), ascent(pain,f)+descent(pain, f),
frame_color);
return;
#else
pain.fillRectangle(top_x+drawTextXOffset, top_y, last_width,
last_height);
need_update = FULL;
#endif
}
if (!cleared && (need_update == NONE))
return;
xpos = x;
UpdatableInset::draw(bv, f, baseline, x, cleared);
top_baseline = baseline;
top_x = int(x);
top_y = baseline - ascent(pain, f);
last_width = width(pain, f);
last_height = ascent(pain, f) + descent(pain, f);
if (the_locking_inset && (cpos(bv) == inset_pos)) {
inset_x = cx(bv) - top_x + drawTextXOffset;
@ -295,7 +311,8 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
insetDescent = TEXT(bv)->height - row->ascent_of_text() +
TEXT_TO_INSET_OFFSET;
insetWidth = max(textWidth(bv->painter()), TEXT(bv)->width) +
insetWidth = max(textWidth(bv->painter()),
static_cast<int>(TEXT(bv)->width)) +
(2 * TEXT_TO_INSET_OFFSET);
}
@ -336,12 +353,10 @@ void InsetText::InsetUnlock(BufferView * bv)
the_locking_inset = 0;
}
HideInsetCursor(bv);
lyxerr[Debug::INSETS] << "InsetText::InsetUnlock(" << this <<
")" << endl;
no_selection = false;
locked = false;
TEXT(bv)->selection = 0;
UpdateLocal(bv, FULL, false);
UpdateLocal(bv, CURSOR_PAR, false);
bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->GetLayout()+1);
}
@ -384,9 +399,11 @@ bool InsetText::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
return false;
if (the_locking_inset == inset) {
the_locking_inset->InsetUnlock(bv);
TEXT(bv)->UpdateInset(bv, inset);
the_locking_inset = 0;
if (lr)
moveRight(bv, false);
UpdateLocal(bv, FULL, false);
return true;
}
return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
@ -399,9 +416,8 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
return false;
if (the_locking_inset != inset)
return the_locking_inset->UpdateInsetInInset(bv, inset);
lyxerr[Debug::INSETS] << "InsetText::UpdateInsetInInset(" << inset <<
")" << endl;
UpdateLocal(bv, FULL, false);
// UpdateLocal(bv, FULL, false);
TEXT(bv)->UpdateInset(bv, inset);
if (cpos(bv) == inset_pos) {
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
@ -530,17 +546,13 @@ InsetText::LocalDispatch(BufferView * bv,
if (result == DISPATCHED_NOUPDATE)
return result;
else if (result == DISPATCHED) {
the_locking_inset->ToggleInsetCursor(bv);
UpdateLocal(bv, FULL, false);
the_locking_inset->ToggleInsetCursor(bv);
UpdateLocal(bv, CURSOR_PAR, false);
return result;
} else if (result == FINISHED) {
switch(action) {
case -1:
case LFUN_RIGHT:
moveRight(bv);
// TEXT(bv)->cursor.pos(inset_pos + 1);
// resetPos(bv->painter());
moveRight(bv, false);
break;
case LFUN_DOWN:
moveDown(bv);
@ -969,7 +981,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
int InsetText::getMaxTextWidth(Painter & pain, UpdatableInset const * inset) const
{
return getMaxWidth(pain, inset) - 4; // 2+2 width of eventual border
return getMaxWidth(pain, inset) - (2 * TEXT_TO_INSET_OFFSET);
}
void InsetText::SetParagraphData(LyXParagraph *p)

View File

@ -203,6 +203,9 @@ private:
int insetAscent;
int insetDescent;
int insetWidth;
mutable int last_width;
mutable int last_height;
mutable int top_y;
///
int inset_pos;
///

View File

@ -291,7 +291,7 @@ public:
virtual void Edit(BufferView *, int x, int y, unsigned int button);
///
virtual void draw(BufferView *, LyXFont const &,
int baseline, float & x) const;
int baseline, float & x, bool cleared) const;
///
virtual void SetFont(BufferView *, LyXFont const &,
bool toggleall = false);

View File

@ -14,7 +14,7 @@
Row::Row()
: par_(0), pos_(0), fill_(0), height_(0),
: par_(0), pos_(0), fill_(0), height_(0), width_(0),
ascent_of_text_(0), baseline_(0), next_(0), previous_(0)
{}
@ -73,6 +73,18 @@ unsigned short Row::height() const
}
void Row::width(unsigned int w)
{
width_ = w;
}
unsigned int Row::width() const
{
return width_;
}
void Row::ascent_of_text(unsigned short a)
{
ascent_of_text_ = a;

View File

@ -38,6 +38,10 @@ public:
///
unsigned short height() const;
///
void width(unsigned int w);
///
unsigned int width() const;
///
void ascent_of_text(unsigned short a);
///
unsigned short ascent_of_text() const;
@ -64,6 +68,8 @@ private:
///
unsigned short height_;
///
unsigned int width_;
///
unsigned short ascent_of_text_;
///
unsigned int baseline_;

View File

@ -63,7 +63,7 @@ public:
mutable int number_of_rows;
///
mutable long height;
mutable int width;
mutable unsigned int width;
/// the current font settings
mutable LyXFont current_font;
/// the current font

View File

@ -1675,7 +1675,18 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
row_ptr->baseline(maxasc + labeladdon);
height += row_ptr->height();
width = maxwidth;
float x, dummy;
PrepareToPrint(bview, row_ptr, x, dummy, dummy, dummy);
row_ptr->width(maxwidth+x);
if (inset_owner) {
Row * r = firstrow;
width = 0;
while(r) {
if (r->width() > width)
width = r->width();
r = r->next();
}
}
}

View File

@ -70,7 +70,7 @@ void LyXText::init()
number_of_rows = 0;
refresh_y = 0;
height = 0;
width = -1;
width = 0;
first = 0;
status = LyXText::UNCHANGED;
// set cursor at the very top position