mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 06:19:36 +00:00
Manage the initial setting of Default or Plain Layout more simply.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29093 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
193074b384
commit
920bfedf1f
@ -40,13 +40,8 @@ using namespace std;
|
||||
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()
|
||||
|
@ -48,13 +48,11 @@ namespace lyx {
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,16 +102,14 @@ InsetCollapsable::Geometry InsetCollapsable::geometry() const
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,11 +32,8 @@ namespace frontend { class Painter; }
|
||||
*/
|
||||
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);
|
||||
///
|
||||
|
@ -490,7 +490,6 @@ Tabular::CellData::CellData(Buffer & buf)
|
||||
inset(new InsetTableCell(buf))
|
||||
{
|
||||
inset->setBuffer(const_cast<Buffer &>(buf));
|
||||
inset->paragraphs().back().setLayout(buf.params().documentClass().plainLayout());
|
||||
}
|
||||
|
||||
|
||||
@ -2841,7 +2840,7 @@ Tabular::BoxType Tabular::useParbox(idx_type cell) const
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
InsetTableCell::InsetTableCell(Buffer & buf)
|
||||
: InsetText(buf), isFixedWidth(false),
|
||||
: InsetText(buf, InsetText::PlainLayout), isFixedWidth(false),
|
||||
contentAlign(LYX_ALIGN_CENTER)
|
||||
{}
|
||||
|
||||
|
@ -71,11 +71,11 @@ using graphics::PreviewLoader;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -99,13 +99,17 @@ void InsetText::setBuffer(Buffer & buf)
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,8 +34,15 @@ class InsetTabular;
|
||||
*/
|
||||
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 &);
|
||||
///
|
||||
@ -169,7 +176,7 @@ public:
|
||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
private:
|
||||
///
|
||||
void initParagraphs();
|
||||
void initParagraphs(UsePlain type);
|
||||
///
|
||||
void setParagraphOwner();
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user