From b1a87cc7781bd11d9481b69e96eb67b2d637e167 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 3 Jul 2006 22:31:51 +0000 Subject: [PATCH] Extracted from r14281 from the younes branch. * BufferView,BufferView::Pimple: - workArea_ removed * frontends/LyXView: - now contains a pointer reference to the current WorkArea instead of the BufferView. - workArea(): temporary access method * frontends/WorkArea: - bufferView(): new access methods. * GuiImplementation: updated due to above changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14329 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 5 ++--- src/BufferView.h | 3 +-- src/BufferView_pimpl.C | 16 ++++++++-------- src/BufferView_pimpl.h | 5 +---- src/frontends/LyXView.C | 24 ++++++++++++++---------- src/frontends/LyXView.h | 11 ++++++----- src/frontends/WorkArea.C | 12 ++++++++++++ src/frontends/WorkArea.h | 5 +++++ src/frontends/gtk/GuiImplementation.C | 6 +++--- src/frontends/qt3/GuiImplementation.h | 4 ++-- src/frontends/qt4/GuiImplementation.C | 4 ++-- 11 files changed, 56 insertions(+), 39 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index bd4324cb77..677abdad0a 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -43,7 +43,6 @@ #include "frontends/Dialogs.h" #include "frontends/LyXView.h" #include "frontends/Gui.h" -#include "frontends/WorkArea.h" #include "insets/insetcommand.h" // ChangeRefs #include "insets/insettext.h" @@ -62,8 +61,8 @@ using std::vector; extern BufferList bufferlist; -BufferView::BufferView(LyXView * owner, lyx::frontend::WorkArea * workArea) - : pimpl_(new Pimpl(*this, owner, workArea)) +BufferView::BufferView(LyXView * owner) + : pimpl_(new Pimpl(*this, owner)) {} diff --git a/src/BufferView.h b/src/BufferView.h index 1edfa4c563..375683de7c 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -38,7 +38,6 @@ class ParIterator; namespace lyx { namespace frontend { class Painter; -class WorkArea; } } @@ -94,7 +93,7 @@ public: * Create a view with the given owner main window, * of the given dimensions. */ - BufferView(LyXView * owner, lyx::frontend::WorkArea * workArea); + BufferView(LyXView * owner); ~BufferView(); diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 2a16604e23..7fd68c85cd 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -137,9 +137,9 @@ T * getInsetByCode(LCursor & cur, InsetBase::Code code) } // anon namespace -BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner, WorkArea * workArea) - : bv_(&bv), owner_(owner), buffer_(0), wh_(0), cursor_timeout(400), - using_xterm_cursor(false), workArea_(workArea), cursor_(bv), +BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner) + : bv_(&bv), owner_(owner), buffer_(0), wh_(0), cursor_timeout(400), + using_xterm_cursor(false), cursor_(bv), multiparsel_cache_(false), anchor_ref_(0), offset_ref_(0) { xsel_cache_.set = false; @@ -149,7 +149,7 @@ BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner, WorkArea * workArea) .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this)); cursor_timeout.start(); - + saved_positions.resize(saved_positions_num); // load saved bookmarks lyx::Session::BookmarkList & bmList = LyX::ref().session().loadBookmarks(); @@ -321,7 +321,7 @@ lyx::frontend::Gui & BufferView::Pimpl::gui() const lyx::frontend::Painter & BufferView::Pimpl::painter() const { - return workArea_->getPainter(); + return owner_->workArea()->getPainter(); } @@ -724,14 +724,14 @@ void BufferView::Pimpl::update(Update::flags flags) } if (forceupdate) { // Second drawing step - workArea_->redraw(*bv_, vi); + owner_->workArea()->redraw(*bv_, vi); } else { // Abort updating of the coord // cache - just restore the old one std::swap(theCoords, backup); } } else - workArea_->greyOut(); + owner_->workArea()->greyOut(); owner_->view_state_changed(); } @@ -1249,7 +1249,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd) case LFUN_OUTLINE_IN: lyx::toc::outline(lyx::toc::In, cursor_); updateLabels(*buffer_); - break; + break; case LFUN_OUTLINE_OUT: lyx::toc::outline(lyx::toc::Out, cursor_); updateLabels(*buffer_); diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 4f49920c79..6359c26ed3 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -39,7 +39,6 @@ class ViewMetricsInfo; namespace lyx { namespace frontend { class Gui; -class WorkArea; class Painter; } } @@ -49,7 +48,7 @@ class Painter; class BufferView::Pimpl : public boost::signals::trackable { public: /// - Pimpl(BufferView & bv, LyXView * owner, lyx::frontend::WorkArea * workArea); + Pimpl(BufferView & bv, LyXView * owner); /// lyx::frontend::Painter & painter() const; /// @@ -193,8 +192,6 @@ private: /// void menuInsertLyXFile(std::string const & filen); - lyx::frontend::WorkArea * workArea_; - /// this is used to handle XSelection events in the right manner struct { CursorSlice cursor; diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index 7f53e0ed5e..9b4408ae0d 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -17,6 +17,7 @@ #include "Timeout.h" #include "Toolbars.h" #include "Menubar.h" +#include "WorkArea.h" #include "buffer.h" #include "bufferparams.h" @@ -48,6 +49,7 @@ #endif using lyx::frontend::Gui; +using lyx::frontend::WorkArea; using lyx::support::makeDisplayPath; using lyx::support::onlyFilename; @@ -64,6 +66,7 @@ Gui & LyXView::gui() return owner_; } + LyXView::LyXView(Gui & owner) : owner_(owner), toolbars_(new Toolbars(*this)), @@ -72,14 +75,15 @@ LyXView::LyXView(Gui & owner) lyxfunc_(new LyXFunc(this)), dialogs_(new Dialogs(*this)), controlcommand_(new ControlCommandBuffer(*this)), - bufferview_(0) + work_area_(0) { lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl; } -void LyXView::setBufferView(BufferView * buffer_view) + +void LyXView::setWorkArea(WorkArea * work_area) { - bufferview_ = buffer_view; + work_area_ = work_area; } @@ -106,13 +110,13 @@ void LyXView::init() Buffer * LyXView::buffer() const { - return bufferview_->buffer(); + return work_area_->bufferView().buffer(); } BufferView * LyXView::view() const { - return bufferview_; + return &work_area_->bufferView(); } @@ -124,7 +128,7 @@ void LyXView::setLayout(string const & layout) void LyXView::updateToolbars() { - bool const math = bufferview_->cursor().inMathed(); + bool const math = work_area_->bufferView().cursor().inMathed(); bool const table = getLyXFunc().getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled(); toolbars_->update(math, table); @@ -171,11 +175,11 @@ void LyXView::updateLayoutChoice() current_layout = buffer()->params().getLyXTextClass().defaultLayoutName(); } - if (bufferview_->cursor().inMathed()) + if (work_area_->bufferView().cursor().inMathed()) return; string const & layout = - bufferview_->cursor().paragraph().layout()->name(); + work_area_->bufferView().cursor().paragraph().layout()->name(); if (layout != current_layout) { toolbars_->setLayout(layout); @@ -221,9 +225,9 @@ Buffer const * const LyXView::updateInset(InsetBase const * inset) const { Buffer const * buffer_ptr = 0; if (inset) { - buffer_ptr = bufferview_->buffer(); + buffer_ptr = work_area_->bufferView().buffer(); // No FitCursor: - bufferview_->update(Update::Force); + work_area_->bufferView().update(Update::Force); } return buffer_ptr; } diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index 77316e6124..ef1377a4ed 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -35,6 +35,7 @@ class FuncRequest; namespace lyx { namespace frontend { class Gui; +class WorkArea; class ControlCommandBuffer; } // namespace frontend @@ -60,8 +61,7 @@ public: virtual ~LyXView(); - void setBufferView(BufferView * buffer_view); - + void setWorkArea(lyx::frontend::WorkArea * work_area); /** * This is called after the concrete view has been created. * We have to have the toolbar and the other stuff created @@ -152,12 +152,13 @@ public: /// virtual lyx::frontend::Gui & gui(); + lyx::frontend::WorkArea * workArea() const { return work_area_; } protected: - /// current bufferview (view of a buffer). + /// current work area (screen view of a BufferView). /** - \todo FIXME: this should be moved out of LyXView. + \todo FIXME: there is only one workArea per LyXView for now. */ - BufferView * bufferview_; + lyx::frontend::WorkArea * work_area_; /// view's menubar boost::scoped_ptr menubar_; diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index acc34663e3..4dc2314b8c 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -136,6 +136,18 @@ void WorkArea::setBufferView(BufferView * buffer_view) } +BufferView & WorkArea::bufferView() +{ + return *buffer_view_; +} + + +BufferView const & WorkArea::bufferView() const +{ + return *buffer_view_; +} + + void WorkArea::checkAndGreyOut() { if (greyed_out_) diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index 113f2ce936..33ca042d09 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -42,6 +42,11 @@ public: void setBufferView(BufferView * buffer_view); + /// + BufferView & bufferView(); + /// + BufferView const & bufferView() const; + /// return the painter object for this work area virtual Painter & getPainter() = 0; diff --git a/src/frontends/gtk/GuiImplementation.C b/src/frontends/gtk/GuiImplementation.C index 98d4d879f7..056a677296 100644 --- a/src/frontends/gtk/GuiImplementation.C +++ b/src/frontends/gtk/GuiImplementation.C @@ -31,11 +31,11 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int /*view_id work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get())); clipboard_.reset(new GuiClipboard(old_work_area_.get())); guiCursor().connect(work_area_.get()); - + // FIXME BufferView creation should be independant of WorkArea creation - buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get())); + buffer_views_[0].reset(new BufferView(view_.get())); work_area_->setBufferView(buffer_views_[0].get()); - view_->setBufferView(buffer_views_[0].get()); + view_->setWorkArea(work_area_.get()); return 0; } diff --git a/src/frontends/qt3/GuiImplementation.h b/src/frontends/qt3/GuiImplementation.h index adf345b7b6..55a4e34f79 100644 --- a/src/frontends/qt3/GuiImplementation.h +++ b/src/frontends/qt3/GuiImplementation.h @@ -78,9 +78,9 @@ public: guiCursor().connect(work_area_.get()); // FIXME BufferView creation should be independant of WorkArea creation - buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get())); + buffer_views_[0].reset(new BufferView(view_.get())); work_area_->setBufferView(buffer_views_[0].get()); - view_->setBufferView(buffer_views_[0].get()); + view_->setWorkArea(work_area_.get()); return 0; } diff --git a/src/frontends/qt4/GuiImplementation.C b/src/frontends/qt4/GuiImplementation.C index d66aa4e956..09bf245d03 100644 --- a/src/frontends/qt4/GuiImplementation.C +++ b/src/frontends/qt4/GuiImplementation.C @@ -70,9 +70,9 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int view_id) work_areas_[id].reset(new GuiWorkArea(w, h, view)); // FIXME BufferView creation should be independant of WorkArea creation - buffer_views_[id].reset(new BufferView(view, work_areas_[id].get())); + buffer_views_[id].reset(new BufferView(view)); work_areas_[id]->setBufferView(buffer_views_[id].get()); - view->setBufferView(buffer_views_[id].get()); + view->setWorkArea(work_areas_[id].get()); view->mainWidget()->setCentralWidget(work_areas_[id].get()); -- 2.39.5