remove unneeded Inset::getMaxWidth(

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7319 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-07-18 15:30:20 +00:00
parent 82b445649a
commit 4127ff8a32
13 changed files with 9 additions and 156 deletions

View File

@ -1,4 +1,13 @@
2003-07-18 André Pönitz <poenitz@gmx.net>
* insetert.[Ch]:
* insetminipage.[Ch]:
* insettabular.[Ch]:
* insettext.[Ch]:
* insetwrap.[Ch]:
* updatableinset.[Ch]: remove unneeded Inset::getMaxWidth()
2003-07-18 André Pönitz <poenitz@gmx.net>
* inset.[Ch]:

View File

@ -647,22 +647,6 @@ void InsetERT::getDrawFont(LyXFont & font) const
}
int InsetERT::getMaxWidth(BufferView * bv, UpdatableInset const * in) const
{
int w = InsetCollapsable::getMaxWidth(bv, in);
if (status_ != Inlined || w < 0)
return w;
LyXText * text = inset.getLyXText(bv);
int rw = text->rows().begin()->width();
if (!rw)
rw = w;
rw += 40;
if (text->rows().size() == 1 && rw < w)
return -1;
return w;
}
string const InsetERTMailer::name_("ert");
InsetERTMailer::InsetERTMailer(InsetERT & inset)

View File

@ -112,8 +112,6 @@ public:
bool forceDefaultParagraphs(Inset const *) const {
return true;
}
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
private:
///

View File

@ -296,26 +296,6 @@ bool InsetMinipage::showInsetDialog(BufferView * bv) const
}
int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
const
{
if (owner() &&
static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, inset) < 0) {
return -1;
}
if (!params_.width.zero()) {
int ww1 = latexTextWidth(bv);
int ww2 = InsetCollapsable::getMaxWidth(bv, inset);
if (ww2 > 0 && ww2 < ww1) {
return ww2;
}
return ww1;
}
// this should not happen!
return InsetCollapsable::getMaxWidth(bv, inset);
}
int InsetMinipage::latexTextWidth(BufferView * bv) const
{
return params_.width.inPixels(InsetCollapsable::latexTextWidth(bv));

View File

@ -79,8 +79,6 @@ public:
///
bool insetAllowed(Inset::Code) const;
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
///
bool needFullRow() const { return false; }
/** returns true if, when outputing LaTeX, font changes should
be closed before generating this inset. This is needed for

View File

@ -2073,39 +2073,6 @@ bool InsetTabular::insetHit(BufferView *, int x, int) const
}
// This returns paperWidth() if the cell-width is unlimited or the width
// in pixels if we have a pwidth for this cell.
int InsetTabular::getMaxWidthOfCell(BufferView * bv, int cell) const
{
LyXLength const len = tabular.getPWidth(cell);
if (len.zero())
return -1;
return len.inPixels(latexTextWidth(bv));
}
int InsetTabular::getMaxWidth(BufferView * bv,
UpdatableInset const * inset) const
{
int cell = tabular.getCellFromInset(inset, actcell);
if (cell == -1) {
lyxerr << "Own inset not found, shouldn't really happen!"
<< endl;
return -1;
}
int w = getMaxWidthOfCell(bv, cell);
if (w > 0) {
// because the inset then subtracts it's top_x and owner->x()
w += (inset->x() - top_x);
}
return w;
}
void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const
{
resizeLyXText(bv, recursive);

View File

@ -146,8 +146,6 @@ public:
void setFont(BufferView *, LyXFont const &, bool toggleall = false,
bool selectall = false);
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
///
LyXText * getLyXText(BufferView const *,
bool const recursive = false) const;
///
@ -289,8 +287,6 @@ private:
///
bool insetHit(BufferView * bv, int x, int y) const;
///
int getMaxWidthOfCell(BufferView * bv, int cell) const;
///
bool hasPasteBuffer() const;
///
bool copySelection(BufferView *);

View File

@ -1758,25 +1758,6 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
}
int InsetText::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const
{
#if 0
int w = UpdatableInset::getMaxWidth(bv, inset);
if (w < 0) {
return -1;
}
if (owner()) {
w = w - top_x + owner()->x();
return w;
}
w -= (2 * TEXT_TO_INSET_OFFSET);
return w - top_x;
#else
return UpdatableInset::getMaxWidth(bv, inset);
#endif
}
void InsetText::setParagraphData(ParagraphList const & plist)
{
// we have to unlock any locked inset otherwise we're in troubles
@ -1962,10 +1943,6 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
Assert(bv);
setViewCache(bv);
// one endless line, resize normally not necessary
if (!force && getMaxWidth(bv, this) < 0)
return;
saveLyXTextState();
for_each(const_cast<ParagraphList&>(paragraphs).begin(),

View File

@ -142,8 +142,6 @@ public:
bool toggleall = false,
bool selectall = false);
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
///
void init(InsetText const * ins);
///
void writeParagraphData(Buffer const *, std::ostream &) const;

View File

@ -218,26 +218,6 @@ bool InsetWrap::insetAllowed(Inset::Code code) const
}
int InsetWrap::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
const
{
if (owner() &&
static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, inset) < 0) {
return -1;
}
if (!params_.width.zero()) {
int const ww1 = latexTextWidth(bv);
int const ww2 = InsetCollapsable::getMaxWidth(bv, inset);
if (ww2 > 0 && ww2 < ww1) {
return ww2;
}
return ww1;
}
// this should not happen!
return InsetCollapsable::getMaxWidth(bv, inset);
}
int InsetWrap::latexTextWidth(BufferView * bv) const
{
return params_.width.inPixels(InsetCollapsable::latexTextWidth(bv));

View File

@ -62,8 +62,6 @@ public:
///
bool insetAllowed(Inset::Code) const;
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
///
void addToToc(toc::TocList &, Buffer const *) const;
///
bool showInsetDialog(BufferView *) const;

View File

@ -133,36 +133,6 @@ Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev)
}
int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
{
int w;
if (owner()) {
w = owner()->getMaxWidth(bv, this);
} else {
w = bv->text->workWidth(this);
}
if (w < 0) {
return -1;
}
// check for margins left/right and extra right margin "const 5"
if ((w - (2 * TEXT_TO_INSET_OFFSET + 5)) >= 0)
w -= 2 * TEXT_TO_INSET_OFFSET + 5;
// Deep magic. I don't understand this either.
if (owner() && owner()->owner()) {
// add the right paper margin
w -= 20;
}
// FIXME: why ?
if (w < 10) {
w = 10;
}
return w;
}
LyXCursor const & Inset::cursor(BufferView * bv) const
{
if (owner())

View File

@ -91,8 +91,6 @@ public:
/// An updatable inset could handle lyx editing commands
virtual RESULT localDispatch(FuncRequest const & cmd);
///
virtual int getMaxWidth(BufferView * bv, UpdatableInset const *) const;
///
int scroll(bool recursive = true) const {
// We need this method to not clobber the real method in Inset
return Inset::scroll(recursive);