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,214 +24,214 @@
using std::endl;
/* Insets default methods */
// Insets default methods
bool Inset::Deletable() const
{
return true;
return true;
}
bool Inset::DirectWrite() const
{
return false;
return false;
}
Inset::EDITABLE Inset::Editable() const
{
return NOT_EDITABLE;
return NOT_EDITABLE;
}
void Inset::Validate(LaTeXFeatures &) const
{
}
{}
bool Inset::AutoDelete() const
{
return false;
return false;
}
void Inset::Edit(BufferView *, int, int, unsigned int)
{
}
{}
LyXFont const Inset::ConvertFont(LyXFont const & font) const
{
return LyXFont(font);
return LyXFont(font);
}
string const Inset::EditMessage() const
{
return _("Opened inset");
return _("Opened inset");
}
LyXText * Inset::getLyXText(BufferView const * bv, bool const) const
{
if (owner())
return owner()->getLyXText(bv, false);
else
return bv->text;
if (owner())
return owner()->getLyXText(bv, false);
else
return bv->text;
}
/* some stuff for inset locking */
// some stuff for inset locking
void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
{
lyxerr.debug() << "Inset Button Press x=" << x
<< ", y=" << y << ", button=" << button << endl;
lyxerr.debug() << "Inset Button Press x=" << x
<< ", y=" << y << ", button=" << button << endl;
}
void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
{
lyxerr.debug() << "Inset Button Release x=" << x
<< ", y=" << y << ", button=" << button << endl;
lyxerr.debug() << "Inset Button Release x=" << x
<< ", y=" << y << ", button=" << button << endl;
}
void UpdatableInset::InsetKeyPress(XKeyEvent *)
{
lyxerr.debug() << "Inset Keypress" << endl;
lyxerr.debug() << "Inset Keypress" << endl;
}
void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
{
lyxerr.debug() << "Inset Motion Notify x=" << x
<< ", y=" << y << ", state=" << state << endl;
lyxerr.debug() << "Inset Motion Notify x=" << x
<< ", y=" << y << ", state=" << state << endl;
}
void UpdatableInset::InsetUnlock(BufferView *)
{
lyxerr.debug() << "Inset Unlock" << endl;
lyxerr.debug() << "Inset Unlock" << endl;
}
// An updatable inset is highly editable by definition
Inset::EDITABLE UpdatableInset::Editable() const
{
return HIGHLY_EDITABLE;
return HIGHLY_EDITABLE;
}
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!!!
// top_x = int(x);
// top_baseline = baseline;
x += float(scx);
// ATTENTION: don't do the following here!!!
// top_x = int(x);
// top_baseline = baseline;
}
void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
{
}
{}
void UpdatableInset::scroll(BufferView * bv, float s) const
{
LyXFont font;
LyXFont font;
if (!s) {
scx = 0;
return;
}
if (((top_x - scx) > 0) &&
(top_x - scx + width(bv, font)) < bv->workWidth())
return;
if ((s > 0) && (top_x > 0))
return;
if (!s) {
scx = 0;
return;
}
// int mx_scx=abs((width(bv,font) - bv->workWidth())/2);
int save_scx = scx;
int const workW = bv->workWidth();
int const tmp_top_x = top_x - scx;
scx = int(s*bv->workWidth()/2);
// if (!display())
// scx += 20;
if (tmp_top_x > 0 &&
(tmp_top_x + width(bv, font)) < workW)
return;
if (s > 0 && top_x > 0)
return;
if ((top_x - save_scx + scx + width(bv, font)) < (bv->workWidth()/2)) {
scx += (bv->workWidth()/2) - (top_x - save_scx + scx + width(bv,font));
}
// bv->updateInset(const_cast<UpdatableInset *>(this), false);
// int mx_scx=abs((width(bv,font) - bv->workWidth())/2);
//int const save_scx = scx;
scx = int(s * workW / 2);
// if (!display())
// scx += 20;
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);
}
void UpdatableInset::scroll(BufferView * bv, int offset) const
{
if (offset > 0) {
if (!scx && top_x >= 20)
return;
if ((top_x + offset) > 20)
scx = 0;
// scx += offset - (top_x - scx + offset - 20);
else
scx += offset;
} else {
LyXFont font;
if (!scx && (top_x+width(bv, font)) < (bv->workWidth()-20))
return;
if ((top_x - scx + offset + width(bv,font)) < (bv->workWidth()-20)) {
scx = bv->workWidth() - width(bv,font) - top_x + scx - 20;
if (offset > 0) {
if (!scx && top_x >= 20)
return;
if ((top_x + offset) > 20)
scx = 0;
// scx += offset - (top_x - scx + offset - 20);
else
scx += offset;
} else {
scx += offset;
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)) {
scx = bv->workWidth() - width(bv, font) - top_x + scx - 20;
} else {
scx += offset;
}
}
}
// bv->updateInset(const_cast<UpdatableInset *>(this), false);
// bv->updateInset(const_cast<UpdatableInset *>(this), false);
}
/// An updatable inset could handle lyx editing commands
UpdatableInset::RESULT
UpdatableInset::LocalDispatch(BufferView * bv,
kb_action action, string const & arg)
{
if (!arg.empty() && (action==LFUN_SCROLL_INSET)) {
if (arg.find('.') != arg.npos) {
float xx = static_cast<float>(strToDbl(arg));
scroll(bv, xx);
} else {
int xx = strToInt(arg);
scroll(bv, xx);
}
bv->updateInset(this, false);
if (!arg.empty() && (action==LFUN_SCROLL_INSET)) {
if (arg.find('.') != arg.npos) {
float const xx = static_cast<float>(strToDbl(arg));
scroll(bv, xx);
} else {
int const xx = strToInt(arg);
scroll(bv, xx);
}
bv->updateInset(this, false);
return DISPATCHED;
}
return UNDISPATCHED;
return DISPATCHED;
}
return UNDISPATCHED;
}
int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
{
if (owner())
return static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, this);
return bv->workWidth();
if (owner())
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)
@ -88,7 +91,7 @@ void InsetCollapsable::Read(Buffer const * buf, LyXLex & lex)
collapsed = lex.GetBool();
} else {
lyxerr << "InsetCollapsable::Read: Missing collapsed!"
<< endl;
<< endl;
}
}
inset.Read(buf, lex);
@ -101,7 +104,7 @@ int InsetCollapsable::ascent_collapsed(Painter & pain, LyXFont const &) const
int ascent = 0;
int descent = 0;
pain.buttonText(0, 0, label, labelfont, false,
width, ascent, descent);
width, ascent, descent);
return ascent;
}
@ -112,7 +115,7 @@ int InsetCollapsable::descent_collapsed(Painter & pain, LyXFont const &) const
int ascent = 0;
int descent = 0;
pain.buttonText(0, 0, label, labelfont, false,
width, ascent, descent);
width, ascent, descent);
return descent;
}
@ -123,7 +126,7 @@ int InsetCollapsable::width_collapsed(Painter & pain, LyXFont const &) const
int ascent;
int descent;
pain.buttonText(TEXT_TO_INSET_OFFSET, 0, label, labelfont, false,
width, ascent, descent);
width, ascent, descent);
return width + (2*TEXT_TO_INSET_OFFSET);
}
@ -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;
}
@ -155,37 +160,39 @@ int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const &,
int baseline, float & x) const
int baseline, float & x) const
{
int width = 0;
pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET,
baseline, label, labelfont, true, width);
baseline, label, labelfont, true, width);
x += width + TEXT_TO_INSET_OFFSET;
}
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool cleared) const
int baseline, float & x, bool cleared) const
{
Painter & pain = bv->painter();
button_length = widthCollapsed;
button_top_y = -ascent(bv, f);
button_bottom_y = -ascent(bv, f) + ascent_collapsed(pain,f) +
descent_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,17 +208,18 @@ 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,
bl + descent_collapsed(pain, f) + inset.ascent(bv, f),
x, cleared);
bl + descent_collapsed(pain, f) + inset.ascent(bv, f),
x, cleared);
need_update = NONE;
}
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);
}
}
@ -259,7 +269,7 @@ void InsetCollapsable::InsetButtonRelease(BufferView * bv,
int x, int y, int button)
{
if ((x >= 0) && (x < button_length) &&
(y >= button_top_y) && (y <= button_bottom_y)) {
(y >= button_top_y) && (y <= button_bottom_y)) {
if (collapsed) {
collapsed = false;
inset.InsetButtonRelease(bv, 0, 0, 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);
}
}
@ -291,7 +303,7 @@ void InsetCollapsable::InsetKeyPress(XKeyEvent * xke)
int InsetCollapsable::Latex(Buffer const * buf, ostream & os,
bool fragile, bool free_spc) const
bool fragile, bool free_spc) const
{
return inset.Latex(buf, os, fragile, free_spc);
}
@ -313,7 +325,7 @@ int InsetCollapsable::getMaxWidth(BufferView * bv,
void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
bool reinit)
bool reinit)
{
if (reinit) {
need_update = FULL;
@ -423,7 +435,7 @@ UpdatableInset * InsetCollapsable::GetFirstLockingInsetOfType(Inset::Code c)
void InsetCollapsable::SetFont(BufferView * bv,
LyXFont const & font, bool toggleall)
LyXFont const & font, bool toggleall)
{
inset.SetFont(bv, font, toggleall);
}
@ -436,7 +448,7 @@ bool InsetCollapsable::doClearArea() const
LyXText * InsetCollapsable::getLyXText(BufferView const * bv,
bool const recursive) const
bool const recursive) const
{
return inset.getLyXText(bv, recursive);
}

View File

@ -35,8 +35,8 @@ class InsetCollapsable : public UpdatableInset {
public:
///
enum UpdateCodes {
NONE = 0,
FULL
NONE = 0,
FULL
};
///
static int const TEXT_TO_TOP_OFFSET = 2;
@ -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 *);
///
@ -92,7 +93,7 @@ public:
void InsetKeyPress(XKeyEvent *);
///
UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
string const &);
string const &);
///
int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;

View File

@ -63,8 +63,8 @@ string const InsetERT::EditMessage() const
void InsetERT::SetFont(BufferView *, LyXFont const &, bool)
{
WriteAlert(_("Impossible Operation!"),
_("Not permitted to change font-types inside ERT-insets!"),
_("Sorry."));
_("Not permitted to change font-types inside ERT-insets!"),
_("Sorry."));
}

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;