remove Inset::id

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8019 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-11-03 16:46:44 +00:00
parent 807bc25587
commit b8a3ae7449
14 changed files with 36 additions and 113 deletions

View File

@ -1,4 +1,10 @@
2003-11-03 André Pönitz <poenitz@gmx.net>
* buffer.C:
* buffer.h:
* bufferview_funcs.C: remove getInsetFromId()
2003-11-03 Alfredo Braunstein <abraunst@libero.it>
* PosIterator.C (distance, advance): new

View File

@ -1418,21 +1418,6 @@ void Buffer::inset_iterator::setParagraph()
}
InsetOld * Buffer::getInsetFromID(int id_arg) const
{
for (inset_iterator it = inset_const_iterator_begin();
it != inset_const_iterator_end(); ++it)
{
if (it->id() == id_arg)
return &(*it);
InsetOld * in = it->getInsetFromID(id_arg);
if (in)
return in;
}
return 0;
}
ParIterator Buffer::getParFromID(int id) const
{
#warning FIXME: const correctness! (Andre)

View File

@ -359,9 +359,6 @@ public:
///
ParConstIterator par_iterator_end() const;
///
InsetOld * getInsetFromID(int id_arg) const;
/** \returns true only when the file is fully loaded.
* Used to prevent the premature generation of previews
* and by the citation inset.

View File

@ -372,9 +372,9 @@ string const currentState(BufferView * bv)
state << _(", Inset: ");
InsetOld * inset = pit->inInset();
if (inset)
state << inset << " id: " << inset->id()
<< " text: " << inset->getLyXText(bv, true)
<< " owner: " << inset->owner();
state << inset
<< " text: " << inset->getLyXText(bv, true)
<< " owner: " << inset->owner();
else
state << -1;
#endif

View File

@ -27,8 +27,7 @@ using std::string;
namespace {
inline
void waitForX(bool discard)
inline void waitForX(bool discard)
{
XSync(fl_get_display(), discard);
}
@ -272,15 +271,18 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
XEvent * ev = static_cast<XEvent*>(xev);
XWorkArea * area = static_cast<XWorkArea*>(ob->u_vdata);
if (!area) return 1;
if (!area)
return 1;
switch (event) {
case FL_DRAW:
if (!area->work_area || !area->work_area->form->visible)
return 1;
lyxerr[Debug::WORKAREA] << "Workarea event: DRAW" << endl;
area->redraw(area->workWidth(), area->workHeight());
break;
case FL_PUSH:
if (!ev || ev->xbutton.button == 0) break;
// Should really have used xbutton.state
@ -291,6 +293,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
ev->xbutton.y - ob->y,
x_button_state(key)));
break;
case FL_RELEASE:
if (!ev || ev->xbutton.button == 0) break;
// Should really have used xbutton.state
@ -301,8 +304,8 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
ev->xbutton.y - ob->y,
x_button_state(key)));
break;
case FL_DRAG:
{
case FL_DRAG: {
if (!ev || !area->scrollbar)
break;
@ -367,8 +370,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
break;
}
case FL_KEYPRESS:
{
case FL_KEYPRESS: {
lyxerr[Debug::WORKAREA] << "Workarea event: KEYPRESS" << endl;
KeySym keysym = 0;
@ -456,8 +458,8 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
area->workAreaKeyPress(LyXKeySymPtr(xlk),
x_key_state(ret_state));
break;
}
break;
case FL_KEYRELEASE:
lyxerr[Debug::WORKAREA] << "Workarea event: KEYRELEASE" << endl;
@ -467,11 +469,13 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
lyxerr[Debug::WORKAREA] << "Workarea event: ENTER" << endl;
fl_set_cursor(FL_ObjWin(area->work_area), XC_xterm);
break;
case FL_LEAVE:
lyxerr[Debug::WORKAREA] << "Workarea event: LEAVE" << endl;
// There should be no need for this. But there is.
fl_set_cursor(FL_ObjWin(area->work_area), FL_DEFAULT_CURSOR);
break;
case FL_DBLCLICK:
if (ev) {
lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl;
@ -482,6 +486,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
area->dispatch(cmd);
}
break;
case FL_TRPLCLICK:
if (ev) {
lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl;
@ -492,6 +497,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
area->dispatch(cmd);
}
break;
case FL_OTHER:
if (ev)
lyxerr[Debug::WORKAREA] << "Workarea event: OTHER" << endl;

View File

@ -1,3 +1,11 @@
2003-11-03 André Pönitz <poenitz@gmx.net>
* inset.[Ch]:
* insetcollapsable.[Ch]:
* insettabular.[Ch]:
* insettext.[Ch]: remove Inset::id and related functions
2003-11-01 Lars Gullik Bjønnes <larsbj@gullik.net>
* insets: adjust for DispatchResult changes.

View File

@ -24,21 +24,16 @@
using std::string;
// Initialization of the counter for the inset id's,
unsigned int InsetOld::inset_id = 0;
InsetOld::InsetOld()
: InsetBase(),
top_x(0), top_baseline(0), scx(0),
id_(inset_id++), owner_(0),
top_x(0), top_baseline(0), scx(0), owner_(0),
background_color_(LColor::inherit)
{}
InsetOld::InsetOld(InsetOld const & in)
: InsetBase(),
top_x(0), top_baseline(0), scx(0),
id_(in.id_), owner_(0),
top_x(0), top_baseline(0), scx(0), owner_(0),
name_(in.name_), background_color_(in.background_color_)
{}
@ -106,16 +101,6 @@ LColor_color InsetOld::backgroundColor() const
}
int InsetOld::id() const
{
return id_;
}
void InsetOld::id(int id_arg)
{
id_ = id_arg;
}
void InsetOld::setFont(BufferView *, LyXFont const &, bool, bool)
{}

View File

@ -230,9 +230,6 @@ public:
return 0;
}
/// try to get a inset pointer from it's id if we have
/// an inset to give back!
virtual InsetOld * getInsetFromID(int /*id*/) const { return 0; }
/// if this insets owns paragraphs (f.ex. InsetText) then it
/// should return it's very first one!
virtual ParagraphList * getParagraphs(int /*num*/) const { return 0; }
@ -244,10 +241,6 @@ public:
/// return the cursor if we own one otherwise giv'em just the
/// BufferView cursor to work with.
virtual LyXCursor const & cursor(BufferView * bview) const;
/// id functions
int id() const;
///
void id(int id_arg);
/// lock cell with given index
virtual void edit(BufferView *, int /*index*/) {}
@ -315,8 +308,6 @@ protected:
/// Used to identify the inset for cursor positioning when undoing
unsigned int id_;
///
static unsigned int inset_id;
///
mutable Dimension dim_;
private:

View File

@ -490,14 +490,6 @@ LyXCursor const & InsetCollapsable::cursor(BufferView * bv) const
}
InsetOld * InsetCollapsable::getInsetFromID(int id_arg) const
{
if (id_arg == id())
return const_cast<InsetCollapsable *>(this);
return inset.getInsetFromID(id_arg);
}
void InsetCollapsable::open(BufferView * bv)
{
if (!collapsed_)

View File

@ -115,8 +115,6 @@ public:
///
void scroll(BufferView *bv, int offset) const;
///
InsetOld * getInsetFromID(int id) const;
///
ParagraphList * getParagraphs(int) const;
///
int numParagraphs() const;

View File

@ -441,7 +441,6 @@ bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
if (!the_locking_inset) {
int const n = tabular.getNumberOfCells();
int const id = inset->id();
for (int i = 0; i < n; ++i) {
InsetText * in = &tabular.getCellInset(i);
if (inset == in) {
@ -451,11 +450,9 @@ bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
resetPos(bv);
return true;
}
if (in->getInsetFromID(id)) {
actcell = i;
in->dispatch(FuncRequest(bv, LFUN_INSET_EDIT));
return the_locking_inset->lockInsetInInset(bv, inset);
}
actcell = i;
in->dispatch(FuncRequest(bv, LFUN_INSET_EDIT));
return the_locking_inset->lockInsetInInset(bv, inset);
}
return false;
}
@ -2416,22 +2413,6 @@ LyXCursor const & InsetTabular::cursor(BufferView * bv) const
}
InsetOld * InsetTabular::getInsetFromID(int id_arg) const
{
if (id_arg == id())
return const_cast<InsetTabular *>(this);
for (int i = 0; i < tabular.rows(); ++i) {
for (int j = 0; j < tabular.columns(); ++j) {
InsetOld * inset = tabular.getCellInset(i, j).getInsetFromID(id_arg);
if (inset)
return inset;
}
}
return 0;
}
WordLangTuple const
InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
{

View File

@ -158,8 +158,6 @@ public:
UpdatableInset::scroll(bv, offset);
}
///
InsetOld * getInsetFromID(int id) const;
///
ParagraphList * getParagraphs(int) const;
///
int numParagraphs() const;

View File

@ -1440,28 +1440,6 @@ LyXCursor const & InsetText::cursor(BufferView * bv) const
}
InsetOld * InsetText::getInsetFromID(int id_arg) const
{
if (id_arg == id())
return const_cast<InsetText *>(this);
ParagraphList::const_iterator pit = paragraphs.begin();
ParagraphList::const_iterator pend = paragraphs.end();
for (; pit != pend; ++pit) {
InsetList::const_iterator it = pit->insetlist.begin();
InsetList::const_iterator end = pit->insetlist.end();
for (; it != end; ++it) {
if (it->inset->id() == id_arg)
return it->inset;
InsetOld * in = it->inset->getInsetFromID(id_arg);
if (in)
return in;
}
}
return 0;
}
WordLangTuple const
InsetText::selectNextWordToSpellcheck(BufferView * bv, float & value) const
{

View File

@ -152,8 +152,6 @@ public:
///
void clearSelection(BufferView * bv);
///
InsetOld * getInsetFromID(int id) const;
///
ParagraphList * getParagraphs(int) const;
///
LyXText * getText(int) const;