namespace lyx {
InsetBranch::InsetBranch(Buffer const & buf, InsetBranchParams const & params)
- : InsetCollapsable(buf), params_(params)
-{
- // override the default for InsetCollapsable, which is to
- // use the plain layout.
- DocumentClass const & dc = buf.params().documentClass();
- paragraphs().back().setDefaultLayout(dc);
-}
+ : InsetCollapsable(buf, InsetText::DefaultLayout), params_(params)
+{}
InsetBranch::~InsetBranch()
InsetCaption::InsetCaption(Buffer const & buf)
- : InsetText(buf)
+ : InsetText(buf, InsetText::PlainLayout)
{
setAutoBreakRows(true);
setDrawFrame(true);
setFrameColor(Color_captionframe);
- // caption insets should use the plain layout
- paragraphs().back().setPlainLayout(buf.params().documentClass());
}
}
-InsetCollapsable::InsetCollapsable(Buffer const & buf)
- : InsetText(buf), status_(Inset::Open),
+InsetCollapsable::InsetCollapsable(Buffer const & buf, InsetText::UsePlain ltype)
+ : InsetText(buf, ltype), status_(Inset::Open),
openinlined_(false), mouse_hover_(false)
{
- DocumentClass const & dc = buf.params().documentClass();
- setLayout(&dc);
+ setLayout(&buf.params().documentClass());
setAutoBreakRows(true);
setDrawFrame(true);
setFrameColor(Color_collapsableframe);
- paragraphs().back().setPlainLayout(dc);
}
*/
class InsetCollapsable : public InsetText {
public:
- /// By default, InsetCollapsable uses the plain layout. If you
- /// want to override this in a subclass, you'll need to call
- /// Paragraph::setDefaultLayout() in its constructor. See
- /// InsetBranch for an example.
- InsetCollapsable(Buffer const &);
+ ///
+ InsetCollapsable(Buffer const &, InsetText::UsePlain = InsetText::PlainLayout);
///
InsetCollapsable(InsetCollapsable const & rhs);
///
inset(new InsetTableCell(buf))
{
inset->setBuffer(const_cast<Buffer &>(buf));
- inset->paragraphs().back().setLayout(buf.params().documentClass().plainLayout());
}
/////////////////////////////////////////////////////////////////////
InsetTableCell::InsetTableCell(Buffer & buf)
- : InsetText(buf), isFixedWidth(false),
+ : InsetText(buf, InsetText::PlainLayout), isFixedWidth(false),
contentAlign(LYX_ALIGN_CENTER)
{}
/////////////////////////////////////////////////////////////////////
-InsetText::InsetText(Buffer const & buf)
+InsetText::InsetText(Buffer const & buf, UsePlain type)
: drawFrame_(false), frame_color_(Color_insetframe)
{
setBuffer(const_cast<Buffer &>(buf));
- initParagraphs();
+ initParagraphs(type);
}
}
-void InsetText::initParagraphs()
+void InsetText::initParagraphs(UsePlain type)
{
LASSERT(paragraphs().empty(), /**/);
paragraphs().push_back(Paragraph());
Paragraph & ourpar = paragraphs().back();
ourpar.setInsetOwner(this);
- ourpar.setDefaultLayout(buffer_->params().documentClass());
+ DocumentClass const & dc = buffer_->params().documentClass();
+ if (type == DefaultLayout)
+ ourpar.setDefaultLayout(dc);
+ else
+ ourpar.setPlainLayout(dc);
}
*/
class InsetText : public Inset {
public:
- ///
- explicit InsetText(Buffer const & buffer);
+ enum UsePlain {
+ DefaultLayout,
+ PlainLayout
+ };
+ /// \param buffer
+ /// \param useplain whether to use the plain layout
+ /// This is needed because we cannot call the virtual function
+ /// usePlainLayout() from within the constructor.
+ explicit InsetText(Buffer const & buffer, UsePlain type = DefaultLayout);
///
InsetText(InsetText const &);
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
private:
///
- void initParagraphs();
+ void initParagraphs(UsePlain type);
///
void setParagraphOwner();
///