reformatting and remove using delc

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1886 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-04-04 20:34:04 +00:00
parent ff367a38b1
commit 74784ee97b
8 changed files with 165 additions and 136 deletions

View File

@ -1,3 +1,23 @@
2001-04-04 Lars Gullik Bjønnes <larsbj@birdstep.com>
* insetfootlike.C: remove using decl at file scope and add std::
where needed
* insetmarginal.C: ditto
* insetfoot.C: some reformatting
* insetfloat.C (InsetButtonRelease): adjust the hit area
* insetert.C (SetFont): some reformatting
* insetcollapsable.C: some reformatting and constification
(Clone): comment out.
* insetcollapsable.h: some reformatting
(Clone): comment out.
* inset.C: reindent
(scroll): simplify
2001-03-30 Juergen Vigna <jug@sad.it>
* insetcollapsable.h: changen *inset to be a InsetText inset.

View File

@ -24,7 +24,7 @@
using std::endl;
/* Insets default methods */
// Insets default methods
bool Inset::Deletable() const
{
@ -45,8 +45,7 @@ Inset::EDITABLE Inset::Editable() const
void Inset::Validate(LaTeXFeatures &) const
{
}
{}
bool Inset::AutoDelete() const
@ -56,8 +55,7 @@ bool Inset::AutoDelete() const
void Inset::Edit(BufferView *, int, int, unsigned int)
{
}
{}
LyXFont const Inset::ConvertFont(LyXFont const & font) const
@ -81,7 +79,7 @@ LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
}
/* some stuff for inset locking */
// some stuff for inset locking
void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
{
@ -124,27 +122,24 @@ Inset::EDITABLE UpdatableInset::Editable() const
void UpdatableInset::ToggleInsetCursor(BufferView *)
{
}
{}
void UpdatableInset::ShowInsetCursor(BufferView *, bool)
{
}
{}
void UpdatableInset::HideInsetCursor(BufferView *)
{
}
{}
void UpdatableInset::Edit(BufferView *, int, int, unsigned int)
{
}
{}
void UpdatableInset::draw(BufferView *, LyXFont const &,
int /* baseline */, float & x, bool/*cleared*/) const
int /* baseline */, float & x,
bool/*cleared*/) const
{
x += float(scx);
// ATTENTION: don't do the following here!!!
@ -154,8 +149,7 @@ void UpdatableInset::draw(BufferView *, LyXFont const &,
void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
{
}
{}
void UpdatableInset::scroll(BufferView * bv, float s) const
@ -166,21 +160,25 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
scx = 0;
return;
}
if (((top_x - scx) > 0) &&
(top_x - scx + width(bv, font)) < bv->workWidth())
int const workW = bv->workWidth();
int const tmp_top_x = top_x - scx;
if (tmp_top_x > 0 &&
(tmp_top_x + width(bv, font)) < workW)
return;
if ((s > 0) && (top_x > 0))
if (s > 0 && top_x > 0)
return;
// int mx_scx=abs((width(bv,font) - bv->workWidth())/2);
int save_scx = scx;
//int const save_scx = scx;
scx = int(s*bv->workWidth()/2);
scx = int(s * workW / 2);
// if (!display())
// scx += 20;
if ((top_x - save_scx + scx + width(bv, font)) < (bv->workWidth()/2)) {
scx += (bv->workWidth()/2) - (top_x - save_scx + scx + width(bv,font));
if ((tmp_top_x + scx + width(bv, font)) < (workW / 2)) {
scx += (workW / 2) - (tmp_top_x + scx + width(bv, font));
}
// bv->updateInset(const_cast<UpdatableInset *>(this), false);
}
@ -196,7 +194,7 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
else
scx += offset;
} else {
LyXFont font;
LyXFont const font;
if (!scx && (top_x + width(bv, font)) < (bv->workWidth() - 20))
return;
if ((top_x - scx + offset + width(bv, font)) < (bv->workWidth() - 20)) {
@ -208,6 +206,7 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
// bv->updateInset(const_cast<UpdatableInset *>(this), false);
}
/// An updatable inset could handle lyx editing commands
UpdatableInset::RESULT
UpdatableInset::LocalDispatch(BufferView * bv,
@ -215,10 +214,10 @@ UpdatableInset::LocalDispatch(BufferView * bv,
{
if (!arg.empty() && (action==LFUN_SCROLL_INSET)) {
if (arg.find('.') != arg.npos) {
float xx = static_cast<float>(strToDbl(arg));
float const xx = static_cast<float>(strToDbl(arg));
scroll(bv, xx);
} else {
int xx = strToInt(arg);
int const xx = strToInt(arg);
scroll(bv, xx);
}
bv->updateInset(this, false);
@ -232,6 +231,7 @@ UpdatableInset::LocalDispatch(BufferView * bv,
int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
{
if (owner())
return static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, this);
return static_cast<UpdatableInset*>
(owner())->getMaxWidth(bv, this);
return bv->workWidth();
}

View File

@ -31,6 +31,7 @@ using std::ostream;
using std::endl;
using std::max;
InsetCollapsable::InsetCollapsable()
: UpdatableInset()
{
@ -48,15 +49,17 @@ InsetCollapsable::InsetCollapsable()
}
#if 0
Inset * InsetCollapsable::Clone(Buffer const &) const
{
InsetCollapsable * result = new InsetCollapsable();
InsetCollapsable * result = new InsetCollapsable;
result->inset.init(&inset);
result->inset.setOwner(result);
result->collapsed = collapsed;
return result;
}
#endif
bool InsetCollapsable::InsertInset(BufferView * bv, Inset * in)
@ -139,8 +142,10 @@ 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;
}
@ -173,19 +178,21 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
button_top_y = -ascent(bv, f);
button_bottom_y = -ascent(bv, f) + ascent_collapsed(pain,f) +
descent_collapsed(pain, f);
if (collapsed) {
draw_collapsed(pain, f, baseline, x);
x += TEXT_TO_INSET_OFFSET;
return;
}
if (!cleared && ((inset.need_update == InsetText::FULL) ||
(inset.need_update == InsetText::INIT) ||
(top_x != int(x)) || (top_baseline != baseline))) {
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);
int tx = (needFullRow() && !owner()) ? 0 : int(x);
int ty = max(0, baseline - ascent(bv, f));
int const tx = (needFullRow() && !owner()) ? 0 : int(x);
int const ty = max(0, baseline - ascent(bv, f));
if ((ty + h) > pain.paperHeight())
h = pain.paperHeight();
@ -201,7 +208,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
top_baseline = baseline;
float dummy = x;
int bl = baseline - ascent(bv, f) + ascent_collapsed(pain, f);
int const bl = baseline - ascent(bv, f) + ascent_collapsed(pain, f);
draw_collapsed(pain, f, bl, dummy);
inset.draw(bv, f,
@ -211,7 +218,8 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
}
void InsetCollapsable::Edit(BufferView * bv, int xp, int yp, unsigned int button)
void InsetCollapsable::Edit(BufferView * bv, int xp, int yp,
unsigned int button)
{
UpdatableInset::Edit(bv, xp, yp, button);
@ -247,10 +255,12 @@ void InsetCollapsable::InsetUnlock(BufferView * bv)
}
void InsetCollapsable::InsetButtonPress(BufferView * bv,int x,int y,int button)
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);
}
}
@ -270,7 +280,8 @@ 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);
}
}
@ -279,7 +290,8 @@ 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);
}
}

