if (inset->lyxCode() != FLEX_CODE)
// FIXME: Should we verify all InsetCollapsable?
continue;
- inset->setLayout(newone);
if (!inset->undefined())
continue;
// The flex inset is undefined in newtc
if (!inset)
return false;
- if (InsetCollapsable * ci = inset->asInsetCollapsable())
- ci->setLayout();
-
cur.recordUndo();
if (cmd.action == LFUN_INDEX_INSERT) {
docstring ds = subst(text->getStringToIndex(cur), '\n', ' ');
params_.type = cmd.getArg(1);
else
string2params(to_utf8(cmd.argument()), params_);
- setLayout();
break;
}
InsetBranchParams params;
InsetBranch::string2params(to_utf8(cmd.argument()), params);
params_.branch = params.branch;
- setLayout();
break;
}
: InsetText(buf, ltype), status_(Inset::Open),
openinlined_(false), mouse_hover_(false)
{
- setLayout(&buf.params().documentClass());
setAutoBreakRows(true);
setDrawFrame(true);
setFrameColor(Color_collapsableframe);
InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs)
: InsetText(rhs),
status_(rhs.status_),
- layout_(rhs.layout_),
labelstring_(rhs.labelstring_),
button_dim(rhs.button_dim),
openinlined_(rhs.openinlined_),
}
-void InsetCollapsable::setLayout()
-{
- setLayout(buffer().params().documentClassPtr());
-}
-
-
-void InsetCollapsable::setLayout(DocumentClass const * const dc)
-{
- if (dc) {
- layout_ = &(dc->insetLayout(name()));
- labelstring_ = translateIfPossible(getLayout().labelstring());
- } else {
- layout_ = &DocumentClass::plainInsetLayout();
- labelstring_ = _("UNDEFINED");
- }
-
- setButtonLabel();
-}
-
-
void InsetCollapsable::write(ostream & os) const
{
os << "status ";
status_ = Open;
// this must be set before we enter InsetText::read()
- setLayout();
InsetText::read(lex);
- // set button label again as the inset contents was not read yet at
- // setLayout() time.
setButtonLabel();
// Force default font, if so requested
Dimension InsetCollapsable::dimensionCollapsed(BufferView const & bv) const
{
- LASSERT(layout_, /**/);
Dimension dim;
theFontMetrics(getLayout().labelfont()).buttonText(
buttonLabel(bv), dim.wid, dim.asc, dim.des);
docstring toolTip(BufferView const & bv, int x, int y) const;
///
docstring name() const { return from_ascii("Collapsable"); }
-#if 0
- ///
- InsetLayout const & getLayout() const { return *layout_; }
-#endif
- ///
- void setLayout();
- /// (Re-)set the character style parameters from \p tc according
- /// to name()
- void setLayout(DocumentClass const * const tc);
///
void read(Lexer &);
///
///
mutable CollapseStatus status_;
private:
- /// cache for the layout_. Make sure it is in sync with the document class!
- InsetLayout const * layout_;
///
Dimension dimensionCollapsed(BufferView const & bv) const;
///
InsetFlex::InsetFlex(Buffer const & buf, string const & layoutName)
: InsetCollapsable(buf), name_(layoutName)
{
- // again, because now the name is initialized
- setLayout(buf.params().documentClassPtr());
status_= Collapsed;
}
case LFUN_INSET_MODIFY: {
if (cmd.getArg(0) == "changetype") {
params_.index = from_utf8(cmd.getArg(1));
- setLayout();
break;
}
InsetIndexParams params;
InsetIndex::string2params(to_utf8(cmd.argument()), params);
params_.index = params.index;
- setLayout();
break;
}
_("Missing \\end_inset at this point."),
from_utf8(token));
}
- setLayout();
updateInfo();
}
string type;
name_ = trim(split(name, type, ' '));
type_ = nameTranslator().find(type);
- setLayout();
updateInfo();
}
case LFUN_INSET_MODIFY:
string2params(to_utf8(cmd.argument()), params_);
- setLayout();
break;
case LFUN_INSET_DIALOG_UPDATE:
case LFUN_INSET_MODIFY:
string2params(to_utf8(cmd.argument()), params_);
- setLayout();
break;
case LFUN_INSET_DIALOG_UPDATE: