Added various inset functions for Jean-Marc (see Changelog). Small fix in

cua bind-file.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2228 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2001-07-12 14:35:38 +00:00
parent 491f68131a
commit 487f6eb3b4
23 changed files with 104 additions and 87 deletions

View File

@ -1,3 +1,7 @@
2001-07-12 Juergen Vigna <jug@sad.it>
* bind/cua.bind: moved C-l from mode-tex to ert-insert
2001-07-12 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* images/ert-insert.xpm: renamed from tex-mode.xpm

View File

@ -47,7 +47,6 @@
\bind "C-e" "font-emph"
# used below for line-delete-forward
#\bind "C-k" "font-noun" # 'k' for capitals
\bind "C-l" "tex-mode" # 'l' for LaTeX
\bind "C-u" "font-underline"
\bind "C-S-P" "font-code" # 'P' for program
@ -73,6 +72,7 @@
\bind "M-S-Right" "depth-increment"
\bind "M-S-Left" "depth-decrement"
\bind "C-S-space" "protected-space-insert"
\bind "C-l" "ert-insert" # 'l' for LaTeX
#bind "F1" "help" # Not yet implemented!
#bind "C-F1" "help-context" # Not yet implemented!

View File

@ -1,5 +1,14 @@
2001-07-12 Juergen Vigna <jug@sad.it>
* insetcollapsable.h: added implementation of new function for
collapsable status.
* various files: added implementation of new insertInsetAllowed-func
and redone the function a bit more.
* inset.h: added isCollapsable(), bool collapsed(),
collapsed(BufferView *, bool) and insertInsetAllowed(Inset::Code).
* insetfloat.C (insertInsetAllowed): make a bit more checks.
* insettext.C (getLyXText): use 'lt' to assure we're not erasing the

View File

