+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]:
}
-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)
bool forceDefaultParagraphs(Inset const *) const {
return true;
}
- ///
- int getMaxWidth(BufferView *, UpdatableInset const *) const;
private:
///
}
-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));
///
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
}
-// 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);
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;
///
///
bool insetHit(BufferView * bv, int x, int y) const;
///
- int getMaxWidthOfCell(BufferView * bv, int cell) const;
- ///
bool hasPasteBuffer() const;
///
bool copySelection(BufferView *);
}
-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
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(),
bool toggleall = false,
bool selectall = false);
///
- int getMaxWidth(BufferView *, UpdatableInset const *) const;
- ///
void init(InsetText const * ins);
///
void writeParagraphData(Buffer const *, std::ostream &) 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));
///
bool insetAllowed(Inset::Code) const;
///
- int getMaxWidth(BufferView *, UpdatableInset const *) const;
- ///
void addToToc(toc::TocList &, Buffer const *) const;
///
bool showInsetDialog(BufferView *) const;
}
-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())
/// 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);