mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-14 12:25:11 +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 {
|
namespace lyx {
|
||||||
|
|
||||||
InsetBranch::InsetBranch(Buffer const & buf, InsetBranchParams const & params)
|
InsetBranch::InsetBranch(Buffer const & buf, InsetBranchParams const & params)
|
||||||
: InsetCollapsable(buf), params_(params)
|
: InsetCollapsable(buf, InsetText::DefaultLayout), params_(params)
|
||||||
{
|
{}
|
||||||
// override the default for InsetCollapsable, which is to
|
|
||||||
// use the plain layout.
|
|
||||||
DocumentClass const & dc = buf.params().documentClass();
|
|
||||||
paragraphs().back().setDefaultLayout(dc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
InsetBranch::~InsetBranch()
|
InsetBranch::~InsetBranch()
|
||||||
|
@ -48,13 +48,11 @@ namespace lyx {
|
|||||||
|
|
||||||
|
|
||||||
InsetCaption::InsetCaption(Buffer const & buf)
|
InsetCaption::InsetCaption(Buffer const & buf)
|
||||||
: InsetText(buf)
|
: InsetText(buf, InsetText::PlainLayout)
|
||||||
{
|
{
|
||||||
setAutoBreakRows(true);
|
setAutoBreakRows(true);
|
||||||
setDrawFrame(true);
|
setDrawFrame(true);
|
||||||
setFrameColor(Color_captionframe);
|
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)
|
InsetCollapsable::InsetCollapsable(Buffer const & buf, InsetText::UsePlain ltype)
|
||||||
: InsetText(buf), status_(Inset::Open),
|
: InsetText(buf, ltype), status_(Inset::Open),
|
||||||
openinlined_(false), mouse_hover_(false)
|
openinlined_(false), mouse_hover_(false)
|
||||||
{
|
{
|
||||||
DocumentClass const & dc = buf.params().documentClass();
|
setLayout(&buf.params().documentClass());
|
||||||
setLayout(&dc);
|
|
||||||
setAutoBreakRows(true);
|
setAutoBreakRows(true);
|
||||||
setDrawFrame(true);
|
setDrawFrame(true);
|
||||||
setFrameColor(Color_collapsableframe);
|
setFrameColor(Color_collapsableframe);
|
||||||
paragraphs().back().setPlainLayout(dc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,11 +32,8 @@ namespace frontend { class Painter; }
|
|||||||
*/
|
*/
|
||||||
class InsetCollapsable : public InsetText {
|
class InsetCollapsable : public InsetText {
|
||||||
public:
|
public:
|
||||||
/// By default, InsetCollapsable uses the plain layout. If you
|
///
|
||||||
/// want to override this in a subclass, you'll need to call
|
InsetCollapsable(Buffer const &, InsetText::UsePlain = InsetText::PlainLayout);
|
||||||
/// Paragraph::setDefaultLayout() in its constructor. See
|
|
||||||
/// InsetBranch for an example.
|
|
||||||
InsetCollapsable(Buffer const &);
|
|
||||||
///
|
///
|
||||||
InsetCollapsable(InsetCollapsable const & rhs);
|
InsetCollapsable(InsetCollapsable const & rhs);
|
||||||
///
|
///
|
||||||
|
@ -490,7 +490,6 @@ Tabular::CellData::CellData(Buffer & buf)
|
|||||||
inset(new InsetTableCell(buf))
|
inset(new InsetTableCell(buf))
|
||||||
{
|
{
|
||||||
inset->setBuffer(const_cast<Buffer &>(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)
|
InsetTableCell::InsetTableCell(Buffer & buf)
|
||||||
: InsetText(buf), isFixedWidth(false),
|
: InsetText(buf, InsetText::PlainLayout), isFixedWidth(false),
|
||||||
contentAlign(LYX_ALIGN_CENTER)
|
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)
|
: drawFrame_(false), frame_color_(Color_insetframe)
|
||||||
{
|
{
|
||||||
setBuffer(const_cast<Buffer &>(buf));
|
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(), /**/);
|
LASSERT(paragraphs().empty(), /**/);
|
||||||
paragraphs().push_back(Paragraph());
|
paragraphs().push_back(Paragraph());
|
||||||
Paragraph & ourpar = paragraphs().back();
|
Paragraph & ourpar = paragraphs().back();
|
||||||
ourpar.setInsetOwner(this);
|
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 {
|
class InsetText : public Inset {
|
||||||
public:
|
public:
|
||||||
///
|
enum UsePlain {
|
||||||
explicit InsetText(Buffer const & buffer);
|
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 &);
|
InsetText(InsetText const &);
|
||||||
///
|
///
|
||||||
@ -169,7 +176,7 @@ public:
|
|||||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
void initParagraphs();
|
void initParagraphs(UsePlain type);
|
||||||
///
|
///
|
||||||
void setParagraphOwner();
|
void setParagraphOwner();
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user