@ -368,6 +368,7 @@ public:
virtual bool insertInset(BufferView *, Inset *) { return false; }
///
virtual bool insertInsetAllowed(Inset *) const { return false; }
virtual bool insertInsetAllowed(Inset::Code) const { return false; }
///
virtual UpdatableInset * getLockingInset() const {
return const_cast<UpdatableInset *>(this);
@ -408,6 +409,11 @@ public:
virtual bool nodraw() const {
return block_drawing_;
}
///
virtual bool isCollapsable() const { return false; }
///
virtual bool collapsed() const { return false; }
virtual void collapsed(BufferView *, bool) {}
protected:
///

View File

@ -36,7 +36,7 @@ InsetCollapsable::InsetCollapsable()
: UpdatableInset()
{
inset.setOwner(this);
collapsed = false;
collapsed_ = false;
label = "Label";
autocollapse = true;
inset.setAutoBreakRows(true);
@ -62,7 +62,7 @@ bool InsetCollapsable::insertInset(BufferView * bv, Inset * in)
void InsetCollapsable::write(Buffer const * buf, ostream & os) const
{
os << "collapsed " << tostr(collapsed) << "\n";
os << "collapsed " << tostr(collapsed_) << "\n";
inset.writeParagraphData(buf, os);
}
@ -75,7 +75,7 @@ void InsetCollapsable::read(Buffer const * buf, LyXLex & lex)
string const token = lex.GetString();
if (token == "collapsed") {
lex.next();
collapsed = lex.GetBool();
collapsed_ = lex.GetBool();
} else {
lyxerr << "InsetCollapsable::Read: Missing collapsed!"
<< endl;
@ -126,7 +126,7 @@ int InsetCollapsable::ascent(BufferView * bv, LyXFont const & font) const
int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
{
if (collapsed)
if (collapsed_)
return descent_collapsed(bv->painter(), font);
return descent_collapsed(bv->painter(), font)
@ -138,7 +138,7 @@ int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
{
if (collapsed)
if (collapsed_)
return widthCollapsed;
return (inset.width(bv, font) > widthCollapsed) ?
@ -169,7 +169,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
button_bottom_y = -ascent(bv, f) + ascent_collapsed(pain,f) +
descent_collapsed(pain, f);
if (collapsed) {
if (collapsed_) {
draw_collapsed(pain, f, baseline, x);
x += TEXT_TO_INSET_OFFSET;
return;
@ -229,8 +229,8 @@ void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
{
UpdatableInset::edit(bv, xp, yp, button);
if (collapsed) {
collapsed = false;
if (collapsed_) {
collapsed_ = false;
if (!bv->lockInset(this))
return;
bv->updateInset(this, false);
@ -245,7 +245,7 @@ void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
Inset::EDITABLE InsetCollapsable::editable() const
{
if (collapsed)
if (collapsed_)
return IS_EDITABLE;
return HIGHLY_EDITABLE;
}
@ -254,7 +254,7 @@ Inset::EDITABLE InsetCollapsable::editable() const
void InsetCollapsable::insetUnlock(BufferView * bv)
{
if (autocollapse) {
collapsed = true;
collapsed_ = true;
}
inset.insetUnlock(bv);
if (scroll())
@ -266,7 +266,7 @@ void InsetCollapsable::insetUnlock(BufferView * bv)
void InsetCollapsable::insetButtonPress(BufferView * bv, int x, int y,
int button)
{
if (!collapsed && (y > button_bottom_y)) {
if (!collapsed_ && (y > button_bottom_y)) {
inset.insetButtonPress(bv, x, y + (top_baseline - inset.y()),
button);
}
@ -278,16 +278,16 @@ void InsetCollapsable::insetButtonRelease(BufferView * bv,
{
if ((x >= 0) && (x < button_length) &&
(y >= button_top_y) && (y <= button_bottom_y)) {
if (collapsed) {
collapsed = false;
if (collapsed_) {
collapsed_ = false;
inset.insetButtonRelease(bv, 0, 0, button);
bv->updateInset(this, false);
} else {
collapsed = true;
collapsed_ = true;
bv->unlockInset(this);
bv->updateInset(this, false);
}
} else if (!collapsed && (y > button_top_y)) {
} else if (!collapsed_ && (y > button_top_y)) {
inset.insetButtonRelease(bv, x, y + (top_baseline-inset.y()),
button);
}
@ -523,3 +523,11 @@ Inset * InsetCollapsable::getInsetFromID(int id_arg) const
return const_cast<InsetCollapsable *>(this);
return inset.getInsetFromID(id_arg);
}
void InsetCollapsable::collapsed(BufferView * bv, bool flag)
{
if (flag == collapsed_)
return;
collapsed_ = flag;
bv->updateInset(this, false);
}

View File

@ -67,6 +67,9 @@ public:
bool insertInsetAllowed(Inset * in) const {
return inset.insertInsetAllowed(in);
}
bool insertInsetAllowed(Inset::Code code) const {
return inset.insertInsetAllowed(code);
}
///
bool isTextInset() const { return true; }
///
@ -74,7 +77,7 @@ public:
///
void insetUnlock(BufferView *);
///
bool needFullRow() const { return !collapsed; }
bool needFullRow() const { return !collapsed_; }
///
bool lockInsetInInset(BufferView *, UpdatableInset *);
///
@ -153,6 +156,10 @@ public:
Paragraph * firstParagraph() const;
///
LyXCursor const & cursor(BufferView *) const;
///
bool isCollapsable() const { return true; }
bool collapsed() const { return collapsed_; }
void collapsed(BufferView *, bool);
protected:
///
@ -167,7 +174,7 @@ protected:
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
///
bool collapsed;
bool collapsed_;
///
LColor::color framecolor;
///

View File

@ -74,7 +74,7 @@ Inset * InsetERT::clone(Buffer const &, bool same_id) const
InsetERT * result = new InsetERT;
result->inset.init(&inset, same_id);
result->collapsed = collapsed;
result->collapsed_ = collapsed_;
if (same_id)
result->id_ = id_;
return result;

View File

@ -176,7 +176,7 @@ Inset * InsetFloat::clone(Buffer const &, bool same_id) const
InsetFloat * result = new InsetFloat(floatType_);
result->inset.init(&inset, same_id);
result->collapsed = collapsed;
result->collapsed_ = collapsed_;
if (same_id)
result->id_ = id_;
return result;
@ -236,15 +236,18 @@ int InsetFloat::docBook(Buffer const * buf, ostream & os) const
bool InsetFloat::insertInsetAllowed(Inset * in) const
{
if (in->lyxCode() == Inset::FLOAT_CODE)
return insertInsetAllowed(in->lyxCode());
}
bool InsetFloat::insertInsetAllowed(Inset::Code code) const
{
if (code == Inset::FLOAT_CODE)
return false;
if (inset.getLockingInset() != this)
return inset.insertInsetAllowed(in);
if ((in->lyxCode() == Inset::FOOT_CODE) ||
(in->lyxCode() == Inset::MARGIN_CODE))
{
return inset.insertInsetAllowed(code);
if ((code == Inset::FOOT_CODE) || (code == Inset::MARGIN_CODE))
return false;
}
return true;
}

View File

@ -45,6 +45,7 @@ public:
string const editMessage() const;
///
bool insertInsetAllowed(Inset * inset) const;
bool insertInsetAllowed(Inset::Code) const;
///
void insetButtonRelease(BufferView * bv, int x, int y, int button);
///

View File

@ -37,7 +37,7 @@ Inset * InsetFoot::clone(Buffer const &, bool same_id) const
InsetFoot * result = new InsetFoot;
result->inset.init(&inset, same_id);
result->collapsed = collapsed;
result->collapsed_ = collapsed_;
if (same_id)
result->id_ = id_;
return result;
@ -60,13 +60,3 @@ int InsetFoot::latex(Buffer const * buf,
return i + 2;
}
bool InsetFoot::insertInsetAllowed(Inset * in) const
{
if ((in->lyxCode() == Inset::FOOT_CODE) ||
(in->lyxCode() == Inset::MARGIN_CODE)) {
return false;
}
return true;
}

View File

@ -35,8 +35,6 @@ public:
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
string const editMessage() const;
///
bool insertInsetAllowed(Inset * inset) const;
};
#endif

View File

@ -38,3 +38,16 @@ void InsetFootlike::write(Buffer const * buf, std::ostream & os) const
os << getInsetName() << "\n";
InsetCollapsable::write(buf, os);
}
bool InsetFootlike::insertInsetAllowed(Inset * in) const
{
return insertInsetAllowed(in->lyxCode());
}
bool InsetFootlike::insertInsetAllowed(Inset::Code code) const
{
if ((code == Inset::FOOT_CODE) || (code == Inset::MARGIN_CODE))
return false;
return InsetCollapsable::insertInsetAllowed(code);
}

View File

@ -31,6 +31,9 @@ public:
InsetFootlike();
///
void write(Buffer const * buf, std::ostream & os) const;
///
bool insertInsetAllowed(Inset * inset) const;
bool insertInsetAllowed(Inset::Code) const;
};
#endif

View File

@ -62,7 +62,7 @@ Inset * InsetList::clone(Buffer const &, bool same_id) const
InsetList * result = new InsetList;
result->inset.init(&inset, same_id);
result->collapsed = collapsed;
result->collapsed_ = collapsed_;
if (same_id)
result->id_ = id_;
return result;
@ -85,13 +85,3 @@ int InsetList::latex(Buffer const * buf,
return i + 2;
}
bool InsetList::insertInsetAllowed(Inset * in) const
{
if ((in->lyxCode() == Inset::FOOT_CODE) ||
(in->lyxCode() == Inset::MARGIN_CODE)) {
return false;
}
return true;
}

View File

@ -35,8 +35,6 @@ public:
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
string const editMessage() const;
///
bool insertInsetAllowed(Inset * inset) const;
};
#endif

View File

@ -37,7 +37,7 @@ Inset * InsetMarginal::clone(Buffer const &, bool same_id) const
InsetMarginal * result = new InsetMarginal;
result->inset.init(&inset, same_id);
result->collapsed = collapsed;
result->collapsed_ = collapsed_;
if (same_id)
result->id_ = id_;
return result;
@ -60,13 +60,3 @@ int InsetMarginal::latex(Buffer const * buf,
return i + 2;
}
bool InsetMarginal::insertInsetAllowed(Inset * in) const
{
if ((in->lyxCode() == Inset::FOOT_CODE) ||
(in->lyxCode() == Inset::MARGIN_CODE)) {
return false;
}
return true;
}

View File

@ -33,8 +33,6 @@ public:
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
string const editMessage() const;
///
bool insertInsetAllowed(Inset * inset) const;
};
#endif

View File

@ -179,7 +179,7 @@ Inset * InsetMinipage::clone(Buffer const &, bool same_id) const
InsetMinipage * result = new InsetMinipage;
result->inset.init(&inset, same_id);
result->collapsed = collapsed;
result->collapsed_ = collapsed_;
result->pos_ = pos_;
result->inner_pos_ = inner_pos_;
result->height_ = height_;
@ -192,7 +192,7 @@ Inset * InsetMinipage::clone(Buffer const &, bool same_id) const
int InsetMinipage::ascent(BufferView * bv, LyXFont const & font) const
{
if (collapsed)
if (collapsed_)
return ascent_collapsed(bv->painter(), font);
else {
// Take placement into account.
@ -216,7 +216,7 @@ int InsetMinipage::ascent(BufferView * bv, LyXFont const & font) const
int InsetMinipage::descent(BufferView * bv, LyXFont const & font) const
{
if (collapsed)
if (collapsed_)
return descent_collapsed(bv->painter(), font);
else {
// Take placement into account.
@ -271,11 +271,15 @@ int InsetMinipage::latex(Buffer const * buf,
bool InsetMinipage::insertInsetAllowed(Inset * in) const
{
if ((in->lyxCode() == Inset::FLOAT_CODE) ||
(in->lyxCode() == Inset::MARGIN_CODE)) {
return false;
return insertInsetAllowed(in->lyxCode());
}
return true;
bool InsetMinipage::insertInsetAllowed(Inset::Code code) const
{
if ((code == Inset::FLOAT_CODE) || (code == Inset::MARGIN_CODE))
return false;
return InsetCollapsable::insertInsetAllowed(code);
}

View File

@ -60,6 +60,7 @@ public:
string const editMessage() const;
///
bool insertInsetAllowed(Inset * inset) const;
bool insertInsetAllowed(Inset::Code) const;
///
Position pos() const;
///

View File

@ -1436,6 +1436,13 @@ bool InsetText::insertInsetAllowed(Inset * in) const
return true;
}
bool InsetText::insertInsetAllowed(Inset::Code code) const
{
if (the_locking_inset)
return the_locking_inset->insertInsetAllowed(code);
return true;
}
UpdatableInset * InsetText::getLockingInset() const
{

View File

@ -153,6 +153,7 @@ public:
bool insertInset(BufferView *, Inset *);
///
bool insertInsetAllowed(Inset *) const;
bool insertInsetAllowed(Inset::Code) const;
///
UpdatableInset * getLockingInset() const;
///

View File

@ -59,7 +59,7 @@ Inset * InsetTheorem::clone(Buffer const &, bool) const
#warning Is this inset used? If YES this is WRONG!!! (Jug)
InsetTheorem * result = new InsetTheorem;
result->collapsed = collapsed;
result->collapsed_ = collapsed_;
return result;
}
@ -80,15 +80,3 @@ int InsetTheorem::latex(Buffer const * buf,
return i + 2;
}
bool InsetTheorem::insertInsetAllowed(Inset * inset) const
{
lyxerr << "InsetTheorem::InsertInsetAllowed" << endl;
if ((inset->lyxCode() == Inset::FOOT_CODE) ||
(inset->lyxCode() == Inset::MARGIN_CODE)) {
return false;
}
return true;
}

View File

@ -37,8 +37,6 @@ public:
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
string const editMessage() const;
///
bool insertInsetAllowed(Inset * inset) const;
};
#endif