From b8a3ae7449dc47aedbfb6c38428287f426b47ebc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Mon, 3 Nov 2003 16:46:44 +0000 Subject: [PATCH] remove Inset::id git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8019 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++++ src/buffer.C | 15 --------------- src/buffer.h | 3 --- src/bufferview_funcs.C | 6 +++--- src/frontends/xforms/XWorkArea.C | 22 ++++++++++++++-------- src/insets/ChangeLog | 8 ++++++++ src/insets/inset.C | 19 ++----------------- src/insets/inset.h | 9 --------- src/insets/insetcollapsable.C | 8 -------- src/insets/insetcollapsable.h | 2 -- src/insets/insettabular.C | 25 +++---------------------- src/insets/insettabular.h | 2 -- src/insets/insettext.C | 22 ---------------------- src/insets/insettext.h | 2 -- 14 files changed, 36 insertions(+), 113 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c4dfb6df28..1ba35ce9cd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,10 @@ +2003-11-03 André Pönitz + + * buffer.C: + * buffer.h: + * bufferview_funcs.C: remove getInsetFromId() + 2003-11-03 Alfredo Braunstein * PosIterator.C (distance, advance): new diff --git a/src/buffer.C b/src/buffer.C index 81d1ee2887..9d646999e6 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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) diff --git a/src/buffer.h b/src/buffer.h index 12fb74ea92..5b3de3e38b 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -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. diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 82397a6274..3c2738ace2 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -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 diff --git a/src/frontends/xforms/XWorkArea.C b/src/frontends/xforms/XWorkArea.C index e37ee7167f..379e1d82e8 100644 --- a/src/frontends/xforms/XWorkArea.C +++ b/src/frontends/xforms/XWorkArea.C @@ -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(xev); XWorkArea * area = static_cast(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; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index f7138266c8..0296b86086 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,11 @@ + +2003-11-03 André Pönitz + + * inset.[Ch]: + * insetcollapsable.[Ch]: + * insettabular.[Ch]: + * insettext.[Ch]: remove Inset::id and related functions + 2003-11-01 Lars Gullik Bjønnes * insets: adjust for DispatchResult changes. diff --git a/src/insets/inset.C b/src/insets/inset.C index f28c9d6b8d..26162984b8 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -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) {} diff --git a/src/insets/inset.h b/src/insets/inset.h index dde1afa7d9..50616a2b9a 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -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: diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 11b4c06d74..1e9d18f1dd 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -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(this); - return inset.getInsetFromID(id_arg); -} - - void InsetCollapsable::open(BufferView * bv) { if (!collapsed_) diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 1dbfe38860..da1723bda0 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -115,8 +115,6 @@ public: /// void scroll(BufferView *bv, int offset) const; /// - InsetOld * getInsetFromID(int id) const; - /// ParagraphList * getParagraphs(int) const; /// int numParagraphs() const; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index aacabc46a4..96963ae297 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -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(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 { diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 4991244e9c..52186a4ebf 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -158,8 +158,6 @@ public: UpdatableInset::scroll(bv, offset); } /// - InsetOld * getInsetFromID(int id) const; - /// ParagraphList * getParagraphs(int) const; /// int numParagraphs() const; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index a2934b3ab9..44de629aba 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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(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 { diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 5ebfe1ee9f..bb5d1b980b 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -152,8 +152,6 @@ public: /// void clearSelection(BufferView * bv); /// - InsetOld * getInsetFromID(int id) const; - /// ParagraphList * getParagraphs(int) const; /// LyXText * getText(int) const; -- 2.39.2