Changed InsetText * in InsetCollapsable to be a InsetText.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1861 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2001-03-30 14:28:17 +00:00
parent 79a7f6b162
commit 77639efa94
12 changed files with 78 additions and 71 deletions

View File

@ -18,9 +18,13 @@ src/frontends/controllers/character.C
src/frontends/controllers/ControlCharacter.C
src/frontends/controllers/ControlCopyright.C
src/frontends/controllers/ControlCredits.C
src/frontends/controllers/ControlExternal.C
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlInclude.C
src/frontends/controllers/ControlPreamble.C
src/frontends/controllers/ControlPrint.C
src/frontends/controllers/ControlSearch.C
src/frontends/controllers/helper_funcs.C
src/frontends/gnome/FormCitation.C
src/frontends/gnome/FormCopyright.C
src/frontends/gnome/FormError.C

View File

@ -1157,7 +1157,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
lyxerr << "WP:" << mini->width() << endl;
mini->width(tostr(par->params.pextraWidthp())+"%");
}
mini->inset->par = par;
mini->inset.par = par;
// Insert the minipage last in the
// previous paragraph.
if (par->params.pextraHfill()) {
@ -1227,7 +1227,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
lyxerr << "WP:" << mini->width() << endl;
mini->width(tostr(par->params.pextraWidthp())+"%");
}
mini->inset->par = minipar;
mini->inset.par = minipar;
// Insert the minipage last in the
// previous paragraph.
@ -3712,7 +3712,7 @@ Buffer::Lists const Buffer::getLists() const
// Now find the caption in the float...
// We now tranverse the paragraphs of
// the inset...
LyXParagraph * tmp = il->inset->par;
LyXParagraph * tmp = il->inset.par;
while (tmp) {
if (tmp->layout == cap) {
SingleList & item = l[type];

View File

@ -1,3 +1,9 @@
2001-03-30 Juergen Vigna <jug@sad.it>
* insetcollapsable.h: changen *inset to be a InsetText inset.
* some files: changed to reflect the above change.
2001-03-29 Angus Leeming <a.leeming@ic.ac.uk>
* insetexternal.[Ch]: renamed InsetExternal::InsetExternalParams as

View File

@ -32,16 +32,15 @@ using std::endl;
using std::max;
InsetCollapsable::InsetCollapsable()
: UpdatableInset(), inset(new InsetText)
: UpdatableInset()
{
//inset = new InsetText;
inset->setOwner(this);
inset.setOwner(this);
collapsed = false;
label = "Label";
autocollapse = true;
inset->SetAutoBreakRows(true);
inset->SetDrawFrame(0, InsetText::ALWAYS);
inset->SetFrameColor(0, LColor::footnoteframe);
inset.SetAutoBreakRows(true);
inset.SetDrawFrame(0, InsetText::ALWAYS);
inset.SetFrameColor(0, LColor::footnoteframe);
button_length = button_top_y = button_bottom_y = 0;
setInsetName("Collapsable");
widthCollapsed = oldWidth = 0;
@ -52,8 +51,8 @@ InsetCollapsable::InsetCollapsable()
Inset * InsetCollapsable::Clone(Buffer const &) const
{
InsetCollapsable * result = new InsetCollapsable();
result->inset->init(inset);
result->inset->setOwner(result);
result->inset.init(&inset);
result->inset.setOwner(result);
result->collapsed = collapsed;
return result;
@ -68,14 +67,14 @@ bool InsetCollapsable::InsertInset(BufferView * bv, Inset * in)
return false;
}
return inset->InsertInset(bv, in);
return inset.InsertInset(bv, in);
}
void InsetCollapsable::Write(Buffer const * buf, ostream & os) const
{
os << "collapsed " << tostr(collapsed) << "\n";
inset->WriteParagraphData(buf, os);
inset.WriteParagraphData(buf, os);
}
@ -93,7 +92,7 @@ void InsetCollapsable::Read(Buffer const * buf, LyXLex & lex)
<< endl;
}
}
inset->Read(buf, lex);
inset.Read(buf, lex);
}
@ -141,8 +140,8 @@ int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
if (collapsed)
return descent_collapsed(bv->painter(), font);
return descent_collapsed(bv->painter(), font) + inset->descent(bv, font) +
inset->ascent(bv, font) + TEXT_TO_BOTTOM_OFFSET;
return descent_collapsed(bv->painter(), font) + inset.descent(bv, font) +
inset.ascent(bv, font) + TEXT_TO_BOTTOM_OFFSET;
}
@ -151,8 +150,8 @@ int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
if (collapsed)
return widthCollapsed;
return (inset->width(bv, font) > widthCollapsed) ?
inset->width(bv, font) : widthCollapsed;
return (inset.width(bv, font) > widthCollapsed) ?
inset.width(bv, font) : widthCollapsed;
}
@ -181,8 +180,8 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
return;
}
if (!cleared && ((inset->need_update == InsetText::FULL) ||
(inset->need_update == InsetText::INIT) ||
if (!cleared && ((inset.need_update == InsetText::FULL) ||
(inset.need_update == InsetText::INIT) ||
(top_x != int(x)) || (top_baseline != baseline))) {
int w = owner() ? width(bv, f) : pain.paperWidth();
int h = ascent(bv, f) + descent(bv, f);
@ -206,8 +205,8 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
int bl = baseline - ascent(bv, f) + ascent_collapsed(pain, f);
draw_collapsed(pain, f, bl, dummy);
inset->draw(bv, f,
bl + descent_collapsed(pain, f) + inset->ascent(bv, f),
inset.draw(bv, f,
bl + descent_collapsed(pain, f) + inset.ascent(bv, f),
x, cleared);
need_update = NONE;
}
@ -222,11 +221,11 @@ void InsetCollapsable::Edit(BufferView * bv, int xp, int yp, unsigned int button
if (!bv->lockInset(this))
return;
bv->updateInset(this, false);
inset->Edit(bv, 0, 0, button);
inset.Edit(bv, 0, 0, button);
} else if (!collapsed) {
if (!bv->lockInset(this))
return;
inset->Edit(bv, xp, yp+(top_baseline - inset->y()), button);
inset.Edit(bv, xp, yp+(top_baseline - inset.y()), button);
}
}
@ -244,7 +243,7 @@ void InsetCollapsable::InsetUnlock(BufferView * bv)
if (autocollapse) {
collapsed = true;
}
inset->InsetUnlock(bv);
inset.InsetUnlock(bv);
bv->updateInset(this, false);
}
@ -252,7 +251,7 @@ void InsetCollapsable::InsetUnlock(BufferView * bv)
void InsetCollapsable::InsetButtonPress(BufferView * bv,int x,int y,int button)
{
if (!collapsed && (y > button_bottom_y)) {
inset->InsetButtonPress(bv, x, y+(top_baseline - inset->y()), button);
inset.InsetButtonPress(bv, x, y+(top_baseline - inset.y()), button);
}
}
@ -264,7 +263,7 @@ void InsetCollapsable::InsetButtonRelease(BufferView * bv,
(y >= button_top_y) && (y <= button_bottom_y)) {
if (collapsed) {
collapsed = false;
inset->InsetButtonRelease(bv, 0, 0, button);
inset.InsetButtonRelease(bv, 0, 0, button);
bv->updateInset(this, false);
} else {
collapsed = true;
@ -272,7 +271,7 @@ void InsetCollapsable::InsetButtonRelease(BufferView * bv,
bv->updateInset(this, false);
}
} else if (!collapsed && (y > button_top_y)) {
inset->InsetButtonRelease(bv, x, y+(top_baseline-inset->y()), button);
inset.InsetButtonRelease(bv, x, y+(top_baseline-inset.y()), button);
}
}
@ -281,21 +280,21 @@ void InsetCollapsable::InsetMotionNotify(BufferView * bv,
int x, int y, int state)
{
if (x > button_bottom_y) {
inset->InsetMotionNotify(bv, x, y+(top_baseline - inset->y()), state);
inset.InsetMotionNotify(bv, x, y+(top_baseline - inset.y()), state);
}
}
void InsetCollapsable::InsetKeyPress(XKeyEvent * xke)
{
inset->InsetKeyPress(xke);
inset.InsetKeyPress(xke);
}
int InsetCollapsable::Latex(Buffer const * buf, ostream & os,
bool fragile, bool free_spc) const
{
return inset->Latex(buf, os, fragile, free_spc);
return inset.Latex(buf, os, fragile, free_spc);
}
@ -325,7 +324,7 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
}
if (!widthCollapsed) {
widthCollapsed = width_collapsed(bv->painter(), font);
inset->resizeLyXText(bv);
inset.resizeLyXText(bv);
need_update = FULL;
if (owner()) {
owner()->update(bv, font);
@ -334,14 +333,14 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
}
if (oldWidth != width(bv, font)) {
oldWidth = width(bv, font);
inset->resizeLyXText(bv);
inset.resizeLyXText(bv);
need_update = FULL;
if (owner()) {
owner()->update(bv, font);
return;
}
}
inset->update(bv, font);
inset.update(bv, font);
}
@ -349,7 +348,7 @@ UpdatableInset::RESULT
InsetCollapsable::LocalDispatch(BufferView * bv, kb_action action,
string const & arg)
{
UpdatableInset::RESULT result = inset->LocalDispatch(bv, action, arg);
UpdatableInset::RESULT result = inset.LocalDispatch(bv, action, arg);
if (result == FINISHED)
bv->unlockInset(this);
return result;
@ -358,59 +357,59 @@ InsetCollapsable::LocalDispatch(BufferView * bv, kb_action action,
bool InsetCollapsable::LockInsetInInset(BufferView * bv, UpdatableInset * in)
{
if (inset == in)
if (&inset == in)
return true;
return inset->LockInsetInInset(bv, in);
return inset.LockInsetInInset(bv, in);
}
bool InsetCollapsable::UnlockInsetInInset(BufferView * bv, UpdatableInset * in,
bool lr)
{
if (inset == in) {
if (&inset == in) {
bv->unlockInset(this);
return true;
}
return inset->UnlockInsetInInset(bv, in, lr);
return inset.UnlockInsetInInset(bv, in, lr);
}
bool InsetCollapsable::UpdateInsetInInset(BufferView * bv, Inset *in)
{
if (in == inset)
if (&inset == in)
return true;
return inset->UpdateInsetInInset(bv, in);
return inset.UpdateInsetInInset(bv, in);
}
unsigned int InsetCollapsable::InsetInInsetY()
{
return inset->InsetInInsetY() - (top_baseline - inset->y());
return inset.InsetInInsetY() - (top_baseline - inset.y());
}
void InsetCollapsable::Validate(LaTeXFeatures & features) const
{
inset->Validate(features);
inset.Validate(features);
}
void InsetCollapsable::GetCursorPos(BufferView * bv, int & x, int & y) const
{
inset->GetCursorPos(bv, x , y);
inset.GetCursorPos(bv, x , y);
}
void InsetCollapsable::ToggleInsetCursor(BufferView * bv)
{
inset->ToggleInsetCursor(bv);
inset.ToggleInsetCursor(bv);
}
UpdatableInset * InsetCollapsable::GetLockingInset()
{
UpdatableInset * in = inset->GetLockingInset();
if (inset == in)
UpdatableInset * in = inset.GetLockingInset();
if (&inset == in)
return this;
return in;
}
@ -420,39 +419,39 @@ UpdatableInset * InsetCollapsable::GetFirstLockingInsetOfType(Inset::Code c)
{
if (c == LyxCode())
return this;
return inset->GetFirstLockingInsetOfType(c);
return inset.GetFirstLockingInsetOfType(c);
}
void InsetCollapsable::SetFont(BufferView * bv,
LyXFont const & font, bool toggleall)
{
inset->SetFont(bv, font, toggleall);
inset.SetFont(bv, font, toggleall);
}
bool InsetCollapsable::doClearArea() const
{
return inset->doClearArea();
return inset.doClearArea();
}
LyXText * InsetCollapsable::getLyXText(BufferView const * bv,
bool const recursive) const
{
return inset->getLyXText(bv, recursive);
return inset.getLyXText(bv, recursive);
}
void InsetCollapsable::deleteLyXText(BufferView * bv, bool recursive) const
{
inset->deleteLyXText(bv, recursive);
inset.deleteLyXText(bv, recursive);
}
void InsetCollapsable::resizeLyXText(BufferView * bv) const
{
inset->resizeLyXText(bv);
inset.resizeLyXText(bv);
LyXFont font(LyXFont::ALL_SANE);
oldWidth = width(bv, font);
}

View File

@ -18,6 +18,7 @@
#endif
#include "lyxinset.h"
#include "insettext.h"
#include "lyxfont.h"
#include "LColor.h"
#if 1 // NEW_INSETS
@ -25,7 +26,6 @@
#endif
class Painter;
class InsetText;
class LyXText;
/** A colapsable text inset
@ -151,9 +151,7 @@ protected:
public:
#endif
///
InsetText * inset;
// Instead of making these ints protected we could have a
// protected method "clickInButton" (Lgb)
InsetText inset;
protected:
///
mutable int button_length;

View File

@ -47,7 +47,7 @@ void InsetERT::Write(Buffer const * buf, ostream & os) const
Inset * InsetERT::Clone(Buffer const &) const
{
InsetERT * result = new InsetERT;
result->inset->init(inset);
result->inset.init(&inset);
result->collapsed = collapsed;
return result;

View File

@ -154,7 +154,7 @@ void InsetFloat::Validate(LaTeXFeatures & features) const
Inset * InsetFloat::Clone(Buffer const &) const
{
InsetFloat * result = new InsetFloat(floatType_);
result->inset->init(inset);
result->inset.init(&inset);
result->collapsed = collapsed;
return result;
@ -176,7 +176,7 @@ int InsetFloat::Latex(Buffer const * buf,
os << "[" << floatPlacement_ << "]";
os << "%\n";
int const i = inset->Latex(buf, os, fragile, fp);
int const i = inset.Latex(buf, os, fragile, fp);
os << "\\end{" << floatType_ << "}%\n";
return i + 2;
@ -186,7 +186,7 @@ int InsetFloat::Latex(Buffer const * buf,
int InsetFloat::DocBook(Buffer const * buf, ostream & os) const
{
os << "<" << floatType_ << ">";
int const i = inset->DocBook(buf, os);
int const i = inset.DocBook(buf, os);
os << "</" << floatType_ << ">";
return i;

View File

@ -37,7 +37,7 @@ InsetFoot::InsetFoot()
Inset * InsetFoot::Clone(Buffer const &) const
{
InsetFoot * result = new InsetFoot;
result->inset->init(inset);
result->inset.init(&inset);
result->collapsed = collapsed;
return result;
@ -55,7 +55,7 @@ int InsetFoot::Latex(Buffer const * buf,
{
os << "\\footnote{%\n";
int const i = inset->Latex(buf, os, fragile, fp);
int const i = inset.Latex(buf, os, fragile, fp);
os << "}%\n";
return i + 2;

View File

@ -60,7 +60,7 @@ void InsetList::Write(Buffer const * buf, ostream & os) const
Inset * InsetList::Clone(Buffer const &) const
{
InsetList * result = new InsetList;
result->inset->init(inset);
result->inset.init(&inset);
result->collapsed = collapsed;
return result;
@ -78,7 +78,7 @@ int InsetList::Latex(Buffer const * buf,
{
os << "\\footnote{%\n";
int i = inset->Latex(buf, os, fragile, fp);
int i = inset.Latex(buf, os, fragile, fp);
os << "}%\n";
return i + 2;

View File

@ -38,7 +38,7 @@ InsetMarginal::InsetMarginal()
Inset * InsetMarginal::Clone(Buffer const &) const
{
InsetMarginal * result = new InsetMarginal;
result->inset->init(inset);
result->inset.init(&inset);
result->collapsed = collapsed;
return result;
@ -56,7 +56,7 @@ int InsetMarginal::Latex(Buffer const * buf,
{
os << "\\marginpar{%\n";
int i = inset->Latex(buf, os, fragile, fp);
int i = inset.Latex(buf, os, fragile, fp);
os << "}%\n";
return i + 2;

View File

@ -176,7 +176,7 @@ void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
Inset * InsetMinipage::Clone(Buffer const &) const
{
InsetMinipage * result = new InsetMinipage;
result->inset->init(inset);
result->inset.init(&inset);
result->collapsed = collapsed;
result->pos_ = pos_;
@ -259,7 +259,7 @@ int InsetMinipage::Latex(Buffer const * buf,
os << "\\begin{minipage}[" << s_pos << "]{"
<< LyXLength(width_).asLatexString() << "}%\n";
int i = inset->Latex(buf, os, fragile, fp);
int i = inset.Latex(buf, os, fragile, fp);
os << "\\end{minipage}%\n";
return i + 2;
@ -326,7 +326,7 @@ void InsetMinipage::width(string const & ll)
bool InsetMinipage::ShowInsetDialog(BufferView * bv) const
{
if (!inset->ShowInsetDialog(bv))
if (!inset.ShowInsetDialog(bv))
bv->owner()->getDialogs()->showMinipage(const_cast<InsetMinipage *>(this));
return true;
}

View File

@ -74,7 +74,7 @@ int InsetTheorem::Latex(Buffer const * buf,
{
os << "\\begin{theorem}%\n";
int i = inset->Latex(buf, os, fragile, fp);
int i = inset.Latex(buf, os, fragile, fp);
os << "\\end{theorem}%\n";
return i + 2;