mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 14:15:32 +00:00
Make all of InsetCollapsable's member variables (save 'inset') private.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7777 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
38deeee705
commit
35abda384d
@ -1,3 +1,17 @@
|
||||
2003-09-16 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetcollapsable.[Ch]: make all member variables, except for 'inset', private.
|
||||
|
||||
* insetert.C (init): use InsetCollapsable::setLabelFont rather than access
|
||||
labelfont directly.
|
||||
(read, updateStatus, lfunMouseRelease, status, showInsetDialog): use
|
||||
InsetCollapsable::setCollapsed, isOpen rather than access collapsed_ directly.
|
||||
|
||||
* insetminipage.C (metrics):
|
||||
* insetnote.C (metrics):
|
||||
* insettheorem.C (clone): use InsetCollapsable::isOpen rather than
|
||||
access collapsed_ directly.
|
||||
|
||||
2003-09-16 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetbibitem.C: add #include "lyxfont.h".
|
||||
@ -9,10 +23,10 @@
|
||||
|
||||
2003-09-16 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetcollapsable.h: remove ununsed framecolor variable.
|
||||
* insetcollapsable.h: remove unused framecolor variable.
|
||||
Remove #include "LColor.h".
|
||||
|
||||
* insetcollapsable.C: remove ununsed framecolor variable.
|
||||
* insetcollapsable.C: remove unused framecolor variable.
|
||||
|
||||
* insetcaption.C:
|
||||
* insetcollapsable.C:
|
||||
|
@ -37,7 +37,7 @@ using std::ostream;
|
||||
|
||||
|
||||
InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
|
||||
: UpdatableInset(), collapsed_(collapsed), inset(bp),
|
||||
: UpdatableInset(), inset(bp), collapsed_(collapsed),
|
||||
button_dim(0, 0, 0, 0), label("Label"),
|
||||
#if 0
|
||||
autocollapse(false),
|
||||
@ -53,9 +53,8 @@ InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
|
||||
|
||||
|
||||
InsetCollapsable::InsetCollapsable(InsetCollapsable const & in)
|
||||
: UpdatableInset(in), collapsed_(in.collapsed_),
|
||||
labelfont(in.labelfont), inset(in.inset),
|
||||
button_dim(0, 0, 0, 0), label(in.label),
|
||||
: UpdatableInset(in), inset(in.inset), collapsed_(in.collapsed_),
|
||||
labelfont_(in.labelfont_), button_dim(0, 0, 0, 0), label(in.label),
|
||||
#if 0
|
||||
autocollapse(in.autocollapse),
|
||||
#endif
|
||||
@ -105,14 +104,14 @@ void InsetCollapsable::read(Buffer const & buf, LyXLex & lex)
|
||||
|
||||
void InsetCollapsable::dimension_collapsed(Dimension & dim) const
|
||||
{
|
||||
font_metrics::buttonText(label, labelfont, dim.wid, dim.asc, dim.des);
|
||||
font_metrics::buttonText(label, labelfont_, dim.wid, dim.asc, dim.des);
|
||||
}
|
||||
|
||||
|
||||
int InsetCollapsable::height_collapsed() const
|
||||
{
|
||||
Dimension dim;
|
||||
font_metrics::buttonText(label, labelfont, dim.wid, dim.asc, dim.des);
|
||||
font_metrics::buttonText(label, labelfont_, dim.wid, dim.asc, dim.des);
|
||||
return dim.asc + dim.des;
|
||||
}
|
||||
|
||||
@ -133,7 +132,7 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
pi.pain.buttonText(x, y, label, labelfont);
|
||||
pi.pain.buttonText(x, y, label, labelfont_);
|
||||
}
|
||||
|
||||
|
||||
@ -499,6 +498,12 @@ void InsetCollapsable::setLabel(string const & l) const
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::setCollapsed(bool c) const
|
||||
{
|
||||
collapsed_ = c;
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::markErased()
|
||||
{
|
||||
inset.markErased();
|
||||
|
@ -57,11 +57,9 @@ public:
|
||||
///
|
||||
bool insertInset(BufferView *, InsetOld * inset);
|
||||
///
|
||||
virtual bool insetAllowed(InsetOld::Code code) const {
|
||||
return inset.insetAllowed(code);
|
||||
}
|
||||
virtual bool insetAllowed(InsetOld::Code code) const;
|
||||
///
|
||||
bool isTextInset() const { return true; }
|
||||
bool isTextInset() const;
|
||||
///
|
||||
void insetUnlock(BufferView *);
|
||||
///
|
||||
@ -89,9 +87,8 @@ public:
|
||||
/// Get the absolute document x,y of the cursor
|
||||
virtual void getCursor(BufferView &, int &, int &) const;
|
||||
///
|
||||
void fitInsetCursor(BufferView * bv) const {
|
||||
inset.fitInsetCursor(bv);
|
||||
}
|
||||
void fitInsetCursor(BufferView * bv) const;
|
||||
///
|
||||
UpdatableInset * getLockingInset() const;
|
||||
///
|
||||
UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code);
|
||||
@ -101,10 +98,10 @@ public:
|
||||
///
|
||||
void setLabel(string const & l) const;
|
||||
///
|
||||
void setLabelFont(LyXFont & f) { labelfont = f; }
|
||||
void setLabelFont(LyXFont & f);
|
||||
#if 0
|
||||
///
|
||||
void setAutoCollapse(bool f) { autocollapse = f; }
|
||||
void setAutoCollapse(bool f);
|
||||
#endif
|
||||
///
|
||||
LyXText * getLyXText(BufferView const *, bool const recursive) const;
|
||||
@ -115,13 +112,9 @@ public:
|
||||
///
|
||||
int scroll(bool recursive=true) const;
|
||||
///
|
||||
void scroll(BufferView *bv, float sx) const {
|
||||
UpdatableInset::scroll(bv, sx);
|
||||
}
|
||||
void scroll(BufferView *bv, float sx) const;
|
||||
///
|
||||
void scroll(BufferView *bv, int offset) const {
|
||||
UpdatableInset::scroll(bv, offset);
|
||||
}
|
||||
void scroll(BufferView *bv, int offset) const;
|
||||
///
|
||||
InsetOld * getInsetFromID(int id) const;
|
||||
///
|
||||
@ -129,20 +122,18 @@ public:
|
||||
///
|
||||
LyXCursor const & cursor(BufferView *) const;
|
||||
///
|
||||
bool isOpen() const { return !collapsed_; }
|
||||
bool isOpen() const;
|
||||
///
|
||||
void open(BufferView *);
|
||||
///
|
||||
void close(BufferView *) const;
|
||||
///
|
||||
bool allowSpellcheck() const { return inset.allowSpellcheck(); }
|
||||
bool allowSpellcheck() const;
|
||||
///
|
||||
WordLangTuple const
|
||||
selectNextWordToSpellcheck(BufferView *, float &) const;
|
||||
///
|
||||
void selectSelectedWord(BufferView * bv) {
|
||||
inset.selectSelectedWord(bv);
|
||||
}
|
||||
void selectSelectedWord(BufferView *);
|
||||
|
||||
void markErased();
|
||||
|
||||
@ -171,20 +162,10 @@ protected:
|
||||
void draw_collapsed(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
|
||||
|
||||
/// Should be non-const...
|
||||
void setCollapsed(bool) const;
|
||||
///
|
||||
mutable bool collapsed_;
|
||||
///
|
||||
LyXFont labelfont;
|
||||
public:
|
||||
///
|
||||
mutable InsetText inset;
|
||||
protected:
|
||||
///
|
||||
mutable Box button_dim;
|
||||
///
|
||||
mutable int topx;
|
||||
mutable int topbaseline;
|
||||
Box const & buttonDim() const;
|
||||
|
||||
private:
|
||||
///
|
||||
@ -192,6 +173,20 @@ private:
|
||||
///
|
||||
FuncRequest adjustCommand(FuncRequest const &);
|
||||
|
||||
public:
|
||||
///
|
||||
mutable InsetText inset;
|
||||
private:
|
||||
///
|
||||
mutable bool collapsed_;
|
||||
///
|
||||
LyXFont labelfont_;
|
||||
///
|
||||
mutable Box button_dim;
|
||||
///
|
||||
mutable int topx;
|
||||
mutable int topbaseline;
|
||||
|
||||
///
|
||||
mutable string label;
|
||||
#if 0
|
||||
@ -206,4 +201,80 @@ private:
|
||||
mutable boost::weak_ptr<BufferView> view_;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
bool InsetCollapsable::insetAllowed(InsetOld::Code code) const
|
||||
{
|
||||
return inset.insetAllowed(code);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
bool InsetCollapsable::isTextInset() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void InsetCollapsable::fitInsetCursor(BufferView * bv) const
|
||||
{
|
||||
inset.fitInsetCursor(bv);
|
||||
}
|
||||
|
||||
inline
|
||||
void InsetCollapsable::setLabelFont(LyXFont & f)
|
||||
{
|
||||
labelfont_ = f;
|
||||
}
|
||||
|
||||
#if 0
|
||||
inline
|
||||
void InsetCollapsable::setAutoCollapse(bool f)
|
||||
{
|
||||
autocollapse = f;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
void InsetCollapsable::scroll(BufferView *bv, float sx) const
|
||||
{
|
||||
UpdatableInset::scroll(bv, sx);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void InsetCollapsable::scroll(BufferView *bv, int offset) const
|
||||
{
|
||||
UpdatableInset::scroll(bv, offset);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
bool InsetCollapsable::isOpen() const
|
||||
{
|
||||
return !collapsed_;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
bool InsetCollapsable::allowSpellcheck() const
|
||||
{
|
||||
return inset.allowSpellcheck();
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void InsetCollapsable::selectSelectedWord(BufferView * bv)
|
||||
{
|
||||
inset.selectSelectedWord(bv);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Box const & InsetCollapsable::buttonDim() const
|
||||
{
|
||||
return button_dim;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -45,10 +45,13 @@ using std::ostream;
|
||||
void InsetERT::init()
|
||||
{
|
||||
setButtonLabel();
|
||||
labelfont = LyXFont(LyXFont::ALL_SANE);
|
||||
labelfont.decSize();
|
||||
labelfont.decSize();
|
||||
labelfont.setColor(LColor::latex);
|
||||
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
font.decSize();
|
||||
font.decSize();
|
||||
font.setColor(LColor::latex);
|
||||
setLabelFont(font);
|
||||
|
||||
setInsetName("ERT");
|
||||
}
|
||||
|
||||
@ -145,7 +148,7 @@ void InsetERT::read(Buffer const & buf, LyXLex & lex)
|
||||
string const token = lex.getString();
|
||||
if (token == "collapsed") {
|
||||
lex.next();
|
||||
collapsed_ = lex.getBool();
|
||||
setCollapsed(lex.getBool());
|
||||
} else {
|
||||
// Take countermeasures
|
||||
lex.pushToken(token);
|
||||
@ -170,11 +173,10 @@ void InsetERT::read(Buffer const & buf, LyXLex & lex)
|
||||
#endif
|
||||
|
||||
if (!token_found) {
|
||||
if (collapsed_) {
|
||||
status(0, Collapsed);
|
||||
} else {
|
||||
if (isOpen())
|
||||
status(0, Open);
|
||||
}
|
||||
else
|
||||
status(0, Collapsed);
|
||||
}
|
||||
setButtonLabel();
|
||||
}
|
||||
@ -259,11 +261,10 @@ void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall)
|
||||
void InsetERT::updateStatus(BufferView * bv, bool swap) const
|
||||
{
|
||||
if (status_ != Inlined) {
|
||||
if (collapsed_) {
|
||||
status(bv, swap ? Open : Collapsed);
|
||||
} else {
|
||||
if (isOpen())
|
||||
status(bv, swap ? Collapsed : Open);
|
||||
}
|
||||
else
|
||||
status(bv, swap ? Open : Collapsed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,10 +303,9 @@ bool InsetERT::lfunMouseRelease(FuncRequest const & cmd)
|
||||
cmd1.y = ascent() + cmd.y - inset.ascent();
|
||||
|
||||
// inlined is special - the text appears above
|
||||
// button_dim.y2
|
||||
if (status_ == Inlined)
|
||||
inset.localDispatch(cmd1);
|
||||
else if (!collapsed_ && (cmd.y > button_dim.y2)) {
|
||||
else if (isOpen() && (cmd.y > buttonDim().y2)) {
|
||||
cmd1.y -= height_collapsed();
|
||||
inset.localDispatch(cmd1);
|
||||
}
|
||||
@ -590,11 +590,11 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const
|
||||
case Inlined:
|
||||
break;
|
||||
case Open:
|
||||
collapsed_ = false;
|
||||
setCollapsed(false);
|
||||
setButtonLabel();
|
||||
break;
|
||||
case Collapsed:
|
||||
collapsed_ = true;
|
||||
setCollapsed(true);
|
||||
setButtonLabel();
|
||||
if (bv)
|
||||
bv->unlockInset(const_cast<InsetERT *>(this));
|
||||
@ -617,7 +617,7 @@ bool InsetERT::showInsetDialog(BufferView * bv) const
|
||||
|
||||
void InsetERT::open(BufferView * bv)
|
||||
{
|
||||
if (!collapsed_)
|
||||
if (isOpen())
|
||||
return;
|
||||
status(bv, Open);
|
||||
}
|
||||
|
@ -203,9 +203,7 @@ void InsetMinipage::read(Buffer const & buf, LyXLex & lex)
|
||||
|
||||
void InsetMinipage::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
if (collapsed_)
|
||||
dimension_collapsed(dim);
|
||||
else {
|
||||
if (isOpen()) {
|
||||
Dimension d;
|
||||
MetricsInfo m = mi;
|
||||
m.base.textwidth = params_.width.inPixels(mi.base.textwidth);
|
||||
@ -225,7 +223,9 @@ void InsetMinipage::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
break;
|
||||
}
|
||||
dim.wid = d.wid;
|
||||
}
|
||||
} else
|
||||
dimension_collapsed(dim);
|
||||
|
||||
dim_ = dim;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ void InsetNote::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
// Contrary to Greyedout, these cannot be construed as part of the
|
||||
// running text: make them stand on their own
|
||||
if (params_.type == "Note" || params_.type == "Comment")
|
||||
if (!collapsed_)
|
||||
if (isOpen())
|
||||
dim.wid = mi.base.textwidth;
|
||||
dim_ = dim;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ InsetBase * InsetTheorem::clone() const
|
||||
#endif
|
||||
InsetTheorem * result = new InsetTheorem;
|
||||
|
||||
result->collapsed_ = collapsed_;
|
||||
result->setCollapsed(!isOpen());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user