send UpdatableInset down the way of the Dodo

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10228 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2005-07-15 22:10:25 +00:00
parent 5d9e560f71
commit 282f86fbb1
27 changed files with 68 additions and 220 deletions

View File

@ -45,7 +45,6 @@
#include "frontends/WorkArea.h"
#include "insets/insetcommand.h" // ChangeRefs
#include "insets/updatableinset.h"
#include "insets/insettext.h"
using lyx::support::bformat;

View File

@ -32,7 +32,6 @@
#include "paragraph_funcs.h"
#include "pariterator.h"
#include "insets/updatableinset.h"
#include "insets/insettabular.h"
#include "insets/insettext.h"

View File

@ -21,9 +21,6 @@
#include "mathed/math_inset.h"
#include "mathed/math_data.h"
#include "insets/updatableinset.h"
#include <boost/assert.hpp>
using std::endl;
@ -90,13 +87,6 @@ MathInset * CursorSlice::asMathInset() const
}
UpdatableInset * CursorSlice::asUpdatableInset() const
{
BOOST_ASSERT(inset_);
return inset_->asUpdatableInset();
}
MathArray & CursorSlice::cell() const
{
BOOST_ASSERT(asMathInset());

View File

@ -28,13 +28,12 @@ class MathInset;
class MathArray;
class LyXText;
class Paragraph;
class UpdatableInset;
/// This encapsulates a single slice of a document iterator as used e.g.
/// for cursors.
// After IU, the distinction of MathInset and UpdatableInset as well as
// After IU, the distinction of MathInset and InsetOld as well as
// that of MathArray and LyXText should vanish. They are conceptually the
// same (now...)
@ -108,8 +107,6 @@ public:
LyXText * text();
/// returns text corresponding to this position
LyXText const * text() const;
/// returns the owning inset if it is an UpdatableInset, else 0
UpdatableInset * asUpdatableInset() const;
/// paragraph in this cell
Paragraph & paragraph();
/// paragraph in this cell

View File

@ -159,32 +159,28 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd)
bv->getLyXText()->getStringToIndex(bv->cursor()) :
cmd.argument;
icp.setContents(contents);
return new InsetIndex(icp);
}
case LFUN_TABULAR_INSERT:
if (!cmd.argument.empty()) {
std::istringstream ss(cmd.argument);
int r = 0, c = 0;
ss >> r >> c;
if (r <= 0) r = 2;
if (c <= 0) c = 2;
return new InsetTabular(*bv->buffer(), r, c);
}
return 0;
case LFUN_TABULAR_INSERT: {
if (!cmd.argument.empty())
return 0;
std::istringstream ss(cmd.argument);
int r = 0, c = 0;
ss >> r >> c;
if (r <= 0)
r = 2;
if (c <= 0)
c = 2;
return new InsetTabular(*bv->buffer(), r, c);
}
case LFUN_INSET_CAPTION: {
UpdatableInset * up = bv->cursor().inset().asUpdatableInset();
if (!up) {
auto_ptr<InsetCaption> inset(new InsetCaption(params));
inset->setAutoBreakRows(true);
inset->setDrawFrame(true);
inset->setFrameColor(LColor::captionframe);
return inset.release();
}
return 0;
auto_ptr<InsetCaption> inset(new InsetCaption(params));
inset->setAutoBreakRows(true);
inset->setDrawFrame(true);
inset->setFrameColor(LColor::captionframe);
return inset.release();
}
case LFUN_INDEX_PRINT:

View File

@ -35,8 +35,6 @@
#include "rowpainter.h"
#include "version.h"
#include "insets/updatableinset.h"
#include "graphics/GraphicsImage.h"
#include "graphics/GraphicsLoader.h"

View File

@ -1,3 +1,11 @@
2005-07-15 André Pönitz <poenitz@gmx.net>
* Makefile.am:
* inset.[Ch]:
* insetcollapsable.[Ch]:
* insettabular.[Ch]:
* updatableinset.[Ch]: remove UpdatableInset
2005-07-15 José Matos <jamatos@lyx.org>
* insettext.C (plaintext): fix call to asciiParagraph.

View File

@ -110,12 +110,12 @@ libinsets_la_SOURCES = \
insetvspace.C \
insetvspace.h \
insetwrap.h \
insetwrap.C \
updatableinset.C \
updatableinset.h
insetwrap.C
# insetlist.C \
# insetlist.h \
# insetsection.h \
# insetsection.C \
# insettheorem.C \
# insettheorem.h

View File

@ -14,7 +14,6 @@
#include <config.h>
#include "inset.h"
#include "updatableinset.h"
#include "BufferView.h"
#include "debug.h"

View File

@ -19,7 +19,6 @@
#include "dimension.h"
class LColor_color;
class UpdatableInset;
/// Insets

View File

@ -74,8 +74,6 @@ public:
/// identification as math inset
virtual MathInset * asMathInset() { return 0; }
/// identification as non-math inset
virtual UpdatableInset * asUpdatableInset() { return 0; }
/// true for 'math' math inset, but not for e.g. mbox
virtual bool inMathed() const { return false; }
@ -116,6 +114,8 @@ public:
virtual void drawSelection(PainterInfo &, int, int) const {}
///
virtual bool editing(BufferView * bv) const;
///
virtual bool showInsetDialog(BufferView *) const { return false; }
/// draw four angular markers
void drawMarkers(PainterInfo & pi, int x, int y) const;
/// draw two angular markers

View File

@ -367,17 +367,6 @@ bool InsetCollapsable::getStatus(LCursor & cur, FuncRequest const & cmd,
}
int InsetCollapsable::scroll(bool recursive) const
{
int sx = UpdatableInset::scroll(false);
if (recursive)
sx += InsetText::scroll(false);
return sx;
}
void InsetCollapsable::setLabel(string const & l)
{
label = l;

View File

@ -65,8 +65,6 @@ public:
///
void setLabelFont(LyXFont & f);
///
int scroll(bool recursive = true) const;
///
bool isOpen() const { return status_ == Open || status_ == Inlined; }
///
bool inlined() const { return status_ == Inlined; }
@ -80,14 +78,11 @@ public:
void setStatus(LCursor & cur, CollapseStatus st);
protected:
///
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
///
Dimension dimensionCollapsed() const;
///
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
///
Box const & buttonDim() const;
///
void edit(LCursor & cur, bool left);

View File

@ -164,13 +164,13 @@ bool InsetTabular::hasPasteBuffer() const
InsetTabular::InsetTabular(Buffer const & buf, row_type rows,
col_type columns)
: tabular(buf.params(), max(rows, row_type(1)),
max(columns, col_type(1))), buffer_(&buf), cursorx_(0)
max(columns, col_type(1))), buffer_(&buf), scx_(0)
{}
InsetTabular::InsetTabular(InsetTabular const & tab)
: UpdatableInset(tab), tabular(tab.tabular),
buffer_(tab.buffer_), cursorx_(0)
: InsetOld(tab), tabular(tab.tabular),
buffer_(tab.buffer_), scx_(0)
{}
@ -279,7 +279,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
//resetPos(bv->cursor());
x += scroll();
x += scx_;
x += ADD_TO_TABULAR_WIDTH;
idx_type idx = 0;
@ -329,8 +329,7 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
//resetPos(cur);
x += scroll();
x += ADD_TO_TABULAR_WIDTH;
x += scx_ + ADD_TO_TABULAR_WIDTH;
if (tablemode(cur)) {
row_type rs, re;
@ -772,6 +771,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
default:
// we try to handle this event in the insets dispatch function.
cell(cur.idx())->dispatch(cur, cmd);
resetPos(cur);
break;
}
@ -1111,7 +1111,7 @@ void InsetTabular::cursorPos
}
x += tabular.getBeginningOfTextInCell(idx);
x += ADD_TO_TABULAR_WIDTH;
x += scroll();
x += scx_;
}
@ -1204,7 +1204,7 @@ void InsetTabular::resetPos(LCursor & cur) const
int const maxwidth = bv.workWidth();
if (&cur.inset() != this) {
//scx = 0;
scx_ = 0;
} else {
int const X1 = 0;
int const X2 = maxwidth;
@ -1213,11 +1213,11 @@ void InsetTabular::resetPos(LCursor & cur) const
int const x2 = x1 + tabular.getWidthOfColumn(cur.idx());
if (x1 < X1)
scx = X1 + 20 - x1;
scx_ = X1 + 20 - x1;
else if (x2 > X2)
scx = X2 - 20 - x2;
scx_ = X2 - 20 - x2;
else
scx = 0;
scx_ = 0;
}
cur.needsUpdate();

View File

@ -45,7 +45,7 @@ class Paragraph;
class CursorSlice;
class InsetTabular : public UpdatableInset {
class InsetTabular : public InsetOld {
public:
///
InsetTabular(Buffer const &, row_type rows = 1,
@ -65,6 +65,8 @@ public:
///
std::string const editMessage() const;
///
EDITABLE editable() const { return HIGHLY_EDITABLE; }
///
bool insetAllowed(InsetBase::Code) const { return true; }
///
bool isTextInset() const { return true; }
@ -140,10 +142,10 @@ public:
mutable LyXTabular tabular;
protected:
///
InsetTabular(InsetTabular const &);
///
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
///
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
private:
@ -191,9 +193,9 @@ private:
///
Buffer const * buffer_;
///
mutable int cursorx_;
///
mutable idx_type first_visible_cell;
///
mutable int scx_;
};

View File

@ -86,7 +86,7 @@ InsetText::InsetText(BufferParams const & bp)
InsetText::InsetText(InsetText const & in)
: UpdatableInset(in), text_(in.text_.bv_owner)
: InsetOld(in), text_(in.text_.bv_owner)
{
text_.autoBreakRows_ = in.text_.autoBreakRows_;
drawFrame_ = in.drawFrame_;
@ -194,7 +194,6 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
BufferView * bv = pi.base.bv;
bv->hideCursor();
x += scroll();
text_.draw(pi, x + border_, y);
if (drawFrame_)
@ -299,15 +298,10 @@ InsetBase * InsetText::editXY(LCursor & cur, int x, int y)
void InsetText::doDispatch(LCursor & cur, FuncRequest & cmd)
{
lyxerr[Debug::DEBUG]
<< BOOST_CURRENT_FUNCTION
<< " [ cmd.action = " << cmd.action << ']'
<< endl;
lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
<< " [ cmd.action = " << cmd.action << ']' << endl;
setViewCache(&cur.bv());
text_.dispatch(cur, cmd);
}

View File

@ -12,7 +12,7 @@
#ifndef INSETTEXT_H
#define INSETTEXT_H
#include "updatableinset.h"
#include "inset.h"
#include "RowList_fwd.h"
#include "lyxfont.h"
#include "lyxtext.h"
@ -24,9 +24,9 @@
class Buffer;
class BufferParams;
class BufferView;
class CursorSlice;
class Dimension;
class LColor_color;
class CursorSlice;
class Painter;
class ParagraphList;
class Row;
@ -36,7 +36,7 @@ class Row;
A text inset is like a TeX box to write full text
(including styles and other insets) in a given space.
*/
class InsetText : public UpdatableInset {
class InsetText : public InsetOld {
public:
///
explicit InsetText(BufferParams const &);
@ -57,6 +57,8 @@ public:
///
std::string const editMessage() const;
///
EDITABLE editable() const { return HIGHLY_EDITABLE; }
///
bool isTextInset() const { return true; }
///
int latex(Buffer const &, std::ostream &,

View File

@ -1,54 +0,0 @@
/**
* \file updatableinset.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
* \author Jürgen Vigna
* \author Lars Gullik Bjønnes
* \author Matthias Ettrich
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "updatableinset.h"
#include "BufferView.h"
#include "coordcache.h"
#include "cursor.h"
#include "debug.h"
#include "dispatchresult.h"
#include "funcrequest.h"
#include "lyxtext.h"
#include "support/convert.h"
#include <boost/assert.hpp>
// An updatable inset is highly editable by definition
InsetBase::EDITABLE UpdatableInset::editable() const
{
return HIGHLY_EDITABLE;
}
int UpdatableInset::scroll(bool) const
{
return scx;
}
void UpdatableInset::setScroll(int maxwidth, int pos) const
{
scx = pos;
}
void UpdatableInset::getCursorDim(int &, int &) const
{
BOOST_ASSERT(false);
}

View File

@ -1,47 +0,0 @@
// -*- C++ -*-
/**
* \file updatableinset.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
* \author Jürgen Vigna
* \author Lars Gullik Bjønnes
* \author Matthias Ettrich
*
* Full author contact details are available in file CREDITS.
*/
#ifndef UPDATABLEINSET_H
#define UPDATABLEINSET_H
// Updatable Insets. These insets can receive directly user interaction.
// Note that all pure methods from Inset class are pure here too.
// [Alejandro 080596]
#include "inset.h"
class UpdatableInset : public InsetOld {
public:
///
UpdatableInset() : scx(0) {}
///
virtual EDITABLE editable() const;
/// identification as text inset in a cursor slice
UpdatableInset * asUpdatableInset() { return this; }
/// return the cursor dim
virtual void getCursorDim(int &, int &) const;
///
virtual bool showInsetDialog(BufferView *) const { return false; }
protected:
/// scrolls offset pixels
void setScroll(int maxwidth, int offset) const;
/// returns the actual scroll value
virtual int scroll(bool recursive = true) const;
///
mutable int scx;
};
#endif

View File

@ -428,12 +428,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
enable = false;
if (!cur)
break;
UpdatableInset * inset = cur.inset().asUpdatableInset();
lyxerr << "inset: " << inset << endl;
if (!inset)
break;
InsetBase::Code code = inset->lyxCode();
InsetBase::Code code = cur.inset().lyxCode();
switch (code) {
case InsetBase::TABULAR_CODE:
enable = cmd.argument == "tabular";

View File

@ -1250,14 +1250,6 @@ string const MathHullInset::editMessage() const
}
void MathHullInset::getCursorDim(int & asc, int & desc) const
{
asc = 10;
desc = 2;
//math_font_max_dim(font_, asc, des);
}
void MathHullInset::revealCodes(LCursor & cur) const
{
if (!cur.inMathed())

View File

@ -184,8 +184,6 @@ public:
/// what appears in the minibuffer when opening
virtual std::string const editMessage() const;
///
virtual void getCursorDim(int &, int &) const;
///
virtual bool isTextInset() const { return true; }
///
virtual void mutateToText();

View File

@ -521,7 +521,7 @@ void Paragraph::setFont(pos_type pos, LyXFont const & font)
if (it->pos() >= pos)
break;
}
unsigned int i = distance(beg, it);
size_t const i = distance(beg, it);
bool notfound = (it == endit);
if (!notfound && pimpl_->fontlist[i].font() == font)
@ -1644,7 +1644,7 @@ string const Paragraph::asString(Buffer const & buffer,
}
void Paragraph::setInsetOwner(UpdatableInset * inset)
void Paragraph::setInsetOwner(InsetBase * inset)
{
pimpl_->inset_owner = inset;
}
@ -1742,7 +1742,7 @@ void Paragraph::layout(LyXLayout_ptr const & new_layout)
}
UpdatableInset * Paragraph::inInset() const
InsetBase * Paragraph::inInset() const
{
return pimpl_->inset_owner;
}

View File

@ -47,7 +47,7 @@ class OutputParams;
class PainterInfo;
class ParagraphParameters;
class TexRow;
class UpdatableInset;
/// A Paragraph holds all text, attributes and insets in a text paragraph
class Paragraph {
@ -76,7 +76,6 @@ public:
Paragraph & operator=(Paragraph const &);
///
~Paragraph();
///
int id() const;
@ -164,9 +163,9 @@ public:
void makeSameLayout(Paragraph const & par);
///
void setInsetOwner(UpdatableInset * inset);
void setInsetOwner(InsetBase * inset);
///
UpdatableInset * inInset() const;
InsetBase * inInset() const;
///
InsetBase::Code ownerCode() const;
///

View File

@ -78,7 +78,7 @@ public:
/// erase the given range
int erase(lyx::pos_type start, lyx::pos_type end);
///
UpdatableInset * inset_owner;
InsetBase * inset_owner;
/** A font entry covers a range of positions. Notice that the
entries in the list are inserted in random order.

View File

@ -727,8 +727,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
}
case LFUN_INSET_SETTINGS:
if (cur.inset().asUpdatableInset())
cur.inset().asUpdatableInset()->showInsetDialog(bv);
cur.inset().showInsetDialog(bv);
break;
case LFUN_NEXT_INSET_TOGGLE: {

View File

@ -24,7 +24,7 @@
#include "paragraph.h"
#include "mathed/math_support.h"
#include "insets/updatableinset.h"
#include "insets/inset.h"
#include <algorithm>
@ -182,8 +182,7 @@ bool textUndoOrRedo(BufferView & bv,
ParagraphList::const_iterator pit = undo.pars.begin();
ParagraphList::const_iterator end = undo.pars.end();
for (; pit != end; ++pit)
const_cast<Paragraph &>(*pit).setInsetOwner(
dynamic_cast<UpdatableInset *>(&dit.inset()));
const_cast<Paragraph &>(*pit).setInsetOwner(&dit.inset());
plist.insert(first, undo.pars.begin(), undo.pars.end());
}