View File

@ -45,7 +45,7 @@ public:
///
InsetCollapsable();
///
Inset * Clone(Buffer const &) const;
//Inset * Clone(Buffer const &) const;
///
void Read(Buffer const *, LyXLex &);
///
@ -77,7 +77,8 @@ public:
///
bool LockInsetInInset(BufferView *, UpdatableInset *);
///
bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
bool UnlockInsetInInset(BufferView *, UpdatableInset *,
bool lr = false);
///
bool UpdateInsetInInset(BufferView *, Inset *);
///

View File

@ -205,7 +205,7 @@ bool InsetFloat::InsertInsetAllowed(Inset * in) const
void InsetFloat::InsetButtonRelease(BufferView * bv, int x, int y, int button)
{
if (x >= 0
if (x >= top_x
&& x < button_length
&& y >= button_top_y
&& y < button_bottom_y
@ -213,6 +213,7 @@ void InsetFloat::InsetButtonRelease(BufferView * bv, int x, int y, int button)
// This obviously need to change.
lyxerr << "InsetFloat: Let's edit this floats parameters!"
<< endl;
//bv->owner()->getDialogs()->showFloat(this);
} else {
InsetCollapsable::InsetButtonRelease(bv, x, y, button);
}

View File

@ -20,8 +20,6 @@
#include "lyxtext.h"
#include "support/LOstream.h"
using std::ostream;
using std::endl;
InsetFootlike::InsetFootlike()
: InsetCollapsable()
@ -35,7 +33,7 @@ InsetFootlike::InsetFootlike()
}
void InsetFootlike::Write(Buffer const * buf, ostream & os) const
void InsetFootlike::Write(Buffer const * buf, std::ostream & os) const
{
os << getInsetName() << "\n";
InsetCollapsable::Write(buf, os);

View File

@ -23,9 +23,6 @@
#include "support/LOstream.h"
#include "debug.h"
using std::ostream;
using std::endl;
InsetMarginal::InsetMarginal()
: InsetFootlike()
@ -52,11 +49,11 @@ string const InsetMarginal::EditMessage() const
int InsetMarginal::Latex(Buffer const * buf,
ostream & os, bool fragile, bool fp) const
std::ostream & os, bool fragile, bool fp) const
{
os << "\\marginpar{%\n";
int i = inset.Latex(buf, os, fragile, fp);
int const i = inset.Latex(buf, os, fragile, fp);
os << "}%\n";
return i + 2;