+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".
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:
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),
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
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;
}
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_);
}
}
+void InsetCollapsable::setCollapsed(bool c) const
+{
+ collapsed_ = c;
+}
+
+
void InsetCollapsable::markErased()
{
inset.markErased();
///
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 *);
///
/// 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);
///
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;
///
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;
///
///
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();
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;
+ ///
+ Box const & buttonDim() const;
+private:
///
- mutable bool collapsed_;
+ void lfunMouseRelease(FuncRequest const &);
///
- LyXFont labelfont;
+ FuncRequest adjustCommand(FuncRequest const &);
+
public:
///
mutable InsetText inset;
-protected:
+private:
+ ///
+ mutable bool collapsed_;
+ ///
+ LyXFont labelfont_;
///
mutable Box button_dim;
///
mutable int topx;
mutable int topbaseline;
-private:
- ///
- void lfunMouseRelease(FuncRequest const &);
- ///
- FuncRequest adjustCommand(FuncRequest const &);
-
///
mutable string label;
#if 0
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
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");
}
string const token = lex.getString();
if (token == "collapsed") {
lex.next();
- collapsed_ = lex.getBool();
+ setCollapsed(lex.getBool());
} else {
// Take countermeasures
lex.pushToken(token);
#endif
if (!token_found) {
- if (collapsed_) {
- status(0, Collapsed);
- } else {
+ if (isOpen())
status(0, Open);
- }
+ else
+ status(0, Collapsed);
}
setButtonLabel();
}
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);
}
}
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);
}
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));
void InsetERT::open(BufferView * bv)
{
- if (!collapsed_)
+ if (isOpen())
return;
status(bv, Open);
}
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);
break;
}
dim.wid = d.wid;
- }
+ } else
+ dimension_collapsed(dim);
+
dim_ = dim;
}
// 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;
}
#endif
InsetTheorem * result = new InsetTheorem;
- result->collapsed_ = collapsed_;
+ result->setCollapsed(!isOpen());
return result;
}