* InsetCollapsable:

- InsetCollapsable(): Move labelfont initialisation to InsetCollapsable::setLayout().
- read(): reset the inset layout.

All other insets: get rid of redundant setLayout() calls.

This commit fixes the multiple crashes in trunk but the color used for text and background are completely wrong...


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21382 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-11-02 17:47:51 +00:00
parent 37af3d5a3d
commit c51f1cffaa
9 changed files with 23 additions and 29 deletions

View File

@ -94,7 +94,6 @@ void InsetBox::init()
InsetBox::InsetBox(BufferParams const & bp, string const & label)
: InsetCollapsable(bp), params_(label)
{
setLayout(bp);
init();
}
@ -135,7 +134,6 @@ void InsetBox::read(Buffer const & buf, Lexer & lex)
{
params_.read(lex);
InsetCollapsable::read(buf, lex);
setLayout(buf.params());
setButtonLabel();
}

View File

@ -45,7 +45,6 @@ InsetBranch::InsetBranch(BufferParams const & bp,
InsetBranchParams const & params)
: InsetCollapsable(bp), params_(params)
{
setLayout(bp);
init();
}
@ -86,8 +85,6 @@ void InsetBranch::read(Buffer const & buf, Lexer & lex)
{
params_.read(lex);
InsetCollapsable::read(buf, lex);
setLayout(buf.params());
setButtonLabel();
}
@ -137,7 +134,6 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
InsetBranchMailer::string2params(to_utf8(cmd.argument()), params);
params_.branch = params.branch;
setLayout(cur.buffer().params());
setButtonLabel();
break;
}

View File

@ -82,14 +82,7 @@ InsetCollapsable::InsetCollapsable
setDrawFrame(true);
setFrameColor(Color_collapsableframe);
setButtonLabel();
// Fallback for lacking inset layout item
layout_.bgcolor = Color_background;
// FIXME: it seems some insets don't properly initialise that!
layout_.labelfont = sane_font;
layout_.labelfont.decSize();
layout_.labelfont.decSize();
layout_.labelfont.setColor(Color_collapsable);
setLayout(bp);
}
@ -110,7 +103,25 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs)
void InsetCollapsable::setLayout(BufferParams const & bp)
{
// Fallback for lacking inset layout item
layout_.bgcolor = Color_background;
// FIXME: it seems the default background is red!
layout_ = getLayout(bp);
// FIXME: it seems the provided font is partly realized... so we
// re-initialize the label font in any case.
/*
if (layout_.labelfont != inherit_font)
return;
*/
// FIXME: it seems some insets don't properly initialise that...
layout_.labelfont = sane_font;
layout_.labelfont.decSize();
layout_.labelfont.decSize();
layout_.labelfont.setColor(Color_collapsable);
}
@ -165,6 +176,7 @@ void InsetCollapsable::read(Buffer const & buf, Lexer & lex)
status_ = isOpen() ? Open : Collapsed;
setButtonLabel();
setLayout(buf.params());
// Force default font, if so requested
// This avoids paragraphs in buffer language that would have a

View File

@ -61,7 +61,6 @@ void InsetERT::init()
InsetERT::InsetERT(BufferParams const & bp, CollapseStatus status)
: InsetCollapsable(bp, status)
{
setLayout(bp);
init();
}

View File

@ -36,9 +36,7 @@ using std::ostream;
InsetFoot::InsetFoot(BufferParams const & bp)
: InsetFootlike(bp)
{
setLayout(bp);
}
{}
InsetFoot::InsetFoot(InsetFoot const & in)

View File

@ -30,9 +30,7 @@ using std::ostream;
InsetIndex::InsetIndex(BufferParams const & bp)
: InsetCollapsable(bp)
{
setLayout(bp);
}
{}
InsetIndex::InsetIndex(InsetIndex const & in)

View File

@ -59,7 +59,6 @@ void InsetListings::init()
InsetListings::InsetListings(BufferParams const & bp, InsetListingsParams const & par)
: InsetCollapsable(bp, par.status())
{
setLayout(bp);
init();
}

View File

@ -25,9 +25,7 @@ namespace lyx {
InsetMarginal::InsetMarginal(BufferParams const & bp)
: InsetFootlike(bp)
{
setLayout(bp);
}
{}
InsetMarginal::InsetMarginal(InsetMarginal const & in)

View File

@ -116,7 +116,6 @@ InsetNote::InsetNote(BufferParams const & bp, string const & label)
: InsetCollapsable(bp)
{
params_.type = notetranslator().find(label);
setLayout(bp);
setButtonLabel();
}
@ -175,8 +174,6 @@ void InsetNote::read(Buffer const & buf, Lexer & lex)
{
params_.read(lex);
InsetCollapsable::read(buf, lex);
setLayout(buf.params());
setButtonLabel();
}
@ -202,7 +199,6 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd)
InsetNoteMailer::string2params(to_utf8(cmd.argument()), params_);
// get a bp from cur:
setLayout(cur.buffer().params());
setButtonLabel();
break;
case LFUN_INSET_DIALOG_UPDATE: