#include "frontends/WorkArea.h"
#include "insets/insetcommand.h" // ChangeRefs
-#include "insets/updatableinset.h"
#include "insets/insettext.h"
using lyx::support::bformat;
#include "paragraph_funcs.h"
#include "pariterator.h"
-#include "insets/updatableinset.h"
#include "insets/insettabular.h"
#include "insets/insettext.h"
#include "mathed/math_inset.h"
#include "mathed/math_data.h"
-#include "insets/updatableinset.h"
-
-
#include <boost/assert.hpp>
using std::endl;
}
-UpdatableInset * CursorSlice::asUpdatableInset() const
-{
- BOOST_ASSERT(inset_);
- return inset_->asUpdatableInset();
-}
-
-
MathArray & CursorSlice::cell() const
{
BOOST_ASSERT(asMathInset());
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...)
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
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:
#include "rowpainter.h"
#include "version.h"
-#include "insets/updatableinset.h"
-
#include "graphics/GraphicsImage.h"
#include "graphics/GraphicsLoader.h"
+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.
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
+
#include <config.h>
#include "inset.h"
-#include "updatableinset.h"
#include "BufferView.h"
#include "debug.h"
#include "dimension.h"
class LColor_color;
-class UpdatableInset;
/// Insets
/// 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; }
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
}
-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;
///
void setLabelFont(LyXFont & f);
///
- int scroll(bool recursive = true) const;
- ///
bool isOpen() const { return status_ == Open || status_ == Inlined; }
///
bool inlined() const { return status_ == Inlined; }
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);
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)
{}
//resetPos(bv->cursor());
- x += scroll();
+ x += scx_;
x += ADD_TO_TABULAR_WIDTH;
idx_type idx = 0;
//resetPos(cur);
- x += scroll();
- x += ADD_TO_TABULAR_WIDTH;
+ x += scx_ + ADD_TO_TABULAR_WIDTH;
if (tablemode(cur)) {
row_type rs, re;
default:
// we try to handle this event in the insets dispatch function.
cell(cur.idx())->dispatch(cur, cmd);
+ resetPos(cur);
break;
}
}
x += tabular.getBeginningOfTextInCell(idx);
x += ADD_TO_TABULAR_WIDTH;
- x += scroll();
+ x += scx_;
}
int const maxwidth = bv.workWidth();
if (&cur.inset() != this) {
- //scx = 0;
+ scx_ = 0;
} else {
int const X1 = 0;
int const X2 = maxwidth;
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();
class CursorSlice;
-class InsetTabular : public UpdatableInset {
+class InsetTabular : public InsetOld {
public:
///
InsetTabular(Buffer const &, row_type rows = 1,
///
std::string const editMessage() const;
///
+ EDITABLE editable() const { return HIGHLY_EDITABLE; }
+ ///
bool insetAllowed(InsetBase::Code) const { return true; }
///
bool isTextInset() const { return true; }
mutable LyXTabular tabular;
protected:
+ ///
InsetTabular(InsetTabular const &);
-
+ ///
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
-
///
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
private:
///
Buffer const * buffer_;
///
- mutable int cursorx_;
- ///
mutable idx_type first_visible_cell;
+ ///
+ mutable int scx_;
};
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_;
BufferView * bv = pi.base.bv;
bv->hideCursor();
- x += scroll();
text_.draw(pi, x + border_, y);
if (drawFrame_)
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);
-
}
#ifndef INSETTEXT_H
#define INSETTEXT_H
-#include "updatableinset.h"
+#include "inset.h"
#include "RowList_fwd.h"
#include "lyxfont.h"
#include "lyxtext.h"
class Buffer;
class BufferParams;
class BufferView;
+class CursorSlice;
class Dimension;
class LColor_color;
-class CursorSlice;
class Painter;
class ParagraphList;
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 &);
///
std::string const editMessage() const;
///
+ EDITABLE editable() const { return HIGHLY_EDITABLE; }
+ ///
bool isTextInset() const { return true; }
///
int latex(Buffer const &, std::ostream &,
+++ /dev/null
-/**
- * \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);
-}
-
+++ /dev/null
-// -*- 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
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";
}
-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())
/// 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();
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)
}
-void Paragraph::setInsetOwner(UpdatableInset * inset)
+void Paragraph::setInsetOwner(InsetBase * inset)
{
pimpl_->inset_owner = inset;
}
}
-UpdatableInset * Paragraph::inInset() const
+InsetBase * Paragraph::inInset() const
{
return pimpl_->inset_owner;
}
class PainterInfo;
class ParagraphParameters;
class TexRow;
-class UpdatableInset;
+
/// A Paragraph holds all text, attributes and insets in a text paragraph
class Paragraph {
Paragraph & operator=(Paragraph const &);
///
~Paragraph();
-
///
int id() const;
void makeSameLayout(Paragraph const & par);
///
- void setInsetOwner(UpdatableInset * inset);
+ void setInsetOwner(InsetBase * inset);
///
- UpdatableInset * inInset() const;
+ InsetBase * inInset() const;
///
InsetBase::Code ownerCode() const;
///
/// 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.
}
case LFUN_INSET_SETTINGS:
- if (cur.inset().asUpdatableInset())
- cur.inset().asUpdatableInset()->showInsetDialog(bv);
+ cur.inset().showInsetDialog(bv);
break;
case LFUN_NEXT_INSET_TOGGLE: {
#include "paragraph.h"
#include "mathed/math_support.h"
-#include "insets/updatableinset.h"
+#include "insets/inset.h"
#include <algorithm>
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());
}